Browse Source

New Error Reporting:
- Checks for ASCII and Version are done in the parse method instead of the load method.
- Load will properly forward errors to passed in onError functions.

Kyle-Larson 8 years ago
parent
commit
d011b95824
2 changed files with 32 additions and 12 deletions
  1. 29 12
      examples/js/loaders/FBXLoader2.js
  2. 3 0
      examples/webgl_loader_fbx.html

+ 29 - 12
examples/js/loaders/FBXLoader2.js

@@ -59,23 +59,22 @@
 
 			this.fileLoader.load( url, function ( text ) {
 
-				if ( ! isFbxFormatASCII( text ) ) {
+				try {
 
-					console.error( 'FBXLoader: FBX Binary format not supported.' );
-					self.manager.itemError( url );
-					return;
+					var scene = self.parse( text, resourceDirectory );
+					onLoad( scene );
 
-				}
-				if ( getFbxVersion( text ) < 7000 ) {
+				} catch ( error ) {
 
-					console.error( 'FBXLoader: FBX version not supported for file at ' + url + ', FileVersion: ' + getFbxVersion( text ) );
-					self.manager.itemError( url );
-					return;
+					window.setTimeout( function () {
 
-				}
+						if ( onError ) onError( error );
 
-				var scene = self.parse( text, resourceDirectory );
-				onLoad( scene );
+						self.manager.itemError( url );
+
+					}, 0 );
+
+				}
 
 			}, onProgress, onError );
 
@@ -93,6 +92,24 @@
 
 			var loader = this;
 
+			if ( ! isFbxFormatASCII( FBXText ) ) {
+
+				throw new Error( 'FBXLoader: FBX Binary format not supported.' );
+				self.manager.itemError( url );
+				return;
+
+				//TODO: Support Binary parsing.  Hopefully in the future,
+				//we call var FBXTree = new BinaryParser().parse( FBXText );
+
+			}
+			if ( getFbxVersion( FBXText ) < 7000 ) {
+
+				throw new Error( 'FBXLoader: FBX version not supported for file at ' + url + ', FileVersion: ' + getFbxVersion( text ) );
+				self.manager.itemError( url );
+				return;
+
+			}
+
 			var FBXTree = new TextParser().parse( FBXText );
 
 			var connections = parseConnections( FBXTree );

+ 3 - 0
examples/webgl_loader_fbx.html

@@ -92,6 +92,9 @@
 				};
 
 				var onError = function( xhr ) {
+
+					console.error( xhr );
+
 				};
 
 				var loader = new THREE.FBXLoader( manager );