소스 검색

Merge pull request #11543 from WestLangley/dev-lookAt

Matrix4.lookAt(): accommodate z-up edge case
Mr.doob 8 년 전
부모
커밋
d7512d2f5f
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  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 );
 
 			}