未验证 提交 5a0972ab 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #19319 from Mugen87/dev49

ColladaLoader: Fix parsing of nested animations.
......@@ -217,6 +217,8 @@ THREE.ColladaLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
channels: {}
};
var hasChildren = false;
for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
var child = xml.childNodes[ i ];
......@@ -242,6 +244,12 @@ THREE.ColladaLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
data.channels[ id ] = parseAnimationChannel( child );
break;
case 'animation':
// hierarchy of related animations
parseAnimation( child );
hasChildren = true;
break;
default:
console.log( child );
......@@ -249,7 +257,13 @@ THREE.ColladaLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
}
library.animations[ xml.getAttribute( 'id' ) ] = data;
if ( hasChildren === false ) {
// since 'id' attributes can be optional, it's necessary to generate a UUID for unqiue assignment
library.animations[ xml.getAttribute( 'id' ) || THREE.MathUtils.generateUUID() ] = data;
}
}
......
......@@ -257,6 +257,8 @@ ColladaLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
channels: {}
};
var hasChildren = false;
for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
var child = xml.childNodes[ i ];
......@@ -282,6 +284,12 @@ ColladaLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
data.channels[ id ] = parseAnimationChannel( child );
break;
case 'animation':
// hierarchy of related animations
parseAnimation( child );
hasChildren = true;
break;
default:
console.log( child );
......@@ -289,7 +297,13 @@ ColladaLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
}
library.animations[ xml.getAttribute( 'id' ) ] = data;
if ( hasChildren === false ) {
// since 'id' attributes can be optional, it's necessary to generate a UUID for unqiue assignment
library.animations[ xml.getAttribute( 'id' ) || MathUtils.generateUUID() ] = data;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册