Browse Source

Propagate error during loading of STL files via onError callback

Matthias Baumann 7 năm trước cách đây
mục cha
commit
ca6eb12182
1 tập tin đã thay đổi với 14 bổ sung1 xóa
  1. 14 1
      examples/js/loaders/STLLoader.js

+ 14 - 1
examples/js/loaders/STLLoader.js

@@ -48,7 +48,20 @@ THREE.STLLoader.prototype = {
 		loader.setResponseType( 'arraybuffer' );
 		loader.load( url, function ( text ) {
 
-			onLoad( scope.parse( text ) );
+		    try {
+
+				onLoad( scope.parse( text ) );
+
+			} catch ( exception ) {
+
+		        if ( onError ) {
+
+		            onError( exception );
+
+				}
+
+		    }
+
 
 		}, onProgress, onError );