IsInFrustum always return true?


Today I played a bit with the frustum check functionallity and I cant get it running.

In playground I added 2 objects, box 1 is visible and in frustum. Box 2 is not visible und should be out of the frustum.

There are 2 strange things for me which I did not understand:
I added 4 different frustum checks and the results are always true, neither if the box is in or outside of the view. What I did wrong?

To get the frustumplanes of the actual camera I used initially the scene frustumPlanes property.
Tooltip says “Gets the list of frustum planes (built from the active camera)” … Active camera is set but the result of the property is undefinied. Is this a bug?

See here

Okay I found the problem.
It is only working after a scene.render() call.

Would be helpful to add a hint in the documentation. :slight_smile:

1 Like

Pinging our doc master @PirateJC

It’s a side effect that calling scene.render make it work.

You need the view and projection matrices to be up to date to use the camera.isInFrustum method. It appears calling scene.render make the necessary calls, but you can do them yourself.

Also, the world matrices of the meshes you want to test must be up to date too (which is also done automatically by scene.render):

Note that scene.frustumPlanes is undefined because it is updated in the course of scene.render.

1 Like

Thank you for the explanation. Now I understand a little more what is happening in the background.