|
@@ -3814,6 +3814,32 @@ THREE.ColladaLoader.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // convert the parser error element into text with each child elements text
|
|
|
+ // separated by new lines.
|
|
|
+ function parserErrorToText( parserError ) {
|
|
|
+
|
|
|
+ var result = '';
|
|
|
+ var stack = [ parserError ];
|
|
|
+ while ( stack.length ) {
|
|
|
+
|
|
|
+ var node = stack.shift();
|
|
|
+ if ( node.nodeType === Node.TEXT_NODE ) {
|
|
|
+
|
|
|
+ result += node.textContent;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ result += '\n';
|
|
|
+ stack.push.apply( stack, node.childNodes );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return result.trim();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if ( text.length === 0 ) {
|
|
|
|
|
|
return { scene: new THREE.Scene() };
|
|
@@ -3824,6 +3850,28 @@ THREE.ColladaLoader.prototype = {
|
|
|
|
|
|
var collada = getElementsByTagName( xml, 'COLLADA' )[ 0 ];
|
|
|
|
|
|
+ var parserError = xml.getElementsByTagName( 'parsererror' )[ 0 ];
|
|
|
+ if ( parserError !== undefined ) {
|
|
|
+
|
|
|
+ // Chrome will return parser error with a div in it
|
|
|
+ var errorElement = getElementsByTagName( parserError, 'div' )[ 0 ];
|
|
|
+ var errorText;
|
|
|
+ if ( errorElement ) {
|
|
|
+
|
|
|
+ errorText = errorElement.textContent;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ errorText = parserErrorToText( parserError );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ console.error( 'ColladaLoader: Failed to parse collada file.\n', errorText );
|
|
|
+
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// metadata
|
|
|
|
|
|
var version = collada.getAttribute( 'version' );
|