Hey, im trying out webXR with ThreeJs. Currently Im creating the VRButton and can enter the vr world and everything works well. But what I dont find on the web is how to get the navigator or the XRSession.
And further on how to get events from XRSession. I need to know when the user exits VR.
this is my onClick function which gets fired when clicking on VRButton.
The session variable is only set after WebXRManager.setSesstion() was called. And this only happens if you start a XR session by activating the ENTER VR button.
Have you considered to register event listeners to the session start and end events like so?
renderer.xr.addEventListener( 'sessionstart', function ( event ) {
//
} );
renderer.xr.addEventListener( 'sessionend', function ( event ) {
//
} );
Property ‘addEventListener’ does not exist on type ‘WebXRManager’.
Found a workaround for this:
let xr : any = this.renderer.xr
xr.addEventListener('sessionstart', this.onSessionStart.bind(this))
xr.addEventListener('sessionend', this.onSessionEnd.bind(this))
Probably happens because of missing typescript typings.