javascript - THREE.js PerspectiveCamera focusLength 相差两倍,与 FOV 不一致

标签 javascript three.js perspectivecamera

在 THREE.js 中,我们使用以下函数构造一个摄像头

const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);

我们从光学中知道,相机的视场与焦距有关,公式如下:
FOV = arctan(d/2f)

在哪里 FOV是以度为单位的垂直 FOV,d是图像平面的高度,以 mm 为单位,f是相机的焦距,单位为 mm。

看完the documentation在这件事上,似乎 d默认设置为 35mm / aspectRatio .

我们可以 express FOV像这样
FOV = arctan((35/(width/height))/2f) = arctan(filmHeight / 2f)

作为健全性检查,我打印了以下值,以查看是否可以取回 75 的输入 FOV .
Math.atan(camera.getFilmHeight()/(2 * camera.getFocalLength())) * 180 / Math.PI;

但是..这个值是37.50000000000001
这恰好是 75 的预期焦距的一半.

所以,我想知道我是否在某个地方做错了数学,或者我是否误解了 THREE.js 的报告值。

最佳答案

.fov Angular 是

Camera frustum vertical field of view, from bottom to top of view, in degrees.



但是你计算的是, View 中心到顶部的 Angular :
Math.atan( (camera.getFilmHeight()/2) / camera.getFocalLength())) * 180 / Math.PI;



这确实是 .fov 的一半:
fov = 2 * Math.atan( (camera.getFilmHeight()/2) / camera.getFocalLength())) * 180 / Math.PI;

关于javascript - THREE.js PerspectiveCamera focusLength 相差两倍,与 FOV 不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53881693/

相关文章:

three.js - 如何在 BufferGeometry 上应用 SubdivisionModifier?

three.js - 如何在 ThreeJS 中获取边界框的角点?

javascript - 如何控制THREE.PerspectiveCamera的透视变形

OpenGL NDC 和坐标

javascript - 更改导航栏高度时内容下推页面

javascript - 使用 php 和 mysql 进行 AJAX 查询

javascript - 使用 JavaScript 和 JSON 构建内联 SVG 图表

javascript - 在 Internet Explorer 6 中更改后模糊选择

javascript - Clara.io 导出的对象在 Three.JS Canvas 中不可见 - 仅黑色方 block