Is there a way to merge meshes dynamically (via mouse)?

For example, if I have 5 isolated boxes and I would want to make a table out of them ( 4 legs 1 on top), so that i could drop / drag one on another one and they get merged.

1 Like

Any reason why you need the meshes themselves to be merged? Would parenting them all to the same parent node not be sufficient?

No, no specific reason. I just want to be able to unite objects and to separate them again and I thought I needed to merge their meshes for that.

Hi guys. Interesting subject/discussion. Here’s a starter playground, if anyone wants to pursue.

https://www.babylonjs-playground.com/#1UFGZH#183

Let’s see, we can drag-around the center sphere (that part is finished)… and when it intersects with another mesh, the “other” mesh gets… umm… bakeCurrentTransformIntoVertices()… and then “other” .parent = sphere? Yeah, maybe so. (none of that is finished).

Wait, bake won’t work. umm… othermesh.position.subtractInPlace(sphere.position)… before the parenting? Maybe that. I dunno. Whatever it takes to keep the intersected mesh from “position-jump” when the parenting-to-sphere happens (and before continued drag-along). Cool.

I suppose we would set ground.powdered = true; … to keep ground from getting stuck to sticky sphere. (no such property, of course, but it made ya smile, right?)

If everything works right (after others code it), we should SOON be dragging-around a substantial pile of mesh (all parented to the sphere). StickySphere v.1.0 :smiley: Like a lint-roller for grounds. Scene item (node) magnet. FUN! Grouping… without merging. Yeah.

Wherever 2 or more mesh are overlapping, all overlappers get parented to an invislble “gizmo” parent. A group manager mesh. Then the drag-magnet can pick-up and drop single mesh, or group manager mesh… which go visible when any mesh in the group… is moused-over. Err… something. Perhaps ActionManagers to the rescue!

Let’s see… how to de-group? Maybe RIGHT click on any mesh, and it separates that mesh from any group that it is “attached-to”, and sticks it to the drag-sphere for re-location? hmm. Drop it in a place that overlaps another mesh, grouped or not, and the separated mesh then joins that new group. Wow!

1 Like