Browse Source

VREffect and VRControls: Catch error retreiving VR Displays (#9825)

This can happen if the page is inside an iframe that doesn't have an `allowvr` attribute set or if permission is otherwise denied.
Brian Chirls 8 years ago
parent
commit
56a96d8880
2 changed files with 10 additions and 2 deletions
  1. 5 1
      examples/js/controls/VRControls.js
  2. 5 1
      examples/js/effects/VREffect.js

+ 5 - 1
examples/js/controls/VRControls.js

@@ -37,7 +37,11 @@ THREE.VRControls = function ( object, onError ) {
 
 
 	if ( navigator.getVRDisplays ) {
 	if ( navigator.getVRDisplays ) {
 
 
-		navigator.getVRDisplays().then( gotVRDisplays );
+		navigator.getVRDisplays().then( gotVRDisplays ).catch ( function () {
+
+			console.warn( 'THREE.VRControls: Unable to get VR Displays' );
+
+		} );
 
 
 	}
 	}
 
 

+ 5 - 1
examples/js/effects/VREffect.js

@@ -42,7 +42,11 @@ THREE.VREffect = function ( renderer, onError ) {
 
 
 	if ( navigator.getVRDisplays ) {
 	if ( navigator.getVRDisplays ) {
 
 
-		navigator.getVRDisplays().then( gotVRDisplays );
+		navigator.getVRDisplays().then( gotVRDisplays ).catch ( function () {
+
+			console.warn( 'THREE.VREffect: Unable to get VR Displays' );
+
+		} );
 
 
 	}
 	}