three.js: matrix.extractRotation() returns incorrect rotation matrix when scale is negative

setFromRotationMatrix is incorrect when scale is negative on any axis. matrix.decompose returns correct rotation.

I assume this is because the following code is missing in setFromRotationMatrix (present in matrix.decompose):

// if determine is negative, we need to invert one scale
var det = this.determinant();
if ( det < 0 ) sx = - sx;

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

I would probably prefer to remove it, but I added a comment and patched it, instead.

In your case, are you referring to Quaternion or Euler?

In either case, you have to pass in a pure rotation matrix. (That is where the method name comes from.)

See the code comment:

// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)