import {} from "./LightCollector.js";
import {} from "./CascadedShadowMaps.js";
export class LightingDebug {
    buildLightLines(lights, length = 1) {
        if (!(length > 0)) {
            throw new RangeError("Debug light line length must be positive");
        }
        return lights.map((light) => {
            const from = light.position;
            const to = [
                from[0] + light.direction[0] * length,
                from[1] + light.direction[1] * length,
                from[2] + light.direction[2] * length
            ];
            return {
                from,
                to,
                color: [light.color[0], light.color[1], light.color[2], 1]
            };
        });
    }
    buildShadowMapLabel(light) {
        return `${light.kind}:${light.castsShadow ? "shadow" : "unshadowed"}:${light.intensity.toFixed(3)}`;
    }
    buildCascadeLines(splits, width = 2) {
        if (!(width > 0)) {
            throw new RangeError("Cascade debug width must be positive");
        }
        const lines = [];
        for (const split of splits) {
            if (!(split.near > 0) || !(split.far > split.near)) {
                throw new RangeError("Cascade split near/far range is invalid");
            }
            const halfWidth = width / 2;
            const color = cascadeColor(split.index);
            const nearZ = -split.near;
            const farZ = -split.far;
            const nearCorners = [
                [-halfWidth, -halfWidth, nearZ],
                [halfWidth, -halfWidth, nearZ],
                [halfWidth, halfWidth, nearZ],
                [-halfWidth, halfWidth, nearZ]
            ];
            const farCorners = [
                [-halfWidth, -halfWidth, farZ],
                [halfWidth, -halfWidth, farZ],
                [halfWidth, halfWidth, farZ],
                [-halfWidth, halfWidth, farZ]
            ];
            for (let index = 0; index < 4; index += 1) {
                const next = (index + 1) % 4;
                lines.push({ from: nearCorners[index], to: nearCorners[next], color });
                lines.push({ from: farCorners[index], to: farCorners[next], color });
                lines.push({ from: nearCorners[index], to: farCorners[index], color });
            }
        }
        return lines;
    }
}
function cascadeColor(index) {
    const palette = [
        [0.95, 0.3, 0.2, 1],
        [0.2, 0.75, 0.35, 1],
        [0.2, 0.45, 1, 1],
        [0.95, 0.8, 0.2, 1]
    ];
    return palette[Math.abs(index) % palette.length];
}
//# sourceMappingURL=LightingDebug.js.map