<!-- NEW2 — TEST 2 · THE DISTRICT OF 800 · part 11 -->
stBuilding() {
  let best = null, bd = Infinity;
  for (const b of district.meta.buildings) {
    const d = (b.x - king.x) ** 2 + (b.z - king.z) ** 2;
    if (d < bd) { bd = d; best = b; }
  }
  return best;
}

/* ---------- the loop ---------- */
const clock = new THREE.Clock();
let censusTimer = 0;
function frame() {
  requestAnimationFrame(frame);
  const dt = Math.min(clock.getDelta(), 0.05);
  const t = clock.elapsedTime;
  if (mode === 'sky') {
    stage.update(dt, t);
  } else if (mode === 'diving' || mode === 'rising') {
    trans.k += dt / trans.dur;
    const s = smooth(Math.min(1, trans.k));
    king.update(dt);
    if (mode === 'diving') {
      const bt = boomTarget();
      _v1.copy(bt.position);
      _v2.lerpVectors(trans.fromLook, bt.look, s);
      camera.position.lerpVectors(trans.fromPos, _v1, s);
      camera.lookAt(_v2);
      if (trans.k >= 1) { mode = 'street'; document.body.classList.add('inside'); enterBtn.textContent = 'EXIT TO THE SKY'; }
    } else {
      camera.position.lerpVectors(trans.fromPos, trans.toPos, s);
      _v1.lerpVectors(trans.fromLook, trans.toLook, s);
      camera.lookAt(_v1);
      if (trans.k >= 1) { mode = 'sky'; document.body.classList.remove('inside'); enterBtn.textContent = 'ENTER THE CITY'; king.hide(); }
    }
  } else {
    king.update(dt);
    king.boom(camera, dt);
  }
  renderer.render(scene, camera);
  diag.frames++;
  diag.calls = renderer.info.render.calls;
  diag.triangles = renderer.info.render.triangles;
  censusTimer += dt;
  if (censusTimer > 0.5) {
    censusTimer = 0;
    let insideLine = '';
    if (mode !== 'sky') {
      const nb = nearestBuilding();
      insideLine = '\n<span class="spot">You are in the city — the nearest face rises ' + nb.floors + ' floors, crowned with ' + (CROWNS[nb.crown] || 'a plain crown') + '</span>';
    }
    censusEl.innerHTML =
      '<b>THE WITNESS</b> · TEST 2\n' +
      'buildings ' + diag.buildings + ' · faces unique ' + diag.uniqueFaces + '\n' +
      'draw calls ' + diag.calls + ' · triangles ' + diag.triangles.toLocaleString('en-US') + '\n' +
      'tallest ' + Math.round(district.meta.tallest) + ' · one fashion · sixteen plates' +
      insideLine +
      (diag.errors.length ? '\n<span class="err">errors: ' + diag.errors[0] + '</span>' : '');
  }
}
frame();

window.addEventListener('resize', () => {
  renderer.setSize(window.innerWidth, window.innerHeight);
  stage.setAspect(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>


===== FILE: public/new2/lib/three.core.js =====
/**
 * @license
 * Copyright 2010-2026 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const REVISION = '186';

/**
 * Represents mouse buttons and interaction types in context of controls.
 *
 * @type {ConstantsMouse}
 * @constant
 */
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };

/**
 * Represents touch interaction types in context of controls.
 *
 * @type {ConstantsTouch}
 * @constant
 */
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };

/**
 * Disables face culling.
 *
 * @type {number}
 * @constant
 */
const CullFaceNone = 0;

/**
 * Culls back faces.
 *
 * @type {number}
 * @constant
 */
const CullFaceBack = 1;

/**
 * Culls front faces.
 *
 * @type {number}
 * @constant
 */
const CullFaceFront = 2;

/**
 * Culls both front and back faces.
 *
 * @type {number}
 * @constant
 */
const CullFaceFrontBack = 3;

/**
 * Gives unfiltered shadow maps - fastest, but lowest quality.
 *
 * @type {number}
 * @constant
 */
const BasicShadowMap = 0;

/**
 * Filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm.
 *
 * @type {number}
 * @constant
 */
const PCFShadowMap = 1;

/**
 * Filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm with
 * better soft shadows especially when using low-resolution shadow maps.
 *
 * @type {number}
 * @constant
 * @deprecated since r186. Use `PCFShadowMap` instead.
 */
const PCFSoftShadowMap = 2;

/**
 * Filters shadow maps using the Variance Shadow Map (VSM) algorithm.
 * When using VSMShadowMap all shadow receivers will also cast shadows.
 *
 * @type {number}
 * @constant
 */
const VSMShadowMap = 3;

/**
 * Only front faces are rendered.
 *
 * @type {number}
 * @constant
 */
const FrontSide = 0;

/**
 * Only back faces are rendered.
 *
 * @type {number}
 * @constant
 */
const BackSide = 1;

/**
 * Both front and back faces are rendered.
 *
 * @type {number}
 * @constant
 */
const DoubleSide = 2;

/**
 * No blending is performed which effectively disables
 * alpha transparency.
 *
 * @type {number}
 * @constant
 */
const NoBlending = 0;

/**
 * The default blending.
 *
 * @type {number}
 * @constant
 */
const NormalBlending = 1;

/**
 * Represents additive blending.
 *
 * @type {number}
 * @constant
 */
const AdditiveBlending = 2;

/**
 * Represents subtractive blending.
 *
 * @type {number}
 * @constant
 */
const SubtractiveBlending = 