提交 90a7955e 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #12128 from WestLangley/dev-lookAt

Support Object3D.lookAt( x, y, z )
......@@ -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]
......
......@@ -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>
......
......@@ -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 ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册