import { Box3, RGBA, RGBA32, Segment, Vector2, Vector3 } from "../utils/math3d"; import { HitCheckResult } from "./marshal"; import { MaterialHandle, RpcClient } from "./rpcClient"; export type VimLoadingState = { status: VimLoadingStatus; progress: number; }; export declare enum InputMode { Orbit = "orbit", Free = "free" } export type SceneSettings = { toneMappingWhitePoint: number; hdrScale: number; hdrBackgroundScale: number; hdrBackgroundSaturation: number; backGroundBlur: number; backgroundColor: RGBA; }; export declare const defaultSceneSettings: SceneSettings; export declare enum VimLoadingStatus { Unknown = 0, Loading = 1, Downloading = 2, Done = 3, FailedToDownload = 4, FailedToLoad = 5 } /** * Provides safe, validated methods to interact with the RpcClient. * This class wraps the raw RPC methods with input validation and batching support for large operations. */ export declare class RpcSafeClient { private readonly rpc; private readonly batchSize; constructor(rpc: RpcClient, batchSize?: number); /******************************************************************************* * SCENE MANAGEMENT METHODS * Methods for managing the overall scene, including initialization, lighting, * and scene-wide settings. ******************************************************************************/ /** * Initializes and starts the scene with specified settings. * @param settings - Optional partial scene settings to override defaults * @remarks If no settings are provided, default values will be used */ RPCStartScene(settings?: Partial): void; /** * Sets the lighting settings for the scene. * @param settings - The lighting settings to apply */ RPCSetLighting(settings: SceneSettings): void; RPCLockIblRotation(lock: boolean): void; /******************************************************************************* * NODE VISIBILITY METHODS * Methods for controlling node visibility, including show/hide, ghosting, * and highlighting functionality. ******************************************************************************/ /** * Hides all nodes in a component, making the entire component invisible. * @param componentHandle - The component to hide entirely * @throws {Error} If the component handle is invalid */ RPCHideAll(componentHandle: number): void; /** * Shows all nodes in a component, making the entire component visible. * @param componentHandle - The component to show entirely * @throws {Error} If the component handle is invalid */ RPCShowAll(componentHandle: number): void; /** * Makes all nodes in a component semi-transparent (ghosted). * @param componentHandle - The component to ghost entirely * @throws {Error} If the component handle is invalid */ RPCGhostAll(componentHandle: number): void; /** * Highlights all nodes in a component. * @param componentHandle - The component to highlight entirely * @throws {Error} If the component handle is invalid */ RPCHighlightAll(componentHandle: number): void; /** * Hides specified nodes in a component, making them invisible. * Large node arrays are automatically processed in batches. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices to hide * @throws {Error} If the component handle is invalid or nodes array is invalid */ RPCHide(componentHandle: number, nodes: number[]): void; /** * Shows specified nodes in a component, making them visible. * Large node arrays are automatically processed in batches. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices to show * @throws {Error} If the component handle is invalid or nodes array is invalid */ RPCShow(componentHandle: number, nodes: number[]): void; /** * Makes specified nodes semi-transparent (ghosted) in a component. * Large node arrays are automatically processed in batches. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices to ghost * @throws {Error} If the component handle is invalid or nodes array is invalid */ RPCGhost(componentHandle: number, nodes: number[]): void; /** * Highlights specified nodes in a component. * Large node arrays are automatically processed in batches. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices to highlight * @throws {Error} If the component handle is invalid or nodes array is invalid */ RPCHighlight(componentHandle: number, nodes: number[]): void; /******************************************************************************* * TEXT AND UI METHODS * Methods for creating and managing 3D text elements in the scene. ******************************************************************************/ /** * Creates a 3D text element in the scene. * @param position - The world-space position for the text * @param color - The color of the text * @param text - The content to display * @returns Promise resolving to the handle of the created text component * @throws {Error} If the text is empty */ RPCCreateText(position: Vector3, color: RGBA32, text: string): Promise; /** * Destroys a text component, removing it from the scene. * @param componentHandle - The handle of the text component to destroy * @throws {Error} If the component handle is invalid */ RPCDestroyText(componentHandle: number): void; /******************************************************************************* * CAMERA AND VIEW METHODS * Methods for controlling camera position, movement, framing, and view settings. ******************************************************************************/ /** * Retrieves the current camera position and orientation. * @returns Promise resolving to a segment representing the camera's current position and target */ RPCGetCameraPosition(): Promise; /** * Sets the camera position and orientation. * @param segment - The desired camera position and target * @param blendTime - Duration of the camera transition in seconds (non-negative) * @throws {Error} If segment is invalid or blendTime is negative */ RPCSetCameraPosition(segment: Segment, blendTime: number): void; /** * Calculates the bounding box for specified nodes in a component. * Large node arrays are automatically processed in batches for better performance. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices to calculate bounds for * @returns Promise resolving to the combined bounding box * @throws {Error} If the component handle is invalid or nodes array is invalid */ RPCGetBoundingBox(componentHandle: number, nodes: number[]): Promise; private getBoundingBoxBatched; /** * Frames the camera to show all components in the scene. * @param blendTime - Duration of the camera transition in seconds (non-negative) * @returns Promise resolving to camera segment representing the final position */ RPCFrameAll(blendTime: number): Promise; /** * Frames a specific VIM component in the scene. * @param componentHandle - The handle of the VIM component to frame * @param blendTime - Duration of the camera transition in seconds (non-negative) * @returns Promise resolving to camera segment representing the final position * @throws {Error} If the component handle is invalid */ RPCFrameVim(componentHandle: number, blendTime: number): Promise; /** * Frames specific instances within a component. For large numbers of instances, * automatically switches to bounding box framing for better performance. * @param componentHandle - The component containing the instances * @param nodes - Array of node indices to frame * @param blendTime - Duration of the camera transition in seconds (non-negative) * @returns Promise resolving to camera segment representing the final position * @throws {Error} If the component handle is invalid or nodes array is empty */ RPCFrameInstances(componentHandle: number, nodes: number[], blendTime: number): Promise; /** * Frames the camera to show a specific bounding box. * @param box - The bounding box to frame * @param blendTime - Duration of the camera transition in seconds (non-negative) * @throws {Error} If the box is invalid (min values must be less than max values) */ RPCFrameBox(box: Box3, blendTime: number): Promise; /******************************************************************************* * INPUT HANDLING METHODS * Methods for handling user input including mouse, keyboard, and camera controls. ******************************************************************************/ /** * Sets the camera movement speed. * @param speed - The desired movement speed (must be positive) * @throws {Error} If speed is not positive */ RPCSetMoveSpeed(speed: number): void; RPCSetCameraMode(mode: InputMode): void; /** * Sets the viewer's aspect ratio. * @param width - The width component of the aspect ratio * @param height - The height component of the aspect ratio * @throws {Error} If width or height are not positive integers */ RPCSetAspectRatio(width: number, height: number): void; /******************************************************************************* * VIM FILE MANAGEMENT METHODS * Methods for loading, unloading, and managing VIM files and components. ******************************************************************************/ /** * Loads a VIM file from the local filesystem. * @param fileName - The path to the VIM file (supports file:// protocol) * @returns Promise resolving to the handle of the loaded VIM component * @throws {Error} If the filename is invalid or empty */ RPCLoadVim(fileName: string): Promise; /** * Loads a VIM file from a remote URL. * @param url - The URL of the VIM file to load * @returns Promise resolving to the handle of the loaded VIM component * @throws {Error} If the URL is invalid */ RPCLoadVimURL(url: string): Promise; /** * Retrieves the current loading state and progress of a VIM component. * @param componentHandle - The handle of the VIM component * @returns Promise resolving to the current loading state and progress * @throws {Error} If the component handle is invalid */ RPCGetVimLoadingState(componentHandle: number): Promise; /** * Unloads a VIM component and frees associated resources. * @param componentHandle - The handle of the component to unload * @throws {Error} If the component handle is invalid */ RPCUnloadVim(componentHandle: number): void; /** * Clears the entire scene, removing all components and resetting to initial state. */ RPCClearScene(): void; /** * Sets the color used for ghosted geometry. * @param ghostColor - The RGBA color to use for ghosted elements */ RPCSetGhostColor(ghostColor: RGBA): void; /** * Performs hit testing at a specified screen position. * @param pos - Normalized screen coordinates (0-1, 0-1) * @returns Promise resolving to hit test result if something was hit, undefined otherwise */ RPCPerformHitTest(pos: Vector2): Promise; /** * Sends a mouse button event to the viewer. * @param position - The normalized screen coordinates (0-1, 0-1) * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right) * @param down - True if button is pressed down, false if released * @throws {Error} If mouseButton is not a valid positive integer */ RPCMouseButtonEvent(position: Vector2, mouseButton: number, down: boolean): void; /** * Sends a mouse double-click event to the viewer. * @param position - The normalized screen coordinates (0-1, 0-1) * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right) * @throws {Error} If mouseButton is not a valid positive integer */ RPCMouseDoubleClickEvent(position: Vector2, mouseButton: number): void; /** * Sends a mouse movement event to the viewer. * @param position - The normalized screen coordinates (0-1, 0-1) */ RPCMouseMoveEvent(position: Vector2): void; /** * Sends a mouse scroll wheel event to the viewer. * @param scrollValue - The scroll amount (-1 to 1) */ RPCMouseScrollEvent(scrollValue: number): void; /** * Sends a mouse selection event to the viewer. * @param position - The normalized screen coordinates (0-1, 0-1) * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right) * @throws {Error} If mouseButton is not a valid positive integer */ RPCMouseSelectEvent(position: Vector2, mouseButton: number): void; /** * Sends a keyboard event to the viewer. * @param keyCode - The key code of the event * @param down - True if key is pressed down, false if released */ RPCKeyEvent(keyCode: number, down: boolean): void; /******************************************************************************* * MATERIAL MANAGEMENT METHODS * Methods for creating and managing materials and material instances. ******************************************************************************/ /** * Creates multiple material instances with the same smoothness but different colors. * Large color arrays are automatically processed in batches for better performance. * @param materialHandle - The base material to create instances from * @param smoothness - The smoothness value to apply (clamped between 0 and 1) * @param colors - Array of colors for each material instance * @returns Array of handles for the created material instances * @throws {Error} If the material handle is invalid or smoothness is out of range */ RPCCreateMaterialInstances(materialHandle: MaterialHandle, smoothness: number, colors: RGBA32[]): Promise; private createMaterialInstancesBatched; /** * Destroys multiple material instances, freeing associated resources. * @param materialInstanceHandle - Array of handles for material instances to destroy * @throws {Error} If any handle in the array is invalid */ RPCDestroyMaterialInstances(materialInstanceHandle: number[]): void; /** * Sets material overrides for specific nodes in a component. * Large arrays are automatically processed in batches for better performance. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices to override * @param materialInstanceHandles - Array of material instance handles to apply (must match nodes length) * @throws {Error} If arrays have different lengths or any handle is invalid */ RPCSetMaterialOverrides(componentHandle: number, nodes: number[], materialInstanceHandles: number[]): void; private setMaterialOverridesBatched; /** * Clears all material overrides for the specified component, restoring default materials. * @param componentHandle - The unique identifier of the component * @throws {Error} If the component handle is invalid or INVALID_HANDLE */ RPCClearMaterialOverrides(componentHandle: number): void; /******************************************************************************* * DEBUG AND UTILITY METHODS * Utility methods for debugging, error handling, and misc functionality. ******************************************************************************/ /** * Retrieves the current API version from the RPC client. * @returns Promise resolving to the API version string */ RPCGetAPIVersion(): Promise; /** * Gets the API version of the underlying RPC client. * @returns The API version string. */ get API_VERSION(): string; /** * Retrieves the last error message from the RPC client. * @returns Promise resolving to the last error message string */ RPCGetLastError(): Promise; /** * Pauses or resumes the rendering loop. * @param pause - True to pause rendering, false to resume */ RPCPauseRendering(pause: boolean): void; /** * Triggers a RenderDoc frame capture if RenderDoc is attached. */ RPCTriggerRenderDocCapture(): void; /** * Shows axis-aligned bounding boxes (AABBs) for specified nodes with custom colors. * Large arrays are automatically processed in batches for better performance. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices to show AABBs for * @param colors - Array of colors for each AABB (must match nodes length) * @throws {Error} If arrays have different lengths or component handle is invalid */ RPCShowAABBs(componentHandle: number, nodes: number[], colors: RGBA32[]): void; /** * Hides the axis-aligned bounding boxes (AABBs) for specified nodes. * Large node arrays are automatically processed in batches. * @param componentHandle - The component containing the nodes * @param nodes - Array of node indices whose AABBs should be hidden * @throws {Error} If the component handle is invalid or nodes array is invalid */ RPCHideAABBs(componentHandle: number, nodes: number[]): void; /** * Hides all axis-aligned bounding boxes (AABBs) in a component. * @param componentHandle - The component whose AABBs should be hidden * @throws {Error} If the component handle is invalid */ RPCHideAllAABBs(componentHandle: number): void; private safeCall; }