Is there a way to cut an object into two? For example when I press the mouse at an object and move it to the end, the objects should be cut into two objects (two halfs). If so, how?
Hi @issabln, welcome to the Babylon forum!
Mesh slicing sounds like a fun math problem to solve, you can definitely find solutions implemented in other engines floating around the internet, Like this solver implemented in Unity3D.
I’d assume your algorithm would be:
- Figure out your bisecting plane, and its positional and normal vectors (I suggest starting with either a perfectly horizontal or vertical plane).
- Find the edges that intersect the plane, and use the intersection point to create your new vertices for the sliced meshes.
- Recreate your “top” and “bottom” meshes using the vertices on either side of the slicing plane
2 and 3 are probably a lot easier said than done here, but I hope this gives you a head start.
Or, you can always fake it with pre-sliced geometry that you substitute in, if your usecase allows it
Do you need it to be dynamic? If not there’s tons of tools that you can use to swap out the model for any modeling suite, example: YouTube
I have been looking into how to slice meshes in Babylon as well. Any pointers would be great …,
you can even split a mesh in as many parts you want : Use the Solid Particle System - Babylon.js Documentation
thats exactly what I’m looking for, but I need it inside babylon.js
Wow, thanks a lot, that’s great!!! Do You know what’s causing the cut parts to jump so weird sometimes and to fall through the ground?
I could not get work … when I click on sphere or plane … I don’t the plane sliced into tiles or prices
It works better with a box
SPS is one of babylon’s best features.
The jumping is due to me adding physics to the cut pieces, the physics impostor “meshes” are probably overlapping on creation (and don’t really match up with the mesh), causing them to explosively decompress as they get out from inside each other😂.
But then, we lose the ability to collide with the other cut meshes…
Does @issabln need physics?