How to make holes in babylon box?

Hello everyone,

I would like to make a hole in a Babylon box. I do not know if it’s possible.
I succeeded with a polygon, but I would be simpler for me if it is possible on a simple Babylon box.

https://www.babylonjs-playground.com/#PTTMVI#124

If you have a solution or an idea to help me, it would be perfect!

Sorry for my bad English, if you don’t understand something, don’t hesitate to ask me, and I can explain in french.

Thank you for your help.

You could use CSG:

https://www.babylonjs-playground.com/#T6NP3F#0

https://doc.babylonjs.com/api/classes/babylon.csg.html

2 Likes

I try to use CSG but with MergeMeshes it makes strange things.
https://www.babylonjs-playground.com/#KUM5WC
Do you have a solution for this ?

Thanks

Sorry I would have thought it would work with MergeMeshes. Probably the overlapping facets you get with merging the meshes confuses the algorithm or could be because the resulting mesh is convex.

Here is a solution without using merge meshes. Note in line 29 the second parameter so that the first meshes are not disposed. https://www.babylonjs-playground.com/#KUM5WC#1

1 Like

Thanks for your fast response.

I removed MergeMeshs but it was just for the holes. To avoid move 3 meshes I using parenting, but this is a problem too :confused:

https://www.babylonjs-playground.com/#KUM5WC#2

Using a transform node as parent https://www.babylonjs-playground.com/#KUM5WC#3 seems to work but I do not know enough about CSG to say it will work in all circumstances.

1 Like

Hi, thank you for this post. I see there also solution for my problem.
But Playground behaves very strange in this example. After loading it, it shows 2 plates. But after clicking the “Run” button, it shows only one plate. Is it a bug of Playground?
Thanks.

Probably something is not fully loaded in the first instance bur after the second run it is in the cache so can be used straight away. Something within the PG will need a tweak.

There’s a small bug in the PG, this.scene should be replaced by scene:

https://www.babylonjs-playground.com/#KUM5WC#13