s

three.js 透视相机工作原理的理解

关于PerspectiveCamera(透视摄像机)的理解:

three.js基础【英文版】

PerspectiveCamera四个参数

fov aspect near far
fov 越大,模型看起来越小【相机固定时】 摄像机视锥体长宽比,一般是选择document或者承载canvas的容器的width/height near defines where the front of the frustum starts. far defines where it ends.【如上图】

 

关于near 和 far 的理解:

near:  相机延伸出的视锥体的近平面

far:   相机延伸出的视锥体的远平面

 

也就是说near越小,far 越大的话,相机视野内的可见范围越大,那么为什么不把near设置为:0.00001, far设置为 1000000000呢?

来自外网找到的解释:
this brings up the question, why not just set near to 0.0000000001 and far to 10000000000000 or something like that so you can just see everything? The reason is your GPU only has so much precision to decide if something is in front or behind something else. That precision is spread out between near and far. Worse, by default the precision close the camera is detailed and the precision far from the camera is coarse. The units start with near and slowly expand as they approach far.

 

这是一个如上设置的例子【near很小,far很大】:可以看到模型看着有问题

 

solution:

One solution is to tell three.js use to a different method to compute which pixels are in front and which are behind. We can do that by enabling logarithmicDepthBuffer when we create the WebGLRenderer,

 this didn't fix the issue for you then you've run into one reason why you can't always use this solution. That reason is because only certain GPUs support it.

 

更多信息可以查阅【 https://r105.threejsfundamentals.org/threejs/lessons/threejs-cameras.html】

posted @ 2022-02-25 13:42  努力不搬砖的iori  阅读(755)  评论(0)    收藏  举报