How to rotate camera around sphere in sync with mouse movement for proper panning?

orbit-controls
mouse

#1

Consider this fiddle, just a sphere with wireframe, which I took from this fiddle.

I would like to rotate the camera around a sphere in sync with my mouse movement. On mousedown-and-drag, you can obviously rotate the camera around that sphere. BUT, depending on your distance from the surface of the sphere, it seems as if the sphere is either rotating faster beneath you (when zoomed in) or slower (when zoomed out; i.e. the sphere is pretty small on the screen).

As the size of the sphere will not change in my application, I thought about just modifying the mouse panning speed depending on the distance of the camera to the sphere’s surface. There is a SE post about this, and it seems that panSpeed is now part of OrbitControls.

Question(s): Is panSpeed in reference to the rotational speed, or the speed of the mouse on the 2D screen? What is the unit of panSpeed? It does not seem trivial to me what the correct speed would be, given the distance to the surface of the sphere (or world center).

Any other ideas or pointers on how to do this properly are much appreciated.

Thanks!


#2

I think it’s important to clarify that OrbitControls does not transform the sphere. It transforms the camera.


#3

Yes, good point. It was not clear in my post.


#4

First, panSpeed is not a method but a property. The brackets at the end of the name in your post are misleading.

Second, panSpeed is used to compute the panDelta vector. panDelta.x and panDelta.y are in pixels. panSpeed is just a scalar value that modulates panDelta.