• Compresses a flat array of UV coordinates into a quantized representation.

    This function maps the input UV coordinates to a 16-bit integer range [0, 65535] based on the provided min and max bounds for each coordinate. The resulting quantized UVs are returned along with a matrix that can be used to decompress them back to their original range. This is commonly used in texture mapping for more efficient storage.

    The compression uses a simple linear transformation based on the provided min and max values for each component of the UV coordinates.

    Parameters

    • array: FloatArrayParam

      The input array of UV coordinates (each UV pair consisting of [u, v]).

    • min: FloatArrayParam

      The minimum values for [u, v] coordinates to scale to the quantized range.

    • max: FloatArrayParam

      The maximum values for [u, v] coordinates to scale to the quantized range.

    Returns { decompressMatrix: FloatArrayParam; quantized: Uint16Array<any> }

    • An object containing:
      • quantized: The quantized UV coordinates as a Uint16Array.
      • decompressMatrix: A matrix (either FloatArray or Float64Array) used to decompress the quantized UVs back to their original values.
    const uvs = new Float32Array([0.1, 0.2, 0.5, 0.6]);
    const min = new Float32Array([0, 0]);
    const max = new Float32Array([1, 1]);
    const { quantized, decompressMatrix } = compressUVs(uvs, min, max);
MMNEPVFCICPMFPCPTTAAATR