extrudeFace method
Pushes face out along its own normal by distance, walling in the gap.
Rebuilt rather than rewired, and it is the one operation still shaped
like the spike. mesh-23 does it in place; what is here is enough to
measure the pipeline and to give the viewport something to draw, and it
returns a fresh mesh rather than editing this one.
Implementation
EditMesh extrudeFace(int face, double distance) {
final loop = verticesOf(face);
final offset = normalOf(face)..scale(distance);
final points = <Vector3>[
for (var vertex = 0; vertex < _vertexSlots; vertex++)
if (_vertexAlive[vertex] != 0) positionOf(vertex),
];
final base = points.length;
final lifted = <int>[for (var i = 0; i < loop.length; i++) base + i];
for (final vertex in loop) {
points.add(positionOf(vertex)..add(offset));
}
final rebuilt = <List<int>>[
for (var f = 0; f < _faceSlots; f++)
if (_faceAlive[f] != 0 && f != face) verticesOf(f),
lifted,
for (var i = 0; i < loop.length; i++)
<int>[
loop[i],
loop[(i + 1) % loop.length],
lifted[(i + 1) % loop.length],
lifted[i],
],
];
return EditMesh.fromFaces(points, rebuilt);
}