In Frustum calculations with a large ground

I am working with large terrains, and each tile is a separate point cloud system or solid particle system, it is working nicely apart from the in frustum calculation. This is a simple playground that highlights the issue

https://playground.babylonjs.com/#24VLV0#30 with a large ground and camera height.

However frustum culling works nicely for https://playground.babylonjs.com/#D7KY32#100 with a lower camera

I am guessing it is trig, but any hints appreciated on how to detect when a block is in/out of the frustum

Hi @normanb

Box doesn’t have a “mesh” property, it is a mesh :slight_smile:

...
console.log(box.mesh)
if (!box.mesh?.isInFrustum(planes)) {
    console.log('Box is not in frustum');
}
...
undefined
Box is not in frustum
...
What happend here?

!box.mesh?.isInFrustum(planes)

If mesh is undefined, suddenly the if statement looks like so:
(!box.mesh) === true
...
if (!box?.isInFrustum(planes)) {
    console.log('Box is not in frustum');
}
else {
    console.log('Box is in frustum')
}
...
Box is in frustum
1 Like

Thank you, I was using a box to save a bit of time in the example with the playground, that was a mistake by me, I am still quite new to this. Turns out there are multiple cameras in the scene and I was using the wrong one to do a frustum test. Sorry for the noise.