import { BufferAttribute, BufferGeometry, Float32BufferAttribute } from "three";

export function makeHelperBoxGeometry(sx = 1, sy = 1, sz = 1) {

    const geometry = new BufferGeometry();

    const dx = sx / 2;
    const dy = sy / 2;
    const dz = sz / 2;

    const vertices = new Float32Array([
        -dx, -dy, -dz,
        dx, -dy, -dz,
        dx, dy, -dz,
        -dx, dy, -dz,

        -dx, dy, dz,
        dx, dy, dz,
        dx, -dy, dz,
        -dx, -dy, dz
    ]);

    geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));

    geometry.setIndex(new BufferAttribute(new Uint8Array([
        0, 1,
        1, 2,
        2, 3,
        3, 0,

        4, 5,
        5, 6,
        6, 7,
        7, 4,


        0, 7,
        1, 6,
        2, 5,
        3, 4
    ]), 1, false));

    return geometry;
}
