소스 검색

Vector3: Improve feedback of .angleTo().

Mugen87 5 년 전
부모
커밋
04c1ca5ea5
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      src/math/Vector3.js

+ 5 - 1
src/math/Vector3.js

@@ -557,7 +557,11 @@ Object.assign( Vector3.prototype, {
 
 		// assumes this and v are not the zero vector
 
-		var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
+		var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
+
+		if ( denominator === 0 ) console.error( 'THREE.Vector3: angleTo() does not accept zero vectors.' );
+
+		var theta = this.dot( v ) / denominator;
 
 		// clamp, to handle numerical problems