# Intuitive way to handle dragging outside the Arc Ball?

So I'm writing a game (or toy, rather), which involves manipulating a 3d object with the mouse. I'm trying to get the most intuitive control that I can.

I've implemented the "Arc Ball" mouse control. I'm happy with how it "feels", except for when I drag the mouse outside the range of the virtual ball.

Currently when the ray from camera to mouse-pointer in world-space does not intersect the virtual sphere, I simply find the closest point to it.

This results in something that acts like this example (not my code, just an example I found with the same implementation as me).

Notice the behaviour change when you click and drag away from the cube.

I'm not sure if it makes sense, but I am hoping for some way of allowing the cube to continue to rotate no matter how far away the mouse pointer gets, while still maintaining the useful property of standard Arc Ball that returning the pointer to the starting point will undo all rotation.

Any suggestions?

-

Let the distance from the center of the sphere to the border (in screen coordinates) be X. When the mouse moves away X from the center of the sphere, the sphere should rotate 1/4PI for a correct feeling (eg keeping under the mouse which was under the mouse). Now let Y be the distance from the sphere center to mouse in screen coordinates. The radians the sphere should rotate now is Y/X * 1/4PI and you should rotate over the axis perpendicular to that of the imaginary line between the center of the sphere and the mouse pointer (be sure to map this back to world coordinates this time first).

Be sure to be careful with rotations after rotations, maybe use quaternions if you're not already using them.

-
That sounds like it might work - I'll give it go tonight after work. – Blorgbeard Feb 15 '12 at 9:05

When implementing arc-ball rotation myself, I personally found that thinking it from the camera's perspective was must more easy and intuitive for me. Also, most (if not all) 3D programs (CAD, level editors) allow you to rotate the camera around a focus point (in your program, the focus point can be the centre of your object).