Gets the WebXR framebuffer for rendering.
The WebGL framebuffer provided by the XR system, or undefined if not available.
Checks if the system is ready to enter WebXR.
True if WebXR initialization is complete and ready for session start.
Checks if currently in WebXR rendering mode.
True if WebXR mode is active.
Gets the projection matrix for the left eye. Derived from the XR system's view information.
The projection matrix for left eye rendering.
Gets the view matrix for the left eye camera.
The view matrix for left eye rendering.
Checks if a WebXR session has been requested.
True if WebXR session entry has been requested.
Gets the projection matrix for the right eye. Derived from the XR system's view information.
The projection matrix for right eye rendering.
Gets the view matrix for the right eye camera.
The view matrix for right eye rendering.
Gets the current XR session object.
The active XRSession, or undefined if no session is active.
InternalGets the camera component for the specified eye.
Eye index (0: left, 1: right).
The CameraComponent for the specified eye.
InternalGets the component SID (System ID) for the specified camera.
Eye index (0: left, 1: right).
The SID of the CameraComponent for the specified eye.
InternalGets the world position of the specified VR camera. Combines XR pose data with user position offset and viewer transformations.
Eye index (0: left, 1: right).
The world position of the VR camera.
InternalGets the viewport configuration for the left eye.
The viewport vector (x, y, width, height) for the left eye.
InternalGets the projection matrix for the specified eye.
Eye index (0: left, 1: right).
The projection matrix for the specified eye.
InternalGets the viewport configuration for the right eye. Accounts for multiview rendering mode differences.
The viewport vector (x, y, width, height) for the right eye.
InternalGets the view matrix for the specified eye.
Eye index (0: left, 1: right).
The view matrix for the specified eye.
InternalGets the viewport configuration for the specified eye.
Eye index (0: left, 1: right).
The viewport vector (x, y, width, height) for the specified eye.
InternalPerforms post-rendering cleanup for WebXR. Currently handles multiview framebuffer operations when enabled. Called once per frame after rendering is complete.
InternalPerforms pre-rendering updates for WebXR. Updates view matrices, input sources, and gamepad states. Called once per frame before rendering begins.
Current time in milliseconds.
The XRFrame object for this rendering frame.
Initiates a WebXR VR session with specified configuration. Requests an immersive VR session, sets up reference space, WebGL layer, and input handling.
Configuration object for WebXR session.
Callback function executed when the XR session ends.
Callback function executed when the XR session starts.
OptionalinitialUserPosition?: Vector3Initial position of the user in world space. Defaults to [0, 1.1, 0].
Array of controller profile names in priority order for input mapping.
Promise that resolves to an array of controller entities, or undefined on failure.
const controllers = await webXRSystem.enterWebXR({
initialUserPosition: Vector3.fromCopyArray([0, 1.6, 2]),
callbackOnXrSessionStart: () => {
console.log('VR session started');
// Initialize VR-specific UI or game logic
},
callbackOnXrSessionEnd: () => {
console.log('VR session ended');
// Clean up VR-specific resources
},
profilePriorities: ['oculus-touch-v2', 'oculus-touch', 'generic-trigger']
});
Gets the canvas height configured for VR rendering.
The height of the VR canvas in pixels.
Gets the canvas width configured for VR rendering.
The width of the VR canvas in pixels.
Gets all currently tracked controller entities.
Array of scene graph entities representing VR controllers.
Checks if multiview rendering is supported and enabled.
True if multiview VR rendering is supported.
Prepares the WebXR system for VR session initialization. Checks for WebXR support, loads required modules, and sets up the entry point.
HTML element to serve as the VR entry button. If null, creates a default button.
Base path for loading controller models and assets.
Promise that resolves to an empty array on success.
Resets all viewer transformation parameters to their default values. Useful for resetting user position and orientation to origin.
StaticinitGets the singleton instance of WebXRSystem. Creates a new instance if one doesn't exist.
The singleton WebXRSystem instance.
WebXRSystem class manages WebXR session and rendering for virtual reality experiences. This singleton class handles WebXR session lifecycle, camera setup for stereo rendering, input source management, and coordinate space transformations for VR applications.
Example