Three.js: Object3D.lookAt question

Created on 18 Sep 2018  路  4Comments  路  Source: mrdoob/three.js

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?

Question

All 4 comments

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.

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.

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.

Please, use the forum or the chat for help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieljack picture danieljack  路  3Comments

Horray picture Horray  路  3Comments

yqrashawn picture yqrashawn  路  3Comments

makc picture makc  路  3Comments

jlaquinte picture jlaquinte  路  3Comments