projectionMatrix method

Matrix4 projectionMatrix()

Column-major OpenGL projection built from intrinsics. Uses ndcYSign to control vertical orientation.

Implementation

Matrix4 projectionMatrix() {
  final fovX = (2 * fx) / width;
  final fovY = ndcYSign * (2 * fy) / height;
  final a = zfar / (zfar - znear);
  final b = -(zfar * znear) / (zfar - znear);

  return Matrix4(
    fovX,
    0,
    0,
    0,
    0,
    fovY,
    0,
    0,
    0,
    0,
    a,
    1,
    0,
    0,
    b,
    0,
  );
}