Skip to content

Use drag gestures to rotate Three camera with damping #1898

Discussion options

You must be logged in to vote

Perhaps too late of an answer, but I don't think there's a simpler way to "automatically" bind the rotation to the drag. I think the closest would be using the transform option in use-gesture, but that just moves the calculation and you still have to use the spring api.

Here's one way to accomplish the drag + inertia rotation (still doing the cursor -> rotation calc, but the spring is used to handle the momentum animation):

  1. While the user is dragging, use api.set() to directly update the rotation (to make it feel responsive to the cursor).
  2. When the drag ends, calculate the projected "end position" based on the velocity of the drag, and use api.start() to animate to that end position.

De…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@janrembold
Comment options

Answer selected by janrembold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants