using cannon.js I needed to rotate some bodies (otherwise the wheels fly onto the body of a car during the first few moments of your scene)… the following code rotates a vector by using a quaternion. More insights into quaternions you can find here
// Rotate the vector according to the quaternion
// quaternion needs to be normalized!!!
function rotateVector(vector, quaternion)
//The given quaternion is R in the form P'=RPR'
//Make a quaternion of the given vector
var quaternionVec = new CANNON.Quaternion(vector.x, vector.y, vector.z, 0); //P
var quaternionCon = quaternion.conjugate(); //R'
var newQuat = quaternion.mult(quaternionVec); //RP
newQuat = newQuat.mult(quaternionCon); //(RP)R'
//New vector is contained in calculated quaternion
return new CANNON.Vec3(newQuat.x, newQuat.y, newQuat.z);