Skip to content

Commit

Permalink
Fix matrix decompose wrong when has negative scale component
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Jun 9, 2017
1 parent d2cf4ba commit 3c9dc7a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/math/Matrix4.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,15 @@ define(function(require) {
var sx = vec3.length(x);
var sy = vec3.length(y);
var sz = vec3.length(z);

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

if (scale) {
scale.x = sx;
scale.y = sy;
scale.z = sz;
scale._dirty = true;
scale.set(sx, sy, sz);
}

position.set(el[12], el[13], el[14]);
Expand Down

0 comments on commit 3c9dc7a

Please sign in to comment.