瀏覽代碼

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 年之前
父節點
當前提交
56a96d8880
共有 2 個文件被更改,包括 10 次插入2 次删除
  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' );
+
+		} );
 
 	}