I’m wondering if there is a correct way to initialise WebXR using the new Babylonjs Viewer? I can see there is documentation on how to activate this feature in the old version of the viewer, but not the new one. I have tried to initialise webXR using the scene object and the BabylonXRHelper but it seems like this is behaving differently because the device (android and chrome with the webXR extension) switch to XR but the 3d model is no longer shown.
Since I don’t know if I can use the viewer in the playground, I’ve made a github example and it’s available to view online:
This happens because the Babylon Viewer suspends the render loop when it thinks nothing has changed that requires the scene to be rendered (to save power/battery on mobile devices). It does this by watching for changes in the things it controls, like the main camera pose. When using XR in your own code, the Viewer is not aware of it and does not know that it should not suspend the render loop.
In this case, since an XR camera is pretty much always moving anyway, try just disabling the render loop suspend feature by adding the render-when-idle attribute (e.g. <babylon-viewer id="babylonCanvas" source="/boombox.glb" render-when-idle></babylon-viewer>).
We are tentatively planning to add XR support to the Viewer sometime before our 9.0 release, and when we do, we’ll be sure to handle this case to make it easier by default!