计算所需摄像机变倍对象以适应屏幕高度 [英] Calculate camera zoom required for object to fit in screen height
问题描述
在Three.js我用这个公式来计算可视宽度放大器;身高
VAR VFOV = camera.fov * Math.PI / 180; //转换成垂直视场角为弧度
VAR HEIGHT = 2 * Math.tan(VFOV / 2)* DIST; //可见高度
VAR方面= window.width / window.height;
VAR WIDTH =身高*方面; //可见宽度
和与我计算所需的对象相机变焦,从而精确匹配到由宽度渲染面积
VAR变焦=(ObjectHeight /纵横)/(2 * Math.tan(VFOV / 2))+ ObjectDepth;
我如何计算所需的对象,相机变焦,从而精确匹配到由高度渲染区域?
由于GuyGood,我找到了解决办法:
VAR变焦=(ObjectHeight / 2)/ Math.tan(VFOV / 2) - ObjectDepth;
我做的是基于BoundingSphere所半径如下:
geometry.computeBoundingSphere();
半径= geometry.boundingSphere.radius;
distanceFactor = Math.abs(纵横*半径/ Math.sin(FOV / 2);
这是基于这个东西就在这里,我希望我跨preTED的正确方法: HTTP://www.flip$c$c.com/forums/thread/4172
本 distanceFactor
是你需要移动相机沿其视线方向正确地安装它的因素。目前,我不知道,如果它是由高度或宽度,但也许它可以帮助你看着办吧。 :)
In Three.js I'm using this formulas to calculate visible width & height
var vFOV = camera.fov * Math.PI / 180; // convert vertical fov to radians
var height = 2 * Math.tan( vFOV / 2 ) * dist; // visible height
var aspect = window.width / window.height;
var width = height * aspect; // visible width
And with that I calculate the camera zoom required for object to fit exactly into render area by WIDTH
var zoom = (ObjectHeight/aspect) / (2*Math.tan(vFOV/2)) + ObjectDepth;
How do I calculate the camera zoom required for object to fit exactly into render area by HEIGHT?
Thanks to GuyGood, I found the solution:
var zoom = (ObjectHeight/2) / Math.tan(vFOV/2) - ObjectDepth;
I am doing the following which is based on the boundingSphere radius:
geometry.computeBoundingSphere();
radius = geometry.boundingSphere.radius;
distanceFactor = Math.abs( aspect * radius / Math.sin( fov/2 );
This is based on this stuff right here and I hope i interpreted it the right way: http://www.flipcode.com/forums/thread/4172
This distanceFactor
is the factor you need to move the camera along its viewing direction to fit it correctly. At the moment i am not sure if it is by height or width but maybe it helps you figure it out. :)
这篇关于计算所需摄像机变倍对象以适应屏幕高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!