Is it possible to clip a particular mesh instead of the whole scene?

Hi guys! I want to dynamically clip mesh like in the PG for clipping plane examples: Babylon.js Playground

However, if I have a ground below the mesh, it will be clipped as well. Is it possible somehow clip a particular mesh?

Hi @PavelRomanov , how are you doing?

This example shows that you can set the values of the camera clipping plane between the rendering calls of a particular mesh:

Babylon.js Playground (babylonjs.com)

Basically you can use the onBeforeRenderObservable and onAfterRenderObservable to control which objects get affected by the clipping.

If in your case you wish that the ground is not clipped and all other objects are, you can just use ground’sonBeforeRenderObservable to set the clipping plane values to null and than place their values back during the onAfterRenderObservable

4 Likes

It works like a charm, thanks! Seems that I misunderstood the docs

1 Like