PointerDragBehaviour with rotated mesh

I have a specific problem and am wondering if there is an easy solution out there.

I have a box I want to drag around. The box is inside a transformnode which may be rotated. If I rotate the node all the dragging goes crazy. Is there any way to fix this? Do I need to recalculate the dragAxis for example?

Pinging @Cedric

Do you have a PG showing your issue? Most of the computation is done in world space. If the parented transform moves/rotate between 2 frames, while there is a drag, result should be undefined. There might be some way to mitigate the effect.

I just hit that problem yesterday, when I added a rotation gizmo. When you have both a rotation & position gizmo, there is something to the position gizmo, so that it is un-affected by rotation

gizmoManager.gizmos.positionGizmo.updateGizmoRotationToMatchAttachedMesh = false;

Was planning to look at the gizmo source for hints, but not today.

I did experiment with that a little - Babylon.js Playground (babylonjs.com). it does seem a bit off when there is a rotation

I don’t see a difference. I’ve tested with dragaxis and dragPlaneNormal and got no issue.

Thanks for all the replies. I’ll have to come up with a simple PG that demonstrates it. Still getting used to the playground system…

The example from RaananW does show it pretty well actually. I’ll see if I can put something in show as well.

Hard to reproduce so far - I realized I have a transformnode inside a transformnode, but doing that in the playground does not seem to affect anything. (I mean it seems to work there)

I need to do some more testing.

@joelutting were you able to get a playground? If you have any questions about the playground I’m happy to help! :relaxed:

Thanks - no not exactly. Its complicated - was hoping to put my project online soon and then point out the issue - not sure how to create a simple case for this yet.

Could you do a simple scene like @RaananW 's example? Just a simple mesh with a ground. Then you could show us the expected result vs what you’re getting. It’s simpler than putting your project online and also for us to help you, since we wouldn’t have to go through application-specific logic.

1 Like

I have been working on other things, putting this problem aside for later. I have a drag control for resizing a mesh, parented under a transformnode. If not rotated the drag control works perfectly - once rotated it does some weird stuff. Its not so easy to create a simple case, but once I get back to this I will try. I’m sure I’m doing something wrong, but like I said I put this aside for now.

1 Like