Possible issue with enabling AxisDragGizmo

I’ve got a scenario where I have multiple objects, each with four AxisDragGizmos. When I click one object, I want to show its four gizmos and hide the gizmos on all other objects. I use the isEnabled property of the AxisDragGizmo for that.

The issue

I can disable the gizmo with isEnabled=false, but I can’t enable the gizmo after it has been disabled. The PositionGizmo can be turned on and off with the isEnabled property.
Here’s a playground: https://www.babylonjs-playground.com/#31M2AP#130. Toggle line 21 to see the effect.

Workaround

I’m now using the AxisDragGizmo.scaleRatio to toggle the visibility. But I always feel a little bit dirty when using scale to hide an object.

pinging @Cedric

let me check

@klaasnienhuis
when disabled AxisDragGizmo, axisScaleGizmo, planeRotationGizmo , attachedNode/attachedMesh are set to null. You have to set back the attachment when enabling it back.

https://www.babylonjs-playground.com/#31M2AP#131

2 Likes

@Cedric fantastic! thanks for the quick response.
Is this intended behavior? Because for the PositionGizmo you don’t have to reattach. Is that perhaps because PositionGizmo is more like a collection of gizmos?

yes, the gizmos AxisDragGizmo, axisScaleGizmo, planeRotationGizmo are ‘base’ gizmo that are used to compose other ones. their behavior is a bit different.

1 Like

Apparently attaching a mesh with attachedMesh automatically sets isEnabled to true.