import * as THREE from "three"; import { Intersection, Object3D as Object3D$1, Sphere } from "three"; import { Pass } from "three/addons/postprocessing/Pass.js"; import { GLTF, GLTFLoader } from "three/addons/loaders/GLTFLoader.js"; import { WebGPURenderer } from "three/webgpu"; import { effect } from "@preact/signals-core"; import * as GoogleGenAITypes from "@google/genai"; import OpenAIType from "openai"; import { SparkRenderer } from "@sparkjsdev/spark"; //#region node_modules/@pmndrs/uikit/dist/events.d.ts declare module 'three' { interface Object3DEventMap { childadded: { child: Object3D; }; childremoved: { child: Object3D; }; click: ThreeMouseEvent; contextmenu: ThreeMouseEvent; dblclick: ThreeMouseEvent; wheel: ThreeMouseEvent; pointerup: ThreePointerEvent; pointerdown: ThreePointerEvent; pointerover: ThreePointerEvent; pointerout: ThreePointerEvent; pointerenter: ThreePointerEvent; pointerleave: ThreePointerEvent; pointermove: ThreePointerEvent; pointercancel: ThreePointerEvent; } } type ThreeMouseEvent = Intersection & { nativeEvent?: unknown; stopPropagation?: () => void; stopImmediatePropagation?: () => void; }; type ThreePointerEvent = ThreeMouseEvent & { pointerId?: number; }; //#endregion //#region node_modules/@pmndrs/uikit/dist/panel/interaction-panel-mesh.d.ts type AllowedPointerEventsType = 'all' | ((poinerId: number, pointerType: string, pointerState: unknown) => boolean) | { allow: string | Array; } | { deny: string | Array; }; declare module 'three' { interface Object3D extends PointerEventsProperties { spherecast?(sphere: Sphere, intersects: Array): void; intersectChildren?: boolean; interactableDescendants?: Array; ancestorsHaveListeners?: boolean; defaultPointerEvents?: PointerEventsProperties['pointerEvents']; } } type PointerEventsProperties = { pointerEvents?: 'none' | 'auto' | 'listener'; pointerEventsType?: AllowedPointerEventsType; pointerEventsOrder?: number; }; //#endregion //#region src/core/SerializerTypes.d.ts /** * Minimal WebXR manager contract implemented by SplitEngineWebXrManager. */ interface SerializerXRManager { enabled: boolean; isPresenting: boolean; getController(index: number): THREE.XRTargetRaySpace; getControllerGrip(index: number): THREE.XRGripSpace; getHand(index: number): THREE.XRHandSpace; getFrame?(): XRFrame | undefined; getCamera(): THREE.ArrayCamera; updateCamera(camera: THREE.Camera): void; getBinding?(): XRWebGLBinding | null; getReferenceSpace?(): XRReferenceSpace | null; setReferenceSpaceType(type: XRReferenceSpaceType): void; setFramebufferScaleFactor(factor: number): void; setSession(session: XRSession | null): Promise; getSession?(): XRSession | null; addEventListener?: THREE.EventDispatcher['addEventListener']; removeEventListener?: THREE.EventDispatcher['removeEventListener']; } /** * Minimal renderer contract implemented by SplitEngineSerializer. */ interface SerializerRenderer { readonly isSplitEngineSerializer: true; readonly xr: SerializerXRManager; domElement?: HTMLCanvasElement; shadowMap?: { enabled: boolean; type?: THREE.ShadowMapType; autoUpdate?: boolean; }; render(scene: THREE.Object3D, camera: THREE.Camera): void; setSize(width: number, height: number, updateStyle?: boolean): void; getSize(target?: { set?: (w: number, h: number) => void; width?: number; height?: number; }): { width: number; height: number; }; setPixelRatio(value: number): void; getPixelRatio(): number; setAnimationLoop(callback: ((time: number, frame?: XRFrame) => void) | null): void; dispose(): void; } /** * Factory function that returns or resolves to a `SerializerRenderer`. */ type SerializerRendererFactory = () => SerializerRenderer | Promise; /** * Type guard to determine if a renderer instance is a SplitEngineSerializer * (`SerializerRenderer`). * * @param renderer - The renderer instance to test. * @returns True if the renderer is a SerializerRenderer, false otherwise. */ export declare function isSerializerRenderer(renderer?: unknown): renderer is SerializerRenderer; //#endregion //#region src/core/SerializerSupport.d.ts /** * Resolves a `SerializerRenderer` from `Options.serializer` or from the global * `ThreeSplitEngine.SplitEngineSerializer` runtime entrypoint. */ export declare function resolveSerializerRenderer(serializer?: SerializerRenderer | SerializerRendererFactory): Promise; //#endregion //#region src/ai/AIOptions.d.ts export declare const GEMINI_DEFAULT_FLASH_MODEL = "gemini-3.8-flash"; export declare const GEMINI_DEFAULT_LIVE_MODEL = "gemini-3.8-live"; export declare const GEMINI_DEFAULT_IMAGE_MODEL = "gemini-nano-banana-2.1"; /** * Non-live configuration for the Gemini Interactions API * (`client.interactions.create`). `model` and `input` come from each query * and interactions always run statelessly (`store` is forced off), so * history/state parameters are not accepted here. */ export type GeminiInteractionConfig = Omit; export declare class GeminiOptions { apiKey: string; urlParam: string; keyValid: boolean; enabled: boolean; model: string; liveModel: string; config: GeminiInteractionConfig; } export declare class OpenAIOptions { apiKey: string; urlParam: string; model: string; enabled: boolean; } export type AIModel = 'gemini' | 'openai'; export declare class AIOptions { enabled: boolean; model: AIModel; /** * Show a browser dialog before AI starts so a prototype user can provide, * replace, or remove an API key kept only for the current page. Disabled by * default. The dialog is skipped when the page URL or keys.json already * provides a key. */ promptForApiKey: boolean; gemini: GeminiOptions; openai: OpenAIOptions; globalUrlParams: { key: string; }; } //#endregion //#region src/utils/Types.d.ts /** * Misc collection of types not specific to any XR Blocks module. */ export type Constructor = new (...args: any[]) => T; export type ShaderUniforms = { [uniform: string]: THREE.IUniform; }; /** * Defines the structure for a shader object compatible with PanelMesh, * requiring uniforms, a vertex shader, and a fragment shader. */ export interface Shader { uniforms: ShaderUniforms; vertexShader: string; fragmentShader: string; defines?: { [key: string]: unknown; }; } /** * A recursive readonly type. */ export type DeepReadonly = T extends ((...args: any[]) => any) ? T : T extends object ? { readonly [P in keyof T]: DeepReadonly; } : T; /** * A recursive partial type. */ export type DeepPartial = T extends ((...args: any[]) => any) ? T : T extends object ? { [P in keyof T]?: DeepPartial; } : T; //#endregion //#region src/camera/CameraOptions.d.ts /** * Parameters for RGB to depth UV mapping given different aspect ratios. * These parameters define the distortion model and affine transformations * required to align the RGB camera feed with the depth map. */ export interface RgbToDepthParams { scale: number; scaleX: number; scaleY: number; translateU: number; translateV: number; k1: number; k2: number; k3: number; p1: number; p2: number; xc: number; yc: number; } /** * Default parameters for rgb to depth projection. * For RGB and depth, 4:3 and 1:1, respectively. */ export declare const DEFAULT_RGB_TO_DEPTH_PARAMS: RgbToDepthParams; /** * Configuration options for the device camera. */ export declare class DeviceCameraOptions { enabled: boolean; /** * Constraints for `getUserMedia`. This will guide the initial camera * selection. */ videoConstraints?: MediaTrackConstraints; /** * Hint for performance optimization on frequent captures. */ willCaptureFrequently: boolean; /** * Parameters for RGB to depth UV mapping given different aspect ratios. */ rgbToDepthParams: RgbToDepthParams; cameraLabel?: string; constructor(options?: DeepReadonly>); } export declare const xrDeviceCameraEnvironmentOptions: { readonly enabled: boolean; readonly videoConstraints?: { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly advanced?: readonly { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; }[] | undefined; } | undefined; readonly willCaptureFrequently: boolean; readonly rgbToDepthParams: { readonly scale: number; readonly scaleX: number; readonly scaleY: number; readonly translateU: number; readonly translateV: number; readonly k1: number; readonly k2: number; readonly k3: number; readonly p1: number; readonly p2: number; readonly xc: number; readonly yc: number; }; readonly cameraLabel?: string; }; export declare const xrDeviceCameraUserOptions: { readonly enabled: boolean; readonly videoConstraints?: { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly advanced?: readonly { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; }[] | undefined; } | undefined; readonly willCaptureFrequently: boolean; readonly rgbToDepthParams: { readonly scale: number; readonly scaleX: number; readonly scaleY: number; readonly translateU: number; readonly translateV: number; readonly k1: number; readonly k2: number; readonly k3: number; readonly p1: number; readonly p2: number; readonly xc: number; readonly yc: number; }; readonly cameraLabel?: string; }; export declare const xrDeviceCameraEnvironmentContinuousOptions: { readonly enabled: boolean; readonly videoConstraints?: { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly advanced?: readonly { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; }[] | undefined; } | undefined; readonly willCaptureFrequently: boolean; readonly rgbToDepthParams: { readonly scale: number; readonly scaleX: number; readonly scaleY: number; readonly translateU: number; readonly translateV: number; readonly k1: number; readonly k2: number; readonly k3: number; readonly p1: number; readonly p2: number; readonly xc: number; readonly yc: number; }; readonly cameraLabel?: string; }; export declare const xrDeviceCameraUserContinuousOptions: { readonly enabled: boolean; readonly videoConstraints?: { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly advanced?: readonly { readonly aspectRatio?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly autoGainControl?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly backgroundBlur?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly channelCount?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly deviceId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly displaySurface?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly echoCancellation?: string | boolean | { readonly exact?: boolean | string; readonly ideal?: boolean | string; } | undefined; readonly facingMode?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly frameRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly groupId?: string | readonly string[] | { readonly exact?: string | readonly string[] | undefined; readonly ideal?: string | readonly string[] | undefined; } | undefined; readonly height?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly noiseSuppression?: boolean | { readonly exact?: boolean; readonly ideal?: boolean; } | undefined; readonly sampleRate?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly sampleSize?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; readonly width?: number | { readonly exact?: number; readonly ideal?: number; readonly max?: number; readonly min?: number; } | undefined; }[] | undefined; } | undefined; readonly willCaptureFrequently: boolean; readonly rgbToDepthParams: { readonly scale: number; readonly scaleX: number; readonly scaleY: number; readonly translateU: number; readonly translateV: number; readonly k1: number; readonly k2: number; readonly k3: number; readonly p1: number; readonly p2: number; readonly xc: number; readonly yc: number; }; readonly cameraLabel?: string; }; //#endregion //#region src/context/scene/SceneOptions.d.ts declare class SceneDerivedContextOptions { enabled: boolean; constructor(options?: DeepPartial); enable(): this; } export declare class SceneVisibilityOptions extends SceneDerivedContextOptions { /** * Raycast hits on materials with effective opacity less than or equal to this * threshold are ignored for line-of-sight occlusion. */ occlusionOpacityThreshold: number; } export declare class SceneSetOfMarkOptions extends SceneDerivedContextOptions {} export declare class SceneOptions { enabled: boolean; pollingIntervalMs: number; visibleObjects: SceneVisibilityOptions; som: SceneSetOfMarkOptions; constructor(options?: DeepPartial); enable(): this; enableVisibleObjects(): this; enableSetOfMark(): this; } //#endregion //#region src/context/ContextOptions.d.ts export declare class ContextOptions { debugging: boolean; enabled: boolean; scene: SceneOptions; constructor(options?: DeepPartial); enable(): this; enableScene(): this; enableVisibleObjects(): this; enableSetOfMark(): this; } //#endregion //#region src/depth/DepthOptions.d.ts export declare class DepthMeshOptions { enabled: boolean; updateVertexNormals: boolean; showDebugTexture: boolean; useDepthTexture: boolean; renderShadow: boolean; shadowOpacity: number; patchHoles: boolean; patchHolesUpper: boolean; opacity: number; useDualCollider: boolean; useDownsampledGeometry: boolean; updateFullResolutionGeometry: boolean; colliderUpdateFps: number; /** FPS cap for depth mesh geometry updates. 0 = update every frame. */ depthMeshUpdateFps: number; depthFullResolution: number; ignoreEdgePixels: number; } export declare class DepthOptions { debugging: boolean; enabled: boolean; depthMesh: DepthMeshOptions; depthTexture: { enabled: boolean; constantKernel: boolean; applyGaussianBlur: boolean; applyKawaseBlur: boolean; }; occlusion: { enabled: boolean; resolutionScale: number; }; usagePreference: XRDepthUsage[]; dataFormatPreference: XRDepthDataFormat[]; depthTypeRequest: XRDepthType[]; matchDepthView: boolean; /** Whether to extract and upload CPU depth for all stereo views instead of only view 0. */ updateAllViews: boolean; constructor(options?: DeepReadonly>); } export declare const xrDepthMeshOptions: { readonly debugging: boolean; readonly enabled: boolean; readonly depthMesh: { readonly enabled: boolean; readonly updateVertexNormals: boolean; readonly showDebugTexture: boolean; readonly useDepthTexture: boolean; readonly renderShadow: boolean; readonly shadowOpacity: number; readonly patchHoles: boolean; readonly patchHolesUpper: boolean; readonly opacity: number; readonly useDualCollider: boolean; readonly useDownsampledGeometry: boolean; readonly updateFullResolutionGeometry: boolean; readonly colliderUpdateFps: number; readonly depthMeshUpdateFps: number; readonly depthFullResolution: number; readonly ignoreEdgePixels: number; }; readonly depthTexture: { enabled: boolean; constantKernel: boolean; applyGaussianBlur: boolean; applyKawaseBlur: boolean; }; readonly occlusion: { enabled: boolean; resolutionScale: number; }; readonly usagePreference: readonly XRDepthUsage[]; readonly dataFormatPreference: readonly XRDepthDataFormat[]; readonly depthTypeRequest: readonly XRDepthType[]; readonly matchDepthView: boolean; readonly updateAllViews: boolean; }; export declare const xrDepthMeshVisualizationOptions: { readonly debugging: boolean; readonly enabled: boolean; readonly depthMesh: { readonly enabled: boolean; readonly updateVertexNormals: boolean; readonly showDebugTexture: boolean; readonly useDepthTexture: boolean; readonly renderShadow: boolean; readonly shadowOpacity: number; readonly patchHoles: boolean; readonly patchHolesUpper: boolean; readonly opacity: number; readonly useDualCollider: boolean; readonly useDownsampledGeometry: boolean; readonly updateFullResolutionGeometry: boolean; readonly colliderUpdateFps: number; readonly depthMeshUpdateFps: number; readonly depthFullResolution: number; readonly ignoreEdgePixels: number; }; readonly depthTexture: { enabled: boolean; constantKernel: boolean; applyGaussianBlur: boolean; applyKawaseBlur: boolean; }; readonly occlusion: { enabled: boolean; resolutionScale: number; }; readonly usagePreference: readonly XRDepthUsage[]; readonly dataFormatPreference: readonly XRDepthDataFormat[]; readonly depthTypeRequest: readonly XRDepthType[]; readonly matchDepthView: boolean; readonly updateAllViews: boolean; }; export declare const xrDepthMeshPhysicsOptions: { readonly debugging: boolean; readonly enabled: boolean; readonly depthMesh: { readonly enabled: boolean; readonly updateVertexNormals: boolean; readonly showDebugTexture: boolean; readonly useDepthTexture: boolean; readonly renderShadow: boolean; readonly shadowOpacity: number; readonly patchHoles: boolean; readonly patchHolesUpper: boolean; readonly opacity: number; readonly useDualCollider: boolean; readonly useDownsampledGeometry: boolean; readonly updateFullResolutionGeometry: boolean; readonly colliderUpdateFps: number; readonly depthMeshUpdateFps: number; readonly depthFullResolution: number; readonly ignoreEdgePixels: number; }; readonly depthTexture: { enabled: boolean; constantKernel: boolean; applyGaussianBlur: boolean; applyKawaseBlur: boolean; }; readonly occlusion: { enabled: boolean; resolutionScale: number; }; readonly usagePreference: readonly XRDepthUsage[]; readonly dataFormatPreference: readonly XRDepthDataFormat[]; readonly depthTypeRequest: readonly XRDepthType[]; readonly matchDepthView: boolean; readonly updateAllViews: boolean; }; //#endregion //#region src/input/HandsOptions.d.ts export declare class HandsOptions { /** Whether hand tracking is enabled. */ enabled: boolean; /** Whether to show any hand visualization. */ visualization: boolean; /** Whether to show the tracked hand joints. */ visualizeJoints: boolean; /** Whether to show the virtual hand meshes. */ visualizeMeshes: boolean; debugging: boolean; constructor(options?: DeepReadonly>); /** * Enables hands tracking. * @returns The instance for chaining. */ enableHands(): this; enableHandsVisualization(): this; } //#endregion //#region src/layers/LayersOptions.d.ts /** * Options for WebXR composition layers. * * Off by default. Layers are an optional session feature and the layer types * an app would want are newer than the SDK's baseline browser, so asking for * them unconditionally would mean every app pays for a capability most do not * use. */ export declare class LayersOptions { /** Whether to request the `layers` session feature. */ enabled: boolean; /** * Whether a video shown through {@link VideoView} should be presented as a * composition layer when the platform allows it. * * Falls back to rendering into the scene as a texture when it cannot, so an * app can leave this on and still work everywhere. */ video: boolean; } //#endregion //#region src/input/components/HandJointNames.d.ts export declare const HAND_JOINT_NAMES: readonly ['wrist', 'thumb-metacarpal', 'thumb-phalanx-proximal', 'thumb-phalanx-distal', 'thumb-tip', 'index-finger-metacarpal', 'index-finger-phalanx-proximal', 'index-finger-phalanx-intermediate', 'index-finger-phalanx-distal', 'index-finger-tip', 'middle-finger-metacarpal', 'middle-finger-phalanx-proximal', 'middle-finger-phalanx-intermediate', 'middle-finger-phalanx-distal', 'middle-finger-tip', 'ring-finger-metacarpal', 'ring-finger-phalanx-proximal', 'ring-finger-phalanx-intermediate', 'ring-finger-phalanx-distal', 'ring-finger-tip', 'pinky-finger-metacarpal', 'pinky-finger-phalanx-proximal', 'pinky-finger-phalanx-intermediate', 'pinky-finger-phalanx-distal', 'pinky-finger-tip']; //#endregion //#region src/input/Hands.d.ts export type JointName = (typeof HAND_JOINT_NAMES)[number]; /** * Utility class for managing WebXR hand tracking data based on * reported Handedness. */ /** * Enum for handedness, using WebXR standard strings. */ export declare enum Handedness { NONE = -1 // Represents unknown or unspecified handedness , LEFT = 0, RIGHT = 1 } /** * Represents and provides access to WebXR hand tracking data. * Uses the 'handedness' property of input hands for identification. */ export declare class Hands { hands: THREE.XRHandSpace[]; dominant: Handedness; /** * @param hands - An array containing XRHandSpace objects from Three.js. */ constructor(hands: THREE.XRHandSpace[]); /** * Retrieves a specific joint object for a given hand. * @param jointName - The name of the joint to retrieve (e.g., * 'index-finger-tip'). * @param targetHandednessEnum - The hand enum value * (Handedness.LEFT or Handedness.RIGHT) * to retrieve the joint from. If Handedness.NONE, uses the dominant * hand. * @returns The requested joint object, or null if not * found or invalid input. */ getJoint(jointName: JointName, targetHandednessEnum: Handedness): THREE.XRJointSpace | undefined; /** * Gets the index finger tip joint. * @param handedness - Optional handedness * ('left'/'right'), * defaults to NONE (uses dominant hand). * @returns The joint object or null. */ getIndexTip(handedness?: Handedness): THREE.XRJointSpace | undefined; /** * Gets the thumb tip joint. * @param handedness - Optional handedness * ('left'/'right'), * defaults to NONE (uses dominant hand). * @returns The joint object or null. */ getThumbTip(handedness?: Handedness): THREE.XRJointSpace | undefined; /** * Gets the middle finger tip joint. * @param handedness - Optional handedness * ('left'/'right'), * defaults to NONE (uses dominant hand). * @returns The joint object or null. */ getMiddleTip(handedness?: Handedness): THREE.XRJointSpace | undefined; /** * Gets the ring finger tip joint. * @param handedness - Optional handedness * ('left'/'right'), * defaults to NONE (uses dominant hand). * @returns The joint object or null. */ getRingTip(handedness?: Handedness): THREE.XRJointSpace | undefined; /** * Gets the pinky finger tip joint. * @param handedness - Optional handedness * ('left'/'right'), * defaults to NONE (uses dominant hand). * @returns The joint object or null. */ getPinkyTip(handedness?: Handedness): THREE.XRJointSpace | undefined; /** * Gets the wrist joint. * @param handedness - Optional handedness enum value * (LEFT/RIGHT/NONE), * defaults to NONE (uses dominant hand). * @returns The joint object or null. */ getWrist(handedness?: Handedness): THREE.XRJointSpace | undefined; /** * Generates a string representation of the hand joint data for both hands. * Always lists LEFT hand data first, then RIGHT hand data, if available. * @returns A string containing position data for all available * joints. */ toString(): string; /** * Converts the pose data (position and quaternion) of all joints for both * hands into a single flat array. Each joint is represented by 7 numbers * (3 for position, 4 for quaternion). Missing joints or hands are represented * by zeros. Ensures a consistent output order: all left hand joints first, * then all right hand joints. * @returns A flat array containing position (x, y, z) and * quaternion (x, y, z, w) data for all joints, ordered [left..., * right...]. Size is always 2 * HAND_JOINT_NAMES.length * 7. */ toPositionQuaternionArray(): number[]; /** * Checks for the availability of hand data. * If an integer (0 for LEFT, 1 for RIGHT) is provided, it checks for that * specific hand. If no integer is provided, it checks that data for *both* * hands is available. * @param handIndex - Optional. The index of the hand to validate * (0 or 1). * @returns `true` if the specified hand(s) have data, `false` * otherwise. */ isValid(handIndex?: number): boolean; } //#endregion //#region src/interaction/reticle/Reticle.d.ts interface ReticleUniforms { [uniform: string]: THREE.IUniform; uColor: THREE.IUniform; uPressed: THREE.IUniform; } /** * A 3D visual marker used to indicate a user's aim or interaction * point in an XR scene. It orients itself to surfaces it intersects with and * provides visual feedback for states like "pressed". */ declare class Reticle extends THREE.Mesh { /** Text description of the PanelMesh */ name: string; editorIcon: string; /** The world-space direction vector of the ray that hit the target. */ direction: THREE.Vector3; /** Ensures the reticle is drawn on top of other transparent objects. */ renderOrder: number; /** The smoothing factor for rotational slerp interpolation. */ rotationSmoothing: number; /** The z-offset to prevent visual artifacts (z-fighting). */ offset: number; /** The most recent intersection data that positioned this reticle. */ intersection?: THREE.Intersection; /** Object on which the reticle is hovering. */ targetObject?: THREE.Object3D; /** The uniforms driving this reticle's material. */ readonly uniforms: ReticleUniforms; /** Whether depth test was requested for this reticle. */ readonly depthTestEnabled: boolean; private syncUniforms?; /** Ring shown when the reticle is over an interactable object. */ private readonly hoverRing; private readonly originalNormal; private readonly newRotation; private readonly objectRotation; private readonly normalVector; /** * Creates an instance of Reticle. * @param innerRadius - Inner radius of the reticle ring geometry. * @param outerRadius - Outer radius of the reticle ring geometry. * @param depthTest - Determines if the reticle should be occluded by other * objects. Defaults to `false` to ensure it is always visible. */ constructor(innerRadius?: number, outerRadius?: number, depthTest?: boolean); /** * Replaces the reticle's primary material (e.g. with a WebGPU NodeMaterial) * and registers a callback to synchronize uniform changes. */ setCustomMaterial(material: THREE.Material, syncUniforms?: () => void): void; /** * Orients the reticle to be flush with a surface, based on the surface * normal. It smoothly interpolates the rotation for a polished visual effect. * @param normal - The world-space normal of the surface. */ setRotationFromNormalVector(normal: THREE.Vector3): void; /** * Updates the reticle's complete pose (position and rotation) from a * raycaster intersection object. * @param intersection - The intersection data from a raycast. */ setPoseFromIntersection(intersection: THREE.Intersection): void; /** * Sets the color of the reticle via its shader uniform. * @param color - The color to apply. */ setColor(color: THREE.Color | number | string): void; /** * Gets the current color of the reticle. * @returns The current color from the shader uniform. */ getColor(): THREE.Color; /** * Sets the visual state of the reticle to "pressed" or "unpressed". * This provides visual feedback to the user during interaction. * @param pressed - True to show the pressed state, false otherwise. */ setPressed(pressed: boolean): void; /** * Sets the pressed state as a continuous value for smooth animations. * @param pressedAmount - A value from 0.0 (unpressed) to 1.0 (fully * pressed). */ setPressedAmount(pressedAmount: number): void; /** * Shows a ring around the reticle while it hovers over an interactable * object. */ setHovering(hovering: boolean): void; /** Releases the GPU resources owned by this Reticle. */ dispose(): void; /** * Overrides the default raycast method to make the reticle ignored by * raycasters. */ raycast(): void; } //#endregion //#region src/input/Controller.d.ts interface ControllerEventMap extends THREE.Object3DEventMap { connected: { target: Controller; data?: XRInputSource; }; disconnected: { target: Controller; data?: XRInputSource; }; select: { target: Controller; data?: XRInputSource; }; selectstart: { target: Controller; data?: XRInputSource; }; selectend: { target: Controller; data?: XRInputSource; }; squeeze: { target: Controller; data?: XRInputSource; }; squeezestart: { target: Controller; data?: XRInputSource; }; squeezeend: { target: Controller; data?: XRInputSource; }; } interface Controller extends THREE.Object3D { reticle?: Reticle; gamepad?: Gamepad; inputSource?: Partial; updatePose?(): void; } interface ControllerEvent { type: keyof ControllerEventMap; target: Controller; data?: Partial; } //#endregion //#region src/core/RendererTypes.d.ts /** * Union type representing either a THREE.WebGLRenderer or a THREE.WebGPURenderer. */ type WebGLOrWebGPURenderer = THREE.WebGLRenderer | WebGPURenderer; /** * Union type representing any renderer supported by XR Blocks * (`THREE.WebGLRenderer`, `THREE.WebGPURenderer`, or `SerializerRenderer`). */ type SupportedRenderer = WebGLOrWebGPURenderer | SerializerRenderer; /** * Type guard to determine if a renderer instance is a THREE.WebGPURenderer. * * @param renderer - The renderer instance to test. * @returns True if the renderer is a WebGPURenderer, false otherwise. */ export declare function isWebGPURenderer(renderer?: unknown): renderer is WebGPURenderer; /** * Asserts that the provided renderer is a THREE.WebGLRenderer. * * @param renderer - The renderer instance to check. * @param consumerName - The name of the subsystem or feature requiring WebGLRenderer. * @throws Error if the renderer is a WebGPURenderer. */ export declare function assertWebGLRenderer(renderer: SupportedRenderer | undefined, consumerName: string): asserts renderer is THREE.WebGLRenderer; /** * Dependency injection holder for the active Three.js renderer (`WebGLRenderer`, * `WebGPURenderer`, or `SerializerRenderer`), allowing scripts to request the * renderer via `Registry` in O(1) time without statically importing `three/webgpu`. */ declare class RendererHolder { readonly renderer: WebGLOrWebGPURenderer; constructor(renderer: WebGLOrWebGPURenderer); } //#endregion //#region src/input/GamepadBindings.d.ts export type GamepadAction = 'select' | 'cycleHandPoseLeft' | 'cycleHandPoseRight' | 'cycleSimulatorMode' | 'toggleUI' | 'toggleHand' | 'moveDown' | 'moveUp' | 'openSettings'; /** * Manages gamepad button-to-action mappings with localStorage persistence. * One button per action — assigning a button removes it from any previous action. */ export declare class GamepadBindings { private bindings; constructor(); getBinding(action: GamepadAction): number; getAllBindings(): Record; setBinding(action: GamepadAction, buttonIndex: number): void; resetDefaults(): void; private load; private save; } //#endregion //#region src/input/GamepadController.d.ts /** Defines the event map for the GamepadController's custom events. */ interface GamepadControllerEventMap extends THREE.Object3DEventMap { connected: { target: GamepadController; }; disconnected: { target: GamepadController; }; selectstart: { target: GamepadController; }; selectend: { target: GamepadController; }; } /** * Simulates an XR controller using a connected gamepad (Xbox/PS). * The controller ray always points forward from the camera center, * similar to GazeController but with button-driven selection. */ export declare class GamepadController extends Script implements Controller { static dependencies: { camera: typeof THREE.Camera; }; type: string; name: string; userData: { id: number; connected: boolean; selected: boolean; }; camera?: THREE.Camera; bindings: GamepadBindings; /** The browser Gamepad object, refreshed each frame. */ activeGamepad?: Gamepad | null; gamepad?: Gamepad; /** True if the toast has been shown this session. */ hasShownToast: boolean; /** Callback set by SimulatorInterface for opening settings. */ onOpenSettings?: () => void; /** When true, normal gamepad UI/select actions are suppressed (modal menu). */ menuActive: boolean; private _prevButtons; private _risingEdges; private _captureCallback; constructor(); init({ camera }: { camera: THREE.Camera; }): void; /** * Enters capture mode — the next button press will invoke the callback * instead of triggering normal actions, then exit capture mode. */ captureNextButtonPress(callback: (buttonIndex: number) => void): void; cancelCapture(): void; get captureActive(): boolean; updatePose(): void; update(): void; callSelectStart(): void; callSelectEnd(): void; connect(): void; disconnect(): void; /** * Returns the axes of the active gamepad with deadzone applied. * [leftX, leftY, rightX, rightY] */ getAxes(): [number, number, number, number]; static applyDeadzone(value: number): number; /** * Returns the analog value (0..1) of the given button index, or 0 if * unbound or no gamepad. Useful for triggers (which expose .value). */ getButtonValue(index: number): number; /** * Returns the analog values of the left and right triggers (LT, RT) on a * standard-mapped gamepad, in [0, 1]. Returns [0, 0] when no gamepad. */ getTriggers(): [number, number]; /** * Returns true if the given button index had a rising edge this frame. * Safe to call from any update order — uses pre-computed edges. */ isButtonJustPressed(buttonIndex: number): boolean; private _updatePrevButtons; private _pollGamepad; private _onDisconnect; } //#endregion //#region src/input/GazeController.d.ts interface GazeControllerEventMap extends THREE.Object3DEventMap { connected: { target: GazeController; }; disconnected: { target: GazeController; }; } /** * Supplies a camera-aligned gaze ray for XR interactions. Interaction owns * target resolution and dwell selection. * WebXR Eye Tracking is not yet available. This API simulates a reticle * at the center of the field of view for simulating gaze-based interaction. */ export declare class GazeController extends Script implements Controller { static dependencies: { camera: typeof THREE.Camera; }; /** * User data for the controller, including its connection status, unique ID, * and selection state. */ userData: { connected: boolean; id: number; selected: boolean; }; /** * The visual indicator for where the user is looking. */ reticle: Reticle | undefined; camera: THREE.Camera; init({ camera }: { camera: THREE.Camera; }): void; /** * Syncs the controller with the camera before Input samples its ray. */ updatePose(): void; /** * Connects the gaze controller to the input system. */ connect(): void; /** * Disconnects the gaze controller from the input system. */ disconnect(): void; } //#endregion //#region src/input/headGestures/HeadGestureEvents.d.ts export type HeadGestureEventDetail = { name: string; confidence: number; data?: Record; }; export type HeadGestureEvent = THREE.Event & { type: 'gesture'; target: HeadGestureRecognition; detail: HeadGestureEventDetail; }; export interface HeadGestureEventMap extends THREE.Object3DEventMap { gesture: HeadGestureEvent; } //#endregion //#region src/input/headGestures/HeadGestureTypes.d.ts export type HeadGestureConfiguration = { enabled: boolean; /** Detector-specific sensitivity. Built-in heuristics interpret this as radians. */ threshold?: number; }; export type HeadPoseSample = { timestamp: number; position: THREE.Vector3; orientation: THREE.Quaternion; }; export interface HeadGestureContext { readonly samples: readonly HeadPoseSample[]; } export type HeadGestureDetectionResult = { confidence: number; data?: Record; }; export type HeadGestureScoreMap = Record; export type HeuristicHeadGestureDetector = (context: HeadGestureContext, config: HeadGestureConfiguration) => HeadGestureDetectionResult | undefined; export interface HeadGestureRecognizer { init?(): Promise; recognize(context: HeadGestureContext): HeadGestureScoreMap | Promise; getGestureConfigurations?(): Record; setGestureConfig?(name: string, config: HeadGestureConfiguration): void; dispose?(): void; } //#endregion //#region src/input/headGestures/HeadGestureRecognitionOptions.d.ts export declare class HeadGestureRecognitionOptions { enabled: boolean; minimumConfidence: number; releaseConfidence: number; updateIntervalMs: number; historyDurationMs: number; warmupDurationMs: number; maximumSampleGapMs: number; maximumSampleAngleRadians: number; gestureRecognizer: HeadGestureRecognizer; gestures: Record; constructor(options?: DeepReadonly>); enable(): this; setGestureEnabled(name: string, enabled: boolean): this; setGestureRecognizer(gestureRecognizer: HeadGestureRecognizer): this; setGestureConfig(name: string, config: Partial): this; private applyGestureRecognizerConfigurations; } //#endregion //#region src/input/headGestures/HeadGestureRecognition.d.ts export declare class HeadGestureRecognition extends Script { static dependencies: { camera: typeof THREE.Camera; options: typeof HeadGestureRecognitionOptions; }; private camera; private options; private samples; private latchedGestures; private lastEvaluation; private latestTimestamp; private pendingRecognition; private generation; init({ camera, options }: { camera: THREE.Camera; options: HeadGestureRecognitionOptions; }): Promise; update(time?: number): void; private captureSample; private isDiscontinuity; private pruneSamples; private evaluate; private emitFromScores; private emitGesture; private resetRecognitionState; dispose(): void; } //#endregion //#region src/input/MouseController.d.ts /** Defines the event map for the MouseController's custom events. */ interface MouseControllerEventMap extends THREE.Object3DEventMap { connected: { target: MouseController; }; disconnected: { target: MouseController; }; selectstart: { target: MouseController; }; selectend: { target: MouseController; }; } /** * Simulates an XR controller using the mouse for desktop * environments. This class translates 2D mouse movements on the screen into a * 3D ray in the scene, allowing for point-and-click interactions in a * non-immersive context. It functions as a virtual controller that is always * aligned with the user's pointer. */ export declare class MouseController extends Script implements Controller { static dependencies: { camera: typeof THREE.Camera; }; type: string; name: string; editorIcon: string; /** * User data for the controller, including its connection status, unique ID, * and selection state (mouse button pressed). */ userData: { id: number; connected: boolean; selected: boolean; }; /** A THREE.Raycaster used to determine the 3D direction of the mouse. */ raycaster: THREE.Raycaster; /** A normalized vector representing the default forward direction. */ forwardVector: THREE.Vector3; /** A reference to the main scene camera. */ camera?: THREE.Camera; private lastNormalizedMouse; constructor(); /** * Initialize the MouseController */ init({ camera }: { camera: THREE.Camera; }): void; /** Updates the mouse position/rotation using camera state. */ updatePose(): void; /** * The main update loop, called every frame. * If connected, it syncs the controller's origin point with the camera's * position. */ update(): void; /** * Updates the controller's transform based on the mouse's position on the * screen. This method sets both the position and rotation, ensuring the * object has a valid world matrix for raycasting. * @param event - The mouse event containing clientX and clientY coordinates. */ updateMousePositionFromEvent(event: MouseEvent): void; /** * Dispatches a 'selectstart' event, simulating the start of a controller * press (e.g., mouse down). */ callSelectStart(): void; /** * Dispatches a 'selectend' event, simulating the end of a controller press * (e.g., mouse up). */ callSelectEnd(): void; /** * "Connects" the virtual controller, notifying the input system that it is * active. */ connect(): void; /** * "Disconnects" the virtual controller. */ disconnect(): void; } //#endregion //#region src/core/components/XRSystems.d.ts /** * A node to hold all XR Blocks Systems. */ declare class XRSystems extends THREE.Group { type: string; name: string; } //#endregion //#region src/input/Input.d.ts export declare class ActiveControllers extends THREE.Group { type: string; name: string; } export declare class Reticles extends THREE.Group { type: string; name: string; } /** * Holds physical input sources and samples their current state each frame. */ export declare class Input { options: Options; controllers: Controller[]; controllerGrips: THREE.Group[]; hands: THREE.XRHandSpace[]; /** Completed head gestures, when enabled before initialization. */ headGestures?: HeadGestureRecognition; pivotsEnabled: boolean; gazeController: GazeController; mouseController: MouseController; gamepadController: GamepadController; private readonly builtInControllers; private readonly addonControllers; private readonly removingControllers; private nextControllerId; controllersEnabled: boolean; listeners: Map; private dispatchControllerEvent; private pinchFilter; private releasedControllers; private nativeSelectControllers; private disconnectedTransientPointerControllers; private keyDownListeners; private keyUpListeners; activeControllers: ActiveControllers; leftController?: Controller; rightController?: Controller; reticles: Reticles; private ownedReticles; private reticleConfigurer?; private readonly raySourceInputs; private readonly raySourceSlots; private readonly directTouchInputs; private readonly directTouchSlots; private readonly interactionFrame; /** * Initializes physical input sources. Only called by Core. */ init({ systemsGroup, options, renderer }: { systemsGroup: XRSystems; options: Options; renderer: SupportedRenderer; }): void; /** * Retrieves the controller object by its ID. * @param id - The ID of the controller. * @returns The controller with the specified ID, or undefined after removal. */ get(id: number): Controller | undefined; /** * Adds an object to both controllers by creating a new group and cloning it. * @param obj - The object to add to each controller. */ addObject(obj: THREE.Object3D): void; /** * Creates a pivot point for each hand, primarily used as a reference * point. */ enablePivots(): void; /** * Adds reticles to the controllers and scene, with initial visibility set to * false. */ addReticles(): void; /** * Sets a configuration callback for reticles (such as upgrading to WebGPU materials) * and immediately applies it to all existing reticles. */ setReticleConfigurer(configurer: (reticle: Reticle) => void): void; /** * Default action to handle the start of a selection, setting the selecting * state to true. */ defaultOnSelectStart(event: ControllerEvent): void; /** * Default action to handle the end of a selection, setting the selecting * state to false. */ defaultOnSelectEnd(event: ControllerEvent): void; defaultOnSqueezeStart(event: ControllerEvent): void; defaultOnSqueezeEnd(event: ControllerEvent): void; defaultOnConnected(event: ControllerEvent): void; defaultOnDisconnected(event: ControllerEvent): void; private captureNativeSelectEvent; private setupNativeSelectTracking; private removeNativeSelectTracking; /** * Binds a listener to both controllers. * @param listenerName - Event name * @param listener - Function to call */ bindListener(listenerName: keyof ControllerEventMap, listener: (event: ControllerEvent) => void): void; unbindListener(listenerName: keyof ControllerEventMap, listener: (event: ControllerEvent) => void): void; dispatchEvent(event: ControllerEvent): void; /** * Binds an event listener to handle 'selectstart' events for both * controllers. * @param event - The event listener function. */ bindSelectStart(event: (event: ControllerEvent) => void): void; /** * Binds an event listener to handle 'selectend' events for both controllers. * @param event - The event listener function. */ bindSelectEnd(event: (event: ControllerEvent) => void): void; /** * Binds an event listener to handle 'select' events for both controllers. * @param event - The event listener function. */ bindSelect(event: (event: ControllerEvent) => void): void; /** * Binds an event listener to handle 'squeezestart' events for both * controllers. * @param event - The event listener function. */ bindSqueezeStart(event: (event: ControllerEvent) => void): void; /** * Binds an event listener to handle 'squeezeend' events for both controllers. * @param event - The event listener function. */ bindSqueezeEnd(event: (event: ControllerEvent) => void): void; bindSqueeze(event: (event: ControllerEvent) => void): void; bindKeyDown(event: (event: KeyEvent) => void): void; bindKeyUp(event: (event: KeyEvent) => void): void; unbindKeyDown(event: (event: KeyEvent) => void): void; unbindKeyUp(event: (event: KeyEvent) => void): void; /** Samples current controller, button, and direct-touch state. */ sampleSources(): void; /** Returns the complete physical source state sampled this frame. */ getFrame(): InteractionFrameInput; private getRaySourceType; private updateDirectTouchInputs; enableGazeController(): void; disableGazeController(): void; private registerController; enableController(controller: Controller): void; disableController(controller: Controller): void; /** * Permanently unregisters a source added through enableController. Built-ins * and already-removed sources are ignored. Capture is cancelled as source-lost * next frame; terminal selectend/disconnected notifications are sent once. */ removeController(controller: Controller): void; disableControllers(): void; enableControllers(): void; dispose(): void; } //#endregion //#region src/interaction/HitRegistry.d.ts interface HitSurfaceOptions { /** Additional clipping or containment policy, evaluated in world space. */ containsPoint?: (point: THREE.Vector3, padding?: number) => boolean; /** * Direct touch only. Returns an object that should receive a touch at the * world-space `point` instead of this surface, such as a resize corner of a * card edge, or undefined to keep this surface. The returned object must be * registered with its own hit surface, which supplies its logical target * and manipulation handle; an unregistered object resolves as itself. */ touchTarget?: (point: THREE.Vector3) => THREE.Object3D | undefined; } //#endregion //#region src/interaction/Interaction.d.ts /** Owns all logical target, hover, capture, completion, and cancellation state. */ export declare class Interaction { private readonly callbacks; private readonly manipulation; private readonly reticle; private readonly reticleOptions; private readonly scene?; private readonly registry; private readonly resolver; private readonly directTouch; private longSelectDuration; private readonly gazeDwell; private readonly sourceStates; private readonly frameSnapshots; private readonly rawIntersections; private readonly resolvedRays; private readonly hoverPaths; private readonly captures; private readonly exclusiveControls; private readonly touches; private readonly suppressedUntilRelease; private readonly scaleIntents; private readonly wheelIntents; private focusHandler?; private raycastMode; private frameSources; private nextFrameSources; constructor(dependencies: InteractionDependencies); setLongSelectDuration(seconds: number): void; setRaycastMode(mode: RaycastMode): void; /** Replaces all sampled physical interaction state for one engine frame. */ update(frame: InteractionFrameInput, deltaSeconds?: number): void; clear(): void; registerHitSurface(physical: THREE.Object3D, logical: THREE.Object3D, options?: HitSurfaceOptions): () => void; /** Installs the UI runtime's focus policy without owning a second input path. */ setSelectionFocusHandler(handler?: (target?: THREE.Object3D) => void): void; /** Refreshes bounded direct-touch candidates found by the lifecycle pass. */ syncTouchCandidates(candidates: Iterable): void; /** Cancels captures that belong to an object before its Script is disposed. */ cancelObject(object: THREE.Object3D, reason?: SelectionEndReason): void; removeSource(controller: Controller, reason?: SelectionEndReason): void; getSourceSnapshot(controller: Controller): InteractionSourceState | undefined; getResolvedRay(controller: Controller): ResolvedRay | undefined; isPointingAt(object: THREE.Object3D): boolean; isSelectingAt(object: THREE.Object3D): boolean; isHovered(object: THREE.Object3D): boolean; getIntersectionAt(object: THREE.Object3D, controller?: Controller): THREE.Intersection | null; /** Writes up to two internal cursor points in controller order. */ writeCursorPointsAt(object: THREE.Object3D, first: THREE.Vector3, second: THREE.Vector3): 0 | 1 | 2; isManipulating(object: THREE.Object3D): boolean; /** Explicit zoom also reaches a UI control's manipulable ancestor. */ queueScaleIntent(controller: Controller, factor: number): boolean; /** Routes a normalized wheel delta using the next frame's resolved target. */ queueWheelIntent(controller: Controller, delta: number): boolean; private applyWheelIntent; private applyScaleIntent; private updateRay; private collectIntersections; private beginSelection; private startTargetCapture; private endSelection; private cancelCapture; private processTouchContact; private updateTouch; private finishTouch; private dispatchTouchStart; private dispatchTouch; private createTouchEvent; private updateGrab; private startGrabManipulation; private finishGrab; private createGrabEvent; private updateSemantic; private createScrollCapture; private activateScrollCapture; private updateScrollCapture; private updateLongSelect; private setResolvedRay; private clearResolvedRay; private updateHoverPath; private updateRaySnapshot; private updateTouchSnapshot; private getSourceState; private createSelection; private createSelectEvent; private hasDeliberateInput; private installCapture; private detachCapture; private runCaptureTransition; private cancelFailedCapture; private cancelFailedManipulations; private runManipulationTransition; private invokeSemantic; } //#endregion //#region src/core/User.d.ts /** * User is an embodied instance to manage hands, controllers, speech, and * avatars. It extends Script to update human-world interaction. * * In the long run, User is to manages avatars, hands, and everything of Human * I/O. In third-person view simulation, it should come with an low-poly avatar. * To support multi-user social XR planned for future iterations. */ export declare class User extends Script { private static readonly dependencies; /** * Whether to represent a local user, or another user in a multi-user session. */ local: boolean; /** * The number of hands associated with the XR user. */ numHands: number; /** * The height of the user in meters. */ height: number; /** * The default distance of a UI panel from the user in meters. */ panelDistance: number; /** * The handedness (primary hand) of the user (0 for left, 1 for right, 2 for * both). */ handedness: number; /** * The radius of the safe space around the user in meters. */ safeSpaceRadius: number; /** * The distance of a newly spawned object from the user in meters. */ objectDistance: number; /** * The angle of a newly spawned object from the user in radians. */ objectAngle: number; /** * An array of pivot objects. Pivot are sphere at the **starting** tip of * user's hand / controller / mouse rays for debugging / drawing applications. */ pivots: THREE.Object3D[]; /** * Public data for user interactions, typically holding references to XRHand. */ hands?: Hands; input: Input; private interaction; controllers: Controller[]; /** * Initializes the User. */ init({ input, interaction }: { input: Input; interaction: Interaction; }): void; /** * Sets the user's height on the first frame. * @param camera - */ setHeight(camera: THREE.Camera): void; /** * Adds pivots at the starting tip of user's hand / controller / mouse rays. */ enablePivots(): void; /** * Gets the pivot object for a given controller id. * @param id - The controller id. * @returns The pivot object. */ getPivot(id: number): THREE.Object3D | undefined; /** * Gets the world position of the pivot for a given controller id. * @param id - The controller id. * @returns The world position of the pivot. */ getPivotPosition(id: number): THREE.Vector3 | undefined; getRay(controllerId: number, target?: THREE.Ray): THREE.Ray; getRayIntersection(controllerId: number): THREE.Intersection> | null; /** * Checks if any controller is pointing at the given object or its children. * @param obj - The object to check against. * @returns True if a controller is pointing at the object. */ isPointingAt(obj: THREE.Object3D): boolean; /** * Checks if any controller is selecting the given object or its children. * @param obj - The object to check against. * @returns True if a controller is selecting the object. */ isSelectingAt(obj: THREE.Object3D): boolean; isManipulating(obj: THREE.Object3D): boolean; /** * Gets the intersection point on a specific object. * @param obj - The object to check for intersection. * @param id - The controller ID, or -1 for any controller. * @returns The intersection details, or null if no intersection. */ getIntersectionAt(obj: THREE.Object3D, id?: number): THREE.Intersection> | null; /** * Gets the world position of a controller. * @param id - The controller id. * @param target - The target vector to * store the result. * @returns The world position of the controller. */ getControllerPosition(id: number, target?: THREE.Vector3): THREE.Vector3; /** * Calculates the distance between a controller and an object. * @param id - The controller id. * @param object - The object to measure the distance to. * @returns The distance between the controller and the object. */ getControllerObjectDistance(id: number, object: THREE.Object3D): number; /** * Checks if either controller is selecting. * @param id - The controller id. If -1, check both controllers. * @returns True if selecting, false otherwise. */ isSelecting(id?: number): any; /** * Checks if either controller is squeezing. * @param id - The controller id. If -1, check both controllers. * @returns True if squeezing, false otherwise. */ isSqueezing(id?: number): any; } //#endregion //#region src/input/gestures/GestureTypes.d.ts export type HandLabel = 'left' | 'right'; export declare const HAND_INDEX_TO_LABEL: Partial>; export type JointPositions = Map; export interface HandContext { handedness: Handedness; handLabel: HandLabel; joints: JointPositions; getJoint(jointName: JointName): THREE.Vector3 | undefined; } export type GestureDetectionResult = { confidence: number; data?: Record; }; export type GestureScoreMap = Record; export type HeuristicGestureDetector = (context: HandContext, config: GestureConfiguration) => GestureDetectionResult | undefined; export interface GestureRecognizer { init?(): Promise; recognize(context: HandContext): GestureScoreMap | Promise; getGestureConfigurations?(): Record; dispose?(): void; } export interface PoseEstimator { init?(dependencies?: { user?: User; }): Promise; getHandContext(handedness: Handedness): HandContext | null; getHandContexts(): Partial>; dispose?(): void; } //#endregion //#region src/input/gestures/GestureRecognitionOptions.d.ts export type GestureConfiguration = { enabled: boolean; threshold?: number; }; export declare class GestureRecognitionOptions { enabled: boolean; minimumConfidence: number; updateIntervalMs: number; poseEstimator: PoseEstimator; gestureRecognizer: GestureRecognizer; gestures: Record; constructor(options?: DeepReadonly>); enable(): this; setGestureEnabled(name: string, enabled: boolean): this; setPoseEstimator(poseEstimator: PoseEstimator): this; setGestureRecognizer(gestureRecognizer: GestureRecognizer): this; setGestureConfig(name: string, config: Partial): this; private applyGestureRecognizerConfigurations; } //#endregion //#region src/input/strokes/StrokeRecognitionOptions.d.ts type StrokeProvider = 'onedollar'; declare class StrokeRecognitionOptions { /** Master switch for the stroke recognition block. */ enabled: boolean; /** * Configuration for the stroke recognition provider. */ providerConfig: { /** * Backing provider that recognizes strokes. * - 'onedollar': $1 Unistroke recognizer. */ provider: StrokeProvider; /** * Options specific to the 'onedollar' provider. */ onedollar: { supportedShapes: string[]; }; }; /** * Delay in seconds after gesture start before recording points. */ startDelay: number; /** * Delay in seconds to ignore points before gesture end. */ endDelay: number; /** * The hand joint to track for stroke recognition. */ joint: JointName; /** * Maximum number of points to capture in a single stroke. */ maxPoints: number; constructor(options?: DeepReadonly>); enable(): this; } //#endregion //#region src/lighting/LightingOptions.d.ts /** * Default options for controlling Lighting module features. */ export declare class LightingOptions { /** Enables debugging renders and logs. */ debugging: boolean; /** Enables XR lighting. */ enabled: boolean; /** Add ambient spherical harmonics to lighting. */ useAmbientSH: boolean; /** Add main diredtional light to lighting. */ useDirectionalLight: boolean; /** Cast shadows using diretional light. */ castDirectionalLightShadow: boolean; /** * Adjust hardness of shadows according to relative brightness of main light. */ useDynamicSoftShadow: boolean; constructor(options?: DeepReadonly>); } //#endregion //#region src/physics/RapierTypes.d.ts /** Structural Rapier contracts shared by the standard, compat and SIMD builds. * Only the API used by the SDK is required; no package-private classes cross * this boundary. Applications retain their chosen module for additional APIs. */ interface RapierVector { x: number; y: number; z: number; } interface RapierRotation extends RapierVector { w: number; } interface RapierRigidBodyDesc { setTranslation(x: number, y: number, z: number): RapierRigidBodyDesc; setRotation(rotation: RapierRotation): RapierRigidBodyDesc; setCcdEnabled(enabled: boolean): RapierRigidBodyDesc; } interface RapierColliderDesc { setDensity(density: number): RapierColliderDesc; setFriction(friction: number): RapierColliderDesc; setRestitution(restitution: number): RapierColliderDesc; } interface RapierRigidBody { translation(): RapierVector; rotation(): RapierRotation; setTranslation(translation: RapierVector, wakeUp: boolean): void; setRotation(rotation: RapierRotation, wakeUp: boolean): void; setEnabled(enabled: boolean): void; } interface RapierCollider { readonly handle: number; } interface RapierCharacterController { computeColliderMovement(collider: RapierCollider, movement: RapierVector): void; computedMovement(): RapierVector; setSlideEnabled(enabled: boolean): void; setApplyImpulsesToDynamicBodies(enabled: boolean): void; setCharacterMass(mass: number): void; } interface RapierEventQueue { free(): void; drainCollisionEvents(callback: (handle1: number, handle2: number, started: boolean) => void): void; } interface RapierShape { readonly type: number; } interface RapierWorld { timestep: number; step(eventQueue?: RapierEventQueue): void; free(): void; createRigidBody(desc: RapierRigidBodyDesc): RapierRigidBody; removeRigidBody(body: RapierRigidBody): void; createCollider(desc: RapierColliderDesc, parent?: RapierRigidBody): RapierCollider; removeCollider(collider: RapierCollider, wakeUp: boolean): void; createCharacterController(offset: number): RapierCharacterController; removeCharacterController(controller: RapierCharacterController): void; castShape(position: RapierVector, rotation: RapierRotation, velocity: RapierVector, shape: RapierShape, targetDistance: number, maxToi: number, stopAtPenetration: boolean, filterFlags?: number): { time_of_impact: number; } | null; } /** The module supplied by an application through options.physics.RAPIER. */ interface RAPIERCompat { init?(): Promise; World: new (gravity: RapierVector) => RapierWorld; EventQueue: new (autoDrain: boolean) => RapierEventQueue; Ball: new (radius: number) => RapierShape; RigidBodyDesc: { fixed(): RapierRigidBodyDesc; dynamic(): RapierRigidBodyDesc; kinematicPositionBased(): RapierRigidBodyDesc; }; ColliderDesc: { ball(radius: number): RapierColliderDesc; cuboid(hx: number, hy: number, hz: number): RapierColliderDesc; convexHull(vertices: Float32Array): RapierColliderDesc | null; trimesh(vertices: Float32Array, indices: Uint32Array): RapierColliderDesc; }; QueryFilterFlags: { ONLY_FIXED: number; }; } //#endregion //#region src/physics/PhysicsOptions.d.ts export declare class PhysicsOptions { /** * The target frames per second for the physics simulation loop. */ fps: number; /** * The global gravity vector applied to the physics world. */ gravity: { x: number; y: number; z: number; }; /** * If true, the `Physics` manager will automatically call `world.step()` * on its fixed interval. Set to false if you want to control the * simulation step manually. */ worldStep: boolean; /** * If true, an event queue will be created and passed to `world.step()`, * enabling the handling of collision and contact events. */ useEventQueue: boolean; /** * Instance of RAPIER. */ RAPIER?: RAPIERCompat; } //#endregion //#region src/utils/Keycodes.d.ts /** * A frozen object containing standardized string values for `event.code`. * Used for desktop simulation. */ export declare enum Keycodes { W_CODE = "KeyW", A_CODE = "KeyA", S_CODE = "KeyS", D_CODE = "KeyD", UP = "ArrowUp", DOWN = "ArrowDown", LEFT = "ArrowLeft", RIGHT = "ArrowRight", Q_CODE = "KeyQ" // Often used for 'down' or 'strafe left' , E_CODE = "KeyE" // Often used for 'up' or 'strafe right' , PAGE_UP = "PageUp", PAGE_DOWN = "PageDown", SPACE_CODE = "Space", ENTER_CODE = "Enter", T_CODE = "KeyT" // General purpose 'toggle' or 'tool' key , LEFT_SHIFT_CODE = "ShiftLeft", RIGHT_SHIFT_CODE = "ShiftRight", LEFT_CTRL_CODE = "ControlLeft", RIGHT_CTRL_CODE = "ControlRight", LEFT_ALT_CODE = "AltLeft", RIGHT_ALT_CODE = "AltRight", CAPS_LOCK_CODE = "CapsLock", ESCAPE_CODE = "Escape", TAB_CODE = "Tab", B_CODE = "KeyB", C_CODE = "KeyC", F_CODE = "KeyF", G_CODE = "KeyG", H_CODE = "KeyH", I_CODE = "KeyI", J_CODE = "KeyJ", K_CODE = "KeyK", L_CODE = "KeyL", M_CODE = "KeyM", N_CODE = "KeyN", O_CODE = "KeyO", P_CODE = "KeyP", R_CODE = "KeyR", U_CODE = "KeyU", V_CODE = "KeyV", X_CODE = "KeyX", Y_CODE = "KeyY", Z_CODE = "KeyZ", DIGIT_0 = "Digit0", DIGIT_1 = "Digit1", DIGIT_2 = "Digit2", DIGIT_3 = "Digit3", DIGIT_4 = "Digit4", DIGIT_5 = "Digit5", DIGIT_6 = "Digit6", DIGIT_7 = "Digit7", DIGIT_8 = "Digit8", DIGIT_9 = "Digit9", BACKQUOTE = "Backquote" } //#endregion //#region src/simulator/SimulatorOptions.d.ts export declare enum SimulatorMode { USER = "User", POSE = "Navigation", CONTROLLER = "Hands", POINTER_LOCK = "PointerLock", EDITOR = "Editor" } export interface SimulatorCustomInstruction { header: string; videoSrc?: string; description: string; } export interface SimulatorEnvironment { /** Optional display name; otherwise the manifest name is used. */ name?: string; manifestPath: string; } export interface SimulatorHandPhysicsOptions { enabled: boolean; radius: number; mass: number; contactOffset: number; friction: number; restitution: number; } export declare class SimulatorOptions { initialCameraPosition: { x: number; y: number; z: number; }; environments: { /** Optional display name; otherwise the manifest name is used. */ name?: string; manifestPath: string; }[]; activeEnvironmentIndex: number; defaultMode: SimulatorMode; defaultHand: Handedness; modeToggle: { enabled: boolean; toggleKey: Keycodes | null; toggleOrder: { User: SimulatorMode; Navigation: SimulatorMode; Hands: SimulatorMode; PointerLock: SimulatorMode; Editor: SimulatorMode; }; }; simulatorSettingsPanel: { enabled: boolean; element: string; }; instructions: { enabled: boolean; showAutomatically: boolean; element: string; overlayEnabled: boolean; overlayElement: string; fadeInDelayMs: number; customInstructions: SimulatorCustomInstruction[]; }; handPosePanel: { enabled: boolean; element: string; }; geminiLivePanel: { enabled: boolean; element: string; }; stereo: { enabled: boolean; }; navMesh: { enabled: boolean; showDebugVisualizations: boolean; eyeHeight: number; }; /** Controls the isolated physics world used by the desktop simulator. */ physics: { enabled: boolean; }; deviceCamera: { enabled: boolean; }; renderToRenderTexture: boolean; blendingMode: 'normal' | 'screen'; /** Optional diagonal field of view in degrees for a glasses display. */ displayDiagonalFov?: number; /** Shoulder/chest origin of the left hand in local camera space. */ leftHandOrigin: { x: number; y: number; z: number; }; /** Shoulder/chest origin of the right hand in local camera space. */ rightHandOrigin: { x: number; y: number; z: number; }; /** Optional physical constraints for simulated hands. Requires Rapier. */ handPhysics: SimulatorHandPhysicsOptions; /** Limits how far each hand controller can travel from the user's shoulder origin. */ reachDistance: { enabled: boolean; /** The maximum distance in meters a controller can move from its origin point. */ radius: number; }; /** Limits the angular cone in front of the user within which controllers can move. */ reachAngle: { enabled: boolean; /** The maximum full cone angle in radians around the camera's forward direction (default is Math.PI, a front hemisphere). */ angle: number; }; constructor(options?: DeepReadonly>); } //#endregion //#region src/sound/SoundOptions.d.ts export declare class SpeechSynthesizerOptions { enabled: boolean; /** If true, a new call to speak() will interrupt any ongoing speech. */ allowInterruptions: boolean; } export declare class SpeechRecognizerOptions { enabled: boolean; /** Recognition language (e.g., 'en-US'). */ lang: string; /** If true, recognition continues after a pause. */ continuous: boolean; /** Keywords to detect as commands. */ commands: string[]; /** If true, provides interim results. */ interimResults: boolean; /** Minimum confidence (0-1) for a command. */ commandConfidenceThreshold: number; /** If true, play activation sounds in simulator. */ playSimulatorActivationSounds: boolean; } export declare class SoundOptions { speechSynthesizer: SpeechSynthesizerOptions; speechRecognizer: SpeechRecognizerOptions; } //#endregion //#region src/world/mesh/MeshDetectionOptions.d.ts export declare class MeshDetectionOptions { showDebugVisualizations: boolean; enabled: boolean; constructor(options?: DeepPartial); /** * Enables the mesh detector. */ enable(): this; } //#endregion //#region src/world/objects/ObjectsOptions.d.ts /** * Configuration options for the ObjectDetector. */ export declare class ObjectsOptions { debugging: boolean; enabled: boolean; showDebugVisualizations: boolean; /** Use simulator ground truth instead of a camera detector on desktop. */ simulatorOverride: boolean; /** * Minimum delay in milliseconds between continuous object detection runs. * A value of 0 runs again as soon as the previous detection finishes. */ pollingIntervalMs: number; /** * Margin to add when cropping the object image, as a percentage of image * size. */ objectImageMargin: number; /** * Configuration for the detection backends. */ backendConfig: { /** The active backend to use for detection. */ activeBackend: 'gemini' | 'mediapipe'; gemini: { systemInstruction: string; /** * Extra Gemini generation config merged into the per-call config (over * the SDK defaults). Use to pin sampling parameters such as * `temperature: 0` for deterministic detections. */ generationConfig: Record; responseSchema: { type: string; items: { type: string; required: string[]; properties: { objectName: { type: string; }; ymin: { type: string; }; xmin: { type: string; }; ymax: { type: string; }; xmax: { type: string; }; }; }; }; }; /** Configuration for MediaPipe backend. */ mediapipe: { wasmFilesUrl: string; modelAssetPath: string; scoreThreshold: number; }; }; constructor(options?: DeepPartial); /** * Enables the object detector. */ enable(): this; } //#endregion //#region src/world/planes/PlanesOptions.d.ts export declare class PlanesOptions { debugging: boolean; enabled: boolean; showDebugVisualizations: boolean; constructor(options?: DeepPartial); enable(): this; } //#endregion //#region src/world/sounds/SoundsOptions.d.ts declare class SoundsOptions { enabled: boolean; showDebugInfo: boolean; backendConfig: { activeBackend: string; mediapipe: { wasmFilesUrl: string; modelAssetPath: string; chunkSamples: number; }; }; constructor(options?: DeepPartial); /** * Enables sound detection. */ enable(): this; } //#endregion //#region src/world/humans/HumansOptions.d.ts /** * Configuration options for the Human Pose Detection system. */ export declare class HumansOptions { enabled: boolean; /** * Minimum delay in milliseconds between continuous pose detection runs. * A value of 0 runs again as soon as the previous detection finishes. */ pollingIntervalMs: number; /** * Project each landmark onto the depth mesh to find its world position. * * This is what you want when the people being detected are physically in * front of you, since the ray lands on their actual body. Turn it off when * the camera is showing someone who is not part of the depth scene, such as a * webcam feed on the desktop simulator: every ray would then hit the * surrounding geometry instead and the skeleton would be smeared across it. * With projection off, landmarks are placed along the view ray at a fixed * distance, which keeps the body correctly proportioned. */ useDepthProjection: boolean; /** * Configuration options for the active pose detection backend. */ backendConfig: { activeBackend: string; mediapipe: { wasmFilesUrl: string; modelAssetPath: string; /** * Run inference in a web worker so a detection pass does not stall the * render loop. The worker is limited to the CPU delegate because * MediaPipe only creates a GPU surface for a real DOM canvas, so set * this to false to trade a blocked main thread for GPU inference. * Falls back to the main thread automatically when workers are * unavailable. */ useWorker: boolean; /** * The maximum number of simultaneous human poses/bodies to track. */ numPoses: number; /** * The minimum confidence score [0.0, 1.0] required for a pose to be detected. */ minPoseDetectionConfidence: number; /** * The minimum confidence score [0.0, 1.0] required to confirm a pose is still present. */ minPosePresenceConfidence: number; /** * The minimum confidence score [0.0, 1.0] required for tracking landmarks between frames. */ minTrackingConfidence: number; }; }; constructor(options?: DeepPartial); enable(): this; } //#endregion //#region src/world/faces/FacesOptions.d.ts /** * Configuration options for the Face Landmark Detection system. */ export declare class FacesOptions { enabled: boolean; /** * Minimum delay in milliseconds between continuous face detection runs. * A value of 0 runs again as soon as the previous detection finishes. */ pollingIntervalMs: number; /** * Configuration options for the active face detection backend. */ backendConfig: { activeBackend: string; mediapipe: { wasmFilesUrl: string; modelAssetPath: string; /** * The maximum number of simultaneous faces to track. */ numFaces: number; /** * The minimum confidence score [0.0, 1.0] required for a face to be * detected. */ minFaceDetectionConfidence: number; /** * The minimum confidence score [0.0, 1.0] required to confirm a face is * still present. */ minFacePresenceConfidence: number; /** * The minimum confidence score [0.0, 1.0] required for tracking * landmarks between frames. */ minTrackingConfidence: number; /** * Whether to compute and emit per-face blendshape weights (52 * ARKit-compatible categories). Required for facial expression * mirroring, lipsync feeds, and avatar animation. */ outputFaceBlendshapes: boolean; /** * Whether to compute and emit the 4x4 facial transformation matrix * for each face. Provides a stable rigid head pose for parenting * objects to the head (glasses, masks, hats). */ outputFacialTransformationMatrixes: boolean; }; }; constructor(options?: DeepPartial); enable(): this; } //#endregion //#region src/world/segmentation/SegmentationOptions.d.ts /** * Configuration options for the semantic segmentation system. Mirrors the * other `world/*` perception options (humans, faces, objects). */ export declare class SegmentationOptions { enabled: boolean; /** * Minimum delay in milliseconds between continuous segmentation runs. * A value of 0 runs again as soon as the previous inference finishes. * Defaults to 66 (~15 fps), the rate the magic_window grab loop used before * segmentation moved onto its own polling loop. */ pollingIntervalMs: number; /** * Configuration options for the active segmentation backend. */ backendConfig: { activeBackend: string; mediapipe: { wasmFilesUrl: string; modelAssetPath: string; /** * Output the per-pixel category mask. Required to produce a * {@link SegmentationMask}. */ outputCategoryMask: boolean; }; }; constructor(options?: DeepPartial); enable(): this; } //#endregion //#region src/world/anchors/AnchorsOptions.d.ts /** * Builds the default storage key for a page. * * Scoped to the path because anchors are stored per origin: two apps served * from one host would otherwise restore each other's anchors, which reads as * mysterious content appearing on first run rather than as a shared store. * * @param pathname - Page path; omit when there is no document. * @returns The storage key to default to. */ export declare function defaultAnchorStorageKey(pathname?: string): string; /** * Configuration for the spatial anchor subsystem. * * Anchors pin content to a real place so the platform keeps it there as its * understanding of the room improves. With {@link AnchorsOptions.persistent} * enabled, anchor handles are saved so the same content can be restored in a * later session. */ export declare class AnchorsOptions { /** Logs anchor lifecycle transitions. */ debugging: boolean; /** Whether the anchor subsystem is created at all. */ enabled: boolean; /** * Whether anchor handles are saved so they can be restored in a later * session. Requires platform support for persistent handles; when the * platform only offers session-scoped anchors this degrades to in-session * behaviour rather than failing. */ persistent: boolean; /** * Whether to hold poses locally when the platform has no anchor support. * * Off by default: on a real headset a silent stand-in would look like * working anchors while nothing is actually pinned. Demos and desktop * development opt in deliberately. */ simulatorFallback: boolean; /** * Storage key used when persistence is enabled. * * Defaults to a page-scoped key. Set it explicitly to share anchors between * pages, or to keep a stable key if the app might move path. */ storageKey: string; /** * Upper bound on saved handles. Persistent handles accumulate across * sessions and would otherwise grow without limit; the oldest are evicted * first once the cap is reached. */ maxStoredAnchors: number; constructor(options?: DeepPartial); /** * Enables anchors. * @returns This options object, for chaining. */ enable(): this; /** * Enables anchors and saves handles for restoration in later sessions. * @returns This options object, for chaining. */ enablePersistence(): this; } //#endregion //#region src/world/WorldOptions.d.ts export declare class WorldOptions { debugging: boolean; enabled: boolean; initiateRoomCapture: boolean; planes: PlanesOptions; objects: ObjectsOptions; meshes: MeshDetectionOptions; sounds: SoundsOptions; humans: HumansOptions; faces: FacesOptions; segmentation: SegmentationOptions; anchors: AnchorsOptions; constructor(options?: DeepPartial); /** * Enables plane detection. */ enablePlaneDetection(): this; /** * Enables object detection. */ enableObjectDetection(): this; /** * Enables mesh detection. */ enableMeshDetection(): this; /** * Enables spatial anchors. */ enableAnchors(): this; /** * Enables spatial anchors and saves their handles so anchored content can be * restored in a later session. */ enableAnchorPersistence(): this; /** * Enables sound detection. */ enableSoundDetection(): this; /** * Enables human detection. */ enableHumanDetection(): this; /** * Enables face landmark detection. */ enableFaceDetection(): this; /** * Enables semantic segmentation (person / background category masks). */ enableSegmentation(): this; } //#endregion //#region src/core/Options.d.ts /** * Default options for XR controllers, which encompass hands by default in * Android XR, mouse input on desktop, tracked controllers, and gamepads. */ export declare class InputOptions { /** Whether controller input is enabled. */ enabled: boolean; /** Whether mouse input should act as a controller on desktop. */ enabledMouse: boolean; /** Whether to enable debugging features for controllers. */ debug: boolean; /** Whether to show controller models. */ visualization: boolean; /** Whether to show the ray lines extending from the controllers. */ visualizeRays: boolean; } /** * Default options for the reticle (pointing cursor). */ export declare class ReticleOptions { enabled: boolean; /** Whether reticles use the real-world depth mesh as a surface. */ projectOnDepthMesh: boolean; /** * Maximum reticle drawing distance in meters. It does not limit targeting. */ maxDistance?: number; /** * Distance in meters at which to render the reticle when no valid hit is * found. Set to 0 to hide the reticle on a miss. */ defaultRenderDistance: number; } export type RaycastMode = 'continuous' | 'select'; export declare class InteractionOptions { /** When to sample ray intersections for interaction. */ raycastMode: RaycastMode; /** Seconds a stable object selection must be held before long-select. */ longSelectDuration: number; } /** * Options for the XR transition effect. */ export declare class XRTransitionOptions { /** Whether the transition effect is enabled. */ enabled: boolean; /** The duration of the transition in seconds. */ transitionTime: number; /** The default background color for VR transitions. */ defaultBackgroundColor: number; } declare const FORM_FACTORS: readonly ['auto', 'xr', 'hud', 'vr', 'desktop', 'mobile']; export type FormFactor = (typeof FORM_FACTORS)[number]; export declare const RENDERER_BACKENDS: readonly ['webgl', 'webgpu', 'serializer']; export type RendererBackend = (typeof RENDERER_BACKENDS)[number]; export type FramebufferScaleFactor = number | 'native'; export interface WebGPURendererOptions { forceWebGL?: boolean; } export type AutomationModeOptions = { hideSimulatorUi?: boolean; defaultHand?: Handedness; defaultMode?: SimulatorMode; enableHands?: boolean; enableCamera?: boolean; }; /** * A central configuration class for the entire XR Blocks system. It aggregates * all settings and provides chainable methods for enabling common features. */ export declare class Options { /** * Whether to use antialiasing. */ antialias: boolean; /** * Whether to use a logarithmic depth buffer. Useful for depth-aware * occlusions. */ logarithmicDepthBuffer: boolean; /** * Global flag for enabling various debugging features. */ debugging: boolean; /** * Whether to request a stencil buffer. */ stencil: boolean; /** * Canvas element to use for rendering. * If not defined, a new element will be added to document body. */ canvas?: HTMLCanvasElement; /** * The rendering backend to use. */ rendererBackend: RendererBackend; /** * Optional configuration for WebGPU renderer. */ webgpuOptions?: WebGPURendererOptions; /** * Optional Split Engine serializer instance or factory function used when * `rendererBackend` is `'serializer'`. */ serializer?: SerializerRenderer | SerializerRendererFactory; /** * Optional WebXR framebuffer scale factor. Set to a number (e.g., `1.5`) or * `'native'` to query `XRWebGLLayer.getNativeFramebufferScaleFactor(session)` * before the XR session starts. */ framebufferScaleFactor?: FramebufferScaleFactor; /** * Makes an alpha-blend passthrough session composite like an additive * display by preserving destination RGB while forcing output alpha to zero. * Has no effect in opaque or additive sessions. */ simulateAdditiveDisplay: boolean; /** * Constant alpha written by additive display simulation. `0` preserves all * passthrough; `1` fully dims it. Read every frame while simulation is active. */ simulatedDimming: number; /** * Any additional required features when initializing webxr. */ webxrRequiredFeatures: string[]; /** * Any additional optional features when initializing webxr. */ webxrOptionalFeatures: string[]; referenceSpaceType: XRReferenceSpaceType; controllers: InputOptions; depth: DepthOptions; lighting: LightingOptions; deviceCamera: DeviceCameraOptions; hands: HandsOptions; gestures: GestureRecognitionOptions; headGestures: HeadGestureRecognitionOptions; strokes: StrokeRecognitionOptions; reticles: ReticleOptions; interaction: InteractionOptions; sound: SoundOptions; ai: AIOptions; simulator: SimulatorOptions; world: WorldOptions; context: ContextOptions; physics: PhysicsOptions; layers: LayersOptions; transition: XRTransitionOptions; camera: { near: number; far: number; }; /** * Whether to use post-processing effects. */ usePostprocessing: boolean; enableSimulator: boolean; /** * Whether to catch all exceptions thrown by developer scripts in the main update loop * and physics step, and log them using console.error instead of crashing the application. * When enabled, exceptions in one script will not prevent other scripts or subsystems from updating. */ catchScriptExceptions: boolean; /** * Configuration for the XR session button. */ xrButton: { appTitle: string; appDescription: string; enabled: boolean; startText: string; endText: string; invalidText: string; startSimulatorText: string; showEnterSimulatorButton: boolean; alwaysAutostartSimulator: boolean; }; /** * Which permissions to request before entering the XR session. */ permissions: { geolocation: boolean; camera: boolean; microphone: boolean; }; xrSessionMode: XRSessionMode; private _formFactor; get formFactor(): FormFactor; /** * Form factor is a preset that configures the experience for a specific * device type. Currently it only controls whether the simulator is enabled * and should always be autostarted. */ set formFactor(formFactor: FormFactor); /** * Constructs the Options object by merging default values with provided * custom options. * @param options - A custom options object to override the defaults. */ constructor(options?: DeepReadonly>); protected parseUrlParams(): void; /** * Configures Core to use THREE.WebGPURenderer instead of THREE.WebGLRenderer. * @param options - Optional WebGPU renderer settings such as `forceWebGL`. */ enableWebGPU(options?: WebGPURendererOptions): this; /** * Configures Core to use a SplitEngineSerializer renderer backend instead of * THREE.WebGLRenderer. * @param serializer - Optional SplitEngineSerializer instance or factory function. */ enableSerializer(serializer?: SerializerRenderer | SerializerRendererFactory): this; /** * Alias for `enableSerializer` that configures Core to use a * SplitEngineSerializer renderer backend. * @param serializer - Optional SplitEngineSerializer instance or factory function. */ useSerializer(serializer?: SerializerRenderer | SerializerRendererFactory): this; /** * Sets the session mode to VR and disables the simulator passthrough scene. */ enableVR(): this; /** * Enables a standard simulator-driven setup for automation and external test * harnesses. * @returns The instance for chaining. */ enableAutomationMode(config?: AutomationModeOptions): this; /** * Enables reticles for visualizing targets of hand rays in WebXR. * @returns The instance for chaining. */ enableReticles(): this; /** * Enables depth sensing in WebXR with default options. * @returns The instance for chaining. */ enableDepth(): this; /** * Enables WebXR composition layers. * * Content presented as a layer is composited once at its own resolution * rather than being drawn into the eye buffer and resampled again, so video * and text come out sharper, and the compositor keeps reprojecting it to the * latest head pose even when the app's own frame rate dips. * * Requested optionally, and each layer falls back to ordinary in-scene * rendering where the platform cannot present one. * * @returns The instance for chaining. */ enableLayers(): this; /** * Enables plane detection. * @returns The instance for chaining. */ enablePlaneDetection(): this; /** * Enables object detection. * @returns The instance for chaining. */ enableObjectDetection(): this; /** * Enables human pose detection. * @returns The instance for chaining. */ enableHumanDetection(): this; /** * Enables face landmark detection. Provides 478 per-face landmarks in * world space, optional 52 ARKit-style blendshape weights, and an * optional rigid 4x4 facial transformation matrix per detected face. * @returns The instance for chaining. */ enableFaceDetection(): this; /** * Enables semantic segmentation. Produces per-pixel person / background * category masks from the device camera (MediaPipe, on-device). Unlike face * and human detection it does not require depth. * @returns The instance for chaining. */ enableSegmentation(): this; /** * Enables device camera (passthrough) with a specific facing mode. * @param facingMode - The desired camera facing mode, either 'environment' or * 'user'. * @returns The instance for chaining. */ enableCamera(facingMode?: 'environment' | 'user'): this; /** * Enables hand tracking. * @returns The instance for chaining. */ enableHands(): this; /** * Enables the gesture recognition block and ensures hands are available. * @returns The instance for chaining. */ enableGestures(): this; /** * Enables completed nod and shake recognition from the user's head pose. * @returns The instance for chaining. */ enableHeadGestures(): this; /** * Enables the stroke recognition block and ensures gestures are available. * @returns The instance for chaining. */ enableStrokes(): this; /** * Enables the visualization of rays for hand tracking. * @returns The instance for chaining. */ enableHandRays(): this; /** * Enables a standard set of AI features, including Gemini Live. * @returns The instance for chaining. */ enableAI(): this; /** * Enables agent-facing context detectors such as semantic trees, * view visibility, and Set-of-Mark observations. * @returns The instance for chaining. */ enableContext(): this; /** * Enables agent-facing scene context. * @returns The instance for chaining. */ enableSceneContext(): this; /** * Enables agent-facing visible objects context. * @returns The instance for chaining. */ enableVisibleObjectsContext(): this; /** * Enables agent-facing Set-of-Mark context. * @returns The instance for chaining. */ enableSetOfMarkContext(): this; /** * Enables the XR transition component for toggling VR. * @returns The instance for chaining. */ enableXRTransitions(): this; /** * Enables input from hands and controllers. * Note that this is enabled by default and can also be changed at runtime with * xb.core.input.enableControllers() and xb.core.input.disableControllers(). * @returns The instance for chaining. */ enableControllers(): this; /** * Sets the title of the app to be displayed above the XR button. * @param title - The title of the app. * @returns The instance for chaining. */ setAppTitle(title: string): this; /** * Sets the description of the app to be displayed above the XR button. * @param description - The description of the app. * @returns The instance for chaining. */ setAppDescription(description: string): this; /** * Sets the WebXR framebuffer scale factor (a numeric multiplier or `'native'` * to use `XRWebGLLayer.getNativeFramebufferScaleFactor(session)`). * @param scaleFactor - Numeric scale factor or `'native'`. * @returns The instance for chaining. */ setFramebufferScaleFactor(scaleFactor: FramebufferScaleFactor): this; } //#endregion //#region src/utils/FaceCameraMath.d.ts type FaceCameraMode = 'capsule' | 'cylindrical' | 'spherical'; //#endregion //#region src/interaction/manipulation/ManipulationTypes.d.ts export declare const ManipulationAction: { readonly Translate: 'translate'; readonly Rotate: 'rotate'; readonly Scale: 'scale'; readonly Resize: 'resize'; readonly None: 'none'; }; export type ManipulationAction = (typeof ManipulationAction)[keyof typeof ManipulationAction]; export interface TranslateOptions { faceCamera?: boolean; /** Camera-facing rotation mode used while translating. */ mode?: FaceCameraMode; /** Half-height of the upright region used by capsule mode, in meters. */ capsuleHalfHeight?: number; /** Camera-facing rotation smoothing, matching `FaceCamera`. */ smoothing?: number; /** * Scales the owner with its distance from the camera while translating, * matching Android XR panels: apparent size stays constant up to 1.75 meters, * then scale grows at 0.5 meters per meter so farther owners look smaller. * Clamped by the Scale action limits. */ scaleWithDistance?: boolean; /** * Pushes the owner away or pulls it closer along a controller ray with the * thumbstick while translating: forward pushes, back pulls. */ pushPull?: boolean | PushPullOptions; /** Closest the owner can be moved to the viewer, in meters. */ minDistance?: number; /** Farthest the owner can be moved from the viewer, in meters. */ maxDistance?: number; } export interface PushPullOptions { /** * Exponential distance change rate at full deflection: the distance is * multiplied by e^speed per second. Defaults to 1.5. */ speed?: number; } export interface RotateOptions { axis?: 'x' | 'y' | 'z' | THREE.Vector3Like; space?: 'local' | 'world'; sensitivity?: number; } export interface ScaleOptions { minScale?: number | THREE.Vector3Like; maxScale?: number | THREE.Vector3Like; } export interface ResizeSize { width?: number; height?: number; } /** Options for resizing a `UICard` by dragging one of its corners. */ export interface ResizeOptions { /** * Point kept fixed while a corner is dragged. `center` grows the card around * its center, matching Android XR and Quest panels. `opposite` keeps the * corner opposite the dragged one in place. Defaults to `center`. */ anchor?: 'center' | 'opposite'; /** * Minimum card size in meters. Defaults to 0.1 meters per axis. Without an * explicit `width`, the card never gets narrower than its content allows, * and without an explicit `height` it never gets shorter than its content * needs at the current width. Set `height` when the card scrolls its own * content. */ minSize?: ResizeSize; /** Maximum card size in meters. Unbounded by default. */ maxSize?: ResizeSize; /** Keeps the card's width-to-height ratio while resizing. Defaults to false. */ preserveAspectRatio?: boolean; } export interface ManipulationHandleOptions { action?: typeof ManipulationAction.Translate | typeof ManipulationAction.Rotate | typeof ManipulationAction.Scale | typeof ManipulationAction.Resize | typeof ManipulationAction.None; } export interface ManipulationOptions { actions?: { translate?: boolean | TranslateOptions; rotate?: boolean | RotateOptions; scale?: boolean | ScaleOptions; /** Corner resize. Applies only to `UICard` owners. */ resize?: boolean | ResizeOptions; }; handle?: ManipulationHandleOptions; } export type ManipulationPhase = 'start' | 'update' | 'end' | 'cancel'; export interface BaseManipulationEvent { readonly phase: ManipulationPhase; readonly action: ManipulationAction; readonly source: InteractionSource; readonly sources: readonly InteractionSource[]; readonly target: THREE.Object3D; readonly surface: THREE.Object3D; readonly owner: THREE.Object3D; readonly currentTarget: Script; readonly defaultPrevented: boolean; preventDefault(): void; stopPropagation(): void; } export interface TranslateManipulationEvent extends BaseManipulationEvent { readonly action: typeof ManipulationAction.Translate; readonly point: THREE.Vector3; readonly delta: THREE.Vector3; readonly position: THREE.Vector3; readonly worldPosition: THREE.Vector3; /** Proposed local scale, changed only by `scaleWithDistance`. */ readonly scale: THREE.Vector3; } export interface RotateManipulationEvent extends BaseManipulationEvent { readonly action: typeof ManipulationAction.Rotate; readonly angle: number; readonly quaternion: THREE.Quaternion; } export interface ScaleManipulationEvent extends BaseManipulationEvent { readonly action: typeof ManipulationAction.Scale; readonly factor: number; readonly center: THREE.Vector3; readonly scale: THREE.Vector3; } export interface ResizeManipulationEvent extends BaseManipulationEvent { readonly action: typeof ManipulationAction.Resize; /** * Proposed card size in meters. An automatic height stays `'auto'` until the * resize actually changes the card's size, then becomes fixed. Before the * card's first layout, only the width can change. */ readonly width: number; readonly height: number | 'auto'; /** Proposed local position that keeps the resize anchor in place. */ readonly position: THREE.Vector3; } export type ManipulationEvent = TranslateManipulationEvent | RotateManipulationEvent | ScaleManipulationEvent | ResizeManipulationEvent; //#endregion //#region src/interaction/InteractionTypes.d.ts type PointerEvents = 'auto' | 'none'; type ReticleMode = 'auto' | 'surface' | 'hidden'; interface XBObjectOptions { /** Whether this object and its descendants participate in pointer hits. */ pointerEvents?: PointerEvents; interactionEnabled?: boolean; reticleMode?: ReticleMode; /** Keeps an active text field focused while interacting with an accessory. */ preserveTextFocus?: boolean; manipulation?: boolean | ManipulationOptions; manipulationHandle?: ManipulationHandleOptions | 'none'; } declare module 'three' { interface Object3D { xb?: XBObjectOptions; } } type InteractionSourceType = 'mouse' | 'controller-ray' | 'hand-ray' | 'direct-touch' | 'gaze' | 'simulator'; type RaySourceType = Exclude; interface InteractionSource { readonly type: InteractionSourceType; readonly handedness: 'left' | 'right' | 'none'; readonly controller: Controller; } interface RaySourceInput { controller: Controller; sourceType: RaySourceType; ray: THREE.Ray; /** Optional raw hits supplied by an isolated Interaction adapter. */ intersections?: readonly THREE.Intersection[]; selected: boolean; released?: boolean; position?: THREE.Vector3; orientation?: THREE.Quaternion; } interface DirectTouchInput { controller: Controller; handIndex: number; hand?: THREE.Object3D; point: THREE.Vector3; selected: boolean; orientation?: THREE.Quaternion; } /** All physical interaction input sampled for one engine frame. */ interface InteractionFrameInput { readonly raySources: readonly RaySourceInput[]; readonly directTouches: readonly DirectTouchInput[]; } /** Mutable internal storage for one controller's current logical source. */ declare class InteractionSourceState { readonly controller: Controller; source: InteractionSource; sourceType: InteractionSourceType; readonly position: THREE.Vector3; readonly orientation: THREE.Quaternion; private readonly rayValue; ray?: THREE.Ray; selected: boolean; selectionProgress?: number; constructor(controller: Controller); updateRay(input: RaySourceInput): this; updateTouch(point: THREE.Vector3, orientation?: THREE.Quaternion): this; copyFrom(source: InteractionSourceState): this; } interface ResolvedRay { readonly intersection: THREE.Intersection; /** Physical object that supplied the hit geometry. */ readonly hitObject: THREE.Object3D; /** Public object that owns the hit. */ readonly surface: THREE.Object3D; readonly target?: THREE.Object3D; readonly scriptPath: readonly Script[]; readonly objectPath: readonly THREE.Object3D[]; readonly reticleMode: ReticleMode; readonly semanticControl?: THREE.Object3D; readonly manipulation?: ManipulationResolution; } type ResolvedManipulationAction = Exclude; interface ManipulationResolution { readonly owner: THREE.Object3D; readonly action?: ResolvedManipulationAction; readonly handle?: THREE.Object3D; } type TargetedInteractionHook = 'onObjectSelectStart' | 'onObjectSelectEnd' | 'onObjectLongSelect' | 'onObjectTouchStart' | 'onObjectTouching' | 'onObjectTouchEnd' | 'onObjectGrabStart' | 'onObjectGrabbing' | 'onObjectGrabEnd' | 'onHoverEnter' | 'onHovering' | 'onHoverExit'; type GlobalInteractionHook = 'onSelectStart' | 'onSelecting' | 'onSelect' | 'onSelectEnd' | 'onLongSelect'; type GlobalInteractionEvent = Hook extends 'onSelectEnd' ? SelectEndEvent : Hook extends 'onLongSelect' ? LongSelectEvent : SelectEvent; /** * The only Script-facing seam. The implementation applies the existing Script * exception policy to each invocation. */ interface InteractionCallbackDispatch { isScript(object: THREE.Object3D): boolean; hasTargetHandler(object: THREE.Object3D, sourceType: InteractionSourceType): boolean; hasTargetHook(object: THREE.Object3D, hook: TargetedInteractionHook): boolean; invokeTarget(script: THREE.Object3D, hook: TargetedInteractionHook, argument: unknown): void; invokeSemantic(object: THREE.Object3D, callback: () => void): void; invokeGlobal(hook: Hook, event: GlobalInteractionEvent): void; invokeManipulation(script: Script, event: ManipulationEvent): void; } interface ReticlePresentationObserver { present(snapshot: InteractionSourceState, resolved: ResolvedRay | undefined): void; clear(controller: Controller): void; } interface InteractionDependencies { callbacks: InteractionCallbackDispatch; scene?: THREE.Scene; raycastMode?: RaycastMode; camera?: THREE.Camera; timer?: THREE.Timer; reticle?: ReticlePresentationObserver; reticleOptions?: ReticleOptions; longSelectDuration?: number; } //#endregion //#region src/physics/Physics.d.ts /** * Integrates the RAPIER physics engine into the XRCore lifecycle. * It sets up the physics in a blended world that combines virtual and physical * objects, steps the simulation forward in sync with the application's * framerate, and manages the lifecycle of physics-related objects. */ export declare class Physics { initialized: boolean; options?: PhysicsOptions; RAPIER: RAPIERCompat; fps: number; blendedWorld: RapierWorld; eventQueue: RapierEventQueue; get timestep(): number; /** * Asynchronously initializes the RAPIER physics engine and creates the * blendedWorld. This is called in Core before the physics simulation starts. */ init({ physicsOptions }: { physicsOptions: PhysicsOptions; }): Promise; /** * Advances the physics simulation by one step. */ physicsStep(): void; /** * Frees the memory allocated by the RAPIER physics blendedWorld and event * queue. This is crucial for preventing memory leaks when the XR session * ends. */ dispose(): void; } //#endregion //#region src/core/Script.d.ts export interface SelectEvent { readonly source: InteractionSource; readonly target?: THREE.Object3D; readonly currentTarget?: Script; /** Public hit surface. Private renderer meshes are normalized to their owner. */ readonly surface?: THREE.Object3D; /** Current ray intersection on `surface`, when the source still hits it. */ readonly intersection?: THREE.Intersection; stopPropagation(): void; } export type SelectionEndReason = 'released' | 'released-outside' | 'source-lost' | 'pointer-cancel' | 'removed' | 'hidden' | 'disabled'; export interface SelectEndEvent extends SelectEvent { readonly completed: boolean; readonly reason: SelectionEndReason; } /** Event sent after a captured selection is held past the long-select delay. */ export interface LongSelectEvent extends SelectEvent { /** How long the selection has been held, in seconds. */ duration: number; } export interface ObjectTouchEvent { readonly source: InteractionSource; readonly target: THREE.Object3D; readonly currentTarget?: Script; /** Public contact surface. Private renderer meshes are normalized to it. */ readonly surface: THREE.Object3D; readonly handIndex: number; readonly hand?: THREE.Object3D; readonly touchPosition: THREE.Vector3; stopPropagation(): void; } export interface ObjectTouchStartEvent extends ObjectTouchEvent { readonly defaultPrevented: boolean; preventDefault(): void; } export interface ObjectGrabEvent { readonly source: InteractionSource; readonly target: THREE.Object3D; readonly currentTarget?: Script; /** Public contact surface. Private renderer meshes are normalized to it. */ readonly surface: THREE.Object3D; readonly handIndex: number; readonly hand: THREE.Object3D; readonly touchPosition: THREE.Vector3; stopPropagation(): void; } export interface HoverEvent extends SelectEvent { readonly intersection?: THREE.Intersection; } export interface KeyEvent { code: string; } /** * The Script class facilities development by providing useful life cycle * functions similar to MonoBehaviors in Unity. * * Each Script object is an independent THREE.Object3D entity within the * scene graph. * * See /docs/manual/Scripts.md for the full documentation. * * It manages user, objects, and interaction between user and objects. * See `/templates/00_basic/` for an example to start with. * # Supported interaction functions to extend: * * onSelectStart(event) * onSelectEnd(event) * */ export declare function ScriptMixin>(base: TBase): { new (...args: any[]): { readonly isObject3D: true; readonly id: number; uuid: string; name: string; readonly type: string; parent: THREE.Object3D | null; children: THREE.Object3D[]; up: THREE.Vector3; readonly position: THREE.Vector3; readonly rotation: THREE.Euler; readonly quaternion: THREE.Quaternion; readonly scale: THREE.Vector3; readonly modelViewMatrix: THREE.Matrix4; readonly normalMatrix: THREE.Matrix3; matrix: THREE.Matrix4; matrixWorld: THREE.Matrix4; matrixAutoUpdate: boolean; matrixWorldAutoUpdate: boolean; matrixWorldNeedsUpdate: boolean; layers: THREE.Layers; visible: boolean; castShadow: boolean; receiveShadow: boolean; frustumCulled: boolean; renderOrder: number; animations: THREE.AnimationClip[]; isXRScript: boolean; /** * Initializes an instance with XR controllers, grips, hands, and default * options. We allow all scripts to quickly access its user (e.g., * user.isSelecting(), user.hands), world (e.g., physical depth mesh, * lighting estimation, and recognized objects), and scene (the root of * three.js's scene graph). If this returns a promise, we will wait for it. */ init(_?: object): void | Promise; /** * Runs per frame. */ update(_time?: number, _frame?: XRFrame): void; /** * Enables depth-aware interactions with physics. See /samples/advanced/ballpit */ initPhysics(_physics: Physics): void | Promise; physicsStep(): void; onXRSessionStarted(_session?: XRSession): void; onXRSessionEnded(): void; onSimulatorStarted(): void; /** * Called whenever pinch / mouse click starts, globally. * @param _event - The interaction source and optional captured target. */ onSelectStart(_event: SelectEvent): void; /** * Called whenever pinch / mouse click discontinues, globally. * @param _event - The completed state and end reason. */ onSelectEnd(_event: SelectEndEvent): void; /** * Called whenever pinch / mouse click successfully completes, globally. * @param _event - The interaction source and completed target. */ onSelect(_event: SelectEvent): void; /** * Called whenever pinch / mouse click is happening, globally. */ onSelecting(_event: SelectEvent): void; /** Called when an object selection reaches the long-select delay. */ onLongSelect(_event: LongSelectEvent): void; /** * Called on keyboard keypress. * @param _event - Event containing `.code` to read the keyboard key. */ onKeyDown(_event: KeyEvent): void; onKeyUp(_event: KeyEvent): void; /** * Called whenever gamepad trigger starts, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueezeStart(_event: SelectEvent): void; /** * Called whenever gamepad trigger stops, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueezeEnd(_event: SelectEvent): void; /** * Called whenever gamepad is being triggered, globally. */ onSqueezing(_event: SelectEvent): void; /** * Called whenever gamepad trigger successfully completes, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueeze(_event: SelectEvent): void; /** * Called when a source starts selecting the object this Script represents. * @param _event - `event.target` is the logical object and * `event.source.controller` identifies the controller. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectSelectStart(_event: SelectEvent): void; /** * Called when a source stops selecting the object this Script represents. * @param _event - The completed state and end reason. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectSelectEnd(_event: SelectEndEvent): void; /** * Called once when a captured selection is held for the long-select delay. * Manipulation captures do not emit this callback. * @param _event - The controller and completed hold duration. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectLongSelect(_event: LongSelectEvent): void; /** * Called for each phase of an automatic object manipulation. Call * `event.stopPropagation()` to stop bubbling. Calling `preventDefault()` * on a start event suppresses the automatic action. */ onObjectManipulate(_event: ManipulationEvent): void; /** * Called when a source starts hovering over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHoverEnter(_event: HoverEvent): void; /** * Called when a source stops hovering over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHoverExit(_event: HoverEvent): void; /** * Called while a source hovers over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHovering(_event: HoverEvent): void; /** * Called when a hand's index finger starts touching this object. * Direct touch starts the object's selection lifecycle by default. Call * `event.preventDefault()` to handle contact without selecting. */ onObjectTouchStart(_event: ObjectTouchStartEvent): void; /** * Called every frame that a hand's index finger is touching this object. * The object remains selected during these frames unless touch selection * was prevented when contact started. */ onObjectTouching(_event: ObjectTouchEvent): void; /** * Called when a hand's index finger stops touching this object. * This ends the default selection lifecycle after the touch callback. */ onObjectTouchEnd(_event: ObjectTouchEvent): void; /** * Called when a hand starts grabbing this object (touching + pinching). * A grab starts built-in direct-touch manipulation when enabled. */ onObjectGrabStart(_event: ObjectGrabEvent): void; /** * Called every frame a hand is grabbing this object. */ onObjectGrabbing(_event: ObjectGrabEvent): void; /** * Called when a hand stops grabbing this object. * This ends built-in direct-touch manipulation without ending contact. */ onObjectGrabEnd(_event: ObjectGrabEvent): void; /** * Called when the script is removed from the scene. Opposite of init. */ dispose(): void; addEventListener>(type: T, listener: THREE.EventListener): void; hasEventListener>(type: T, listener: THREE.EventListener): boolean; removeEventListener>(type: T, listener: THREE.EventListener): void; dispatchEvent>(event: THREE.BaseEvent & THREE.Object3DEventMap[T]): void; customDepthMaterial?: THREE.Material | undefined; customDistanceMaterial?: THREE.Material | undefined; static: boolean; userData: Record; pivot: THREE.Vector3 | null; onBeforeShadow(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, shadowCamera: THREE.Camera, geometry: THREE.BufferGeometry, depthMaterial: THREE.Material, group: THREE.Group): void; onAfterShadow(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, shadowCamera: THREE.Camera, geometry: THREE.BufferGeometry, depthMaterial: THREE.Material, group: THREE.Group): void; onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, geometry: THREE.BufferGeometry, material: THREE.Material, group: THREE.Group): void; onAfterRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, geometry: THREE.BufferGeometry, material: THREE.Material, group: THREE.Group): void; applyMatrix4(matrix: THREE.Matrix4): void; applyQuaternion(quaternion: THREE.Quaternion): /*elided*/ any; setRotationFromAxisAngle(axis: THREE.Vector3, angle: number): void; setRotationFromEuler(euler: THREE.Euler): void; setRotationFromMatrix(m: THREE.Matrix4): void; setRotationFromQuaternion(q: THREE.Quaternion): void; rotateOnAxis(axis: THREE.Vector3, angle: number): /*elided*/ any; rotateOnWorldAxis(axis: THREE.Vector3, angle: number): /*elided*/ any; rotateX(angle: number): /*elided*/ any; rotateY(angle: number): /*elided*/ any; rotateZ(angle: number): /*elided*/ any; translateOnAxis(axis: THREE.Vector3, distance: number): /*elided*/ any; translateX(distance: number): /*elided*/ any; translateY(distance: number): /*elided*/ any; translateZ(distance: number): /*elided*/ any; localToWorld(vector: THREE.Vector3): THREE.Vector3; worldToLocal(vector: THREE.Vector3): THREE.Vector3; lookAt(vector: THREE.Vector3): void; lookAt(x: number, y: number, z: number): void; add(...object: THREE.Object3D[]): /*elided*/ any; remove(...object: THREE.Object3D[]): /*elided*/ any; removeFromParent(): /*elided*/ any; clear(): /*elided*/ any; attach(object: THREE.Object3D): /*elided*/ any; getObjectById(id: number): THREE.Object3D | undefined; getObjectByName(name: string): THREE.Object3D | undefined; getObjectByProperty(name: string, value: any): THREE.Object3D | undefined; getObjectsByProperty(name: string, value: any, optionalTarget?: THREE.Object3D[]): THREE.Object3D[]; getWorldPosition(target: THREE.Vector3): THREE.Vector3; getWorldQuaternion(target: THREE.Quaternion): THREE.Quaternion; getWorldScale(target: THREE.Vector3): THREE.Vector3; getWorldDirection(target: THREE.Vector3): THREE.Vector3; raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void; intersectsFrustum(frustum: THREE.Frustum | THREE.FrustumArray): boolean | undefined; traverse(callback: (object: THREE.Object3D) => any): void; traverseVisible(callback: (object: THREE.Object3D) => any): void; traverseAncestors(callback: (object: THREE.Object3D) => any): void; updateMatrix(): void; updateMatrixWorld(force?: boolean): void; updateWorldMatrix(updateParents: boolean, updateChildren: boolean, force?: boolean): void; toJSON(meta?: THREE.JSONMeta): THREE.Object3DJSON; clone(recursive?: boolean): /*elided*/ any; copy(object: THREE.Object3D, recursive?: boolean): /*elided*/ any; count?: number | undefined; occlusionTest?: boolean | undefined; xb?: XBObjectOptions; spherecast?(sphere: THREE.Sphere, intersects: Array): void; intersectChildren?: boolean; interactableDescendants?: Array; ancestorsHaveListeners?: boolean; defaultPointerEvents?: PointerEventsProperties['pointerEvents']; pointerEvents?: 'none' | 'auto' | 'listener'; pointerEventsType?: AllowedPointerEventsType; pointerEventsOrder?: number; }; } & TBase; /** * Script manages app logic or interaction between user and objects. */ declare const ScriptMixinObject3D: { new (...args: any[]): { readonly isObject3D: true; readonly id: number; uuid: string; name: string; readonly type: string; parent: THREE.Object3D | null; children: THREE.Object3D[]; up: THREE.Vector3; readonly position: THREE.Vector3; readonly rotation: THREE.Euler; readonly quaternion: THREE.Quaternion; readonly scale: THREE.Vector3; readonly modelViewMatrix: THREE.Matrix4; readonly normalMatrix: THREE.Matrix3; matrix: THREE.Matrix4; matrixWorld: THREE.Matrix4; matrixAutoUpdate: boolean; matrixWorldAutoUpdate: boolean; matrixWorldNeedsUpdate: boolean; layers: THREE.Layers; visible: boolean; castShadow: boolean; receiveShadow: boolean; frustumCulled: boolean; renderOrder: number; animations: THREE.AnimationClip[]; isXRScript: boolean; /** * Initializes an instance with XR controllers, grips, hands, and default * options. We allow all scripts to quickly access its user (e.g., * user.isSelecting(), user.hands), world (e.g., physical depth mesh, * lighting estimation, and recognized objects), and scene (the root of * three.js's scene graph). If this returns a promise, we will wait for it. */ init(_?: object): void | Promise; /** * Runs per frame. */ update(_time?: number, _frame?: XRFrame): void; /** * Enables depth-aware interactions with physics. See /samples/advanced/ballpit */ initPhysics(_physics: Physics): void | Promise; physicsStep(): void; onXRSessionStarted(_session?: XRSession): void; onXRSessionEnded(): void; onSimulatorStarted(): void; /** * Called whenever pinch / mouse click starts, globally. * @param _event - The interaction source and optional captured target. */ onSelectStart(_event: SelectEvent): void; /** * Called whenever pinch / mouse click discontinues, globally. * @param _event - The completed state and end reason. */ onSelectEnd(_event: SelectEndEvent): void; /** * Called whenever pinch / mouse click successfully completes, globally. * @param _event - The interaction source and completed target. */ onSelect(_event: SelectEvent): void; /** * Called whenever pinch / mouse click is happening, globally. */ onSelecting(_event: SelectEvent): void; /** Called when an object selection reaches the long-select delay. */ onLongSelect(_event: LongSelectEvent): void; /** * Called on keyboard keypress. * @param _event - Event containing `.code` to read the keyboard key. */ onKeyDown(_event: KeyEvent): void; onKeyUp(_event: KeyEvent): void; /** * Called whenever gamepad trigger starts, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueezeStart(_event: SelectEvent): void; /** * Called whenever gamepad trigger stops, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueezeEnd(_event: SelectEvent): void; /** * Called whenever gamepad is being triggered, globally. */ onSqueezing(_event: SelectEvent): void; /** * Called whenever gamepad trigger successfully completes, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueeze(_event: SelectEvent): void; /** * Called when a source starts selecting the object this Script represents. * @param _event - `event.target` is the logical object and * `event.source.controller` identifies the controller. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectSelectStart(_event: SelectEvent): void; /** * Called when a source stops selecting the object this Script represents. * @param _event - The completed state and end reason. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectSelectEnd(_event: SelectEndEvent): void; /** * Called once when a captured selection is held for the long-select delay. * Manipulation captures do not emit this callback. * @param _event - The controller and completed hold duration. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectLongSelect(_event: LongSelectEvent): void; /** * Called for each phase of an automatic object manipulation. Call * `event.stopPropagation()` to stop bubbling. Calling `preventDefault()` * on a start event suppresses the automatic action. */ onObjectManipulate(_event: ManipulationEvent): void; /** * Called when a source starts hovering over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHoverEnter(_event: HoverEvent): void; /** * Called when a source stops hovering over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHoverExit(_event: HoverEvent): void; /** * Called while a source hovers over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHovering(_event: HoverEvent): void; /** * Called when a hand's index finger starts touching this object. * Direct touch starts the object's selection lifecycle by default. Call * `event.preventDefault()` to handle contact without selecting. */ onObjectTouchStart(_event: ObjectTouchStartEvent): void; /** * Called every frame that a hand's index finger is touching this object. * The object remains selected during these frames unless touch selection * was prevented when contact started. */ onObjectTouching(_event: ObjectTouchEvent): void; /** * Called when a hand's index finger stops touching this object. * This ends the default selection lifecycle after the touch callback. */ onObjectTouchEnd(_event: ObjectTouchEvent): void; /** * Called when a hand starts grabbing this object (touching + pinching). * A grab starts built-in direct-touch manipulation when enabled. */ onObjectGrabStart(_event: ObjectGrabEvent): void; /** * Called every frame a hand is grabbing this object. */ onObjectGrabbing(_event: ObjectGrabEvent): void; /** * Called when a hand stops grabbing this object. * This ends built-in direct-touch manipulation without ending contact. */ onObjectGrabEnd(_event: ObjectGrabEvent): void; /** * Called when the script is removed from the scene. Opposite of init. */ dispose(): void; addEventListener>(type: T, listener: THREE.EventListener): void; hasEventListener>(type: T, listener: THREE.EventListener): boolean; removeEventListener>(type: T, listener: THREE.EventListener): void; dispatchEvent>(event: THREE.BaseEvent & THREE.Object3DEventMap[T]): void; customDepthMaterial?: THREE.Material | undefined; customDistanceMaterial?: THREE.Material | undefined; static: boolean; userData: Record; pivot: THREE.Vector3 | null; onBeforeShadow(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, shadowCamera: THREE.Camera, geometry: THREE.BufferGeometry, depthMaterial: THREE.Material, group: THREE.Group): void; onAfterShadow(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, shadowCamera: THREE.Camera, geometry: THREE.BufferGeometry, depthMaterial: THREE.Material, group: THREE.Group): void; onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, geometry: THREE.BufferGeometry, material: THREE.Material, group: THREE.Group): void; onAfterRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, geometry: THREE.BufferGeometry, material: THREE.Material, group: THREE.Group): void; applyMatrix4(matrix: THREE.Matrix4): void; applyQuaternion(quaternion: THREE.Quaternion): /*elided*/ any; setRotationFromAxisAngle(axis: THREE.Vector3, angle: number): void; setRotationFromEuler(euler: THREE.Euler): void; setRotationFromMatrix(m: THREE.Matrix4): void; setRotationFromQuaternion(q: THREE.Quaternion): void; rotateOnAxis(axis: THREE.Vector3, angle: number): /*elided*/ any; rotateOnWorldAxis(axis: THREE.Vector3, angle: number): /*elided*/ any; rotateX(angle: number): /*elided*/ any; rotateY(angle: number): /*elided*/ any; rotateZ(angle: number): /*elided*/ any; translateOnAxis(axis: THREE.Vector3, distance: number): /*elided*/ any; translateX(distance: number): /*elided*/ any; translateY(distance: number): /*elided*/ any; translateZ(distance: number): /*elided*/ any; localToWorld(vector: THREE.Vector3): THREE.Vector3; worldToLocal(vector: THREE.Vector3): THREE.Vector3; lookAt(vector: THREE.Vector3): void; lookAt(x: number, y: number, z: number): void; add(...object: THREE.Object3D[]): /*elided*/ any; remove(...object: THREE.Object3D[]): /*elided*/ any; removeFromParent(): /*elided*/ any; clear(): /*elided*/ any; attach(object: THREE.Object3D): /*elided*/ any; getObjectById(id: number): THREE.Object3D | undefined; getObjectByName(name: string): THREE.Object3D | undefined; getObjectByProperty(name: string, value: any): THREE.Object3D | undefined; getObjectsByProperty(name: string, value: any, optionalTarget?: THREE.Object3D[]): THREE.Object3D[]; getWorldPosition(target: THREE.Vector3): THREE.Vector3; getWorldQuaternion(target: THREE.Quaternion): THREE.Quaternion; getWorldScale(target: THREE.Vector3): THREE.Vector3; getWorldDirection(target: THREE.Vector3): THREE.Vector3; raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void; intersectsFrustum(frustum: THREE.Frustum | THREE.FrustumArray): boolean | undefined; traverse(callback: (object: THREE.Object3D) => any): void; traverseVisible(callback: (object: THREE.Object3D) => any): void; traverseAncestors(callback: (object: THREE.Object3D) => any): void; updateMatrix(): void; updateMatrixWorld(force?: boolean): void; updateWorldMatrix(updateParents: boolean, updateChildren: boolean, force?: boolean): void; toJSON(meta?: THREE.JSONMeta): THREE.Object3DJSON; clone(recursive?: boolean): /*elided*/ any; copy(object: THREE.Object3D, recursive?: boolean): /*elided*/ any; count?: number | undefined; occlusionTest?: boolean | undefined; xb?: XBObjectOptions; spherecast?(sphere: THREE.Sphere, intersects: Array): void; intersectChildren?: boolean; interactableDescendants?: Array; ancestorsHaveListeners?: boolean; defaultPointerEvents?: PointerEventsProperties['pointerEvents']; pointerEvents?: 'none' | 'auto' | 'listener'; pointerEventsType?: AllowedPointerEventsType; pointerEventsOrder?: number; }; } & typeof THREE.Object3D; export declare class Script extends ScriptMixinObject3D {} /** * MeshScript can be constructed with geometry and materials, with * `super(geometry, material)`; for direct access to its geometry. * MeshScripts hold geometry and materials while using the Script lifecycle. */ declare const ScriptMixinMeshScript: { new (...args: any[]): { readonly isObject3D: true; readonly id: number; uuid: string; name: string; readonly type: string; parent: THREE.Object3D | null; children: THREE.Object3D[]; up: THREE.Vector3; readonly position: THREE.Vector3; readonly rotation: THREE.Euler; readonly quaternion: THREE.Quaternion; readonly scale: THREE.Vector3; readonly modelViewMatrix: THREE.Matrix4; readonly normalMatrix: THREE.Matrix3; matrix: THREE.Matrix4; matrixWorld: THREE.Matrix4; matrixAutoUpdate: boolean; matrixWorldAutoUpdate: boolean; matrixWorldNeedsUpdate: boolean; layers: THREE.Layers; visible: boolean; castShadow: boolean; receiveShadow: boolean; frustumCulled: boolean; renderOrder: number; animations: THREE.AnimationClip[]; isXRScript: boolean; /** * Initializes an instance with XR controllers, grips, hands, and default * options. We allow all scripts to quickly access its user (e.g., * user.isSelecting(), user.hands), world (e.g., physical depth mesh, * lighting estimation, and recognized objects), and scene (the root of * three.js's scene graph). If this returns a promise, we will wait for it. */ init(_?: object): void | Promise; /** * Runs per frame. */ update(_time?: number, _frame?: XRFrame): void; /** * Enables depth-aware interactions with physics. See /samples/advanced/ballpit */ initPhysics(_physics: Physics): void | Promise; physicsStep(): void; onXRSessionStarted(_session?: XRSession): void; onXRSessionEnded(): void; onSimulatorStarted(): void; /** * Called whenever pinch / mouse click starts, globally. * @param _event - The interaction source and optional captured target. */ onSelectStart(_event: SelectEvent): void; /** * Called whenever pinch / mouse click discontinues, globally. * @param _event - The completed state and end reason. */ onSelectEnd(_event: SelectEndEvent): void; /** * Called whenever pinch / mouse click successfully completes, globally. * @param _event - The interaction source and completed target. */ onSelect(_event: SelectEvent): void; /** * Called whenever pinch / mouse click is happening, globally. */ onSelecting(_event: SelectEvent): void; /** Called when an object selection reaches the long-select delay. */ onLongSelect(_event: LongSelectEvent): void; /** * Called on keyboard keypress. * @param _event - Event containing `.code` to read the keyboard key. */ onKeyDown(_event: KeyEvent): void; onKeyUp(_event: KeyEvent): void; /** * Called whenever gamepad trigger starts, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueezeStart(_event: SelectEvent): void; /** * Called whenever gamepad trigger stops, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueezeEnd(_event: SelectEvent): void; /** * Called whenever gamepad is being triggered, globally. */ onSqueezing(_event: SelectEvent): void; /** * Called whenever gamepad trigger successfully completes, globally. * @param _event - `event.source.controller` identifies the controller. */ onSqueeze(_event: SelectEvent): void; /** * Called when a source starts selecting the object this Script represents. * @param _event - `event.target` is the logical object and * `event.source.controller` identifies the controller. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectSelectStart(_event: SelectEvent): void; /** * Called when a source stops selecting the object this Script represents. * @param _event - The completed state and end reason. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectSelectEnd(_event: SelectEndEvent): void; /** * Called once when a captured selection is held for the long-select delay. * Manipulation captures do not emit this callback. * @param _event - The controller and completed hold duration. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onObjectLongSelect(_event: LongSelectEvent): void; /** * Called for each phase of an automatic object manipulation. Call * `event.stopPropagation()` to stop bubbling. Calling `preventDefault()` * on a start event suppresses the automatic action. */ onObjectManipulate(_event: ManipulationEvent): void; /** * Called when a source starts hovering over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHoverEnter(_event: HoverEvent): void; /** * Called when a source stops hovering over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHoverExit(_event: HoverEvent): void; /** * Called while a source hovers over this object. * @param _event - The hover source, target, surface, and intersection. * Call `event.stopPropagation()` to stop bubbling to ancestor Scripts. */ onHovering(_event: HoverEvent): void; /** * Called when a hand's index finger starts touching this object. * Direct touch starts the object's selection lifecycle by default. Call * `event.preventDefault()` to handle contact without selecting. */ onObjectTouchStart(_event: ObjectTouchStartEvent): void; /** * Called every frame that a hand's index finger is touching this object. * The object remains selected during these frames unless touch selection * was prevented when contact started. */ onObjectTouching(_event: ObjectTouchEvent): void; /** * Called when a hand's index finger stops touching this object. * This ends the default selection lifecycle after the touch callback. */ onObjectTouchEnd(_event: ObjectTouchEvent): void; /** * Called when a hand starts grabbing this object (touching + pinching). * A grab starts built-in direct-touch manipulation when enabled. */ onObjectGrabStart(_event: ObjectGrabEvent): void; /** * Called every frame a hand is grabbing this object. */ onObjectGrabbing(_event: ObjectGrabEvent): void; /** * Called when a hand stops grabbing this object. * This ends built-in direct-touch manipulation without ending contact. */ onObjectGrabEnd(_event: ObjectGrabEvent): void; /** * Called when the script is removed from the scene. Opposite of init. */ dispose(): void; addEventListener>(type: T, listener: THREE.EventListener): void; hasEventListener>(type: T, listener: THREE.EventListener): boolean; removeEventListener>(type: T, listener: THREE.EventListener): void; dispatchEvent>(event: THREE.BaseEvent & THREE.Object3DEventMap[T]): void; customDepthMaterial?: THREE.Material | undefined; customDistanceMaterial?: THREE.Material | undefined; static: boolean; userData: Record; pivot: THREE.Vector3 | null; onBeforeShadow(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, shadowCamera: THREE.Camera, geometry: THREE.BufferGeometry, depthMaterial: THREE.Material, group: THREE.Group): void; onAfterShadow(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, shadowCamera: THREE.Camera, geometry: THREE.BufferGeometry, depthMaterial: THREE.Material, group: THREE.Group): void; onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, geometry: THREE.BufferGeometry, material: THREE.Material, group: THREE.Group): void; onAfterRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, geometry: THREE.BufferGeometry, material: THREE.Material, group: THREE.Group): void; applyMatrix4(matrix: THREE.Matrix4): void; applyQuaternion(quaternion: THREE.Quaternion): /*elided*/ any; setRotationFromAxisAngle(axis: THREE.Vector3, angle: number): void; setRotationFromEuler(euler: THREE.Euler): void; setRotationFromMatrix(m: THREE.Matrix4): void; setRotationFromQuaternion(q: THREE.Quaternion): void; rotateOnAxis(axis: THREE.Vector3, angle: number): /*elided*/ any; rotateOnWorldAxis(axis: THREE.Vector3, angle: number): /*elided*/ any; rotateX(angle: number): /*elided*/ any; rotateY(angle: number): /*elided*/ any; rotateZ(angle: number): /*elided*/ any; translateOnAxis(axis: THREE.Vector3, distance: number): /*elided*/ any; translateX(distance: number): /*elided*/ any; translateY(distance: number): /*elided*/ any; translateZ(distance: number): /*elided*/ any; localToWorld(vector: THREE.Vector3): THREE.Vector3; worldToLocal(vector: THREE.Vector3): THREE.Vector3; lookAt(vector: THREE.Vector3): void; lookAt(x: number, y: number, z: number): void; add(...object: THREE.Object3D[]): /*elided*/ any; remove(...object: THREE.Object3D[]): /*elided*/ any; removeFromParent(): /*elided*/ any; clear(): /*elided*/ any; attach(object: THREE.Object3D): /*elided*/ any; getObjectById(id: number): THREE.Object3D | undefined; getObjectByName(name: string): THREE.Object3D | undefined; getObjectByProperty(name: string, value: any): THREE.Object3D | undefined; getObjectsByProperty(name: string, value: any, optionalTarget?: THREE.Object3D[]): THREE.Object3D[]; getWorldPosition(target: THREE.Vector3): THREE.Vector3; getWorldQuaternion(target: THREE.Quaternion): THREE.Quaternion; getWorldScale(target: THREE.Vector3): THREE.Vector3; getWorldDirection(target: THREE.Vector3): THREE.Vector3; raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void; intersectsFrustum(frustum: THREE.Frustum | THREE.FrustumArray): boolean | undefined; traverse(callback: (object: THREE.Object3D) => any): void; traverseVisible(callback: (object: THREE.Object3D) => any): void; traverseAncestors(callback: (object: THREE.Object3D) => any): void; updateMatrix(): void; updateMatrixWorld(force?: boolean): void; updateWorldMatrix(updateParents: boolean, updateChildren: boolean, force?: boolean): void; toJSON(meta?: THREE.JSONMeta): THREE.Object3DJSON; clone(recursive?: boolean): /*elided*/ any; copy(object: THREE.Object3D, recursive?: boolean): /*elided*/ any; count?: number | undefined; occlusionTest?: boolean | undefined; xb?: XBObjectOptions; spherecast?(sphere: THREE.Sphere, intersects: Array): void; intersectChildren?: boolean; interactableDescendants?: Array; ancestorsHaveListeners?: boolean; defaultPointerEvents?: PointerEventsProperties['pointerEvents']; pointerEvents?: 'none' | 'auto' | 'listener'; pointerEventsType?: AllowedPointerEventsType; pointerEventsOrder?: number; }; } & typeof THREE.Mesh; export declare class MeshScript extends ScriptMixinMeshScript { /** * {@inheritDoc} */ constructor(geometry?: TGeometry, material?: TMaterial); } //#endregion //#region src/agent/Tool.d.ts export interface ToolCall { name: string; args: unknown; } /** * Standardized result type for tool execution. * @typeParam T - The type of data returned on success. */ export interface ToolResult { /** Whether the tool execution succeeded */ success: boolean; /** The result data if successful */ data?: T; /** Error message if execution failed */ error?: string; /** Additional metadata about the execution */ metadata?: Record; } export type ToolSchema = Omit & { properties?: Record; items?: ToolSchema; type?: keyof typeof GoogleGenAITypes.Type; }; export type ToolOptions = { /** The name of the tool. */ name: string; /** A description of what the tool does. */ description: string; /** The parameters of the tool */ parameters?: ToolSchema; /** A callback to execute when the tool is triggered */ onTriggered?: (args: unknown) => unknown | Promise; behavior?: 'BLOCKING' | 'NON_BLOCKING' | GoogleGenAITypes.Behavior; }; /** * A base class for tools that the agent can use. */ export declare class Tool { name: string; description?: string; parameters?: ToolSchema; onTriggered?: (args: unknown) => unknown; behavior?: 'BLOCKING' | 'NON_BLOCKING'; /** * @param options - The options for the tool. */ constructor(options: ToolOptions); /** * Executes the tool's action with standardized error handling. * @param args - The arguments for the tool. * @returns A promise that resolves with a ToolResult containing success/error information. */ execute(args: unknown): Promise; /** * Returns a JSON representation of the tool. * @returns A valid FunctionDeclaration object. */ toJSON(): GoogleGenAITypes.FunctionDeclaration; /** * Returns the function tool shape for the non-live Interactions API (a * `tools` entry on a query). `behavior` is a Live API concept and has no * Interactions equivalent. * @returns A valid Interactions function tool. */ toInteractions(): GoogleGenAITypes.Interactions.Function; } //#endregion //#region src/ai/AITypes.d.ts interface GeminiResponse { toolCall?: ToolCall; text?: string | null; } //#endregion //#region src/ai/BaseAIModel.d.ts declare abstract class BaseAIModel { constructor(); abstract init(): Promise; abstract isAvailable(): boolean; abstract query(_input: object, _tools: []): Promise; hasApiKey(): Promise; } //#endregion //#region src/ai/Gemini.d.ts export interface GeminiQueryInput { type: 'live' | 'text' | 'uri' | 'base64' | 'multiPart'; action?: 'start' | 'stop' | 'send'; text?: string; uri?: string; base64?: string; mimeType?: string; parts?: GoogleGenAITypes.Part[]; config?: GoogleGenAITypes.LiveConnectConfig; data?: GoogleGenAITypes.LiveSendRealtimeInputParameters; useExponentialBackoff?: boolean; } export declare class Gemini extends BaseAIModel { protected options: GeminiOptions; inited: boolean; liveSession?: GoogleGenAITypes.Session; isLiveMode: boolean; liveCallbacks: Partial; ai?: GoogleGenAITypes.GoogleGenAI; private liveSessionPromise?; private liveSessionGeneration; private liveSessionStopped; constructor(options: GeminiOptions); init(): Promise; isAvailable(): boolean; isLiveAvailable(): false | typeof GoogleGenAITypes.Modality | undefined; /** * Shares a pending connection between concurrent starts. Stopping or disposing * invalidates that start; any session returned later is closed and the start * rejects with AbortError. The provider cannot be aborted before it returns. */ startLiveSession(params?: GoogleGenAITypes.LiveConnectConfig, model?: string): Promise; stopLiveSession(): Promise; /** Invalidates live work synchronously without creating a teardown promise. */ dispose(): void; private closeLiveSession; setLiveCallbacks(callbacks: GoogleGenAITypes.LiveCallbacks): void; sendToolResponse(response: GoogleGenAITypes.LiveSendToolResponseParameters): void; sendRealtimeInput(input: GoogleGenAITypes.LiveSendRealtimeInputParameters): void; getLiveSessionStatus(): { isActive: boolean; hasSession: boolean; isAvailable: boolean | typeof GoogleGenAITypes.Modality | undefined; }; query(input: GeminiQueryInput | { prompt: string; }): Promise; protected queryOnce(input: GeminiQueryInput | { prompt: string; }): Promise; protected queryWithExponentialFalloff(input: GeminiQueryInput | { prompt: string; }): Promise; generate(prompt: string | string[], type?: 'image', systemInstruction?: string, model?: string): Promise; hasApiKey(): Promise; } //#endregion //#region src/ai/OpenAI.d.ts export declare class OpenAI extends BaseAIModel { protected options: OpenAIOptions; openai?: OpenAIType; constructor(options: OpenAIOptions); init(): Promise; isAvailable(): boolean; query(input: { prompt: string; }, _tools?: never[]): Promise<{ text: string; } | null>; generate(): Promise; } //#endregion //#region src/ai/AI.d.ts export type ModelClass = Gemini | OpenAI; export type ModelOptions = GeminiOptions | OpenAIOptions; export type KeysJson = { gemini?: { apiKey?: string; }; openai?: { apiKey?: string; }; }; /** * AI Interface to wrap different AI models (primarily Gemini) * Handles both traditional query-based AI interactions and real-time live * sessions * * Features: * - Text and multimodal queries * - Real-time audio/video AI sessions (Gemini Live) * - Advanced API key management with multiple sources * - Session locking to prevent concurrent operations * * The URL param and key.json shortcut is only for demonstration and prototyping * practice and we strongly suggest not using it for production or deployment * purposes. One should set up a proper server to converse with AI servers in * deployment. * * API Key Management Features: * * 1. Multiple Key Sources (Priority Order): * - Model option * - Generic and model-specific URL parameters * - Current-page memory * - keys.json file * 2. keys.json Support: * - Structure: \{"gemini": \{"apiKey": "YOUR_KEY_HERE"\}\} * - Automatically loads if present */ export declare class AI extends Script { static dependencies: { aiOptions: typeof AIOptions; }; editorIcon: string; model?: ModelClass; lock: boolean; options: AIOptions; keysCache?: KeysJson; /** * Load API keys from keys.json file if available * Parsed keys object or null if not found */ loadKeysFromFile(): Promise; init({ aiOptions }: { aiOptions: AIOptions; }): Promise; initializeModel(ModelClass: typeof Gemini | typeof OpenAI, modelOptions: ModelOptions): Promise; resolveApiKey(modelOptions: ModelOptions): Promise; private resolveApiKeyWithSource; private getUrlApiKey; isValidApiKey(key: string): "" | boolean; isAvailable(): boolean | undefined; query(input: GeminiQueryInput | { prompt: string; }, tools?: never[]): Promise; /** * Concurrent starts share a connection. A start invalidated by stop or dispose * rejects with AbortError when the provider returns, closing that late session. */ startLiveSession(config?: GoogleGenAITypes.LiveConnectConfig, model?: string): Promise; /** * Invalidates pending live work and closes any established session. This does * not wait for an in-flight provider connection to finish. */ stopLiveSession(): Promise; /** Closes live resources synchronously for the Script disposal contract. */ dispose(): void; setLiveCallbacks(callbacks: GoogleGenAITypes.LiveCallbacks): Promise; sendToolResponse(response: GoogleGenAITypes.LiveSendToolResponseParameters): void; sendRealtimeInput(input: GoogleGenAITypes.LiveSendRealtimeInputParameters): void | false; getLiveSessionStatus(): { isActive: boolean; hasSession: boolean; isAvailable: boolean | typeof GoogleGenAITypes.Modality | undefined; }; isLiveAvailable(): false | typeof GoogleGenAITypes.Modality | undefined; generate(prompt: string | string[], type?: 'image', systemInstruction?: string, model?: string): Promise; /** * Create a sample keys.json file structure for reference * @returns Sample keys.json structure */ static createSampleKeysStructure(): { gemini: { apiKey: string; }; openai: { apiKey: string; }; }; /** * Check if the current model has an API key available from any source * @returns True if API key is available */ hasApiKey(): Promise<"" | boolean | null>; } //#endregion //#region src/agent/Memory.d.ts interface MemoryEntry { role: 'user' | 'ai' | 'tool'; content: string; } /** * Manages the agent's memory, including short-term, long-term, and working * memory. */ declare class Memory { private shortTermMemory; /** * Adds a new entry to the short-term memory. * @param entry - The memory entry to add. */ addShortTerm(entry: MemoryEntry): void; /** * Retrieves the short-term memory. * @returns An array of all short-term memory entries. */ getShortTerm(): MemoryEntry[]; /** * Clears all memory components. */ clear(): void; } //#endregion //#region src/agent/Context.d.ts /** * Builds the context to be sent to the AI for reasoning. */ declare class Context$1 { private instructions; constructor(instructions?: string); get instruction(): string; /** * Constructs a formatted prompt from memory and available tools. * @param memory - The agent's memory. * @param tools - The list of available tools. * @returns A string representing the full context for the AI. */ build(memory: Memory, tools: Tool[]): string; private formatEntry; } //#endregion //#region src/agent/Agent.d.ts /** * Lifecycle callbacks for agent events. */ export interface AgentLifecycleCallbacks { /** Called when a session starts */ onSessionStart?: () => void | Promise; /** Called when a session ends */ onSessionEnd?: () => void | Promise; /** Called after a tool is executed */ onToolExecuted?: (toolName: string, result: unknown) => void; /** Called when an error occurs */ onError?: (error: Error) => void; } /** * An agent that can use an AI to reason and execute tools. */ export declare class Agent { static dependencies: {}; ai: AI; tools: Tool[]; memory: Memory; contextBuilder: Context$1; lifecycleCallbacks?: AgentLifecycleCallbacks; isSessionActive: boolean; constructor(ai: AI, tools?: Tool[], instruction?: string, callbacks?: AgentLifecycleCallbacks); /** * Starts the agent's reasoning loop with an initial prompt. * @param prompt - The initial prompt from the user. * @returns The final text response from the agent. */ start(prompt: string): Promise; /** * The main reasoning and action loop of the agent for non-live mode. * It repeatedly builds context, queries the AI, and executes tools * until a final text response is generated. */ private run; findTool(name: string): Tool | undefined; /** * Get the current session state. * @returns Object containing session information */ getSessionState(): { isActive: boolean; toolCount: number; memorySize: number; }; } //#endregion //#region src/core/components/Registry.d.ts export declare class Registry { private instances; /** * Registers an new instanceof a given type. * If an existing instance of the same type is already registered, it will be * overwritten. * @param instance - The instance to register. * @param type - Type to register the instance as. Will default to * `instance.constructor` if not defined. */ register(instance: T, type?: Constructor): void; /** * Gets an existing instance of a registered type. * @param type - The constructor function of the type to retrieve. * @returns The instance of the requested type. */ get(type: Constructor): T | undefined; /** * Gets an existing instance of a registered type, or creates a new one if it * doesn't exist. * @param type - The constructor function of the type to retrieve. * @param factory - A function that creates a new instance of the type if it * doesn't already exist. * @returns The instance of the requested type. */ getOrCreate(type: Constructor, factory: () => T): T; /** * Unregisters an instance of a given type. * @param type - The type to unregister. */ unregister(type: Constructor): void; } //#endregion //#region src/sound/AudioListener.d.ts export interface AudioListenerOptions { sampleRate?: number; channelCount?: number; echoCancellation?: boolean; noiseSuppression?: boolean; autoGainControl?: boolean; } export declare class AudioListener extends Script { static dependencies: { registry: typeof Registry; }; private options; private audioStream?; audioContext?: AudioContext; private sourceNode?; private processorNode?; private isCapturing; private latestAudioBuffer; private accumulatedChunks; private isAccumulating; private registry; aiService?: AI; private onAudioData?; private onError?; constructor(options?: AudioListenerOptions); /** * Init the AudioListener. */ init({ registry }: { registry: Registry; }): void; startCapture(callbacks?: { onAudioData?: (audioBuffer: ArrayBuffer) => void; onError?: (error: Error) => void; accumulate?: boolean; }): Promise; stopCapture(): void; setupAudioCapture(): Promise; private setupAudioWorklet; streamToAI(audioBuffer: ArrayBuffer): void; setAIStreaming(enabled: boolean): void; cleanup(): void; static isSupported(): boolean; getIsCapturing(): boolean; getLatestAudioBuffer(): ArrayBuffer | null; clearLatestAudioBuffer(): void; /** * Gets all accumulated audio chunks as a single combined buffer */ getAccumulatedBuffer(): ArrayBuffer | null; /** * Clears accumulated chunks */ clearAccumulatedBuffer(): void; /** * Gets the number of accumulated chunks */ getAccumulatedChunkCount(): number; dispose(): void; } //#endregion //#region src/sound/CategoryVolumes.d.ts export declare enum VolumeCategory { music = "music", sfx = "sfx", speech = "speech", ui = "ui" } export declare class CategoryVolumes { isMuted: boolean; masterVolume: number; volumes: Record; getCategoryVolume(category: string): number; getEffectiveVolume(category: string, specificVolume?: number): number; } //#endregion //#region src/sound/AudioPlayer.d.ts export interface AudioPlayerOptions { sampleRate?: number; channelCount?: number; category?: string; } export declare class AudioPlayer extends Script { private options; private audioContext?; private audioQueue; private nextStartTime; private gainNode?; private categoryVolumes?; private volume; private category; scheduleAheadTime: number; constructor(options?: AudioPlayerOptions); /** * Sets the CategoryVolumes instance for this player to respect * master/category volumes */ setCategoryVolumes(categoryVolumes: CategoryVolumes): void; /** * Sets the specific volume for this player (0.0 to 1.0) */ setVolume(level: number): void; /** * Updates the gain node volume based on category volumes * Public so CoreSound can update it when master volume changes */ updateGainNodeVolume(): void; initializeAudioContext(): Promise; playAudioChunk(base64AudioData: string): Promise; private scheduleAudioBuffers; clearQueue(): void; getIsPlaying(): boolean; getQueueLength(): number; base64ToArrayBuffer(base64: string): ArrayBuffer; stop(): void; static isSupported(): boolean; dispose(): void; } //#endregion //#region src/sound/BackgroundMusic.d.ts declare const musicLibrary: { readonly ambient: string; readonly background: string; readonly buttonHover: string; readonly buttonPress: string; readonly menuDismiss: string; }; declare class BackgroundMusic extends Script { private listener; private categoryVolumes; private audioLoader; private currentAudio; private isPlaying; private musicLibrary; private specificVolume; private musicCategory; constructor(listener: THREE.AudioListener, categoryVolumes: CategoryVolumes); setVolume(level: number): void; playMusic(musicKey: keyof typeof musicLibrary, category?: string): void; stopMusic(): void; destroy(): void; } //#endregion //#region src/sound/SoundSynthesizer.d.ts /** * Defines common UI sound presets with their default parameters. * Each preset specifies frequency, duration, and waveform type. */ export declare const SOUND_PRESETS: { readonly BEEP: { readonly frequency: 1000; readonly duration: 0.07; readonly waveformType: 'sine'; }; readonly CLICK: readonly [{ readonly frequency: 1500; readonly duration: 0.02; readonly waveformType: 'triangle'; readonly delay: 0; }]; readonly ACTIVATE: readonly [{ readonly frequency: 800; readonly duration: 0.05; readonly waveformType: 'sine'; readonly delay: 0; }, { readonly frequency: 1200; readonly duration: 0.07; readonly waveformType: 'sine'; readonly delay: 50; }]; readonly DEACTIVATE: readonly [{ readonly frequency: 1200; readonly duration: 0.05; readonly waveformType: 'sine'; readonly delay: 0; }, { readonly frequency: 800; readonly duration: 0.07; readonly waveformType: 'sine'; readonly delay: 50; }]; }; export declare class SoundSynthesizer extends Script { audioContext?: AudioContext; isInitialized: boolean; debug: boolean; /** * Initializes the AudioContext. */ private _initAudioContext; /** * Plays a single tone with specified parameters. * @param frequency - The frequency of the tone in Hz. * @param duration - The duration of the tone in seconds. * @param volume - The volume of the tone (0.0 to 1.0). * @param waveformType - The type of waveform ('sine', 'square', 'sawtooth', * 'triangle'). */ playTone(frequency: number, duration: number, volume: number, waveformType: OscillatorType): void; /** * Plays a predefined sound preset. * @param presetName - The name of the preset (e.g., 'BEEP', 'CLICK', * 'ACTIVATE', 'DEACTIVATE'). * @param volume - The volume for the preset (overrides default * if present, otherwise uses this). */ playPresetTone(presetName: keyof typeof SOUND_PRESETS, volume?: number): void; } //#endregion //#region src/sound/SpatialAudio.d.ts declare const spatialSoundLibrary: { readonly ambient: 'musicLibrary/AmbientLoop.opus'; readonly buttonHover: 'musicLibrary/ButtonHover.opus'; readonly paintOneShot1: 'musicLibrary/PaintOneShot1.opus'; }; export interface PlaySoundOptions { loop?: boolean; volume?: number; refDistance?: number; rolloffFactor?: number; onEnded?: () => void; } export declare class SpatialAudio extends Script { private listener; private categoryVolumes; private audioLoader; private soundLibrary; private activeSounds; private specificVolume; private category; private defaultRefDistance; private defaultRolloffFactor; constructor(listener: THREE.AudioListener, categoryVolumes: CategoryVolumes); /** * Plays a sound attached to a specific 3D object. * @param soundKey - Key from the soundLibrary. * @param targetObject - The object the sound should emanate * from. * @param options - Optional settings \{ loop: boolean, volume: * number, refDistance: number, rolloffFactor: number, onEnded: function * \}. * @returns A unique ID for the playing sound instance, or null * if failed. */ playSoundAtObject(soundKey: keyof typeof spatialSoundLibrary, targetObject: THREE.Object3D, options?: PlaySoundOptions): number | null; /** * Stops a specific sound instance by its ID. * @param soundId - The ID returned by playSoundAtObject. */ stopSound(soundId: number): void; /** * Internal method to remove sound from object and map. * @param soundId - id */ private _cleanupSound; /** * Sets the base specific volume for subsequently played spatial sounds. * Does NOT affect currently playing sounds (use updateAllVolumes for that). * @param level - Volume level (0.0 to 1.0). */ setVolume(level: number): void; /** * Updates the volume of all currently playing spatial sounds managed by this * instance. */ updateAllVolumes(): void; destroy(): void; } //#endregion //#region src/sound/SpeechRecognitionTypes.d.ts type SpeechRecognitionErrorCode = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed' | 'phrases-not-supported'; interface SpeechRecognitionEvent extends Event { readonly resultIndex: number; readonly results: SpeechRecognitionResultList; } interface SpeechRecognitionErrorEvent extends Event { readonly error: SpeechRecognitionErrorCode; readonly message: string; } interface SpeechRecognitionEventMap { audioend: Event; audiostart: Event; end: Event; error: SpeechRecognitionErrorEvent; nomatch: SpeechRecognitionEvent; result: SpeechRecognitionEvent; soundend: Event; soundstart: Event; speechend: Event; speechstart: Event; start: Event; } type SpeechRecognitionEventHandlers = { [K in keyof SpeechRecognitionEventMap as `on${K}`]: ((this: SpeechRecognition, event: SpeechRecognitionEventMap[K]) => void) | null; }; interface SpeechGrammar { src: string; weight: number; } interface SpeechGrammarList { readonly length: number; addFromString(grammar: string, weight?: number): void; addFromURI(src: string, weight?: number): void; item(index: number): SpeechGrammar; [index: number]: SpeechGrammar; } /** Browser speech recognizer returned by SpeechRecognizer.recognition. */ interface SpeechRecognition extends EventTarget, SpeechRecognitionEventHandlers { continuous: boolean; grammars: SpeechGrammarList; interimResults: boolean; lang: string; maxAlternatives: number; abort(): void; start(audioTrack?: MediaStreamTrack): void; stop(): void; addEventListener(type: K, listener: (this: SpeechRecognition, event: SpeechRecognitionEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SpeechRecognition, event: SpeechRecognitionEventMap[K]) => void, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } //#endregion //#region src/sound/SpeechRecognizer.d.ts interface SpeechRecognizerEventMap extends THREE.Object3DEventMap { start: object; error: { error: string; }; end: object; result: { originalEvent: SpeechRecognitionEvent; transcript: string; confidence: number; command?: string; isFinal: boolean; }; } export declare class SpeechRecognizer extends Script { private soundSynthesizer; static dependencies: { soundOptions: typeof SoundOptions; }; options: SpeechRecognizerOptions; recognition?: SpeechRecognition; isListening: boolean; lastTranscript: string; lastCommand?: string; lastConfidence: number; error?: string; playActivationSounds: boolean; constructor(soundSynthesizer: SoundSynthesizer); init({ soundOptions }: { soundOptions: SoundOptions; }): void; onSimulatorStarted(): void; start(): void; stop(): void; getLastTranscript(): string; getLastCommand(): string | undefined; getLastConfidence(): number; private _handleStart; private _handleResult; private _handleEnd; private _handleError; destroy(): void; } //#endregion //#region src/sound/SpeechSynthesizer.d.ts export declare class SpeechSynthesizer extends Script { private categoryVolumes; private onStartCallback; private onEndCallback; private onErrorCallback; static dependencies: { soundOptions: typeof SoundOptions; }; private synth; private voices; private selectedVoice?; private isSpeaking; private debug; private specificVolume; private speechCategory; private options; /** * Optional callback invoked on each word boundary while speaking, with the * character index into the spoken text. Lets callers sync visuals (e.g. * gestures) to the actual spoken words. */ onBoundaryCallback?: (charIndex: number) => void; constructor(categoryVolumes: CategoryVolumes, onStartCallback?: () => void, onEndCallback?: () => void, onErrorCallback?: (_: Error) => void); init({ soundOptions }: { soundOptions: SoundOptions; }): void; loadVoices: () => void; setVolume(level: number): void; speak(text: string, lang?: string, pitch?: number, rate?: number): Promise; tts(text: string, lang?: string, pitch?: number, rate?: number): void; cancel(): void; destroy(): void; } //#endregion //#region src/sound/CoreSound.d.ts export declare class CoreSound extends Script { static dependencies: { camera: typeof THREE.Camera; soundOptions: typeof SoundOptions; }; type: string; name: string; categoryVolumes: CategoryVolumes; soundSynthesizer: SoundSynthesizer; listener: THREE.AudioListener; backgroundMusic: BackgroundMusic; spatialAudio: SpatialAudio; speechRecognizer?: SpeechRecognizer; speechSynthesizer?: SpeechSynthesizer; audioListener: AudioListener; audioPlayer: AudioPlayer; options: SoundOptions; init({ camera, soundOptions }: { camera: THREE.Camera; soundOptions: SoundOptions; }): void; getAudioListener(): THREE.AudioListener; setMasterVolume(level: number): void; getMasterVolume(): number; setCategoryVolume(category: VolumeCategory, level: number): void; getCategoryVolume(category: VolumeCategory): number; enableAudio(options?: { streamToAI?: boolean; accumulate?: boolean; }): Promise; disableAudio(): void; /** * Starts recording audio with chunk accumulation */ startRecording(): Promise; /** * Stops recording and returns the accumulated audio buffer */ stopRecording(): ArrayBuffer | null; /** * Gets the accumulated recording buffer without stopping */ getRecordedBuffer(): ArrayBuffer | null; /** * Clears the accumulated recording buffer */ clearRecordedBuffer(): void; /** * Gets the sample rate being used for recording */ getRecordingSampleRate(): number; setAIStreaming(enabled: boolean): void; isAIStreamingEnabled(): boolean; playAIAudio(base64AudioData: string): Promise; stopAIAudio(): void; isAIAudioPlaying(): boolean; /** * Plays a raw audio buffer (Int16 PCM data) with proper sample rate */ playRecordedAudio(audioBuffer: ArrayBuffer, sampleRate?: number): Promise; isAudioEnabled(): boolean; getLatestAudioBuffer(): ArrayBuffer | null; clearLatestAudioBuffer(): void; getEffectiveVolume(category: VolumeCategory, specificVolume?: number): number; muteAll(): void; unmuteAll(): void; destroy(): void; } //#endregion //#region src/agent/SkyboxAgent.d.ts /** * State information for a live session. */ export interface LiveSessionState { /** Whether the session is currently active */ isActive: boolean; /** Timestamp when session started */ startTime?: number; /** Timestamp when session ended */ endTime?: number; /** Number of messages received */ messageCount: number; /** Number of tool calls executed */ toolCallCount: number; /** Last error message if any */ lastError?: string; } /** * Skybox Agent for generating 360-degree equirectangular backgrounds through conversation. * * @example Basic usage * ```typescript * // 1. Enable audio (required for live sessions) * await xb.core.sound.enableAudio(); * * // 2. Create agent * const agent = new xb.SkyboxAgent(xb.core.ai, xb.core.sound, xb.core.scene); * * // 3. Start session * await agent.startLiveSession({ * onopen: () => console.log('Session ready'), * onmessage: (msg) => handleMessage(msg), * onclose: () => console.log('Session closed') * }); * * // 4. Clean up when done * await agent.stopLiveSession(); * xb.core.sound.disableAudio(); * ``` * * @example With lifecycle callbacks * ```typescript * const agent = new xb.SkyboxAgent( * xb.core.ai, * xb.core.sound, * xb.core.scene, * { * onSessionStart: () => updateUI('active'), * onSessionEnd: () => updateUI('inactive'), * onError: (error) => showError(error) * } * ); * ``` * * @remarks * - Audio must be enabled BEFORE starting live session using `xb.core.sound.enableAudio()` * - Users are responsible for managing audio lifecycle * - Always call `stopLiveSession()` before disabling audio * - Session state can be checked using `getSessionState()` and `getLiveSessionState()` */ export declare class SkyboxAgent extends Agent { private sound; private sessionState; constructor(ai: AI, sound: CoreSound, scene: THREE.Scene, callbacks?: AgentLifecycleCallbacks); /** * Starts a live AI session for real-time conversation. * * @param callbacks - Optional callbacks for session events. Can also be set using ai.setLiveCallbacks() * @throws If AI model is not initialized or live session is not available * * @remarks * Audio must be enabled separately using `xb.core.sound.enableAudio()` before starting the session. * This gives users control over when microphone permissions are requested. */ startLiveSession(callbacks?: GoogleGenAITypes.LiveCallbacks): Promise; /** * Stops the live AI session. * * @remarks * Audio must be disabled separately using `xb.core.sound.disableAudio()` after stopping the session. */ stopLiveSession(): Promise; /** * Wraps user callbacks to track session state and trigger lifecycle events. * @param callbacks - The callbacks to wrap. * @returns The wrapped callbacks. */ private wrapCallbacks; /** * Sends tool execution results back to the AI. * * @param response - The tool response containing function results */ sendToolResponse(response: GoogleGenAITypes.LiveSendToolResponseParameters): Promise; /** * Validates that a tool response has the correct format. * @param response - The tool response to validate. * @returns True if the response is valid, false otherwise. */ private validateToolResponse; /** * Helper to create a properly formatted tool response from a ToolResult. * * @param id - The function call ID * @param name - The function name * @param result - The ToolResult from tool execution * @returns A properly formatted FunctionResponse */ static createToolResponse(id: string, name: string, result: ToolResult): GoogleGenAITypes.FunctionResponse; /** * Gets the current live session state. * * @returns Read-only session state information */ getLiveSessionState(): Readonly; /** * Gets the duration of the session in milliseconds. * * @returns Duration in ms, or null if session hasn't started */ getSessionDuration(): number | null; } //#endregion //#region src/agent/tools/GetWeatherTool.d.ts export interface GetWeatherArgs { latitude: number; longitude: number; } export interface WeatherData { temperature: number; weathercode: number; } /** * A tool that gets the current weather for a specific location. */ export declare class GetWeatherTool extends Tool { constructor(); /** * Executes the tool's action. * @param args - The arguments for the tool. * @returns A promise that resolves with a ToolResult containing weather information. */ execute(args: GetWeatherArgs): Promise>; } //#endregion //#region src/agent/tools/GenerateSkyboxTool.d.ts /** * A tool that generates a 360-degree equirectangular skybox image * based on a given prompt using an AI service. */ export declare class GenerateSkyboxTool extends Tool { private ai; private scene; constructor(ai: AI, scene: THREE.Scene); /** * Executes the tool's action. * @param args - The prompt to use to generate the skybox. * @returns A promise that resolves with a ToolResult containing success/error information. */ execute(args: { prompt: string; }): Promise>; } //#endregion //#region src/video/VideoStream.d.ts /** * Enum for video stream states. */ export declare enum StreamState { IDLE = "idle", INITIALIZING = "initializing", STREAMING = "streaming", ERROR = "error", NO_DEVICES_FOUND = "no_devices_found" } export type VideoStreamDetails = { force?: boolean; error?: Error; }; export interface VideoStreamEventMap extends THREE.Object3DEventMap { statechange: { state: StreamState; details?: T; }; } type VideoStreamGetSnapshotImageDataOptionsBase = { /** The target width, defaults to the video width. */ width?: number; /** The target height, defaults to the video height. */ height?: number; }; export type VideoStreamGetSnapshotImageDataOptions = VideoStreamGetSnapshotImageDataOptionsBase & { outputFormat: 'imageData'; }; export type VideoStreamGetSnapshotBase64Options = VideoStreamGetSnapshotImageDataOptionsBase & { outputFormat: 'base64'; mimeType?: string; quality?: number; }; export type VideoStreamGetSnapshotBlobOptions = VideoStreamGetSnapshotImageDataOptionsBase & { outputFormat: 'blob'; mimeType?: string; quality?: number; }; export type VideoStreamGetSnapshotTextureOptions = VideoStreamGetSnapshotImageDataOptionsBase & { outputFormat?: 'texture'; }; export type VideoStreamGetSnapshotOptions = VideoStreamGetSnapshotImageDataOptions | VideoStreamGetSnapshotBase64Options | VideoStreamGetSnapshotTextureOptions | VideoStreamGetSnapshotBlobOptions; export type VideoStreamOptions = { /** Hint for performance optimization for frequent captures. */ willCaptureFrequently?: boolean; }; /** * Subset of the WICG `VideoFrameCallbackMetadata` fields we rely on. For * camera-backed streams Chrome reports `captureTime` (when the frame left the * camera pipeline) in the `performance.now()` timebase. */ export type VideoFrameMetadata = { presentationTime: number; expectedDisplayTime: number; mediaTime: number; presentedFrames: number; captureTime?: number; receiveTime?: number; }; /** * The base class for handling video streams (from camera or file), managing * the underlying