/**
 *
 * @param {BinaryBuffer} buffer
 * @param {number[]} result
 * @param {number} result_offset
 *
 * @author Alex Goldring
 * @copyright Company Named Limited (c) 2026
 */
export function v3_binary_equality_decode(buffer, result, result_offset) {
    const header = buffer.readUint8();

    let x = 0;
    let y = 0;
    let z = 0;

    if ((header & 0b01111) === 0b01111) {
        // special encoded value, all 0

        x = 0;
        y = 0;
        z = 0;

    } else if ((header & 0b10111) === 0b10111) {

        // special encoded value, all 1

        x = 1;
        y = 1;
        z = 1;

    } else if ((header & 7) === 7) {
        //all scale components are the same
        x = buffer.readFloat32();
        y = x;
        z = x;
    } else if ((header & 1) === 1) {
        //X and Y are the same, Z is different
        x = buffer.readFloat32();
        y = x;
        z = buffer.readFloat32();
    } else if ((header & 2) === 2) {
        //Y and Z are the same, X is different
        x = buffer.readFloat32();
        y = buffer.readFloat32();
        z = y;
    } else if ((header & 4) === 4) {
        //X and Z are the same, Y is different
        x = buffer.readFloat32();
        y = buffer.readFloat32();
        z = x;
    } else {
        //scale components are different
        x = buffer.readFloat32();
        y = buffer.readFloat32();
        z = buffer.readFloat32();
    }

    result[result_offset] = x;
    result[result_offset + 1] = y;
    result[result_offset + 2] = z;
}