Gizmo dragging stop when too far from it


It seems that the drag behaviour stops when the cursor is too far away from the gizmo itself, on ‘big scenes’.

I made a playground to demonstrate this issue, you need to start dragging and, at the same time as you move the mouse upwards, you move it sideways.
You’ll notice that at some point the movement stops (but the observable isn’t triggered), and starts again if you move back closer to the gizmo. (video at the end of the post)

According to my initial research, the problem most likely comes from the _moveDrag function, as the condition calling this function seems to be correct.
But the drag function itself relies on raycasting, which might cause problems for scenes of this size.

I do not know if it is a known issue, or if there are parameters on the gizmo or dragBehavior itselves I can tweak to make it work.

Thank you!

It’s a bit windy here :rofl:

cc @Cedric

Indeed, it looks like raycast doesn’t pick the plane.
Do you have an idea why it happens @PolygonalSun ?
If not, I’ll trace into the code.

Reading further, it could be from this line, the dragPlane size is set to 10000, and I guess in my playground the scene is just too big for it to be enough.

I think we should instead use a BABYLON.Plane from @babylonjs/core/Maths, rather than a physical object, and cast the ray on it, it would be lighter on calculations, and the plane would be infinite.
I’ve done some large-scale scene testing with this playground recently and it does seem to have no size limit (which makes perfect sense).

easier said than done :eyes:

Instead of a real fix in the source code, I’ve found a workaround that might suit my use in the short-to-medium term.
Scale the dragPlane by 10 (PG) :fire:

1 Like