lookAt static method

Returns a view matrix oriented from eye toward target, with up defining the vertical axis.

Implementation

static MatrixBase lookAt(Vector3Base eye, Vector3Base target, Vector3Base up)
{
  final vz = eye.sub(target).normalize() as Vector3Base;
  final vx = up.crossProduct(vz).normalize() as Vector3Base;
  final vy = vz.crossProduct(vx);

  final result = zeroFactory();

  result.m0 = vx.x;
  result.m1 = vy.x;
  result.m2 = vz.x;

  result.m4 = vx.y;
  result.m5 = vy.y;
  result.m6 = vz.y;

  result.m8 = vx.z;
  result.m9 = vy.z;
  result.m10 = vz.z;

  result.m12 = vx.dotProduct(eye);
  result.m13 = vy.dotProduct(eye);
  result.m14 = vz.dotProduct(eye);
  result.m15 = 1.0;

  return result;
}