/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import type { XRDevice } from '../device/XRDevice.js'; import type { AcceptSessionResult } from './types.js'; /** * RemoteControlInterface provides frame-synchronized programmatic control of an XRDevice. * * This class implements a command queue that processes actions during each frame update, * enabling smooth animations and coordinated control with DevUI. * * Key features: * - Frame-synchronized execution: Commands are queued and processed during frame update * - Duration-based actions: Smooth animations via lerp over multiple frames * - Automatic capture/release: Captures device on first command, releases 30s after queue empties * - Unified device identifiers: 'headset', 'controller-left', 'hand-right', etc. * * Usage: * ```typescript * import { XRDevice, metaQuest3 } from 'iwer'; * * const device = new XRDevice(metaQuest3); * device.installRuntime(); * * // Get transform * const result = await device.remote.dispatch('get_transform', { device: 'headset' }); * * // Animate headset to new position over 1 second * await device.remote.dispatch('animate_to', { * device: 'headset', * position: { x: 0, y: 1.6, z: -1 }, * duration: 1.0 * }); * ``` */ export declare class RemoteControlInterface { private device; private commandQueue; private _isCaptured; private releaseTimer; private actionIdCounter; /** Release timeout in milliseconds (default: 30000 = 30 seconds) */ readonly RELEASE_TIMEOUT_MS = 30000; constructor(device: XRDevice); private generateActionId; /** * Whether the device is currently captured for programmatic control. * When true, DevUI should go into passive mode (sync FROM device only). */ get isCaptured(): boolean; /** * Number of pending actions in the queue */ get queueLength(): number; /** * Enqueue a discrete action for processing */ private enqueueDiscrete; /** * Enqueue a duration action for processing */ private enqueueDuration; /** * Update method called each frame by XRDevice. * Processes the command queue and handles duration-based animations. * * @param deltaTimeMs - Time since last frame in milliseconds */ update(deltaTimeMs: number): void; private startReleaseTimer; private cancelReleaseTimer; /** * Get the transform (position, quaternion) for a device */ private getDeviceTransform; /** * Set the transform for a device */ private setDeviceTransform; /** * Transform a position from XR-origin-relative coordinates to GlobalSpace. * The XR origin is defined by the first reference space requested by the app. * This is necessary because device positions are in GlobalSpace, but positions * from get_object_transform are relative to the XR origin. */ private transformXROriginToGlobal; /** * Get the select value for an input device (trigger for controller, pinch for hand) */ private getDeviceSelectValue; /** * Set the select value for an input device */ private setDeviceSelectValue; /** * Set connected state for an input device */ private setDeviceConnected; private executeDiscreteAction; private executeGetSessionStatus; private executeAcceptSession; private executeEndSession; private executeGetTransform; private executeSetTransform; private executeLookAt; private executeSetInputMode; private executeSetConnected; private executeGetSelectValue; private executeSetSelectValue; private executeGetGamepadState; private executeSetGamepadState; private executeGetDeviceState; private executeSetDeviceState; private applyInputState; private executeCaptureCanvas; private applyDurationLerpState; private applyDurationFinalState; private getDurationResult; /** * Set of methods that execute immediately (synchronously) without going through the queue. * These are queries and session management commands that need to work outside of XR frames. */ private static readonly IMMEDIATE_METHODS; /** * Set of immediate methods that are "active" - they modify state and should trigger capture mode. * Passive methods (queries) should NOT trigger capture mode. */ private static readonly ACTIVE_IMMEDIATE_METHODS; /** * Set of methods that require an active XR session. * These are state-modifying methods that are processed during frame updates. */ private static readonly SESSION_REQUIRED_METHODS; /** * Activate capture mode for programmatic control. * Called when active methods are executed. */ private activateCaptureMode; /** * Dispatch a method call. * * Immediate methods (queries, session management) execute synchronously. * State-modifying methods require an active session and are queued for frame-synchronized execution. * * @param method - The method name (e.g., 'get_transform', 'animate_to') * @param params - The method parameters * @returns Promise that resolves with the method result */ dispatch(method: string, params?: Record): Promise; /** * Execute an immediate method synchronously (not queued). * Used for queries and session management that must work outside XR frames. */ private executeImmediateMethod; /** * Execute select action - this directly enqueues the three sub-actions without awaiting * The caller's promise resolves when all sub-actions complete */ private executeSelectSequence; /** * Accept an offered XR session (async wrapper for proper session activation) */ acceptSession(): Promise; /** * Force release capture mode (for testing/cleanup) */ forceRelease(): void; } //# sourceMappingURL=RemoteControlInterface.d.ts.map