Browse Source

Object3D.lookAt(): Added distance check.

Mr.doob 8 years ago
parent
commit
08620c6dfa
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/core/Object3D.js

+ 7 - 0
src/core/Object3D.js

@@ -279,6 +279,13 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 
 		return function lookAt( vector ) {
 
+			if ( this.position.distanceToSquared( vector ) === 0 ) {
+
+				console.warn( 'THREE.Object3D.lookAt(): target vector is the same as object position.' );
+				return;
+
+			}
+
 			m1.lookAt( vector, this.position, this.up );
 
 			this.quaternion.setFromRotationMatrix( m1 );