I’m using an Orthographic camera and Trackball controls. There are various reasons why a perspective camera and orbit controls don’t work for me so I’m “stuck” with this setup. I’m very happy with it but I’ve got a problem with the rotate speed of the trackball controls. I’ve defined the “rotateSpeed” as a constant so that the object can be rotated at a comfortable speed. But when zooming in, the speed is too high. The object shoots out of view with the slightest mouse movement. So I’ve made the rotate speed dynamic by calculating it depending on the zoom level. This wasn’t as simple as I’ve thought because the zoom level is not linear (logarithmic?). I’ve managed to get an algorithm that works well with my test object. But my objects can have various sizes and if I test it with a larger object, the speed is very far off.
Does anybody know of a good way to setup a dynamic rotate speed so that the objects rotate slower when zoomed in?
Thanks for the tip. Very interesting. I came up with many of the same techniques, theirs is just more elegant
Unfortunately it doesn’t solve my problem. They are doing this with a simple 1x1x1 cube and their calculation for the rotation speed is a simple “targetSpeed = baseSpeed / zoom” with a lower and upper bound. This fails in my case because the varying size of my objects means the zoom value is wildly different from part to part.
But I like how they calculated the speed in the animation loop. I’m gonna steal that for sure.
Thank you! This led me to a solution I think I’m happy with.
I’ve setup a few scenarios with different objects and zoom levels and manually adjusted the rotate speed to where it’s comfortable to use. Using these recorded values I’ve used the Python SciPy library to fit a polynomial function that produces something close to my desired values. In the end a function in the following form produced the best results:
a * zoom^b + c * boundingRadius^d
If the values become too extreme, the calculated speed gets out of hand so I cap it with a lower and upper bound (0.1 > speed < 20).
Good intuition. I went back and tried some more curve fitting. I could improve the result by using the following form:
a * zoom^b + c * boundingRadius
So I’m getting rid of the exponent for the radius of the bounding sphere, as that is indeed a linear value. But the exponent for the zoom is still beneficial.