Explorar o código

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 %!s(int64=8) %!d(string=hai) anos
pai
achega
56a96d8880
Modificáronse 2 ficheiros con 10 adicións e 2 borrados
  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 ) {
 
-		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 ) {
 
-		navigator.getVRDisplays().then( gotVRDisplays );
+		navigator.getVRDisplays().then( gotVRDisplays ).catch ( function () {
+
+			console.warn( 'THREE.VREffect: Unable to get VR Displays' );
+
+		} );
 
 	}