import { assert } from "../../../assert.js";

/**
 *
 * @param {Plane[]} planes
 * @param {ArrayLike<number>|number[]|Float32Array|Float64Array} array
 */
export function read_three_planes_to_array(planes, array) {
    const plane_count = planes.length;

    assert.greaterThanOrEqual(array.length, plane_count * 4, 'target array is too small');

    for (let i = 0; i < plane_count; i++) {
        const plane = planes[i];

        const offset = i * 4;

        const normal = plane.normal;

        array[offset] = normal.x;
        array[offset + 1] = normal.y;
        array[offset + 2] = normal.z;

        array[offset + 3] = plane.constant;
    }
}
