通过操纵相机的远平面可以部分隐藏几何体吗?

时间:2014-02-03 19:07:23

标签: three.js

我正在尝试操纵相机远平面以隐藏THREE.Line对象的一部分。但是,我一定是做错了。

我使用以下方法设置近平面和远平面:

camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 2, 0);

接下来,我创建几何体:

geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(-1, 0, 0));
geometry.vertices.push(new THREE.Vector3(1, 0, 0));
geometry.vertices.push(new THREE.Vector3(1, 0, -2)); // outside far plane
geometry.vertices.push(new THREE.Vector3(0, 0, -3)); // outside far plane
geometry.vertices.push(new THREE.Vector3(-1, 0, -2)); // outside far plane
geometry.vertices.push(new THREE.Vector3(-1, 0, 0));

最后,我创建了一行并将其添加到场景中:

lines = new THREE.Line(geometry, material);
lines.frustumCulled = true; // default?
scene.add(lines);

整个对象以平截头体显示。

请在http://jsfiddle.net/g52w4/2/

看小提琴

1 个答案:

答案 0 :(得分:0)

nearfar平面参数是距离(距离相机)。他们应该是积极的,far大于near

例如,将far平面设置为5。

小提琴:http://jsfiddle.net/gpT5K/

three.js r.65