Hi everyone,
I really have a problem with an imported mesh that i want to cut with a box using the subtract function.
Here’s my playground https://playground.babylonjs.com/#DFD9IV#2
if the sliced object is a sphere, it works perfectly well, if it’s my object, it doesn’t word because the result (in red) object keeps the box inside instead of deleting it.
Where is my mistake ?
Thanks a lot for any help.
Boris
gltf/glb files are using a right handed system and are a bit hard to work with when using CSG.
What you can do is setting scene.useRightHandedSystem = true;
and passing true
as the 2nd parameter of the CSG.FromMesh
method:
https://playground.babylonjs.com/#DFD9IV#6
Ok, it works now perfectly well in the playground - that’s why there are Jedi Masters but also rookies like me
- but the same code doesn’t work in my environment code.
Is there a special library to add ?
I added three libraries
babylon.js, earcut.min.js, babylon.glTFFileLoader.js
Hard to tell… The Playground is doing this:
You can try to add all dependencies and remove them one by one until it fails.
ok, I will look at that.
and I have another problem. If I try to cut the same object another time, i find again the same issue.
https://playground.babylonjs.com/#DFD9IV#7
Once you have done a CSG operation with the original meshes, they are not in right-handed system anymore, so you should use false
as the 2nd parameter of FromMesh
:
https://playground.babylonjs.com/#DFD9IV#9
1 Like
Thank’s, I will now adapt it in my development environment.