Bläddra i källkod

Matrix4.lookAt(): accommodate z-up edge case

WestLangley 8 år sedan
förälder
incheckning
a4fdb7cdf0
1 ändrade filer med 12 tillägg och 2 borttagningar
  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 );
 
 			}