【问题标题】:THREE.JS: Calculating camera FOV from its position and vice versaTHREE.JS:从其位置计算相机FOV,反之亦然
【发布时间】:2019-02-11 02:34:01
【问题描述】:

我有一个正方形平面和一个垂直于它的相机。

渲染器视图也是平方的。

相机只能从平面沿 Z 轴移动(0 ... 无穷大)。我正在寻找一个从更新的 Z 计算 FOV 的公式,因此平面与渲染器视图的大小相同。

反之亦然,为给定的 FOV 重新计算相机 Z 位置,因此平方平面将匹配平方渲染器视图。

尝试过使用公式

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

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

没有任何成功。有什么想法吗?

【问题讨论】:

标签: three.js camera projection perspectivecamera


【解决方案1】:

如果渲染器视图是正方形的,那么宽度等于高度,纵横比为 1.0,您可以使用以下公式:

//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)))

就这么简单。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 2017-10-17
    • 1970-01-01
    • 2020-11-30
    • 2019-06-22
    • 2014-03-20
    相关资源
    最近更新 更多