如何将光线投射器与CombinedCCamera一起使用

How to use the Raycaster with a CombinedCamera?

本文关键字:CombinedCCamera 一起 光线投射      更新时间:2023-09-26

我尝试使用Raycaster(用于选择),它可以很好地与PerspectiveCamera配合使用,但不能与CombinedCamer配合使用。

首先,CombinedCCamera似乎不受Raycaster的支持,所以在这三行.js中,我添加了以下内容:

if ( camera instanceof THREE.CombinedCamera ) {
    if( camera.inPerspectiveMode ) {
        camera = camera.cameraP;
    } else if ( camera.inOrthographicMode ) {
        camera = camera.cameraO;
    }
}
if ( camera instanceof THREE.PerspectiveCamera ) {
...

因此,当它指的是嵌套摄影机时,但这并没有起到作用,因为我相信,嵌套摄影机的位置四元数旋转没有更新??

如何实现这一点并使Raycaster同时使用CombinedCamer的"正交"answers"透视"模式?

渲染器需要世界矩阵数据才能进行光线投射。对CombinedCCamera代码进行以下修改:

  // 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.