<!-- NEW5 — TEST 5 · THE BEND AT THE HEART · part 440 -->
 name: 'Downtown — the 800', x: 0, z: 0, seed: 3 },
    { kind: 'suburb', name: 'Northbank Homes', x: -300, z: -1180, w: 700, d: 360, seed: 41 },
    { kind: 'suburb', name: 'Westfield Homes', x: -1230, z: 40, w: 460, d: 700, seed: 42 },
    { kind: 'towers', name: 'Canal District', x: 1150, z: -150, w: 580, d: 640, floors: 12, seed: 43 },
    { kind: 'market', name: 'Southgate Market', x: 700, z: 1020, w: 620, d: 280, seed: 44 },
    { kind: 'suburb', name: 'Southgate Homes', x: 250, z: 1330, w: 600, d: 240, seed: 45 },
    { kind: 'park', name: 'Riverside Park', x: 880, z: 380, w: 240, d: 280, seed: 46 },
    { kind: 'towers', name: 'Harborfront', x: 980, z: 1200, w: 400, d: 300, floors: 15, seed: 47 },
    { kind: 'park', name: 'Bay Park', x: 1330, z: 760, w: 400, d: 240, seed: 48 },
  ],
};


===== FILE: public/new5/stage.js =====
/* stage.js — THE STAGE for the King's /new2 test (Test 2: the big district).
 *
 * One factory: makeStage(THREE, renderer, opts) -> stage
 *
 * Same stage as Test 1, same laws, retuned for district scale:
 *   1. THE MAP FLOOR   — one large flat apron. In Test 2 the district's
 *      own streets and blocks are built ON this floor by the Citywright;
 *      the floor itself stays quiet: dark, city-neutral ground that
 *      carries the district without arguing with its plan.
 *   2. THE STAND LAYER — an invisible plane 0.02 above the floor. Every
 *      character in the world resolves its standing height through
 *      stage.groundY(x, z). Decorative geometry can dip, tilt or lie;
 *      feet cannot. Nobody falls beneath a floor again.
 *   3. THE CAMERA RIG  — a slow cinematic establishing move that frames
 *      the WHOLE district at once, with hard anti-incursion clamps:
 *      the polar angle and distance are fenced so the view can never
 *      clip inside a building, dive under the floor, or frame the void
 *      past the world edge. The fences scale with the stage, so the
 *      sky view reads the entire district, far edge included.
 *   4. BUILD MEMORY    — Solid's memory ships in every build (the King's
 *      standing law): window.logBuild / window.readMemory on the
 *      localStorage key 'solid-memory'.
 *
 * Self-contained: no assets, no CDN. THREE is handed in by the caller.
 */

'use strict';

/* ------------------------------------------------------------------ */
/* Build memory (the King's law: no map ships without it)              */
/* ------------------------------------------------------------------ */

var MEMORY_KEY = 'solid-memory';
var memoryMirror = [];

function memoryRead() {
  try {
    var raw = window.localStorage.getItem(MEMORY_KEY);
    if (raw) {
      var list = JSON.parse(raw);
      if (Array.isArray(list)) memoryMirror = list;
    }
    /* raw === null: storage is empty or unreachable — the mirror
     * already holds the truth; never let an empty read erase it. */
  } catch (e) { /* storage unavailable — the mirror still holds the log */ }
  return memoryMirror;
}

function memoryLog(site, what) {
  memoryRead();
  memoryMirror.push({ t: Date.now(), site: site, what: what });
  try {
    window.localStorage.setItem(MEMORY_KEY, JSON.stringify(memoryMirror));
  } catch (e) { /* mirror-only logging still counts */ }
}

if (typeof window !== 'undefined' && !window.logBuild) {
  window.logBuild = function (what) { memoryLog('new2', what); };
  window.readMemory = function () { return memoryRead(); };
}

/* ------------------------------------------------------------------ */
/* Small deterministic helper for floor tinting                        */
/* ------------------------------------------------------------------ */

function mulberry32(seed) {
  var a = seed >>> 0;
  return function () {
    a |= 0; a = (a + 0x6D2B79F5) | 0;
    var t = Math.imul(a ^ (a >>> 15), 1 | a);
    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
  };
}

function clamp(v, lo, hi) { return Math.min(hi, Math.max(lo, v)); }

/* ------------------------------------------------------------------ */
/* The floor's face: a canvas-drawn apron.                             */
/* Test 2's floor carries no plan of its own — the district's streets  */
/* and blocks are built on top of it — so the weave is quiet: deep     */
/* neutral asphalt, gently mottled, a whisper of speckle. Dark enough  */
/* to make a skyline read, plain enough to sit under any district.     */
/* Procedural — no image files, nothing to load.                       */
/* ------------------------------------------------------------------ */

function makeFloorTexture(THREE, size) {
  var px = 512;
  var canvas = document.createElement('canvas');
  canvas.width = px; canvas.height = px;
  var g = canvas.getContext('2d');
  var rand = mulberry32(20261015);

  g.fillStyle = '#131517';                 /* the apron: near-black asphalt */
  g.fillRect(0, 0, px, px);

  /* broad soft mottling