How to make Frustum culling :D

Hi I am back again weeeew :smiley:

So I am making Rpg game on electronjs and I have mid-size scene with lot of obj. A I want to implement Frustum culling but I didn’t find anithig how to make it work, only what I found was camera.isInFrustum() so i tryed something like this on one door obj.:
https://playground.babylonjs.com/#VZRN2V#12
it starts on 250line :

Quistions: Is the better way to do it? and how to make work setEnabled funcion in for loop with all exported obj. ?

Thanks :wink:

https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy

mesh.isInFrustum(scene.frustumPlanes) is already used by BJS to cull every mesh of the scene in the standard rendering process

1 Like

@jerome So babylonjs have defaultly frustum culling. Only what I can do is change the strategy of culling.
am I right ?
sorry for stupid question but my english is not the best.

yep
The meshes to be rendered are selected by a culling process of which you can change the behavior.

Selecting a BoudingSphere based test will increase the perfs and reduce the accuracy (leading potentially to false positives = selection of meshes that won’t be visible anyway).

You can even use mesh.isInFrustum() for your own needs more over (say, to disable unselected meshes ? or any other goal)

2 Likes

Thank you very much @jerome for explanation :slight_smile:

1 Like