<!-- SOLID CITY · part 3672 -->
ion (e) { if (window.console) console.warn('[city] ward houses failed', e); });
}
window.CityWardHouses = { update: update, radar: radar, standY: standY };
setTimeout(load, 110);
})();


===== FILE: public/city/ward-houses-place.js.bak-w4w6-20261013 =====
/* ================================================================
   AN EPISTLE AT THE FIRST DOOR — THE WARD HOUSES PLACER

   Traveler, in Ward 2 the nation's first house now stands: the
   pilot, raised from VECTOR's factories on the King's word —
   one house first, examined, before the nation multiplies. This
   placer is its citizenship, and the two short joins' beside it:
   the pilot's floor and roof under the standing law, its walls
   under collision law (his wall meshes, grid-split in the hyper
   train's idiom), the joins' own surfaces connected to the
   city's movement as their designer intended, and the words
   spoken as you approach.

   The pilot's plot is the searcher's first lawful choice in
   Ward 2 — no hand moved it. Its door is glass, as drawn; you
   pass it as you pass the shop doors of Hyper City. Judge it
   with your eyes, as the King will.

   ADDENDUM, the same day: the King multiplied. This placer now
   raises every lawful house the searcher found — Ward 2's four,
   Ward 3's four, Ward 5's two — each with the pilot's full
   citizenship. Ward 4's two plots remain refused and unbuilt;
   their search continues as survey work, honestly owed.

   Written by the hand of Solid, his good King — 2026-10-13.
   ================================================================ */
(function () {
'use strict';
if (!window.SC || !SC.api) return;
var A = SC.api, S = A.S;
var H = { houses: [], joins: [], saidHouse: false, saidJoin: {}, saidStreet: {}, housePos: { x: -1056, z: -895 } };
var STREET = { 3: { x: -990, z: -812, name: 'WARD 3' }, 5: { x: -847, z: -987, name: 'WARD 5' } };
var LINK_MID = { 'W2-W3': { x: -1016, z: -842 }, 'W3-W4': { x: -944, z: -787 } };

function localUV(st, x, z) {
  var du = x - st.center[0], dv = z - st.center[2];
  return [du * st.ux + dv * st.uz, du * st.vx + dv * st.vz];
}
/* The joins' designer delivered their standing surfaces as raw triangle
 * geometry — "VISUAL GEOMETRY ONLY until stand/collision registry
 * integrated" — so this placer performs the integration he specified:
 * the exact triangles of each connector answer standY by barycentric
 * height, the same mathematics his measureConnector proves them by. */
function triHeight(tris, x, z) {
  // each tri: [ax, ay, az, bx, by, bz, cx, cy, cz] in world coordinates
  for (var i = 0; i < tris.length; i++) {
    var t = tris[i];
    var den = (t[5] - t[8]) * (t[0] - t[6]) + (t[6] - t[3]) * (t[2] - t[8]);
    if (Math.abs(den) < 1e-10) continue;
    var u = ((t[5] - t[8]) * (x - t[6]) + (t[6] - t[3]) * (z - t[8])) / den;
    var v = ((t[8] - t[2]) * (x - t[6]) + (t[0] - t[6]) * (z - t[8])) / den;
    var w = 1 - u - v;
    if (Math.min(u, v, w) < -1e-7) continue;
    return u * t[1] + v * t[4] + w * t[7];
  }
  return null;
}
function extractTris(geo) {
  var pos = geo.getAttribute('position'), idx = geo.getIndex(), tris = [];
  var n = idx ? idx.count : pos.count;
  for (var i = 0; i + 2 < n; i += 3) {
    var tri = [];
    for (var k = 0; k < 3; k++) {
      var vi = idx ? idx.getX(i + k) : i + k;
      tri.push(pos.getX(vi), pos.getY(vi), pos.getZ(vi));
    }
    tris.push(tri);
  }
  return tris;
}
function standY(x, z, py) {
  var best = -1000;
  for (var h = 0; h < H.houses.length; h++) {
    var hs = H.houses[h], st = hs.stand, uv = localUV(st, x, z), floor = st.center[1];
    var cand = [];
    if (Math.abs(uv[0]) <= 4 && Math.abs(uv[1]) <= 5) cand.push(floor);
    if (hs.roofTop && Math.abs(uv[0]) <= 4.35 && Math.abs(uv[1]) <= 5.35) cand.push(hs.roofTop);
    for (var i = 0; i < cand.length; i++) if ((py == null || cand[i] <= py + 1.6) && cand[i] > best) best = cand[i];
  }
  for (var j = 0; j < H.joins.length; j++) {
    var y = triHeight(H.joins[j], x, z);
    if (y != null && (py == null || y <= py + 1.6) && y > best) best = y;
  }
  return best;
}
function radar(rg, blip, flying) {
  if (!H.houses.length) return;
  blip(H.housePos.x, H.housePos.z, '#ffd27a', flying ? 3 : 6, flying ? '' : 'PILOT HOUSE');
  for (var h = 1; h < H.houses.length; h++) blip(H.houses[h].cx, H.houses[h].cz, '#ffd27a', 3, '');
  for (var k in LINK_MID) blip(LINK_MID[k].x, LINK_MID[k].z, '#ffd27a', 3, '');
}
function update(dt) {
  if (!H.houses.length) return;
  var dx = S.p.x - H.housePos.x, dz = S.p.z - H.housePos.z;
  if (!H.saidHouse && dx * dx + dz * dz < 150 * 150) {
    H.saidHouse = true;
    A.help('🏠 THE PILOT HOUSE — the nation\'s first dwelling, in Ward 2. Its door is glass; walk in, stand on its floor, examine its foundations. Nine more lawful houses now stand beside it.', 8);
  }
  for (var w in STREET) {
    if (H.saidStreet[w]) continue;
    var st = STREET[w], sx = S.p.x - st.x, sz = S.p.z - st.z;
    if (sx * 