computeGroups method

dynamic computeGroups(
  1. dynamic geometry
)

Implementation

computeGroups(geometry) {
  List<Map<String, int>> groups = [];

  Map<String, int>? group;
  var i;
  var materialIndex;

  var faces = geometry.faces;

  for (i = 0; i < faces.length; i++) {
    var face = faces[i];

    // materials

    if (face.materialIndex != materialIndex) {
      materialIndex = face.materialIndex;

      if (group != null) {
        group["count"] = (i * 3) - group["start"];
        groups.add(group);
      }

      group = {"start": i * 3, "materialIndex": materialIndex};
    }
  }

  if (group != null) {
    group["count"] = (i * 3) - group["start"];
    groups.add(group);
  }

  this.groups = groups;
}