Guys i got some thing wrong that make a hole

i want to make a hole in scene that can be through engine use setColorWrite,
mesh.onBeforeRenderObservable.add(() => engine.setColorWrite(false))
mesh.onAfterRenderObservable.add(() => engine.setColorWrite(true))
but if mesh in scene.meshs[0] it can work with everymeshs, else if is just can influence meshs after it in scene.meshs
there is an example

how can i fix it or is there better way to make a hole?

i try to change hole mesh to first, in low version (like 4.2) is ok ,but in latest version like 5.38 is not work

I found this example with stencils: Babylon.js Playground (

Depending on your needs, you could also use CSG: Merging Meshes | Babylon.js Documentation (, and @Evgeni_Popov also knows all kinds of cool tricks :slight_smile:

Meshes are now sorted by material to improve performances and not rendered in the order they were created anymore.

You can make sure that sphere3 is rendered first by setting renderingGroupId = 1 for all other meshes:

Or you can provide your own sorting function for opaque objects through scene.renderingManager.setRenderingOrder:


thanks for ur help bigman

@Evgeni_Popov is my favourite bigman :smiley:

Plus 1 vote from me :smile: