Describe the bug or feature request in detail.
ThreeJS field of view option on the camera only adjusts vertical field of view, allow the horizontal field of view to be adjusted as well or create a new camera that has an adjustable horizontal field of view.
This SO answer provides the formula that relates the horizontal and vertical FOVs.
hFOV = 2 * Math.atan( Math.tan( camera.fov * Math.PI / 180 / 2 ) * camera.aspect ) * 180 / Math.PI; // degrees
You can use that to solve for the vertical FOV as a function of the horizontal FOV.
Yes, that鈥檚 how you calculate the horizontal FOV, however Id like to adjust it independent of the vertical FOV.
Yes, that鈥檚 how you calculate the horizontal FOV, however Id like to adjust it independent of the vertical FOV.
That involves solving for the aspect ratio (width to height ratio), given the vertical and horizontal fields of view.
Of the three quantities, vertical FOV, horizontal FOV, and aspect ratio, you can control two of them.
In three.js, a perspective camera is parameterized by its vertical FOV and aspect ratio. If you want to compute either of those two values from the other (plus horizontal FOV), you will have to do that at the application layer.
For example:
const hFOV = 50; // desired horizontal fov, in degrees
camera.fov = Math.atan( Math.tan( hFOV * Math.PI / 360 ) / camera.aspect ) * 360 / Math.PI; // degrees
camera.updateProjectionMatrix();
Most helpful comment
Of the three quantities, vertical FOV, horizontal FOV, and aspect ratio, you can control two of them.
In three.js, a perspective camera is parameterized by its vertical FOV and aspect ratio. If you want to compute either of those two values from the other (plus horizontal FOV), you will have to do that at the application layer.
For example: