import { depthOfFieldPixels } from "../../PostProcessPass.js";
import { createProductionDepthProxy, createProductionPostProcessOutput } from "./ProductionPostProcessTypes.js";
export class DOFPass {
    options;
    name = "production-depth-of-field";
    enabled;
    lastResult = null;
    constructor(options = {}) {
        this.options = options;
        this.enabled = options.enabled ?? true;
    }
    apply(input) {
        const intensity = this.enabled ? this.options.intensity ?? 1 : 0;
        const result = depthOfFieldPixels(input.pixels, input.width, input.height, {
            depth: this.options.depth ?? input.depth ?? createProductionDepthProxy(input.width, input.height),
            focusDepth: this.options.focusDepth ?? 0.44,
            focusRange: this.options.focusRange ?? 0.09,
            maxRadius: this.options.maxRadius ?? Math.max(0, Math.round(3 * intensity))
        });
        this.lastResult = result;
        return createProductionPostProcessOutput(input, this.name, result.pixels, {
            blurredPixels: result.blurredPixels,
            maxBlurRadius: result.maxBlurRadius,
            focusDepth: result.focusDepth
        }, ["DOFPass applies the renderer depth-of-field pixel kernel with supplied or generated depth evidence."]);
    }
    getLastResult() {
        return this.lastResult ? { ...this.lastResult, pixels: new Uint8Array(this.lastResult.pixels) } : null;
    }
}
//# sourceMappingURL=DOFPass.js.map