Object3D.lookAt question

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?

Author: Fantashit

1 thought on “Object3D.lookAt question

  1. 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.

Comments are closed.