Hello, I’m currently working on a project where I need to know, once a translation axis has been selected, which one it is if you push or pull it. Would you know how to do this?
thanks for your help
Hello
Having a look at the doc, I found out that you can actually use observables for each axis :
gizmoManager.gizmos.positionGizmo.xGizmo.dragBehavior.onDragStartObservable
gizmoManager.gizmos.positionGizmo.yGizmo.dragBehavior.onDragStartObservable
gizmoManager.gizmos.positionGizmo.zGizmo.dragBehavior.onDragStartObservable
1 Like
ha cool! but I can’t tell if I’m going one way or the other?
I’d like to be able to use the same principle as this ticket:
to know if I’m going one way it gives me -1 and the other +1
gizmoManager.gizmos.positionGizmo.xGizmo.dragBehavior.onDragObservable.add((evt)=>{
console.log(evt.dragDistance > 0 ? '+1' : '-1')
})
- You can use the
evt
argument of the observer to get additional infos about the gesture (API here). - With
evt.dragDistance
you can get +1 or -1 like in this example : https://playground.babylonjs.com/?BabylonToolkit#C77SMH#35
AND that’s what you need.
+1 is that you go forward or to the right or up depending on the chosen axis.
-1 means that you go backwards or to the left or down depending on the chosen axis.
You can also look at the position values if they go towards + or - when you move the model
1 Like
hi super it works perfectly thank you very much!
1 Like