Convert from one coordinate system to another?

You find the relevant code in the mentioned PR. For example the following matrix:

var matrix = new Matrix4().set(
    1,   0,   0,   0,
    0,   0,   1,   0,
    0, - 1,   0,   0,
    0,   0,   0,   1
);

is a so called change-of-basis matrix. It converts from right-handed Z-up to right-handed Y-up. You can convert a given local or world matrix of a 3D object like so:

var matrixInverse = matrix.clone().transpose();

object.matrix.premultiply( matrix ).multiply( matrixInverse );

This approach also allows to convert from left to right handed coordinates systems (and vice versa) with arbitrary up directions. It’s just a matter of how you compose the change-of-basis matrix.

2 Likes