import { Box3, Vector2, Vector3 } from "../utils/math3d"; import { RpcSafeClient } from "./rpcSafeClient"; import { Vim } from "./vim"; import { IReadonlyVimCollection } from "./vimCollection"; export interface IViewerSelection { hitTest(pos: Vector2): Promise; select(vim: Vim, node: number | number[]): void; toggle(vim: Vim, node: number | number[]): void; add(vim: Vim, node: number | number[]): void; remove(vim: Vim, node: number | number[]): void; clear(vim?: Vim): void; } /** * Represents the result of a hit test operation. */ export type HitTestResult = { /** The Vim instance that was hit */ vim: Vim; /** The index of the node that was hit */ nodeIndex: number; /** The 3D world position of the hit point */ worldPosition: Vector3; /** The surface normal at the hit point */ worldNormal: Vector3; }; /** * Manages selection state of nodes across multiple VIM instances. */ export declare class ViewerSelection implements IViewerSelection { private _rpc; private _vims; private _selectedNodes; /** * Creates a new ViewerSelection instance. * @param rpc - RPC client for communication with the viewer. * @param vims - Collection of VIM instances to manage. */ constructor(rpc: RpcSafeClient, vims: IReadonlyVimCollection); /** * Gets the total number of selected nodes across all VIMs. * @returns The total count of selected nodes. */ get count(): number; /** * Performs a hit test at the specified screen position. * @param pos - The screen position in 2D coordinates. * @returns Promise resolving to hit test result or undefined if no hit. */ hitTest(pos: Vector2): Promise; /** * Replaces the current selection with the specified node(s). * Clears all previous selections across all VIMs. * @param vim - The Vim instance to select nodes from. * @param node - A single node index or array of node indices to select. */ select(vim: Vim, node: number | number[]): void; /** * Toggles the selection state of the specified node(s). * If a node is currently selected, it will be deselected, and vice versa. * @param vim - The Vim instance containing the nodes. * @param node - A single node index or array of node indices to toggle. */ toggle(vim: Vim, node: number | number[]): void; /** * Adds the specified node(s) to the current selection. * If a node is already selected, it remains selected. * @param vim - The Vim instance containing the nodes. * @param node - A single node index or array of node indices to add. */ add(vim: Vim, node: number | number[]): void; /** * Removes the specified node(s) from the current selection. * If a node is not selected, no action is taken for that node. * @param vim - The Vim instance containing the nodes. * @param node - A single node index or array of node indices to remove. */ remove(vim: Vim, node: number | number[]): void; /** * Clears all selections across all VIMs or for a specific VIM. * @param vim - Optional. If provided, only clears selections for the specified VIM. */ clear(vim?: Vim): void; /** * Calculates the bounding box encompassing all selected nodes. * @returns Promise resolving to a Box3 representing the bounds of all selected nodes, * or undefined if no nodes are selected or bounds cannot be calculated. */ getBoundingBox(): Promise; /** * Cleans up resources and releases memory. * Should be called when the selection manager is no longer needed. */ dispose(): void; }