Drag camera/view in a 3D world
- by Dono
I'm trying to make a Draggable view in a 3D world.
Currently, I've made it using mouse position on the screen, but, when I move the distance traveled by my mouse is not equal to the distance traveled in the 3D world.
So, I've tried to do that :
Compute a ray from mouse position to 3D world.
Calculate intersection with the ground.
Check intersection difference old position <- new position.
Translate camera with the difference.
I've got a problem with this method:
The ray is computed with the current camera's position
I move the camera
I compute the new ray with new camera position.
The difference between old ray and new ray is now invalid.
So, graphically my camera don't stop to move to previous/new position everytime.
How can I do a draggable camera with another solution ?
Thanks!