Disable BABYLON.AxisDragGizmo without removing arrows

Hello, I would like to temporary disable BABYLON.AxisDragGizmo. I can do by using enable property, but doing this I remove the arrows allowing to move the mesh. What I am trying to accomplish is to check in the dragBehavior.onDragObservable event if the mesh is intersecting another mesh, and I would like to stop the movement of the current mesh. I can understand when a mesh intersects another, but I cannot “cancel” the onDragObservable movement, and as I mentioned disabling the AxisDragGizmo has that side effect.

Can you give me some suggestion on this?

Thank you

Toni

Adding @Cedric in case he can help.

Hi @Toni_Bruno

I would do it this way:

https://playground.babylonjs.com/#1IJX8T

first clear drag observable, so only yours is taken into account. Then, check if mesh intersects. If not, then apply movement delta,. Check again if intersect and if it does with applied delta, then cancel movement.
Also, note world matrix is updated as it’s been used for mesh intersection.

1 Like

Perfect, thank you very much. I played a lot with movement and collision for far, and I have found validateDrag function on PointerDragBehavior, where I can decide if the drag should be confirmed or not. Do you think it could be a possible alternate solution to avoiding collision between meshes or is it better with your solution?

Thank you

Toni

I forgot validateDrag. Use that predicate instead, code will be simpler.

Yes, but I cannot find it for Gizmo, is that correct? Should I use PointerDragBehavior intead of Gizmo? Do you have any sample using validateDrag in this way, because I’m having some difficulty in understanding the right way to use it…

Thank you again for your help

Toni

there is this PG with validateDrag :

Babylon.js Playground (babylonjs.com)

In that case, you won’t have a gizmo mesh.

1 Like