XR teleportation observable


is there XR equivalent of VRHelper.onBeforeCameraTeleport observable?

I already had a look at WebXRControllerTeleportation.ts, _teleportForward() does not any events.

I’m porting a WebVR world to WebXR, need to update DynamicTerrain before teleportation.
So, how to do it? I.e. how to track movements in XR?

Pulling in the Babylon King of XR @RaananW

XR teleportation uses native XR functionality and changes the reference space. There is an observable for when you change reference space in the session manager. But this is technically after teleportation happened. My main question is - what information do you need before teleporting?

I need destination coordinates.

OK I see, there’s WebXRSessionManager.onXRReferenceSpaceChanged, so I could fetch camera coordinates after teleportation and then update dynamic terrain.

Will try, thank you.

I’ll also file RFE at github, these before/after teleport observables are handy features to have.

That worked. Here’s a code snippet in case anybody else needs the same:

xrHelper.baseExperience.sessionManager.onXRReferenceSpaceChanged.add( (xrReferenceSpace) => {
  targetPosition = xrHelper.baseExperience.camera.position;
  camera.globalPosition.x = targetPosition.x;
  camera.globalPosition.y = targetPosition.y;
  camera.globalPosition.z = targetPosition.z;