• Quantizes the position values of 3D coordinates into a compressed 16-bit representation. The positions are mapped into a defined bounding box (AABB) and then scaled to fit into a 16-bit integer range, minimizing precision loss.

    This process is commonly used in mesh compression techniques to reduce the _gpuMemoryManager footprint of position data while maintaining relative accuracy within the bounds of the specified AABB.

    Parameters

    • positions: FloatArrayParam

      A flat array of 3D position data (x, y, z).

    • aabb: AABB3

      The axis-aligned bounding box (AABB) represented as a 6-element array [xmin, ymin, zmin, xmax, ymax, zmax].

    Returns IntArrayParam

    A new array containing the quantized positions in a compressed 16-bit format.

    const positions = new Float32Array([0.5, 0.7, 1.0, 1.2, 1.8, 2.0]);
    const aabb = new Float32Array([0, 0, 0, 2, 2, 2]);
    const quantizedPositions = quantizePositions3(positions, aabb);
    console.log(quantizedPositions);