Browse Source

WebVR.js: Clean up.

Mr.doob 7 years ago
parent
commit
d782402955
1 changed files with 6 additions and 8 deletions
  1. 6 8
      examples/js/vr/WebVR.js

+ 6 - 8
examples/js/vr/WebVR.js

@@ -11,6 +11,8 @@ var WEBVR = {
 
 
 		function showEnterVR() {
 		function showEnterVR() {
 
 
+			button.style.display = '';
+
 			button.style.cursor = 'pointer';
 			button.style.cursor = 'pointer';
 			button.style.left = 'calc(50% - 50px)';
 			button.style.left = 'calc(50% - 50px)';
 			button.style.width = '100px';
 			button.style.width = '100px';
@@ -21,6 +23,8 @@ var WEBVR = {
 
 
 		function showVRNotFound() {
 		function showVRNotFound() {
 
 
+			button.style.display = '';
+
 			button.style.cursor = 'auto';
 			button.style.cursor = 'auto';
 			button.style.left = 'calc(50% - 75px)';
 			button.style.left = 'calc(50% - 75px)';
 			button.style.width = '150px';
 			button.style.width = '150px';
@@ -32,6 +36,7 @@ var WEBVR = {
 		if ( 'getVRDisplays' in navigator ) {
 		if ( 'getVRDisplays' in navigator ) {
 
 
 			var button = document.createElement( 'button' );
 			var button = document.createElement( 'button' );
+			button.style.display = 'none';
 			button.style.position = 'absolute';
 			button.style.position = 'absolute';
 			button.style.bottom = '20px';
 			button.style.bottom = '20px';
 			button.style.border = '1px solid #fff';
 			button.style.border = '1px solid #fff';
@@ -44,16 +49,12 @@ var WEBVR = {
 			button.style.textAlign = 'center';
 			button.style.textAlign = 'center';
 			button.style.zIndex = '999';
 			button.style.zIndex = '999';
 
 
-			showVRNotFound();
-
 			window.addEventListener( 'vrdisplayconnect', function ( event ) {
 			window.addEventListener( 'vrdisplayconnect', function ( event ) {
 
 
-				console.log( event.display.isConnected );
+				showEnterVR();
 
 
 				var display = event.display;
 				var display = event.display;
 
 
-				showEnterVR();
-
 				button.onclick = function () {
 				button.onclick = function () {
 
 
 					display.isPresenting ? display.exitPresent() : display.requestPresent( [ { source: renderer.domElement } ] );
 					display.isPresenting ? display.exitPresent() : display.requestPresent( [ { source: renderer.domElement } ] );
@@ -66,9 +67,6 @@ var WEBVR = {
 
 
 			window.addEventListener( 'vrdisplaydisconnect', function ( event ) {
 			window.addEventListener( 'vrdisplaydisconnect', function ( event ) {
 
 
-				console.log( event );
-				console.log( event.display.isConnected );
-
 				showVRNotFound();
 				showVRNotFound();
 
 
 				button.onclick = null;
 				button.onclick = null;