Sfoglia il codice sorgente

Merge pull request #11543 from WestLangley/dev-lookAt

Matrix4.lookAt(): accommodate z-up edge case
Mr.doob 8 anni fa
parent
commit
d7512d2f5f
1 ha cambiato i file con 12 aggiunte e 2 eliminazioni
  1. 12 2
      src/math/Matrix4.js

+ 12 - 2
src/math/Matrix4.js

@@ -340,9 +340,19 @@ Object.assign( Matrix4.prototype, {
 
 			if ( x.lengthSq() === 0 ) {
 
-				// eye and target are in the same vertical
+				// up and z are parallel
 
-				z.z += 0.0001;
+				if ( Math.abs( up.z ) === 1 ) {
+
+					z.x += 0.0001;
+
+				} else {
+
+					z.z += 0.0001;
+
+				}
+
+				z.normalize();
 				x.crossVectors( up, z );
 
 			}