Browse Source

Merged Camera.lookAt() and Object3D.lookAt()

Mr.doob 8 years ago
parent
commit
a24962c347
2 changed files with 9 additions and 17 deletions
  1. 0 16
      src/cameras/Camera.js
  2. 9 1
      src/core/Object3D.js

+ 0 - 16
src/cameras/Camera.js

@@ -41,22 +41,6 @@ Camera.prototype.getWorldDirection = function () {
 
 }();
 
-Camera.prototype.lookAt = function () {
-
-	// This routine does not support cameras with rotated and/or translated parent(s)
-
-	var m1 = new Matrix4();
-
-	return function lookAt( vector ) {
-
-		m1.lookAt( this.position, vector, this.up );
-
-		this.quaternion.setFromRotationMatrix( m1 );
-
-	};
-
-}();
-
 Camera.prototype.clone = function () {
 
 	return new this.constructor().copy( this );

+ 9 - 1
src/core/Object3D.js

@@ -286,7 +286,15 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 
 			}
 
-			m1.lookAt( vector, this.position, this.up );
+			if ( this.isCamera ) {
+
+				m1.lookAt( this.position, vector, this.up );
+
+			} else {
+
+				m1.lookAt( vector, this.position, this.up );
+
+			}
 
 			this.quaternion.setFromRotationMatrix( m1 );