/** * WebXR Manager * * Manages the WebXR session lifecycle and WebGPU binding. * Handles: * - Session request/end * - Reference space management * - WebGPU Projection Layer creation * - Input source tracking */ import type { IWebGPUContext } from '../rendering/webgpu/WebGPUTypes'; import { type WebXRFrameEvidence, type WebXRHitTestSourceLike } from '../vr/WebXRFrameEvidence'; export interface XRWebGPUBindingLike { createProjectionLayer(config: { colorFormat: string; depthStencilFormat: string; }): XRProjectionLayerLike; } export interface XRProjectionLayerLike { readonly textureWidth: number; readonly textureHeight: number; } export interface XRWebGPUTypes { binding: XRWebGPUBindingLike; projectionLayer: XRProjectionLayerLike; } export interface XRSession { addEventListener(type: string, listener: (event: unknown) => void): void; removeEventListener(type: string, listener: (event: unknown) => void): void; requestReferenceSpace(type: string): Promise; requestHitTestSource?(options: { space: XRSpace; }): Promise; requestAnimationFrame?(callback: (time: number, frame: XRFrame) => void): number; updateRenderState(state: Record): Promise; end(): Promise; inputSources: XRInputSource[]; renderState: { baseLayer?: { space: XRSpace; }; }; } export interface XRReferenceSpace extends XRSpace { } export interface XRSpace { } export interface XRFrame { session: XRSession; getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined; getPose?(space: XRSpace, baseSpace: XRReferenceSpace): WebXRPoseLike | null | undefined; getHitTestResults?(source: WebXRHitTestSourceLike): WebXRHitTestResultLike[]; trackedAnchors?: Iterable; } type WebXRPoseLike = import('../vr/WebXRFrameEvidence').WebXRPoseLike; type WebXRHitTestResultLike = import('../vr/WebXRFrameEvidence').WebXRHitTestResultLike; type WebXRAnchorLike = import('../vr/WebXRFrameEvidence').WebXRAnchorLike; export interface XRViewerPose { views: XRView[]; } export interface XRView { transform: { position: [number, number, number]; orientation: { x: number; y: number; z: number; w: number; }; inverse: { matrix: Float32Array; }; }; projectionMatrix: Float32Array; } export interface XRGamepad { hapticActuators?: Array<{ pulse(intensity: number, duration: number): Promise; }>; buttons: Array<{ pressed: boolean; touched: boolean; value: number; }>; axes: number[]; } export interface XRInputSource { handedness: 'none' | 'left' | 'right'; targetRayMode: 'gaze' | 'tracked-pointer' | 'screen'; hand?: XRHand; gamepad?: XRGamepad; profiles: string[]; } export interface XRHand extends Map { } export interface XRJointSpace extends XRSpace { } export interface XRInputSourceChangeEvent { session: XRSession; added: XRInputSource[]; removed: XRInputSource[]; } export interface WebXRConfig { features?: string[]; } export type WebXRFrameCallback = (time: number, frame: XRFrame, evidence: WebXRFrameEvidence) => void; export declare class WebXRManager { private session; private referenceSpace; private viewerReferenceSpace; private hitTestSource; private glBinding; private projectionLayer; private context; onSessionStart: ((session: XRSession) => void) | null; onSessionEnd: (() => void) | null; onInputSourcesChange: ((added: XRInputSource[], removed: XRInputSource[]) => void) | null; constructor(context: IWebGPUContext); /** * Check if WebXR is supported */ static isSupported(): Promise; /** * Instance method to check if a specific session mode is supported. */ isSessionSupported(mode?: string): Promise; /** * Trigger haptic pulse on a controller */ triggerHaptic(hand: 'left' | 'right', intensity: number, duration: number): void; /** * Request an immersive VR session */ requestSession(config?: WebXRConfig): Promise; /** * Set a callback to be invoked each XR frame. */ setAnimationLoop(callback: WebXRFrameCallback | null): void; private animationLoopCallback; /** * Collect passive WebXR hit-test and anchor evidence for XRFrameData fields. */ collectFrameEvidence(time: number, frame: XRFrame): WebXRFrameEvidence; /** * End the current session */ endSession(): Promise; /** * Get the current XRSession */ getSession(): XRSession | null; /** * Get the current Reference Space */ getReferenceSpace(): XRReferenceSpace | null; /** * Get the WebGPU Binding */ getBinding(): XRWebGPUBindingLike | null; /** * Get the active Projection Layer */ getProjectionLayer(): XRProjectionLayerLike | null; private handleSessionEnd; private handleInputSourcesChange; private initializeHitTestSource; } export {}; //# sourceMappingURL=WebXRManager.d.ts.map