build method

void build(
  1. List<Polygon> polygons
)

Implementation

void build(List<Polygon> polygons) {
  if (polygons.isEmpty){
    return;
  }
  plane ??= polygons[0].plane.clone();
  final List<Polygon> front = [];
  final List<Polygon> back = [];

  for (int i = 0; i < polygons.length; i++) {
    plane?.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  }
  if (front.isNotEmpty) {
    this.front ??= Node();
    this.front!.build(front);
  }
  if (back.isNotEmpty) {
    this.back ??= Node();
    this.back!.build(back);
  }
}