startMaterial method

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

Implementation

startMaterial(name, libraries) {
  var previous = this._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(this.materials, previous.index, 1);
  }

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

  this.materials.add(material);

  return material;
}