Trick the Frustum with custom Meshes

https://www.babylonjs-playground.com/#f00M0U#52

So I decided to go back to my infinite-terrain chunked quad-tree LOD system… (mouth full) and decided to make some changes to the structure and start getting it ready for porting over to ES6 and add a bunch a new features.

Now I have ran into a couple hurdles I would like others help with, first would be tricking the frustum to think that the blocks are within its non-culling area because at this point I think it is just testing the origin of the mesh. Second the very first mesh does not seem to get anything applied to it and takes me moving the camera for it to rebuild itself and make it look like the rest… odd.

And then the last thought I will need to go over is I am wondering is it possible to substitute out BJS LOD system for my own calculations or is it possible to dynamically rebuild LOD levels?

Hey!
that’s a very long PG :slight_smile:

For the frustum you can either force a mesh to be in with mesh.alwaysSelectAsActiveMesh = true. To force a mesh out, you will need to update the mesh.getBoundingInfo() and call boundingInfo.reConstruct(min, max, worldMatrix)

For LOD so far there is no easy way to provide a custom function but I would gladly add one. Something like scene.setLODSelector(selector: (mesh, camera) => mesh) ?

yeah because with the T-Junctions need to be used when different LOD levels on the terrain chunks are neighbors.

This is actually a pretty old PG, I am converting it all to ES6+ and looking at generating a lot more of the data through the GPU and some ping-ponging.

Ok let me add the setLODSelector for you (will be in next commit)

ok so it will be:

scene.customLODSelector = function(mesh, camera) {
...return the mesh you want
}
1 Like