Javascript 如何将光线投射器与组合摄影机一起使用?
我尝试使用光线投射器(用于选择),它可以与透视相机配合使用,但不能与组合相机配合使用 首先,Raycaster似乎不支持CombinedCamera,因此在three.js中,我添加了以下内容:Javascript 如何将光线投射器与组合摄影机一起使用?,javascript,three.js,Javascript,Three.js,我尝试使用光线投射器(用于选择),它可以与透视相机配合使用,但不能与组合相机配合使用 首先,Raycaster似乎不支持CombinedCamera,因此在three.js中,我添加了以下内容: if ( camera instanceof THREE.CombinedCamera ) { if( camera.inPerspectiveMode ) { camera = camera.cameraP; } else if ( camera.inOrthograp
if ( camera instanceof THREE.CombinedCamera ) {
if( camera.inPerspectiveMode ) {
camera = camera.cameraP;
} else if ( camera.inOrthographicMode ) {
camera = camera.cameraO;
}
}
if ( camera instanceof THREE.PerspectiveCamera ) {
...
因为它指的是嵌套相机,但是这并不能起作用,因为,我相信,嵌套相机的位置四元数旋转并没有更新
如何实现这一点并使光线投射器同时使用组合摄影机的正交和透视模式?渲染器需要世界矩阵数据才能使光线投射工作。对组合摄像机代码进行以下修改:
// Add to the .toPerspective() method:
this.matrixWorldInverse = this.cameraP.matrixWorldInverse; //
this.matrixWorld = this.cameraP.matrixWorld; //
// and to the .toOrthographic() method add:
this.matrixWorldInverse = this.cameraO.matrixWorldInverse; //
this.matrixWorld = this.cameraO.matrixWorld; //
r73.渲染器需要世界矩阵数据才能进行光线投射。对组合摄像机代码进行以下修改:
// Add to the .toPerspective() method:
this.matrixWorldInverse = this.cameraP.matrixWorldInverse; //
this.matrixWorld = this.cameraP.matrixWorld; //
// and to the .toOrthographic() method add:
this.matrixWorldInverse = this.cameraO.matrixWorldInverse; //
this.matrixWorld = this.cameraO.matrixWorld; //
r73.。在if语句中始终包含一个块(即“{//code}”)。@jeum您能做到这一点吗?。在if语句中始终包含一个块(即“{//code}”)。@jeum您能做到这一点吗?