/** * Utility static class providing functionality to pack float values to various storage * representations. * * @category Math */ export class FloatPacking { /** * Packs a float to a 16-bit half-float representation used by the GPU. * * @param {number} value - The float value to pack. * @returns {number} The packed value. */ static float2Half(value: number): number; /** * Packs a float value in [0..1) range to specified number of bytes and stores them in an array * with start offset. Based on: https://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/ * Note: calls to Math.round are only needed on iOS. Precision is somehow really bad without * it. Looks like an issue with their implementation of Uint8ClampedArray. * * @param {number} value - The float value to pack. * @param {Uint8ClampedArray} array - The array to store the packed value in. * @param {number} offset - The start offset in the array to store the packed value at. * @param {number} numBytes - The number of bytes to pack the value to. * * @ignore */ static float2Bytes(value: number, array: Uint8ClampedArray, offset: number, numBytes: number): void; /** * Packs a float into specified number of bytes. Min and max range for the float is specified, * allowing the float to be normalized to 0..1 range. * * @param {number} value - The float value to pack. * @param {Uint8ClampedArray} array - The array to store the packed value in. * @param {number} offset - The start offset in the array to store the packed value at. * @param {number} min - Range minimum. * @param {number} max - Range maximum. * @param {number} numBytes - The number of bytes to pack the value to. * * @ignore */ static float2BytesRange(value: number, array: Uint8ClampedArray, offset: number, min: number, max: number, numBytes: number): void; /** * Packs a float into specified number of bytes, using 1 byte for exponent and the remaining * bytes for the mantissa. * * @param {number} value - The float value to pack. * @param {Uint8ClampedArray} array - The array to store the packed value in. * @param {number} offset - The start offset in the array to store the packed value at. * @param {number} numBytes - The number of bytes to pack the value to. * * @ignore */ static float2MantissaExponent(value: number, array: Uint8ClampedArray, offset: number, numBytes: number): void; }