Dragging walls while keeping all other meshes attached

Hello again!

Example of what I have till now https://www.babylonjs-playground.com/#JDXFPE#3

My goal is to be able to move the grey walls (tubes) while keeping all meshes attached to each other.

When dragging the first wall (any wall) everything looks ok and remains attached.

BUT THEN,
if I try to drag a wall that is nearby, all the pieces become de-attached.
if I try to instead immediately drag the opposite wall, the pieces remain attached.
How it looks -> Recording #509

Why does this happen?

Is there a better approach to this in general?

FInally, once this issue is fixed, I would like to be able to move each wall in one axis only. For example, the top and bottom walls should move in the z axis only, and the left and right walls should move in the x axis only. How can I achieve this?

You’ll notise that dragging the left wall slightly up, then when beginning to drag the bottom or top wall, the left wall is positioned upwards by exactly the same distance you previously moved it, as if the previous drag was applied twice.

You’ll also notise that only the tubes are moved by this, (not the corners)
So it seems the re-creation of the tubes is where the issue lies :slight_smile:

Also, slightly confusing code, first you call them wallId’s then cornersomethingid then back to wallsomethingid, hard to navigate what is what :slight_smile:

https://www.babylonjs-playground.com/#JDXFPE#4

oh I see. Basically all tubes follow the corners, show it make sense to recreate all tubes based on the corners position.