lookAt method

void lookAt(
  1. Vector3 position
)

vector - A vector representing a position in world space. Optionally, the x, y and z components of the world space position.

Rotates the object to face a point in world space.

This method does not support objects having non-uniformly-scaled parent(s).

Implementation

void lookAt(Vector3 position) {
  // This method does not support objects having non-uniformly-scaled parent(s)

  _target.setFrom(position);

  final parent = this.parent;

  updateWorldMatrix(true, false);

  _position.setFromMatrixPosition(matrixWorld);

  if (this is Camera || this is Light) {
    m1.lookAt(_position, _target, up);
  } else {
    m1.lookAt(_target, _position, up);
  }

  quaternion.setFromRotationMatrix(m1);


  if (parent != null) {
    m1.extractRotation(parent.matrixWorld);
    _q1.setFromRotationMatrix(m1);
    _q1.conjugate();
    quaternion.multiply(_q1);
  }
}