message: improve fillEdges in mesh edge smoothing
  sort boundary vertices
  limit the length added edges
diff: @@ -480,20 +480,43 @@ export namespace Mesh {
  const AngleThreshold = degToRad(120);
  const added = new Set<number>();
  - borderNeighboursMap.forEach((nbs, v) => {
  - if (nbs.length >= 2) {
  + const indices = Array.from(borderNeighboursMap.keys())
  + .filter(v => borderNeighboursMap.get(v)!.length < 2)
  + .map(v => {
  + const bnd = borderNeighboursMap.get(v)!;
  +
  + Vec3.fromArray(vA, vb, v * 3);
  + Vec3.fromArray(vB, vb, bnd[0] * 3);
  + Vec3.fromArray(vC, vb, bnd[1] * 3);
  + Vec3.sub(vAB, vB, vA);
  + Vec3.sub(vAC, vC, vA);
  +
  + return [v, Vec3.angle(vAB, vAC)];
  + });
  +
  + // start with the smallest angle
  + indices.sort(([, a], [, b]) => a - b);
  +
  + for (const [v, angle] of indices) {
  + if (added.has(v) || angle > AngleThreshold) continue;
  +
  + const nbs = borderNeighboursMap.get(v)!;
  if (neighboursMap[nbs[0]].includes(nbs[1]) &&
  !borderNeighboursMap.get(nbs[0])?.includes(nbs[1])
  - ) return;
  + ) continue;
  Vec3.fromArray(vA, vb, v * 3);
  - Vec3.fromArray(vAN, nb, v * 3);
  Vec3.fromArray(vB, vb, nbs[0] * 3);
  Vec3.fromArray(vC, vb, nbs[1] * 3);
  Vec3.sub(vAB, vB, vA);
  Vec3.sub(vAC, vC, vA);
  Vec3.add(vABC, vAB, vAC);
  + // NOTE: this will only work for Meshes from Marching cubes
  + // do we need a general solution?
  + // 1.41 ~= diagonal of a unit square
  + if (Vec3.squaredDistance(vA, vB) >= 1.42) continue;
  +
  let add = false;
  for (const nb of neighboursMap[v]) {
  if (nbs.includes(nb)) continue;
  @@ -505,15 +528,9 @@ export namespace Mesh {
  break;
  }
  }
  + if (!add) continue;
  - let count = 0;
  - if (add) {
  - if (added.has(v)) count += 1;
  - if (added.has(nbs[0])) count += 1;
  - if (added.has(nbs[1])) count += 1;
  - }
  -
  - if (add && count < 2 && Vec3.angle(vAB, vAC) < AngleThreshold) {
  + Vec3.fromArray(vAN, nb, v * 3);
  Vec3.triangleNormal(vN, vA, vB, vC);
  if (Vec3.dot(vN, vAN) > 0) {
  ChunkedArray.add3(index, v, nbs[0], nbs[1]);
  @@ -523,8 +540,6 @@ export namespace Mesh {
  added.add(v); added.add(nbs[0]); added.add(nbs[1]);
  newTriangleCount += 1;
  }
  - }
  - });
  const newIb = ChunkedArray.compact(index);
  mesh.triangleCount = newTriangleCount;
  @@ -584,6 +599,7 @@ export namespace Mesh {
  export function smoothEdges(mesh: Mesh, iterations: number) {
  trimEdges(mesh, getNeighboursMap(mesh));
  +
  for (let k = 0; k < 10; ++k) {
  const oldTriangleCount = mesh.triangleCount;
  const edgeCounts = getEdgeCounts(mesh);
  