startMaterial method

dynamic startMaterial(
  1. dynamic name,
  2. dynamic libraries
)

Implementation

startMaterial(name, libraries) {
  var previous = _finalize(false);

  // New usemtl declaration overwrites an inherited material, except if faces were declared
  // after the material, then it must be preserved for proper MultiMaterial continuation.
  if (previous != null && (previous.inherited || previous.groupCount <= 0)) {
    splice(materials, previous.index, 1);
  }

  var material = ParseStateMaterial({
    "index": materials.length,
    "name": name ?? '',
    "mtllib": (libraries is List && libraries.isNotEmpty ? libraries[libraries.length - 1] : ''),
    "smooth": (previous != null ? previous.smooth : smooth),
    "groupStart": (previous != null ? previous.groupEnd : 0),
    "groupEnd": -1,
    "groupCount": -1,
    "inherited": false
  });

  materials.add(material);

  return material;
}