Accessing navigator.xr in TypeScript

Hello, and pardon me if this is a peripheral question. I have been trying to detect xr in the browser without invoking a new session, and I have been unable to make use of custom types in a way that allows me to extend the interface.

The code in webXRSessionManager is accessing the property, and I have found a @types/webxr module which seems related to the Babylon work, but the modules will import and not compile.

Thanks, and I appreciate any advice you might have,
Robert

Adding @RaananW the WebXR master for guidance.

hey!

@types/webxr is actually partly maintained by us! there might have been a change the I didn’t follow, but what seems to be the issue with compiling? Is it something we are doing?
Babylon.js/webxr.d.ts at master · BabylonJS/Babylon.js (github.com)
BTW - we have our own webxr typings file, which you can probably use as well -

Hey, and thanks for chiming in…

I have been trying to use the webxr typings file (npm i --save-dev @node/types | @types/webxr) in a node module (import “@types/webxr”;), but the navigator continues to complain that xr does not exist.

Is there a similarly simple way to check for the presence of xr within Babylon? (which does not require me to create a WebXRExperienceHelper)

r

You can check IsSessionSupportedAsync from WebXRSessionManager which will resolve to false if xr is not available or if the session is, well, not supported