Configuring Drag Anchors and Constraints

Hi there - we’re trying to understand how to set up our drag interactions properly. We’ve looked extensively through the documentation and the comments in the interaction code but are still stuck.

We have a model with a node that needs to snap to one of many drag anchors. The drag anchor coordinates are defined by a grasshopper data output, which we translate into drag anchors for a geometry output in the model.

I’ve put together a sandbox that shows a simplified version of what we are trying to accomplish: MultiDrag Points - CodeSandbox

The first issue is that the node snaps back to the original anchor when dragging it. For example, if we drag the node from anchor 1 to anchor 2, clicking it again to drag it to anchor 3 snaps it back to anchor 1 first. What are we doing wrong here?

The second issue is that the node doesn’t easily snap to the anchors provided relative to the camera perspective. The best experience is when the camera looks directly down at the plane. Is there a way we can make the dragging more responsive to snapping to anchors regardless of the camera perspective?

Appreciate your help here!

Hello @Tim_Thimmaiah
thank you for that detailed issue description. I can definitely confirm that some things here are not working as expected. I will have a look and get back to you!
Cheers, Michael

Hello @Tim_Thimmaiah
I’m currently working on a fix for this issue. The offset is definitely an error on our side. I should have a new version for this in the next days (hopefully tomorrow). Then we can evaluate the issue with the anchors and how that behavior can be improved.
Cheers, Michael

Hello @Tim_Thimmaiah,

so there were two issues. First, the resetting of the object when dragging for a second time has been resolved with the newest viewer version 2.5.0.

The second issue was a misunderstanding of the dragging functionality. For the use case of defining points to drag to, there are PointConstraints. I adapted your example to create the intended behavior: MultiDrag Points (forked) - CodeSandbox

I added comments with NOTE TIM to where I changed something.

Cheers, Michael

Michael - this is great! Thank you so much for the fix and the detailed response. I can confirm that this has improved our experience in the right direction.

An additional question: Is there a way to know if the interactive object is not placed on a snap anchor? I realized that in this approach, users could place the object anywhere. Is there a way we can only let the user place the object on the snap points?

Hello Tim,

glad this example works for you! So there are currently two types of contraints in this example, plane and point constraints. You could remove the plane constraint so that you can only drag the object onto the points, but I think this might not be what you are looking for.

In this extended example I used a different approach. I reset the transformation matrix of the dragged object if it is not on a point constraint. Is this what you were looking for?

Cheers, Michael