The issue here is the mouse picking of this complex scene. Babylon runs a picking function on each frame, which uses your current mouse position over the canvas. when dealing with complex meshes it might take quite some time, because it runs picking against the actual triangle of each mesh it collides with (or better - with its bounding box/sphere). To eliminate this you can set each mesh you loaded to be not-pickable (or at least the more complex meshes). isPickable is set to true per default so you will need to actively set it to false.
Now, saince you are using the emulator, the mouse events are still executed on the canvas. this is why the FPS drops even when you are in XR. when outside of the emulator you won’t have the mouse issue, BUT you will still experience the same behavior when moving your xr controllers. that it because the xr controllers are emulating the pointer system! And they technically work the same as a mouse, but in the 3D space (as opposed to the mouse that works on the 2D canvas and always points “forward”). To disable this behavior you can detach the pointer system (which is part of the default xr experience), or, just like in the case of the mouse, make all meshes not-pickable (line 9, a very simple approach that you might want to adjust in your scenes):
Sorry, I think that my video was not clear enough, I don’t care about the initial performance with the same geometry where Babylon is making great work.
The problem is that AFTER you enter and exit from WebXR the performance is much worse than in the initial case, it seems that entering into WebXR mode makes something dirty in the pick system since if I disable picking in all the objects this behavior is no longer happening.
This example is very cool, but I have two big questions, valid for any other XR example I found:
once I enable the XR dualview mode… how do I exit? Using a cardboard-like viewer I need something to look at to enable it by tapping screen or just by looking at it for long enough, but I can’t see anything. Without exiting, I cannot debug on PC, because I cannot access code anymore!
How can use this and other examples locally? I can’t get the browser loading a local file due to CORS restriction, and I don’t want any server on my PC.
I tried with the documentation, but it’s quite confusing due to overlapping of WebVR with WebXR explanations, obsolete examples no more working, and so on.
How to exit? Depends on the system you are using. Every platform has its own way to quit an XR experience. The quest, for example, is using the left controller’s menu button.
The exit button can also be added by you in the scene itself if you believe it is needed - just call exitXR on the experience helper.
Regarding not serving the files - that could be a bit complicated when it comes to XR, as usually you would not host the files on the XT headset. So a server is needed. a dev server will be helpful here, made available only on your local network
I found the solution to first isse in “exit immersive” button in WebXR emulator for chrome.
About the second one, why do yuo think files should not be hosted locally? This would make things much faster, and even independent of network, which is a great plus.
I think modern HTML5 and “file” tag could allow loading a local file selected by an user, I use this method for several of my scripts, but I don’t know how to use it in babylon:
Many different reasons. The main one is - if you have a headset and you want to access files you are currently editing on your laptop, you will need to serve them somehow. Second, I am not entirely sure WebXR will accept the file protocol as an accepted URL to launch a webxr experience, BUT i haven’t tested it TBH.
I won’t try to convince you to use a local server . Just my 2 cents.
are you talking about serving models, or about serving your XR experience?
You could, for example, convert anything to base64 URLs and use them as regular URLs. it will work. But how are you going to serve the HTML and js to the headset?
EDIT - again, not trying to convince you to use a local server. I am just not sure why you wouldn’t use it, and how you are planning on using the implementation on a headset :-). If you have a solution for that - awesome!