Explorar o código

WebVR: Testing a more raw approach.

Mr.doob %!s(int64=8) %!d(string=hai) anos
pai
achega
397fc18706
Modificáronse 2 ficheiros con 14 adicións e 15 borrados
  1. 0 6
      examples/js/vr/WebVR.js
  2. 14 9
      examples/webvr_cubes.html

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

@@ -18,12 +18,6 @@ var WEBVR = {
 
 	},
 
-	getDisplays: function () {
-
-		return navigator.getVRDisplays();
-
-	},
-
 	getMessage: function () {
 
 		var message;

+ 14 - 9
examples/webvr_cubes.html

@@ -130,15 +130,20 @@
 				controls = new THREE.VRControls( camera );
 				effect = new THREE.VREffect( renderer );
 
-				WEBVR.getDisplays()
-					.then( function( displays ) {
-						effect.setDisplay( displays[ 0 ] );
-						controls.setDisplay( displays[ 0 ] );
-						document.body.appendChild( WEBVR.getButton( effect ) );
-					} )
-					.catch( function() {
-						// no displays
-					} );
+				if ( navigator.getVRDisplays ) {
+
+					navigator.getVRDisplays()
+						.then( function ( displays ) {
+							effect.setVRDisplay( displays[ 0 ] );
+							controls.setVRDisplay( displays[ 0 ] );
+						} )
+						.catch( function () {
+							// no displays
+						} );
+
+					document.body.appendChild( WEBVR.getButton( effect ) );
+
+				}
 
 				renderer.domElement.addEventListener( 'mousedown', onMouseDown, false );
 				renderer.domElement.addEventListener( 'mouseup', onMouseUp, false );