0

I have a squared plane and a camera set perpendicularly to it.

scene

Renderer view is also squared.

The camera could only travel along Z axis from the plane (0 ... infinity). I'm looking for a formula to calculate FOV from updated Z, so the plane would be the same size as renderer view.

And vice versa, to re-calculate camera Z position for a giving FOV, so squared plane would match squared renderer view.

Have tried to play with the formula

var FOV = 2 * Math.atan( planeWidth / ( 2 * camera.position.z ) );

and

var FOV = 2 * Math.atan((aspect) / (2 * camera.position.z)) * (180 / Math.PI); //aspect is 1.0

Without any success. Any ideas?

VVK
  • 435
  • 2
  • 27

1 Answers1

0

In case, if the renderer view is squared, so width equals to height and aspect ratio is 1.0, you can use the following formulas:

//FOV from distance
FOV = THREE.Math.radToDeg(Math.atan(renderWidth / Math.abs(distance * 2))) * 2;

//distance from FOV
distance = renderWidth / (2 * Math.tan(THREE.Math.degToRad(FOV / 2)))

Simply as that.

VVK
  • 435
  • 2
  • 27