Babylon.js: Object moves on the wrong plane when using useObjectOrientationForDragging

Created on 16 Jan 2019  路  5Comments  路  Source: BabylonJS/Babylon.js

Repro:

Playground.

Drag the object left and right rapidly.

Cause:

If you update the rotation of the object it will cause the drag plane to be incorrect.

We do want to use the rotation of the object and we want to update the plane on every frame. It works as expected unless you drag left and right rapidly.

bug

All 5 comments

@haroldma I think this is expected, rotating the object like this will introduce error in your desired drag path as the drag plane is always flat therefore, for large movements between frames, it will be dragged along the flat plane.

Is your goal to drag the object around a cylinder? If that is the case you could try to snap the object to the closest point on the cylinder when a drag event occurs, or disabled auto dragging and handle drag events yourself to snap the position of the sphere based on your own function.

That's indeed what we're trying to do. Makes sense, Trevor. What will be the best way to snap it without disabling auto dragging?

I tried using validateDrag to override the components of the vector but this causes a bug where the delta gets bigger and bigger (I'll make a PG repro).

Here's the PG

Keep dragging left and right and after a while, it starts acting weird.

If you remove this pointerDragBehavior._targetPosition.addInPlace(snapDiff); it will just start shaking like crazy after a bit instead.

Gotcha, it looks like the drag plane is not properly being updated, looking into it.

This playground should work after that gets merged http://playground.babylonjs.com#9UFEBE#37, let me know if you still have issues with your scenario.

Was this page helpful?
0 / 5 - 0 ratings