ThreeJS:计算正射相机中网格的FOV

时间:2014-11-25 11:35:56

标签: three.js orthographic fieldofview

所以我现在尝试解决这个问题几个小时,但无法让它发挥作用。

我在正交视图中创建了一个网格并从上方查看。

网格的尺寸为: 400 * 500 高度(是否需要?)是300

它位于0,0,0点

摄像机位于0,5000,0正面朝下,0,0,0

现在我唯一需要知道的是如何计算fov

_CoreManager.GetCamera().setFov(X);

这样摄像机可以从每侧+100个单位看到整个网格,这样用户就可以看到网格的边界。

试过这个,要么我做错了什么,要么它不适用于ortho, https://github.com/mrdoob/three.js/issues/1239

谢谢:)

更新:

我尝试了一种新方法,我认为这种方式很有意义,但是没有...

http://forums.cgsociety.org/archive/index.php/t-725538.html

var dist = _Camera.position.y - _mesh.position.y;
var width = _mesh.geometry.parameters.width;

var halfHorizontalFOV = Math.atan((width / 2) / dist);
halfHorizontalFOV = Algorithms.ConvertRadiansToDegrees(halfHorizontalFOV);

给了我一些与它应有的相同的学位。

1 个答案:

答案 0 :(得分:1)

使用Orthograpical修复解决了我的问题:

https://github.com/mrdoob/three.js/commit/fb07c9bc192c0eaedb9df187b35f69c37716c1aa

var zoom = orthoWidth / meshWidth;
_Camera.setZoom(zoom);