THREE.js PerspectiveCamera focusLength缩小了两倍,与FOV不一致 [英] THREE.js PerspectiveCamera focalLength off by a factor of two, inconsistent with FOV

查看:77
本文介绍了THREE.js PerspectiveCamera focusLength缩小了两倍,与FOV不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

从光学器件中我们知道,摄像机的视场与焦距有关,其关系式如下:

  FOV = arctan(d/2f) 

其中 FOV 是垂直FOV(以度为单位), d 是图像平面的高度(以mm为单位), f 是焦距相机的毫米数.

在阅读

这确实是 .fov 的一半:

  fov = 2 * Math.atan((camera.getFilmHeight()/2)/camera.getFocalLength()))* 180/Math.PI; 

In THREE.js we construct a camera using the following function

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

We know from optics that the field of view of a camera is related to the focal length by the following equation

FOV = arctan(d/2f)

where FOV is the vertical FOV in degrees, d is the height of the image plane in mm, and f is the focal length of the camera in mm.

After reading the documentation on the matter, it seems as though d is set by default to be 35mm / aspectRatio.

We can express FOV like this

FOV = arctan((35/(width/height))/2f) = arctan(filmHeight / 2f)

As a sanity check, I printed the following value, to see if I would get back the input FOV of 75.

Math.atan(camera.getFilmHeight()/(2 * camera.getFocalLength())) * 180 / Math.PI;

But.. this value comes out to be 37.50000000000001

which is exactly half of the expected focal length of 75.

So, I was wondering if I did the math wrong somewhere, or if I'm misinterpreting THREE.js's reported values.

解决方案

The .fov angle is the

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

But what you calculate is, the angle of the center of the view to the top:

Math.atan( (camera.getFilmHeight()/2) / camera.getFocalLength())) * 180 / Math.PI;

this is indeed the half of .fov:

fov = 2 * Math.atan( (camera.getFilmHeight()/2) / camera.getFocalLength())) * 180 / Math.PI;

这篇关于THREE.js PerspectiveCamera focusLength缩小了两倍,与FOV不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆