Răsfoiți Sursa

Support Object3D.lookAt( x, y, z )

WestLangley 8 ani în urmă
părinte
comite
b2363c60cd
3 a modificat fișierele cu 20 adăugiri și 11 ștergeri
  1. 0 8
      docs/api/cameras/Camera.html
  2. 8 2
      docs/api/core/Object3D.html
  3. 12 1
      src/core/Object3D.js

+ 0 - 8
docs/api/cameras/Camera.html

@@ -80,14 +80,6 @@
 		(which can be reused in this way), otherwise a new vector will be created.
 		</div>
 
-		<h3>[method:null lookAt]( [page:Vector3 target] )</h3>
-		<div>
-		target — position in 3D space for the camera to point towards<br /><br />
-
-		This makes the camera look at the vector position in the global space as long as
-		the parent of this camera is the scene or at position (0,0,0).
-		</div>
-
 		<h2>Source</h2>
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 8 - 2
docs/api/core/Object3D.html

@@ -287,11 +287,17 @@
 		Converts the vector from local space to world space.
 		</div>
 
-		<h3>[method:null lookAt]( [page:Vector3 vector] )</h3>
+		<h3>[method:null lookAt]( [page:Vector3 vector] )</br>
+		[method:null lookAt]( [page:Float x], [page:Float y], [page:Float z] )</h3>
 		<div>
 		vector - A vector representing a position in world space.<br /><br />
+		Optionally, the [page:.x x], [page:.y y] and [page:.z z] components of the world space position.<br /><br />
+
+		Rotates the object to face a point in world space.<br /><br />
+
+		This method does not support objects with rotated and/or translated parent(s).
+		</div>
 
-		Rotates the object to face a point in world space.
 		</div>
 
 		<h3>[method:Array raycast]( [page:Raycaster raycaster], [page:Array intersects] )</h3>

+ 12 - 1
src/core/Object3D.js

@@ -283,8 +283,19 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 		// This method does not support objects with rotated and/or translated parent(s)
 
 		var m1 = new Matrix4();
+		var vector = new Vector3();
 
-		return function lookAt( vector ) {
+		return function lookAt( x, y, z ) {
+
+			if ( x.isVector3 ) {
+
+				vector.copy( x );
+
+			} else {
+
+				vector.set( x, y, z );
+
+			}
 
 			if ( this.isCamera ) {