I am using an orbital camera that orbits around a globe with markers for users to interact with. When a user clicks on a marker, the camera moves to that specific point.
To animate this movement, I am utilizing TweenMax as shown below:
TweenMax.to(currentPos, 3, {
theta:targetPos.theta,
phi:targetPos.phi,
radius:targetPos.radius,
ease:Circ.easeIn,
onComplete:btnZoomComplete,
onUpdateParams:["{self}"],
onComplete:SataliteTweenComplete,
onUpdate: function(tween) {
controls.setThetaPhi(tween.target.theta, tween.target.phi, tween.target.radius);
}
});
While this method works well, it does not always take the shortest route to reach the destination, often resulting in the camera going 'round the back' of the globe.
I have encountered difficulties with ThreeJS's angle measurement system which jumps from 0 to 1.57 (equivalent to 90 degrees), then to 3.14 (180 degrees), and abruptly shifts to negative values starting at -3.14 and so on. This has made it challenging for me to calculate the optimal path.
For instance, if the camera is at 2.6 and needs to move across to -2.61, the animation currently goes counter-clockwise (from 2.6 to -2.16) instead of clockwise (from 2.6 to 3.14, -3.14, and finally -2.61).
I would greatly appreciate any guidance on how to determine the correct direction to traverse and seamlessly animate from one point to another.
The two main challenges I face are figuring out the direction of rotation and smoothly transitioning from one angle to another, such as moving from 2.6 to 3.14, transitioning to -3.14, and arriving at -2.61