PointerDragBehavior dragPlaneNormal problem

Hi, everyone!

Please check this PG: https://www.babylonjs-playground.com/index.html#UTINNB#16

Lines 48-50: PointerDragBehavior is created to work in the XZ plane.
One lines 138 and 138 the behavior is attached and detached to the clicked/released mesh respectively.

What happens is, that the SECOND (and only the second) time you drag a mesh, the XY plane is used. After the second time it works as expected.

Plus, on the SECOND time, when the object is selected it kind of jumps close to the position where the first drag action has ended.

Please, advise!

Ping @trevordev

function _pick_up(a) {
if (a.source == OBJ.itemMove) {
DRAG.detach(OBJ.itemMove);
DRAG.releaseDrag()
OBJ.itemMove = null;
}
}

Should fix it! Never used this method, but I was able to restore your functionality by assuming the jump was caused by not clearing some parameters between attaches and made the lucky guess that the realaseDrag would fix it.

<3

2 Likes

@Pryme8

Thanks! This really fixes it both in my project and in the PG.

Good find, I’ll add this logic to the detach method on the behavior so this isn’t required.

1 Like