lookAt method

void lookAt(
  1. Vector3 target, {
  2. Vector3? up,
})

Implementation

void lookAt(Vector3 target, {Vector3? up}) {
  final upDir = up ?? Vector3(0, 1, 0);

  final m = makeViewMatrix(_position, target, upDir);
  // vector_math's makeViewMatrix already stores the basis vectors as
  // matrix columns, so getRotation() IS the camera world rotation.
  // Transposing here would flip the vertical component of the forward
  // vector (cameras looking down ended up looking up — scene culled).
  _rotation = Quaternion.fromRotation(m.getRotation());
  _rotation.normalize();
  _dirty = true;
}