Calculate near/far plane vertices using THREE.Frustum

后端 未结 1 1131
长发绾君心
长发绾君心 2020-12-17 00:26

I need some help to deal with THREE.Frustum object.

My problem:

I need to calculate near/far plane vertices; I\'ve taken a look at these tutorials

相关标签:
1条回答
  • 2020-12-17 01:03

    Three.Frustum is not really going to help you -- it is a set of planes. The good news is your solution appears correct, but there is an easier way to think about this.

    The upper right corner of the near plane is a point in camera space with these coordinates:

    var ntr = new THREE.Vector3( wNear / 2, hNear / 2, -camera.near );
    

    using your definition of wNear and hNear, which are correct.

    Now, making sure that camera.matrixWorld is updated, you convert that point to world coordinates like so:

    camera.updateMatrixWorld();
    ntr.applyMatrix4( camera.matrixWorld );
    

    Now, flip the signs to get the other three corners, and then repeat the calculation for the far plane.

    See, you had it right; you just took a more complicated route. :-)

    EDIT: updated to three.js r.66

    0 讨论(0)
提交回复
热议问题