Просмотр исходного кода

Vector3: Improve feedback of .angleTo().

Mugen87 5 лет назад
Родитель
Сommit
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