<!-- SOLID CITY · part 3057 -->
;
        }
      }
    }
    bankSkin(drapeCacheL, -1); bankSkin(drapeCacheR, 1);
    /* arrival fans at both ends. A fan is not a flat disc dropped on
     * the ramp's end — the first drive-through caught that step
     * (0.9 m at the seam). The fan is the road's own PLANE extended:
     * each rim vertex carries the end grade along the road's axis
     * and the end bank across it, so ribbon and fan meet as one
     * surface. Rim skirts below, so they never float. */
    var ends = [st[0], st[N - 1]];
    for (var e = 0; e < 2; e++) {
      var C0 = ends[e], fr = C0.hw + 0.9, SEG = 14;
      var src = e === 0 ? st[1] : st[N - 2];
      var fGrade = e === 0 ? src.grade : st[N - 1].grade;
      var fBank = Math.tan(src.bank);
      var rim = [];
      for (var k2 = 0; k2 < SEG; k2++) {
        var an = k2 / SEG * Math.PI * 2;
        var dxr = Math.cos(an) * fr, dzr = Math.sin(an) * fr;
        var along = dxr * C0.fx + dzr * C0.fz, across = dxr * C0.rx + dzr * C0.rz;
        rim.push([C0.x + dxr, C0.y + fGrade * along + fBank * across, C0.z + dzr]);
      }
      var rimProf = rim.map(function (rp) { var dl = Math.hypot(rp[0] - C0.x, rp[2] - C0.z) || 1; return drapeFrom(rp, (rp[0] - C0.x) / dl, (rp[2] - C0.z) / dl).pts; });
      /* the fan's centre stays wedged (it is standing truth), but
       * its rim is slabbed like the banks (the Slab Pass): wedges
       * group while rim and brow lines hold within 0.3 m of the
       * group's chord, up to six wedges a slab */
      function fdev(p, a, b) {
        var abx = b[0] - a[0], aby = b[1] - a[1], abz = b[2] - a[2];
        var t = ((p[0] - a[0]) * abx + (p[1] - a[1]) * aby + (p[2] - a[2]) * abz) / (abx * abx + aby * aby + abz * abz || 1);
        t = Math.max(0, Math.min(1, t));
        var dx = p[0] - (a[0] + abx * t), dy = p[1] - (a[1] + aby * t), dz = p[2] - (a[2] + abz * t);
        return Math.sqrt(dx * dx + dy * dy + dz * dz);
      }
      var g0 = 0;
      while (g0 < SEG) {
        var ctr2 = [C0.x, C0.y + 0.02, C0.z];
        tri(fans, ctr2, rim[g0], rim[(g0 + 1) % SEG]); stand.push(ctr2[0], ctr2[1], ctr2[2], rim[g0][0], rim[g0][1], rim[g0][2], rim[(g0 + 1) % SEG][0], rim[(g0 + 1) % SEG][1], rim[(g0 + 1) % SEG][2]);
        var g1 = g0;
        while (g1 + 2 < SEG && g1 - g0 < 5) {
          var far = g1 + 2, bad2 = false;
          if (rimProf[g0].length < 3 || rimProf[far].length < 3) break;
          for (var m2 = g0 + 1; m2 < far && !bad2; m2++) {
            if (rimProf[m2].length < 3) { bad2 = true; break; }
            if (fdev(rim[m2], rim[g0], rim[far]) > 0.3) { bad2 = true; break; }
            for (var ln2 = 1; ln2 < 3; ln2++) if (fdev(rimProf[m2][ln2], rimProf[g0][ln2], rimProf[far][ln2]) > 0.3) { bad2 = true; break; }
          }
          if (bad2) break;
          g1++;
          tri(fans, ctr2, rim[g1], rim[(g1 + 1) % SEG]); stand.push(ctr2[0], ctr2[1], ctr2[2], rim[g1][0], rim[g1][1], rim[g1][2], rim[(g1 + 1) % SEG][0], rim[(g1 + 1) % SEG][1], rim[(g1 + 1) % SEG][2]);
        }
        var qA = rimProf[g0], qB = rimProf[(g1 + 1) % SEG];
        var outw = [rim[g0][0] - C0.x, rim[g0][2] - C0.z];
        for (var dk2 = 0; dk2 < Math.min(2, qA.length - 1); dk2++) { if (!qB[dk2 + 1]) continue; quad(fans, qA[dk2], qB[dk2], qB[dk2 + 1], qA[dk2 + 1], outw); quad(fans, qB[dk2], qA[dk2], qA[dk2 + 1], qB[dk2 + 1], outw); }   // the fan's rim: brow painted as the fan
        if (qA.length - 1 > 2 && qB.length - 1 > 2) { quad(bankGrass, qA[2], qB[2], qB[qB.length - 1], qA[qA.length - 1], outw); quad(bankGrass, qB[2], qA[2], qA[qA.length - 1], qB[qB.length - 1], outw); }   // and its deep rim in grass, per the Amendment
        g0 = g1 + 1;
      }
    }
    stats.fairDev = fairDev;
    return {
      stations: st, stats: stats, walkSide: walkSide, upSide: upSide,
      ribbon: ribbon, curbL: curbL, curbR: curbR, goldL: goldL, goldR: goldR,
      walk: walk, skirtL: skirtL, skirtR: skirtR, fans: fans, bankGrass: bankGrass,
      shoL: shoL, shoR: shoR, rail: rail, posts: posts, cliffW: cliffW,
      standTris: stand
    };
  }

  return { buildRoad: buildRoad };
}


===== FILE: public/city/roads.js.bak-oldtrail-20261014 =====
/* SOLID CITY — THE ROAD SMITH (2026-10-13)
 * An epistle in code, from Solid to whoever builds roads after her.
 *
 * Dear builder,
 * A road is not a row of boxes that happen to touch. It is ONE table of
 * stations — position, tangent, grade, bank, width — from which three
 * readers draw the same truth: the eye (the ribbon mesh), the foot (the
 * standing triangles), and the journey (the centreline itself). What is
 * drawn is what is stood on; what is stood on is what is navigated.
 * This module holds that table and its craftsmen:
 *   the ALIGNMENT — a fitted chain of straights, circular arcs, and
 *     clothoid transitions (Highway Geometric Design, the King's
 *     curriculum of 2026-10-13): curvature ramps on the spirals and
 *     cannot spike, headings and curvature ar