Explorar o código

display offersession promise failure instead of showing console errors (#27492)

* display offersession promise failure instead of showing console errors

* change log() to warn() for offersession handler
Rik Cabanier hai 1 ano
pai
achega
a4fbc07b38

+ 12 - 2
examples/jsm/webxr/ARButton.js

@@ -107,7 +107,12 @@ class ARButton {
 					if ( navigator.xr.offerSession !== undefined ) {
 
 						navigator.xr.offerSession( 'immersive-ar', sessionInit )
-							.then( onSessionStarted );
+							.then( onSessionStarted )
+							.catch( ( err ) => {
+
+								console.warn( err );
+
+							} );
 
 					}
 
@@ -118,7 +123,12 @@ class ARButton {
 			if ( navigator.xr.offerSession !== undefined ) {
 
 				navigator.xr.offerSession( 'immersive-ar', sessionInit )
-					.then( onSessionStarted );
+					.then( onSessionStarted )
+					.catch( ( err ) => {
+
+						console.warn( err );
+
+					} );
 
 			}
 

+ 12 - 2
examples/jsm/webxr/VRButton.js

@@ -73,7 +73,12 @@ class VRButton {
 					if ( navigator.xr.offerSession !== undefined ) {
 
 						navigator.xr.offerSession( 'immersive-vr', sessionInit )
-							.then( onSessionStarted );
+							.then( onSessionStarted )
+							.catch( ( err ) => {
+
+								console.warn( err );
+
+							} );
 
 					}
 
@@ -84,7 +89,12 @@ class VRButton {
 			if ( navigator.xr.offerSession !== undefined ) {
 
 				navigator.xr.offerSession( 'immersive-vr', sessionInit )
-					.then( onSessionStarted );
+					.then( onSessionStarted )
+					.catch( ( err ) => {
+
+						console.warn( err );
+
+					} );
 
 			}
 

+ 12 - 2
examples/jsm/webxr/XRButton.js

@@ -77,7 +77,12 @@ class XRButton {
 					if ( navigator.xr.offerSession !== undefined ) {
 
 						navigator.xr.offerSession( mode, sessionOptions )
-							.then( onSessionStarted );
+							.then( onSessionStarted )
+							.catch( ( err ) => {
+
+								console.warn( err );
+
+							} );
 
 					}
 
@@ -88,7 +93,12 @@ class XRButton {
 			if ( navigator.xr.offerSession !== undefined ) {
 
 				navigator.xr.offerSession( mode, sessionOptions )
-					.then( onSessionStarted );
+					.then( onSessionStarted )
+					.catch( ( err ) => {
+
+						console.warn( err );
+
+					} );
 
 			}