three.js 透视相机工作原理的理解
关于PerspectiveCamera(透视摄像机)的理解:
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】
本文作者:CV攻城狮中的一员
本文链接:https://www.cnblogs.com/Hijacku/p/15935718.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2021-02-25 网站图片格式选择技巧
2021-02-25 html5 video/audio 标签
2021-02-25 仅使用css实现点击 控制元素的显示与隐藏!