Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将光线投射器与组合摄影机一起使用?_Javascript_Three.js - Fatal编程技术网

Javascript 如何将光线投射器与组合摄影机一起使用?

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

我尝试使用光线投射器(用于选择),它可以与透视相机配合使用,但不能与组合相机配合使用

首先,Raycaster似乎不支持CombinedCamera,因此在three.js中,我添加了以下内容:

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您能做到这一点吗?