Hi,
is it the correct behaviour of pointerDragBehaviour to send out events with invalid points?
The sphere should not be able to move leftwards and get a negative x or z value. This works. But the observables still show negative values, when you check the console log for the onDragEndObservable
Workaround would be, to use the position of the mesh that is using the pointer behaviour.
Best!
From the doc: dragPlanePoint in world space where the drag intersects the drag plane
So, it’s where the mouse/touch pointer has been released. It’s not the delta applied to the mesh position. Best is to do the delta of the mesh position when drag ends on the user side.
I am not sure, if this only happens in my case, but the position of the attached node does not equal the dragHandle position within onDragObservable. Most probably, because pointerDragBehaviour checks drag behaviour in onPointerObservable, but updates attached node within onBeforeRender.
const obs = dragHandle.onDragObservable.add(e => {
// attached node position is used, since sometimes validatedDrag might be used.
// however it does not return same position as e.dragPlanePoint
const pt = dragHandle.attachedNode.position
onChange([pt.x, pt.y, pt.z])
})
const obs = dragHandle.attachedNode.onAfterWorldMatrixUpdateObservable.add(e => {
// using this observable, we get the right position. but it might fire also in other occasions.
onChange([e.position.x, e.position.y, e.position.z])
})
Edit: The reason that the attached node is validated and updated in onBeforeRender loop is the possibility to lerp positions via dragDeltaRatio.