How do I register for onBeforeCameraTeleport observable using WebXR?

Hi @RaananW

Are the observables onBeforeCameraTeleport and onAfterCameraTeleport still available for WebXR?

They appear to be defined in the codebase Babylon.js/WebXRControllerTeleportation.ts at master · BabylonJS/Babylon.js · GitHub even though they are not documented for WebXR (only WebVR Use the WebVR experience helper - Babylon.js Documentation)

But I’m not sure how to get access to them to register for those observables from xrHelper or xrHelper.teleportation or xrHelper.baseExperience. Is there any way to get at them?

My objective is to know where a player is going in order to send the position information through a websocket so that I can move a mesh representing that player animating to that position on another headset.

Thanks!

Hi @owen,

those functions are two members of the XRCamera class, which can be found in your helper’s baseExperience (xrHelper.baseExperience.camera)

Perhaps it’s an issue with vscode intellisense then? For me, there is no onBeforeCameraTeleport or onAfterCameraTeleport, see image:

Incidentally, I’m using these npm packages in package.json:

    "babylonjs": "^4.1.0",
    "babylonjs-gui": "^4.1.0",
    "babylonjs-loaders": "^4.1.0",

Which may not be the latest. Is there a way to install the preview versions using npm? Thanks!

npm install babylonjs@preview :slight_smile: and the same goes for the other packages.

Thanks, now I know how to use the preview in npm. :smiley:

Now I’m using:

"babylonjs": "^4.2.0-beta.16",
"babylonjs-gui": "^4.2.0-beta.16",
"babylonjs-loaders": "^4.2.0-beta.16", 

But it doesn’t seem to solve my original question. There don’t see to be intellisense auto-complete methods onBeforeCameraTeleport and onAfterCameraTeleport on xrHelper.baseExperience.camera object. Do I need to update definitions somewhere for this to show up?

Adding back @RaananW for the rest of the question :slight_smile:

Are you sure it is not available?

image

Want to try in the playground or share some code? I will be happy to fix this!

1 Like

It’s there now. I deleted my node_modules folder and had to restart vscode before I could see it. It’s now updated. Thanks for your help!

2 Likes