/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { Point } from "@vertexvis/geometry";
/**
 * The `Raycaster` class is here.
 */
export class Raycaster {
    constructor(stream, imageScaleProvider) {
        this.stream = stream;
        this.imageScaleProvider = imageScaleProvider;
    }
    /**
     * Performs request on the stream to find items that intersect
     * the given point.
     *
     * @example
     * ```typescript
     * const viewer = document.querySelector("vertex-viewer");
     *
     * viewer.addEventListener("tap", async (event) => {
     *   const scene = await viewer.scene();
     *   const raycaster = scene.raycaster();
     *
     *   // Query the scene for the item at the position of the `tap` event
     *   const [hit] = await raycaster.hitItems(event.detail.position);
     *
     *   if (hit != null) {
     *     // If there was an item present at the position, select it
     *     await scene.elements((op) =>
     *       op.items.where((q) => q.withItemId(hit.itemId.hex)).select()
     *     );
     *   }
     * });
     * ```
     *
     * @see {@link Scene.items} for more information on the operations that
     * can be performed on a hit result.
     *
     * @param point The point to cast from looking for intersections.
     * @param options Optional set of options for the request @see {@link RaycasterOptions}
     * for available options.
     */
    async hitItems(point, options) {
        const scale = this.imageScaleProvider();
        const res = await this.stream.hitItems({
            point: Point.scale(point, (scale === null || scale === void 0 ? void 0 : scale.x) || 1, (scale === null || scale === void 0 ? void 0 : scale.y) || 1),
            includeMetadata: options === null || options === void 0 ? void 0 : options.includeMetadata,
        }, true);
        return res.hitItems || undefined;
    }
}
//# sourceMappingURL=raycaster.js.map
