Here is a snippet for rotating an object using slerp and quaternions:
//Initial and final quaternions var startQ = new THREE.Quaternion(0,0,0,1); var endQ = new THREE.Quaternion(0,1,0,0); //Number of animation frames var animFrames = 100; //Pause between two consecutive animation frames var deltaT = 1; function goSlerping(acc) { if(acc>=1) return; //Let assume that you want to rotate a 3D object named 'mesh'. So: THREE.Quaternion.slerp(startQ, endQ, mesh.quaternion, acc); setTimeout(function() { goSlerping(acc + (1/animFrames)); }, deltaT); } goSlerping(1/animFrames);
So using the script above to rotate the camera is exactly the same: you just need to change mesh.quaternion to camera.quaternion .
source share