开发者

For a given Z depth, how do I find the rectangle of the viewable area?

开发者 https://www.devze.com 2023-04-04 17:44 出处:网络
Or, to ask the same thing another way: For a given Z depth开发者_高级运维 in a 3D scene, I want the X and Y coordinates that will allow me to place an object just outside of the viewable area.

Or, to ask the same thing another way: For a given Z depth开发者_高级运维 in a 3D scene, I want the X and Y coordinates that will allow me to place an object just outside of the viewable area.

I'm using three.js for this.


If you know the horizontal field of view $\alpha$, for example, you can just use some trigonometry to get : $xmin = tan \alpha/2 * Z$ . This $xmin$ is the $x$ coordinate of the begining of the frustum, in the frame of the camera : if you want to use global coordinates, you thus have to rotate and translate this point according to the position and orientation of the camera (basically, multiplying by the inverse of your camera matrix).

0

精彩评论

暂无评论...
验证码 换一张
取 消