1

I have a Perspective Camera with a certain projection matrix ,I just want to extract the fow , near plane and far plane from it. I know there is a function in Three.js :

.updateProjectionMatrix()

it creates a projection matrix based on parameters listed above, basically i want the reverse process.

binaryRat
  • 186
  • 1
  • 11

1 Answers1

5

I solved with this 3 formulas :

fov = 2 * atan(1/camera.projectionMatrix.elements[5]) * 180 / PI;

near = camera.projectionMatrix.elements[14] / (camera.projectionMatrix.elements[10] - 1.0);

far = camera.projectionMatrix.elements[14] / (camera.projectionMatrix.elements[10] + 1.0);

Sources :

3D Projection

Decompose the OpenGL projection matrix

Field of view + Aspect Ratio + View Matrix from Projection Matrix

binaryRat
  • 186
  • 1
  • 11
  • Do you happen to know if there's anything else to extract from the matrix to completely 'clone' the camera behavior? I did setup a [JsFiddle](https://jsfiddle.net/jurito/013x78n4/19/) with an example of what i want to achieve. Basically you click on the scene and it switches camera to another one created with the extracted properties, but as you see it's not working as expected.. – jurito Dec 19 '21 at 15:46