1

我有一个使用three.js 渲染的相当简单的场景。我正在尝试只渲染场景的一部分,就像 MRI 一样。

为了测试目的,我制作了两个版本的场景。

  1. 透视版,效果很好
  2. 一个正交版本,它应该只是给定平面上场景的一部分

渲染正交场景是没有问题的。我曾尝试使用剪裁平面来捕获切片,但无法正常工作。要么我得到一个全白的屏幕,要么得到整个模型。

这是我希望实现的自上而下的视图:

100 *----------------------------------*
    |                                  |
    |                                  |
    |                                  |
    |                                  |
    ####################################  <-- Capture this slice of 100 units width
    |                                  |
    |                                  |
    |                                  |
    |                                  |
 0  *----------------------------------*
    0                                  100





                    \  /
                     \/
                   CAMERA roughly @ (50, -100)

我完全有可能遗漏了一些明显的东西。我的 3D 背景不错,但我不是专家。

What is the best way to go about this in Three.js / WebGL? What is the best place for the camera to go?

PS: Yes, I am aware that slicing through some primitives will not work well. I am using a model built from lines and points which I expect will slice fairly safely. Cutting objects in half is not too much of an issue for me.

4

1 回答 1

2

The answer turned out to be the camera placement. It was obvious in hindsight that the camera should not be set back from the scene as is needed for the perspective projection. Placing the camera right at the edge of the model did the trick and the clipping plane (near, far) worked properly.

eg:

    Z
100 *----------------------------------*
    |                                  |
    |                                  |
75  |                                  |
    |                                  |
    |                                  |
50  |                                  |
    |                                  |
    |                                  |
25  ####################################  <-- Capture this slice of 5 units
    |                                  |      width @ z = 25
    |                                  |
 0  *-----------------X----------------* Y
    0                 .                100
                      .
                      .
                   CAMERA is here at (50,0)
                   near = 25
                   far  = 30 (for width 5, ie: 25 + 5)
于 2013-03-29T21:41:20.270 回答