Create a hole on BABYLON.MeshBuilder object when an mesh passes through

I am trying to use some vectors from the bounding box to create a hole in a wall when the mesh intersects the wall. Can you guys help me to achieve this?

Here is the pg:

Maybe you would want to use CSG instead, as doing it by code may be a bit complicated?

See Merging Meshes | Babylon.js Documentation

Is it possible to do CSG using the bounding box as a tool instead of the mesh? Sometimes the mesh is smaller than the wall. If we are able to extend the bounding box and cut when it intersects with the wall, it would be great

You could simply create a box mesh corresponding to the bounding box, do the CSG with this mesh then delete the mesh.

And how to create a box that matches the bounding box?

You can get the bounding box info through mesh.getBoundingInfo().boundingBox: using the centerWorld and extendSizeWorld properties, you can create a suitable box for CSG.

1 Like

Is it right? BABYLON.Vector3.Distance(mesh.getBoundingInfo().boundingBox.extendSize,mesh.getBoundingInfo() Let suppose that the bounding box has different width, height and depth. How to compute the right distance from all directions?

You can create the box like this:

1 Like