<!-- SOLID CITY · part 2486 -->
e Ancestors' Homes: Hawaiian families living on the green benches around the Ancestral Roads — hale, plantation homes, and Dickey roofs among the taro and the trees." }, agl: false });
    return w;
  };
}
function triYAt(t, o, x, z) {
  var ax = t[o], ay = t[o + 1], az = t[o + 2], bx = t[o + 3], by = t[o + 4], bz = t[o + 5], cx = t[o + 6], cy = t[o + 7], cz = t[o + 8];
  var den = (bz - cz) * (ax - cx) + (cx - bx) * (az - cz);
  if (Math.abs(den) < 1e-9) return null;
  var w0 = ((bz - cz) * (x - cx) + (cx - bx) * (z - cz)) / den;
  var w1 = ((cz - az) * (x - cx) + (ax - cx) * (z - cz)) / den;
  var w2 = 1 - w0 - w1;
  if (w0 < -0.01 || w1 < -0.01 || w2 < -0.01) return null;
  return w0 * ay + w1 * by + w2 * cy;
}
function standY(x, z, py) {
  var rects = M.rects; if (!rects) return -1000;
  var best = -1000;
  for (var i = 0; i < rects.length; i++) {
    var r = rects[i], dx = x - r.cx, dz = z - r.cz;
    var lx = dx * r.cos - dz * r.sin, lz = dx * r.sin + dz * r.cos;
    if (Math.abs(lx - r.lx) <= r.hw && Math.abs(lz - r.lz) <= r.hd) {
      if (py == null || r.y <= py + 1.6) { if (r.y > best) best = r.y; }
    }
  }
  // the pitched surfaces (roads, driveways, paths, pads) — the same reading
  // the ward joins get: the highest triangle that passes the walker's gate
  if (M.triIx) {
    var bx = Math.floor(x / 16), bz = Math.floor(z / 16);
    for (var gx = bx - 1; gx <= bx + 1; gx++) for (var gz = bz - 1; gz <= bz + 1; gz++) {
      var cell = M.triIx[gx + ':' + gz]; if (!cell) continue;
      for (var ci = 0; ci < cell.length; ci++) {
        var ty = triYAt(M.tris, cell[ci], x, z);
        if (ty == null) continue;
        if (py == null || ty <= py + 1.6) { if (ty > best) best = ty; }
      }
    }
  }
  return best;
}
function load() {
  M.state = 'loading';
  var ga = A.groundAt || (typeof groundAt === 'function' ? groundAt : null);
  var p; try { p = import('/city/mountain-homes.js?v=20261013b'); } catch (e) { p = Promise.reject(e); }
  p.then(function (mod) {
    var make = mod.createMountainHomes || mod.default;
    var g = make({ THREE: A.T, groundAt: ga });
    A.world.add(g); M.group = g; M.state = 'ready';
    M.rects = (g.userData && g.userData.standRects) || null;
    M.tris = (g.userData && g.userData.standTris) || null;
    if (M.tris) {
      M.triIx = {};
      for (var ti = 0; ti + 8 < M.tris.length; ti += 9) {
        var tcx = (M.tris[ti] + M.tris[ti + 3] + M.tris[ti + 6]) / 3, tcz = (M.tris[ti + 2] + M.tris[ti + 5] + M.tris[ti + 8]) / 3;
        var tk = Math.floor(tcx / 16) + ':' + Math.floor(tcz / 16);
        (M.triIx[tk] = M.triIx[tk] || []).push(ti);
      }
    }
    collide(g.userData || {}); hyperStop(); watchStop();
  }).catch(function (e) { M.state = 'failed'; try { console.warn('[city] Ancestors homes skipped:', e && e.message); } catch (x) {} });
}
function update(dt) {
  if (M.state === 'idle') { if (A.isBuilt && !A.isBuilt()) return; M.wait -= dt; if (M.wait <= 0) load(); return; }
  if (M.state !== 'ready' || document.hidden) return;
  var c = A.camera.position, d = Math.hypot(c.x + A.origin.x - POS.x, c.z + A.origin.z - POS.z);
  M.group.visible = d < 11000;
  if (S.mode === 'walk') {
    var pd = Math.hypot(S.p.x - POS.x, S.p.z - POS.z);
    if (pd < 420 && !M.said) { M.said = true; if (window.CityHyper && CityHyper.narrate) CityHyper.narrate("<b>Nā Hale o nā Kūpuna</b> — the Ancestors' Homes. 'Ohana compounds on the green benches; every door opens.", 7); }
    else if (pd > 700) M.said = false;
  }
}
function radar(g, blip, fl) { if (M.state === 'ready') blip(POS.x, POS.z, '#4a8a3a', fl ? 3 : 6, fl ? '' : 'HOMES'); }
window.CityMountainHomes = { update: update, radar: radar, pos: POS, standY: standY, state: function () { return M.state; }, group: function () { return M.group; } };
})();


===== FILE: public/city/mountain-homes-place.js.bak-roadbody-20261013 =====
/* Solid City — places NĀ HALE O NĀ KŪPUNA, THE ANCESTORS' HOMES (public/city/mountain-homes.js)
   on the green coastal benches around the Ancestral Roads, by order of the King:
   "We need to build homes for hawaiians."
   Lazy: imported after the city is built; any import/build error is caught and the city carries on.
   The module sites every home on the real terrain at runtime (placement law:
   gentle benches only, ledges and cliffs untouched, a driveway to every door).
   Adds: collision (userData.footprint, world-absolute), P.y-aware standY (floors,
   lanai, stairs), a radar marker 'HOMES', a Hyper Controller stop, and a Watch
   (GRAND TOUR) caption. One quiet line on first approach. */
(function () {
'use strict';
if (!window.SC || !SC.api) return;
var A = SC.api, S = A.S;
var POS = { x: 300, z: -1500 }, NAME = "Nā Hale o nā Kūpuna — The Ancestors' Homes";
var M = { state: 'idle', group: null, wait: 4.5, said: false, rects: null, tris: null, triIx: null };
function addBox(cx, cz, w, d, rot, y0, y1) {
  var nx = Math.max(1, Math.ceil(w / 2.5)), nz = Math.max(1, M