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.
Legacy property for backward compatibility.
True if WebXR session entry has been requested.
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 current XR session object.
The active XRSession, or undefined if no session is active.
Internal
Gets the camera component for the specified eye.
Eye index (0: left, 1: right).
The CameraComponent for the specified eye.
Internal
Gets the projection matrix for the specified eye.
Eye index (0: left, 1: right).
The projection matrix for the specified eye.
Internal
Performs 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.
Optional
initialInitial 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 all currently tracked controller entities.
Array of scene graph entities representing VR controllers.
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.
Static
getGets 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