parseGeometryPrimitive method

Map<String, dynamic> parseGeometryPrimitive(
  1. XmlElement xml
)

Implementation

Map<String, dynamic> parseGeometryPrimitive(XmlElement xml ) {
  final Map<String,dynamic> primitive = {
    'type': xml.name.local,
    'material': xml.getAttribute( 'material' ),
    'count': int.parse( xml.getAttribute( 'count' )! ),
    'inputs': <String,dynamic>{},
    'stride': 0,
    'hasUV': false
  };

  for (final child in xml.descendantElements) {
    switch ( child.name.local ) {
      case 'input':
        final id = parseId( child.getAttribute( 'source' )! );
        final semantic = child.getAttribute( 'semantic' )!;
        final offset = int.parse( child.getAttribute( 'offset' )! );
        final set = int.parse( child.getAttribute( 'set' ) ?? '0');
        final String inputname = ( set > 0 ? semantic + set.toString() : semantic );
        primitive['inputs'][ inputname ] = { 'id': id, 'offset': offset };
        primitive['stride'] = math.max<int>( primitive['stride'], offset + 1 );
        if ( semantic == 'TEXCOORD' ) primitive['hasUV'] = true;
        break;
      case 'vcount':
        primitive['vcount'] = parseInts( child.innerText );
        break;
      case 'p':
        primitive['p'] = parseInts( child.innerText );
        break;
    }
  }

  return primitive;
}