Ver código fonte

WebVR: getVRDisplays() returns [] in Android if Chrome VR Services is not installed.

Mr.doob 8 anos atrás
pai
commit
65697bbeae
1 arquivos alterados com 16 adições e 7 exclusões
  1. 16 7
      examples/js/vr/WebVR.js

+ 16 - 7
examples/js/vr/WebVR.js

@@ -109,18 +109,27 @@ var WEBVR = {
 		button.style.fontStyle = 'normal';
 		button.style.textAlign = 'center';
 		button.style.zIndex = '999';
-		button.textContent = 'ENTER VR';
-		button.onclick = function () {
 
-			display.isPresenting ? display.exitPresent() : display.requestPresent( [ { source: canvas } ] );
+		if ( display ) {
 
-		};
+			button.textContent = 'ENTER VR';
+			button.onclick = function () {
 
-		window.addEventListener( 'vrdisplaypresentchange', function () {
+				display.isPresenting ? display.exitPresent() : display.requestPresent( [ { source: canvas } ] );
 
-			button.textContent = display.isPresenting ? 'EXIT VR' : 'ENTER VR';
+			};
 
-		}, false );
+			window.addEventListener( 'vrdisplaypresentchange', function () {
+
+				button.textContent = display.isPresenting ? 'EXIT VR' : 'ENTER VR';
+
+			}, false );
+
+		} else {
+
+			button.textContent = 'NO VR DISPLAY';			
+
+		}
 
 		return button;