extrudedBox function

EditMesh extrudedBox()

A box with one face pushed out and the top of the tower narrowed.

Two extrusions rather than one, because a single one is symmetric enough to look right with a wall missing; the second gives the shape a silhouette that only closes if every wall of both is there.

Implementation

EditMesh extrudedBox() {
  final mesh = ParametricCuboid().toEditMesh();
  // Face 2 is the +Y one in the table the cuboid shares with the engine, so
  // the tower goes up — which is the direction a viewport frames best.
  final top = Selection.of(ElementLevel.face, <int>[2]);
  mesh.beginStep();
  extrudeFaces(mesh, top, distance: 0.7);
  extrudeFaces(mesh, top, distance: 0.5);
  scaleSelection(mesh, top, by: Vector3(0.45, 0.45, 0.45));
  mesh
    ..endStep()
    ..clearJournal();
  return mesh;
}