I am using OrbitControls for user navigation around the scene.
Now I would like to add some camera animation - on the same camera, or one that appears to be the same one by virtue of starting at the same place where the OrbitControls camera was. When the camera animation is complete, I want to user to be able to seamlessly go back to navigation in the scene using OrbitControls.
I think for this to work, I need to be able to set the azimuth and polar angle values for my OrbitControls object.
Is there a way to do that ?
There are not setters for the azimuthal and polar angles, only getters. These values are internally computed based on the event data and not intended to be set by the user.
If you still want to do this, you have to create a custom version of OrbitControls and add both methods by yourself. When animating, you have to disable OrbitControls (by setting the enabled property to false) and call update() by yourself.
Hi All, I have a simple solution that doesn’t require directly editing the OrbitControls class.
// Create a Spherical object and assign it the internal values of OrbitControls.
var spherical = new Spherical();
spherical.radius = orbitControls.getDistance();
spherical.phi = orbitControls.getPolarAngle();
spherical.theta = orbitControls.getAzimuthalAngle();
// Set the new values on the Spherical object.
spherical.radius = newDistance;
spherical.phi = newPolarAngle;
spherical.theta = newAzimuthalAngle;
// Update the camera position.
orbitControls.object.position.setFromSpherical(spherical);