It doesn’t crash though, but it just has this error when the pipeline adding new cameras while entering XR mode. How to prevent it?
Just came back. i’ll look into that!
To avoid that only add the webXR camera right before the first frame is rendered.
I found an interesting issue with the onXRInit observable (when it comes to initializing the number of cameras needed for the XR scene), and this is why you need to wait for the moment right before the first scene is rendered. Issue can be seen here - https://playground.babylonjs.com/#8H7J9T#3
This is actually per design, so it’s not entirely a bug. I’ll see if I can find a fix that doesn’t break anything. I keep this assigned to me.
Quick note - this new observable can be used to solve this, afte thie PR is merged: [XR] a new on XR Camera initialized observable by RaananW · Pull Request #14231 · BabylonJS/Babylon.js (github.com)