Hi, I came across a little bug where WebXRMotionControllerTeleportation will throw with the following error “Uncaught TypeError: Cannot read property ‘teleportationState’ of undefined” in its _onXRFrame.
This happens when a teleportation timer is started and the user leaves the XR session, after this upon re-entering the XR session the _onXRFrame throws. Apparently this is due to _currentTeleportationControllerId being set by the timer but it will not be cleared upon exiting the session, now after re-entering the session, the _currentTeleportationControllerId is still set but no controllers exist yet. The line that throws is Babylon.js/WebXRControllerTeleportation.ts at master · BabylonJS/Babylon.js · GitHub
This was reproducible in the playground using GearVR as well as the WebXR emulator. Basically if you leave the XR session when the following is happening
and try to re-enter the session, it will throw.
I managed to get it fixed in my application by setting _currentTeleportationControllerId to an empty string (same thing that is done after teleportation is finished) when an XR session ends. So I guess you could add an observer to xrSessionManager’s onXRSessionEnded which would clear the state properly?