Browse Source

ColladaLoader tried to access children-less object childrens. Changend JSONLoader try/catch code (better error logs this way).

Mr.doob 13 years ago
parent
commit
3623a444a3
2 changed files with 8 additions and 10 deletions
  1. 4 6
      src/extras/loaders/ColladaLoader.js
  2. 4 4
      src/extras/loaders/JSONLoader.js

+ 4 - 6
src/extras/loaders/ColladaLoader.js

@@ -164,15 +164,11 @@ THREE.ColladaLoader = function () {
 
 	function parseAsset () {
 
-		var elements = COLLADA.evaluate("//dae:asset",
-										COLLADA,
-										_nsResolver,
-										XPathResult.ORDERED_NODE_ITERATOR_TYPE,
-										null) ;
+		var elements = COLLADA.evaluate( '//dae:asset', COLLADA, _nsResolver, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
 
 		var element = elements.iterateNext();
 
-		if ( element ) {
+		if ( element && element.children ) {
 
 			for ( var i = 0; i < element.children.length; i ++ ) {
 
@@ -2742,6 +2738,8 @@ THREE.ColladaLoader = function () {
 
 	ColorOrTexture.prototype.parseTexture = function ( element ) {
 
+		if ( ! element.children ) return this;
+
 		// This should be supported by Maya, 3dsMax, and MotionBuilder
 
 		if ( element.children[0] && element.children[0].nodeName === 'extra' ) {

+ 4 - 4
src/extras/loaders/JSONLoader.js

@@ -52,16 +52,15 @@ THREE.JSONLoader.prototype.loadAjaxJSON = function( context, url, callback, text
 
 					var jsonObject = JSON.parse( xhr.responseText );
 
-					context.createModel( jsonObject, callback, texturePath );
-					context.onLoadComplete();
-
 				} catch ( error ) {
 
-					console.error( error );
 					console.warn( "DEPRECATED: [" + url + "] seems to be using old model format" );
 
 				}
 
+				context.createModel( jsonObject, callback, texturePath );
+				context.onLoadComplete();
+
 			} else {
 
 				console.error( "Couldn't load [" + url + "] [" + xhr.status + "]" );
@@ -396,6 +395,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 				dstVertices = geometry.morphTargets[ i ].vertices;
 				srcVertices = json.morphTargets [ i ].vertices;
 
+
 				for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
 
 					x = srcVertices[ v ] * scale;