浏览代码

Propagate error during loading of STL files via onError callback

Matthias Baumann 7 年之前
父节点
当前提交
ca6eb12182
共有 1 个文件被更改,包括 14 次插入1 次删除
  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 );