parseMaterial method

dynamic parseMaterial(
  1. Map<String, dynamic> materialNode,
  2. Map textureMap
)

Implementation

parseMaterial(Map<String, dynamic> materialNode, Map textureMap) {
  var id = materialNode["id"];
  var name = materialNode["attrName"];
  var type = materialNode["ShadingModel"];

  // Case where FBX wraps shading model in property object.
  if (type is! String) {
    type = type.value;
  }

  // Ignore unused materials which don't have any connections.
  if (!connections.containsKey(id)) return null;

  Map parameters = parseParameters(materialNode, textureMap, id);

  var material;

  switch (type.toLowerCase()) {
    case 'phong':
      material = MeshPhongMaterial();
      break;
    case 'lambert':
      material = MeshLambertMaterial();
      break;
    default:
      print('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.$type');
      material = MeshPhongMaterial();
      break;
  }

  material.setValues(parameters);
  material.name = name;

  return material;
}