triangles property

Iterable<MeshTriangle> get triangles

Iterates the mesh's triangles with their corner indices and positions.

The yielded positions are copies; mutating them does not touch the snapshot.

Implementation

Iterable<MeshTriangle> get triangles sync* {
  _requireTriangles('triangles');
  final count = triangleCount;
  for (var t = 0; t < count; t++) {
    final a = _cornerIndex(t * 3);
    final b = _cornerIndex(t * 3 + 1);
    final c = _cornerIndex(t * 3 + 2);
    yield MeshTriangle(t, a, b, c, _position(a), _position(b), _position(c));
  }
}