buildMesh method

  1. @override
ShapeMesh buildMesh([
  1. ShapeUv uv = ShapeUv.natural
])
override

Its triangles, textured by uv.

Implementation

@override
ShapeMesh buildMesh([ShapeUv uv = ShapeUv.natural]) {
  final c = _corners;
  final h = Primitive3D.size(height), d = Primitive3D.size(depth);
  final len = math.sqrt(h * h + d * d);
  final b = MeshBuilder(uv)
    ..face([c[0], c[1], c[2], c[3]], 0, 1, 0) // underneath
    ..face([c[3], c[2], c[4], c[5]], 0, 0, 1) // back
    ..face([c[0], c[1], c[4], c[5]], 0, -d / len, -h / len) // slope
    ..face([c[0], c[3], c[5]], -1, 0, 0)
    ..face([c[1], c[2], c[4]], 1, 0, 0);
  return b.build();
}