parseAnimation method
dynamic
parseAnimation(
- XmlElement xml
Implementation
parseAnimation(XmlElement xml ) {
final Map<String,dynamic> data = {
'sources': {},
'samplers': {},
'channels': {}
};
bool hasChildren = false;
for (final child in xml.descendantElements ) {
String id;
switch ( child.name.local ) {
case 'source':
id = child.getAttribute( 'id' )!;
data['sources']![ id ] = parseSource( child );
break;
case 'sampler':
id = child.getAttribute( 'id' )!;
data['samplers']![ id ] = parseAnimationSampler( child );
break;
case 'channel':
id = child.getAttribute( 'target' )!;
data['channels']![ id ] = parseAnimationChannel( child );
break;
case 'animation':
parseAnimation( child );
hasChildren = true;
break;
default:
console.info( child );
}
}
if ( !hasChildren ) {
// since 'id' attributes can be optional, it's necessary to generate a UUID for unqiue assignment
library['animations']![ xml.getAttribute( 'id' ) ?? MathUtils.generateUUID() ] = data;
}
}