Threejs: Disable frustum culling for some objects

心不动则不痛 提交于 2020-06-29 03:53:14

问题


In order to solve the problem of z-fighting, I limited the near and far of camera to a small range.But when I want to add a larger object,it was culled by view frustum.

I tried object3d.frustumCulled property,not working as expected,the reason is as follows: https://github.com/mrdoob/three.js/issues/12170

So,is there a way to ensure that some specific objects are not frustum culled without changing the camera near and far? THX.


回答1:


Culling doesn't mean that an object is drawn or not. It can be either drawn or not drawn depending on where it is. It is an optimization that tries to say something like this:

Hey, i have a really cheap check (plane/sphere intersection) that i can do and tell you if you need to attempt to draw this at all.

So you do a cheap check, and if the object is guaranteed to be entirely out of the frustum, you never issue the draw call. If it intersects, you have to issue a draw call, but you may still see nothing if none of the triangles are actually in the frustum.

If you download something like specter.js and inspect your draw calls, you will infact see that with frustumCulled = false you get a draw call for every object in your scene. Your screen may be empty.



来源:https://stackoverflow.com/questions/59727192/threejs-disable-frustum-culling-for-some-objects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!