Browse Source

fix mobilevr, screenfull

Nikolay Suslov 5 years ago
parent
commit
40c6ada12c

+ 6 - 4
public/index.html

@@ -124,12 +124,12 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
     <div id="vwf-root"></div>
 
     <div id="ui-controls" class="guiwindow">
-        <i id="hideui" class="mdc-icon-toggle material-icons" role="button" aria-pressed="true" aria-label="Hide Toollbar" tabindex="0"
+        <i id="hideui" class="mdc-icon-button material-icons" role="button" aria-pressed="true" aria-label="Hide Toollbar" tabindex="0"
             data-toggle-on='{"label": "Hide", "content": "grid_on"}' data-toggle-off='{"label": "Show", "content": "grid_off"}'>
             grid_on
         </i>
 
-        <i id="fullscreenui" class="mdc-icon-toggle material-icons" role="button" aria-pressed="true" aria-label="Hide Toollbar"
+        <i id="fullscreenui" class="mdc-icon-button material-icons" role="button" aria-pressed="true" aria-label="Hide Toollbar"
             tabindex="0" data-toggle-on='{"label": "Hide", "content": "fullscreen"}' data-toggle-off='{"label": "Show", "content": "fullscreen_exit"}'>
             fullscreen
         </i>
@@ -149,7 +149,8 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
         });
 
         const iconEl = document.querySelector('#hideui');
-        iconEl.addEventListener('MDCIconToggle:change', (e) => {
+        const compHideUI = new mdc.iconButton.MDCIconButtonToggle(iconEl);
+        iconEl.addEventListener('MDCIconButtonToggle:change', (e) => {
 
             let ui = document.querySelector('.mdc-top-app-bar');
             if (ui) {
@@ -165,7 +166,8 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
         });
 
         const fullScreenToggle = document.querySelector('#fullscreenui');
-        fullScreenToggle.addEventListener('MDCIconToggle:change', (e) => {
+        const compfullScreen = new mdc.iconButton.MDCIconButtonToggle(fullScreenToggle);
+        fullScreenToggle.addEventListener('MDCIconButtonToggle:change', (e) => {
 
             if (screenfull.enabled) {
                 screenfull.toggle();

+ 41 - 20
public/lib/screenfull/screenfull.js

@@ -1,6 +1,6 @@
 /*!
 * screenfull
-* v3.3.2 - 2017-10-27
+* v4.2.0 - 2019-04-01
 * (c) Sindre Sorhus; MIT License
 */
 (function () {
@@ -84,29 +84,48 @@
 
 	var screenfull = {
 		request: function (elem) {
-			var request = fn.requestFullscreen;
-
-			elem = elem || document.documentElement;
-
-			// Work around Safari 5.1 bug: reports support for
-			// keyboard in fullscreen even though it doesn't.
-			// Browser sniffing, since the alternative with
-			// setTimeout is even worse.
-			if (/ Version\/5\.1(?:\.\d+)? Safari\//.test(navigator.userAgent)) {
-				elem[request]();
-			} else {
-				elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
-			}
+			return new Promise(function (resolve) {
+				var request = fn.requestFullscreen;
+
+				var onFullScreenEntered = function () {
+					this.off('change', onFullScreenEntered);
+					resolve();
+				}.bind(this);
+
+				elem = elem || document.documentElement;
+
+				// Work around Safari 5.1 bug: reports support for
+				// keyboard in fullscreen even though it doesn't.
+				// Browser sniffing, since the alternative with
+				// setTimeout is even worse.
+				if (/ Version\/5\.1(?:\.\d+)? Safari\//.test(navigator.userAgent)) {
+					elem[request]();
+				} else {
+					elem[request](keyboardAllowed ? Element.ALLOW_KEYBOARD_INPUT : {});
+				}
+
+				this.on('change', onFullScreenEntered);
+			}.bind(this));
 		},
 		exit: function () {
-			document[fn.exitFullscreen]();
+			return new Promise(function (resolve) {
+				if (!this.isFullscreen) {
+					resolve();
+					return;
+				}
+
+				var onFullScreenExit = function () {
+					this.off('change', onFullScreenExit);
+					resolve();
+				}.bind(this);
+
+				document[fn.exitFullscreen]();
+
+				this.on('change', onFullScreenExit);
+			}.bind(this));
 		},
 		toggle: function (elem) {
-			if (this.isFullscreen) {
-				this.exit();
-			} else {
-				this.request(elem);
-			}
+			return this.isFullscreen ? this.exit() : this.request(elem);
 		},
 		onchange: function (callback) {
 			this.on('change', callback);
@@ -162,6 +181,8 @@
 
 	if (isCommonjs) {
 		module.exports = screenfull;
+		// TODO: remove this in the next major version
+		module.exports.default = screenfull;
 	} else {
 		window.screenfull = screenfull;
 	}

File diff suppressed because it is too large
+ 1 - 2
public/lib/screenfull/screenfull.min.js


+ 1 - 0
public/vwf/model/aframe.js

@@ -333,6 +333,7 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                     if (childNode.aframeObj !== undefined) {
                         // removes and destroys object
                         childNode.aframeObj.parentNode.removeChild(childNode.aframeObj);
+                        childNode.aframeObj.destroy();
                         childNode.aframeObj = undefined;
                     }
 

+ 12 - 13
public/vwf/view/aframe.js

@@ -96,26 +96,25 @@ define(["module", "vwf/view"], function (module, view) {
 
                     if (this.wmrright == true) {
                         console.log("CREATE WMR RIGHT HERE!!");
-                        if (AFRAME.utils.device.checkHeadsetConnected()) {
-                        if (AFRAME.utils.device.checkHasPositionalTracking()) {
-                            let nodeName = 'wmrvr-right-' + self.kernel.moniker();
-                            createWMRVRControls('right');
-                            createWMRVR.call(this, childID, nodeName);
+                        if (!AFRAME.utils.device.isMobileVR()) {
+                            if (AFRAME.utils.device.checkHeadsetConnected()) {
+                                let nodeName = 'wmrvr-right-' + self.kernel.moniker();
+                                createWMRVRControls('right');
+                                createWMRVR.call(this, childID, nodeName);
+                            }
                         }
                     }
 
-                    }
-
                     if (this.wmrleft == true) {
                         console.log("CREATE WMR LEFT HERE!!");
-                        if (AFRAME.utils.device.checkHeadsetConnected()) {
-                        if (AFRAME.utils.device.checkHasPositionalTracking()) {
-                            let nodeName = 'wmrvr-left-' + self.kernel.moniker();
-                            createWMRVRControls('left');
-                            createWMRVR.call(this, childID, nodeName);
+                        if (!AFRAME.utils.device.isMobileVR()) {
+                            if (AFRAME.utils.device.checkHeadsetConnected()) {
+                                let nodeName = 'wmrvr-left-' + self.kernel.moniker();
+                                createWMRVRControls('left');
+                                createWMRVR.call(this, childID, nodeName);
+                            }
                         }
                     }
-                    }
 
                 })
                 // this.state.appInitialized  = true;

Some files were not shown because too many files changed in this diff