0
votes

I am trying to make an object mirror another objects rotation. The two objects have different parents. object3D's .getWorldQuaternion will give me the source objects rotation in world coordinates. How can I translate this to local space for the destination object?

1
Try updating the quaternion of the destination object like so: qDestLocal.multiplyQuaternions( qSourceWorld, qDestParentWorld.inverse() ); – WestLangley
I find that multiplying in the opposite order works. Don't ask me why. qDestLocal.multiplyQuaternions( qDestParentWorld.inverse(), qSourceWorld ); – Doguleez

1 Answers

0
votes

Its not quite the answer to my question, but here is how I solved my problem.

This will copy copy the entire world transform (including rotation) between objects even if they have different parents

// Copys the world transforms between objects even if the have different parents
var copyTransform = (function()
{
    var scratchMat = new THREE.Matrix4();
    return function(source, destination)
    {
        destination.matrix.copy(source.matrixWorld);
        destination.applyMatrix(scratchMat.getInverse(destination.parent.matrixWorld));     
    }
})();