瀏覽代碼

Matrix4: Cache determinant result in decompose(). (#32658)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mrdoob 1 周之前
父節點
當前提交
548f3412b4
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/math/Matrix4.js

+ 4 - 3
src/math/Matrix4.js

@@ -1046,7 +1046,9 @@ class Matrix4 {
 		position.y = te[ 13 ];
 		position.z = te[ 14 ];
 
-		if ( this.determinant() === 0 ) {
+		const det = this.determinant();
+
+		if ( det === 0 ) {
 
 			scale.set( 1, 1, 1 );
 			quaternion.identity();
@@ -1059,8 +1061,7 @@ class Matrix4 {
 		const sy = _v1.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
 		const sz = _v1.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
 
-		// if determine is negative, we need to invert one scale
-		const det = this.determinant();
+		// if determinant is negative, we need to invert one scale
 		if ( det < 0 ) sx = - sx;
 
 		// scale the rotation part

粤ICP备19079148号