拼写块?
Orthographic Frustum?
当我使用透视相机检查点是否在平截头体内时,它起作用了。但是当我使用正交相机检查时,截锥体框显得不准确。平面设置正确。如果使用正交相机,是否还有其他我忽略的需要更改的东西?
这是我设置平面的方式..
if((this.mouse.screenx>mouse.screen.x && this.mouse.screeny<mouse.screen.y)||
(this.mouse.screenx<mouse.screen.x && this.mouse.screeny>mouse.screen.y)){
topPlane.setFromCoplanarPoints(camera.position, topRight, topLeft );
rightPlane.setFromCoplanarPoints(camera.position, bottomRight, topRight );
bottomPlane.setFromCoplanarPoints(camera.position, bottomLeft,bottomRight );
leftPlane.setFromCoplanarPoints(camera.position, topLeft, bottomLeft );
}else{
topPlane.setFromCoplanarPoints(camera.position, topLeft , topRight );
rightPlane.setFromCoplanarPoints(camera.position, topRight , bottomRight );
bottomPlane.setFromCoplanarPoints(camera.position,bottomRight , bottomLeft );
leftPlane.setFromCoplanarPoints(camera.position, bottomLeft , topLeft );
}
nearPlane.setFromNormalAndCoplanarPoint(vector,camera.position);
vector.set( 0, 0, 1 );
vector.applyQuaternion( camera.quaternion );
var vector2 = new THREE.Vector3( 0, 0, -config.camera.far );
vector2.applyQuaternion( camera.quaternion );
vector2.add(camera.position);
farPlane.setFromNormalAndCoplanarPoint(vector,vector2);
好的,我想通了。
我正在创建我的平面,以便它们从相机的位置延伸,但是,这会创建一个锥形的截锥体。
在正交模式下,没有锥度 - 一切都是直的,所以截锥体平面不应该从相机延伸。
我所做的是获取相机的方向:
var vector = new THREE.Vector3( 0, 0, -1 );
vector.applyQuaternion( camera.quaternion );
然后我用它来创建每个平面-例如:
var top = topRight.clone(), right = bottomRight.clone(), bottom = bottomLeft.clone(), left = topLeft.clone();
top.add(vector), right.add(vector), bottom.add(vector), left.add(vector);
topPlane.setFromCoplanarPoints(top, topLeft , topRight );
rightPlane.setFromCoplanarPoints(right, topRight , bottomRight );
bottomPlane.setFromCoplanarPoints(bottom,bottomRight , bottomLeft );
leftPlane.setFromCoplanarPoints(left, bottomLeft , topLeft );
我有它所以平截头体可以倒转 - 所以一定要检查飞机是否面向正确的方向。
当我使用透视相机检查点是否在平截头体内时,它起作用了。但是当我使用正交相机检查时,截锥体框显得不准确。平面设置正确。如果使用正交相机,是否还有其他我忽略的需要更改的东西?
这是我设置平面的方式..
if((this.mouse.screenx>mouse.screen.x && this.mouse.screeny<mouse.screen.y)||
(this.mouse.screenx<mouse.screen.x && this.mouse.screeny>mouse.screen.y)){
topPlane.setFromCoplanarPoints(camera.position, topRight, topLeft );
rightPlane.setFromCoplanarPoints(camera.position, bottomRight, topRight );
bottomPlane.setFromCoplanarPoints(camera.position, bottomLeft,bottomRight );
leftPlane.setFromCoplanarPoints(camera.position, topLeft, bottomLeft );
}else{
topPlane.setFromCoplanarPoints(camera.position, topLeft , topRight );
rightPlane.setFromCoplanarPoints(camera.position, topRight , bottomRight );
bottomPlane.setFromCoplanarPoints(camera.position,bottomRight , bottomLeft );
leftPlane.setFromCoplanarPoints(camera.position, bottomLeft , topLeft );
}
nearPlane.setFromNormalAndCoplanarPoint(vector,camera.position);
vector.set( 0, 0, 1 );
vector.applyQuaternion( camera.quaternion );
var vector2 = new THREE.Vector3( 0, 0, -config.camera.far );
vector2.applyQuaternion( camera.quaternion );
vector2.add(camera.position);
farPlane.setFromNormalAndCoplanarPoint(vector,vector2);
好的,我想通了。 我正在创建我的平面,以便它们从相机的位置延伸,但是,这会创建一个锥形的截锥体。 在正交模式下,没有锥度 - 一切都是直的,所以截锥体平面不应该从相机延伸。
我所做的是获取相机的方向:
var vector = new THREE.Vector3( 0, 0, -1 );
vector.applyQuaternion( camera.quaternion );
然后我用它来创建每个平面-例如:
var top = topRight.clone(), right = bottomRight.clone(), bottom = bottomLeft.clone(), left = topLeft.clone();
top.add(vector), right.add(vector), bottom.add(vector), left.add(vector);
topPlane.setFromCoplanarPoints(top, topLeft , topRight );
rightPlane.setFromCoplanarPoints(right, topRight , bottomRight );
bottomPlane.setFromCoplanarPoints(bottom,bottomRight , bottomLeft );
leftPlane.setFromCoplanarPoints(left, bottomLeft , topLeft );
我有它所以平截头体可以倒转 - 所以一定要检查飞机是否面向正确的方向。