2
0
Эх сурвалжийг харах

Merge pull request #17583 from Mugen87/dev34

Vector3: Improve feedback of .angleTo().
Michael Herzog 5 жил өмнө
parent
commit
e9420ca735
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