/**
 * Creates a new projection matrix for customized orthographic view
 * Adapted for WebGPU.
 * @param {number[]|Float32Array[]} output 4x4 matrix will be written here
 * @param {number} left Lower x-value at the near plane (x0)
 * @param {number} right Upper x-value at the near plane (x1)
 * @param {number} bottom Lower y-coordinate at the near plane (y0)
 * @param {number} top Upper y-value at the near plane (y1)
 * @param {number} z_near Depth of the near plane (z0)
 * @param {number} z_far Depth of the far plane (z1)
 * @returns {number[]} `output` parameter
 */
export function m4_orthographic_off_center_z0(
    output,
    left, right,
    bottom, top,
    z_near, z_far
) {
    // see https://github.com/TheRealMJP/Shadows/blob/338290a57e7c65d493783fd48f39a28321e84e81/Shadows/SetupShadows.hlsl#L39

    output[0] = 2 / (right - left);
    output[1] = 0;
    output[2] = 0;
    output[3] = 0;

    output[4] = 0;
    output[5] = 2 / (top - bottom);
    output[6] = 0;
    output[7] = 0;

    output[8] = 0;
    output[9] = 0;
    output[10] = 1.0 / (z_far - z_near);
    output[11] = 0;

    output[12] = (left + right) / (left - right);
    output[13] = (top + bottom) / (bottom - top);
    output[14] = z_near / (z_near - z_far);
    output[15] = 1;

    return output;
}