VR and XR Cameras

Babylon.js 7 includes enhanced support for Virtual Reality and Augmented Reality through the WebXR standard:

// Create default experience helper
const xrHelper = await scene.createDefaultXRExperienceAsync({
    floorMeshes: [ground] // Optional meshes to use as floor reference
});

// Check if XR is available
if (xrHelper.isSupported) {
    // Create button for VR entry
    const vrButton = document.createElement("button");
    vrButton.textContent = "Enter VR";
    vrButton.style.position = "absolute";
    vrButton.style.bottom = "10px";
    vrButton.style.right = "10px";
    document.body.appendChild(vrButton);
    
    vrButton.addEventListener("click", async () => {
        await xrHelper.enterXRAsync("immersive-vr", "local-floor");
    });
}