Hello everyone.
I’d like to remove gizmo observers when specific mesh is clicked. For example, I want to put gizmo on polygon and move it with every vertices (spheres), but now onDrag always rerender my polygon so when none of the vertice is moving it’s gonna rerender polygon in the same place. I though that onDragObservable.remove(createPolygonDragbehaviour) should solve my problem but it doesn’t… Any suggestion will be helpful, thanks.
Lines 152-157, lines 240-241 https://playground.babylonjs.com/#QNJLCY#31 you meant something like this? I still can’t figure this out.
The problem is that some of the drag behaviours of gizmo should work on specific meshes and some not I think.
It’s mostly copy/paste of what you did without the GUI and infos on the polygon.
Polygon and spheres are parented to the root.
The root is also in the gizmo pickable list.
That list is updated when the polygon is updated.
When the polygon is picked, the root is set as the editable one instead.
Your solution is very clear to me. I was thinking about making two gizmos - separate for polygon and spheres. It was kinda working, but your solution is much much better Thanks for the explanation!
@Cedric, actually I need some more explanation I’m wondering why roots yPlaneGizmo renders in the world center and not like in the center of the root. In the picture, you can see the bounding box of the root and it’s yPlane.
the yplane gizmo renders at the position of root.
if you move root and move polygon/spheres, at some point the yplane gizmo can be very far from the center of polygon.
To resolve that, when a sphere onDragEnd occurs, unparent spheres and polygon from root, move the root to the center of polygon. then reparent sphere/polygon to root.
Sorry for having such a hard time understanding it but I think I made everything from your instructions and it still doesn’t work.
I mean even if you render the polygon like near to the end of the ground the yPlane of root gonna show in the center of the world - without spheres/polygon dragging. In the picture above I showed just created polygon, without any draggig.
yes, the root is positioned at (0,0,0). you can create spheres far beyond that. and the root will not move in my PG.
As long as you don’t change root position programatically (when a new sphere is added or moved), the root will only move with the gizmo is moved.
I changed my mind and did all the position computation in relative space. see function recomputeRootSpace()
Also, when adding a new sphere, its position is now relative to root position.