ZhaDeveloper
ZhaDeveloper

Reputation: 48

Threejs: Disable frustum culling for some objects

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.

Upvotes: 0

Views: 3830

Answers (1)

pailhead
pailhead

Reputation: 5421

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.

Upvotes: 2

Related Questions