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
  };
}