Skip to content

Commit

Permalink
fix(event-display): catch VR request session error
Browse files Browse the repository at this point in the history
  • Loading branch information
9inpachi committed Mar 9, 2021
1 parent a3ac9f6 commit d2874b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/phoenix-event-display/src/three/vr-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,20 @@ export class VRManager {
this.renderer = renderer;
this.onSessionEnded = onSessionEnded;

if ((navigator as any)?.xr) {
const webXR = (navigator as any)?.xr;

if (webXR) {
const sessionInit = {
optionalFeatures: ['local-floor', 'bounded-floor', 'hand-tracking']
};
(navigator as any)?.xr?.requestSession(VRManager.SESSION_TYPE, sessionInit)

(webXR.requestSession(VRManager.SESSION_TYPE, sessionInit) as Promise<any>)
.then((session: any) => {
this.onVRSessionStarted(session);
onSessionStarted?.();
})
.catch((error: any) => {
console.log('VR Error:', error);
});

this.setupVRControls();
Expand Down Expand Up @@ -168,7 +174,7 @@ export class VRManager {
this.controller2.add(line.clone());

// Set up movement

// Distance for a single step
const stepDistance = 30;
// Unit vector in camera direction
Expand Down

0 comments on commit d2874b8

Please sign in to comment.