parseMaterialIndices method

dynamic parseMaterialIndices(
  1. Map MaterialNode
)

Implementation

parseMaterialIndices(Map MaterialNode) {
  var mappingType = MaterialNode["MappingInformationType"];
  var referenceType = MaterialNode["ReferenceInformationType"];

  if (mappingType == 'NoMappingInformation') {
    return {
      "dataSize": 1,
      "buffer": [0],
      "indices": [0],
      "mappingType": 'AllSame',
      "referenceType": referenceType
    };
  }

  var materialIndexBuffer = MaterialNode["Materials"]["a"];

  // Since materials are stored as indices, there's a bit of a mismatch between FBX and what
  // we expect.So we create an intermediate buffer that points to the index in the buffer,
  // for conforming with the other functions we've written for other data.
  var materialIndices = [];

  for (var i = 0; i < materialIndexBuffer.length; ++i) {
    materialIndices.add(i);
  }

  return {
    "dataSize": 1,
    "buffer": materialIndexBuffer,
    "indices": materialIndices,
    "mappingType": mappingType,
    "referenceType": referenceType
  };
}