Babylonjs Subtracting Cylinder From Mesh Solid

506 Views Asked by At

I've put together a simple test using CSG in Babylon. I am trying to subtract the cylinder "hole" from the "upright" panel that I have created. However, It's not working properly. I feel that I am missing something.

Here's my playground https://playground.babylonjs.com/#4489EV

1

There are 1 best solutions below

0
On

I'm also inexperienced in Babylon.js but I could get it to work as follows:

  • The meshes you create (e.g. hole) are automatically added to the scene and you don't want that;
  • Use [hole|Upright].setEnabled(false) to prevent showing them in the scene;
  • After you compute your CSG object, you then call .toMesh() so that the CSG mesh is displayed;
  • Note that if you use subtract, it returns a new CSG, maybe you rather want subtractInPlace.