/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
export class PointToPointHitTester {
    constructor(stencil, depthBuffer, viewport, camera) {
        this.stencil = stencil;
        this.depthBuffer = depthBuffer;
        this.viewport = viewport;
        this.camera = camera;
    }
    hitTest(pt) {
        const dpt = this.viewport.transformPointToFrame(pt, this.depthBuffer);
        if (this.stencil != null) {
            const spt = this.viewport.transformPointToFrame(pt, this.stencil);
            return this.stencil.hitTest(spt) || this.depthBuffer.hitTest(dpt);
        }
        else {
            return this.depthBuffer.hitTest(dpt);
        }
    }
    snapToNearestPixel(pt, radius) {
        if (this.stencil != null) {
            const framePt = this.viewport.transformPointToFrame(pt, this.stencil);
            const snapPt = this.stencil.snapToNearestPixel(framePt, radius);
            return this.viewport.transformPointToViewport(snapPt, this.stencil);
        }
        else {
            return pt;
        }
    }
    transformPointToWorld(pt, { ignoreHitTest = false } = {}) {
        const buffer = this.pickDepthBuffer(pt);
        if (buffer != null) {
            return this.viewport.transformPointToWorldSpace(pt, buffer);
        }
        else if (ignoreHitTest) {
            return this.viewport.transformPointToWorldSpace(pt, this.depthBuffer);
        }
    }
    pickDepthBuffer(pt) {
        if (this.stencil != null) {
            const stencilPt = this.viewport.transformPointToFrame(pt, this.stencil);
            if (this.stencil.hitTest(stencilPt)) {
                return this.stencil.depthBuffer;
            }
        }
        const depthPt = this.viewport.transformPointToFrame(pt, this.depthBuffer);
        return this.depthBuffer.hitTest(depthPt) ? this.depthBuffer : undefined;
    }
}
//# sourceMappingURL=hitTest.js.map
