Răsfoiți Sursa

MaterialXLoader: improve onError handling (#27433)

hybridherbst 1 an în urmă
părinte
comite
299f53ff4e
1 a modificat fișierele cu 16 adăugiri și 2 ștergeri
  1. 16 2
      examples/jsm/loaders/MaterialXLoader.js

+ 16 - 2
examples/jsm/loaders/MaterialXLoader.js

@@ -141,6 +141,20 @@ class MaterialXLoader extends Loader {
 
 
 	load( url, onLoad, onProgress, onError ) {
 	load( url, onLoad, onProgress, onError ) {
 
 
+		const _onError = function ( e ) {
+
+			if ( onError ) {
+
+				onError( e );
+
+			} else {
+
+				console.error( e );
+
+			}
+
+		};
+
 		new FileLoader( this.manager )
 		new FileLoader( this.manager )
 			.setPath( this.path )
 			.setPath( this.path )
 			.load( url, async ( text ) => {
 			.load( url, async ( text ) => {
@@ -151,11 +165,11 @@ class MaterialXLoader extends Loader {
 
 
 				} catch ( e ) {
 				} catch ( e ) {
 
 
-					onError( e );
+					_onError( e );
 
 
 				}
 				}
 
 
-			}, onProgress, onError );
+			}, onProgress, _onError );
 
 
 		return this;
 		return this;