import { computeConePlaneSide } from "../../../../../core/geom/3d/cone/computeConePlaneSide.js";

/**
 *
 * @param {SpotLight} light
 * @param {number[]} points
 * @param {number[]|Float32Array|Float64Array} planes
 * @returns {boolean}
 */
export function spot_light_inside_volume(light, points, planes) {
    for (let j = 0; j < 6; j++) {

        const plane_address = j * 4;

        const plane_normal_x = planes[plane_address];
        const plane_normal_y = planes[plane_address + 1];
        const plane_normal_z = planes[plane_address + 2];
        const plane_constant = planes[plane_address + 3];

        const side = computeConePlaneSide(
            plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
            light.position.x, light.position.y, light.position.z,
            light.direction.x, light.direction.y, light.direction.z,
            light.angle.getValue(), light.distance.getValue()
        );

        if (side < 0) {
            return false;
        }
    }

    return true;
}
