From 6986819790f5687fad1dff26684f4bf9d1ad917a Mon Sep 17 00:00:00 2001
From: Greg Fodor <gfodor@gmail.com>
Date: Sun, 4 Nov 2018 18:49:04 +0000
Subject: [PATCH] Disable VR mode when not in room yet

---
 src/assets/stylesheets/hub.scss |  2 +-
 src/hub.html                    |  1 +
 src/hub.js                      | 12 +++++++++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/assets/stylesheets/hub.scss b/src/assets/stylesheets/hub.scss
index 1f7f530e9..a562a8013 100644
--- a/src/assets/stylesheets/hub.scss
+++ b/src/assets/stylesheets/hub.scss
@@ -9,7 +9,7 @@
 @import 'info-dialog';
 
 body.vr-mode {
-  a-scene.fullscreen {
+  a-scene {
     .a-canvas {
       width: 200% !important;
     }
diff --git a/src/hub.html b/src/hub.html
index a4eff0a00..276efb05f 100644
--- a/src/hub.html
+++ b/src/hub.html
@@ -342,6 +342,7 @@
                 class="camera"
                 camera
                 personal-space-bubble="radius: 0.4;"
+                rotation
                 pitch-yaw-rotator
             >
                 <a-entity
diff --git a/src/hub.js b/src/hub.js
index cee2b1be8..d967dc934 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -317,7 +317,17 @@ document.addEventListener("DOMContentLoaded", async () => {
 
   window.APP.scene = scene;
 
-  scene.addEventListener("enter-vr", () => document.body.classList.add("vr-mode"));
+  scene.addEventListener("enter-vr", () => {
+    document.body.classList.add("vr-mode");
+
+    if (!scene.is("entered")) {
+      // If VR headset is activated, refreshing page will fire vrdisplayactivate
+      // which puts A-Frame in VR mode, so exit VR mode whenever it is attempted
+      // to be entered and we haven't entered the room yet.
+      scene.exitVR();
+    }
+  });
+
   scene.addEventListener("exit-vr", () => document.body.classList.remove("vr-mode"));
 
   registerNetworkSchemas();
-- 
GitLab