Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object3D.lookAt question #14930

Closed
makc opened this issue Sep 18, 2018 · 4 comments
Closed

Object3D.lookAt question #14930

makc opened this issue Sep 18, 2018 · 4 comments
Labels

Comments

@makc
Copy link
Contributor

makc commented Sep 18, 2018

Not sure if (or why) is this supposed to be like that, but Object3D.lookAt is currently long-ass code that does not work within hierarchy, and it even says so in the docs:

This method does not support objects with rotated and/or translated parent(s).

What am I currently using instead of mesh.lookAt (target) is these 2 lines:

				matrix4.lookAt (mesh.position, target, up);
  				mesh.quaternion.setFromRotationMatrix (matrix4);

I have target in local space, and could not care less where does up point to, so it works for me. However, even if I had to use world space and specific up, it would add at most couple of lines to convert them into local space and we're back to this simple code.

With that in mind, I'd like to know what is the reason behind current Object3D.lookAt version?

@WestLangley
Copy link
Collaborator

lookAt()orients the object so its local, positive z-axis points in the direction of the target, and its local x-axis is orthogonal to the world-space up direction. (For example, if the object were an airplane, its wings would remain level.)

Rotated parents are now supported; non-uniformly-scaled parents are not.

The docs, by the way, are outdated.

@makc
Copy link
Contributor Author

makc commented Oct 16, 2018

Rotated parents are now supported

I wonder why I couldn't get it to work then. Very well, I am closing this since I don't have a fiddle to back it up.

@backspaces
Copy link

Is this still the case?

lookAt() orients the object so its local, positive z-axis points in the direction of the target, and its local x-axis is orthogonal to the world-space up direction. (For example, if the object were an airplane, its wings would remain level.)

.. I need to point the positive x-axis at the target.

@mrdoob
Copy link
Owner

mrdoob commented Aug 18, 2020

Please, use the forum or the chat for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants