Search code examples
three.jsquaternions

Three.js How to use quaternion to rotate camera (part 2)


Can anyone modify this basic file

http://jsfiddle.net/koweiny/MQkKW/

so that the camera (not the cube) rotates around the cube using quaternions?

I've been searching for an example around the web and I haven't found any. Found indications simply don't work. And I've checked that there are also many people looking for an example. A simple rotation would be enough to illustrate the mechanism.

By the way:

THREE.Quaternion.slerp(a, b, c, d);

What are a, b, c and d used for in that function? Is slerp the best way to rotate a camera?


Solution

  • Quaternions are used to set an object's orientation, not to rotate an object around a another object. So the answer to your question is "No". Sorry.

    THREE.Quaternion.slerp( fromQuaternion, toQuaternion, quaternionToSet, fractionOfTheWay);
    

    You can change an camera's orientation by setting either camera.rotation or camera.quaternion.

    three.js r.55