浏览代码

Merge pull request #16868 from takahirox/XRNotFoundButton

WebVR: Use XR NOT FOUND string with WebXR API
Mr.doob 6 年之前
父节点
当前提交
12589ae758
共有 1 个文件被更改,包括 18 次插入4 次删除
  1. 18 4
      examples/js/vr/WebVR.js

+ 18 - 4
examples/js/vr/WebVR.js

@@ -93,7 +93,7 @@ var WEBVR = {
 
 		}
 
-		function showVRNotFound() {
+		function disableButton() {
 
 			button.style.display = '';
 
@@ -101,17 +101,31 @@ var WEBVR = {
 			button.style.left = 'calc(50% - 75px)';
 			button.style.width = '150px';
 
-			button.textContent = 'VR NOT FOUND';
-
 			button.onmouseenter = null;
 			button.onmouseleave = null;
 
 			button.onclick = null;
 
+		}
+
+		function showVRNotFound() {
+
+			disableButton();
+
+			button.textContent = 'VR NOT FOUND';
+
 			renderer.vr.setDevice( null );
 
 		}
 
+		function showXRNotFound() {
+
+			disableButton();
+
+			button.textContent = 'XR NOT FOUND';
+
+		}
+
 		function stylizeElement( element ) {
 
 			element.style.position = 'absolute';
@@ -136,7 +150,7 @@ var WEBVR = {
 
 			stylizeElement( button );
 
-			navigator.xr.supportsSession( 'immersive-vr' ).then( showEnterXR ).catch( showVRNotFound );
+			navigator.xr.supportsSession( 'immersive-vr' ).then( showEnterXR ).catch( showXRNotFound );
 
 			return button;