Prompt specification
Build or customize the Three.js 3D scene "Trace changing access around the Bastille site" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Trace changing access around the Bastille site
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/trace-changing-access-around-the-bastille-site-x2412
Scene Description Prompt:
Make a low-poly Three.js scene in a self-contained HTML file using cdnjs: Trace changing access around the Bastille site. Let users compare pedestrian connectivity across the staged site models. Present measured geometric changes separately from broader political interpretations of the French Revolution.
Working Three.js Starter (trace-changing-access-around-the-bastille-site-x2412):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bastille — Changing Access</title>
<style>
:root {
--paper: #f3f0e7;
--panel: #fffdf8;
--ink: #192826;
--muted: #68736e;
--line: #d8d7cd;
--teal: #167c70;
--teal-soft: #d9ebe5;
--rust: #b9553f;
--gold: #d6a23b;
--blue: #527b8c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
min-height: 100%;
margin: 0;
}
body {
overflow: hidden;
color: var(--ink);
background: var(--paper);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
header {
height: 76px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 26px;
border-bottom: 1px solid var(--line);
background: var(--panel);
}
.brand {
display: flex;
align-items: baseline;
gap: 18px;
min-width: 0;
}
.eyebrow {
flex: 0 0 auto;
color: var(--rust);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(20px, 2vw, 29px);
font-weight: 500;
letter-spacing: -0.025em;
white-space: nowrap;
}
.header-note {
display: flex;
align-items: center;
gap: 9px;
color: var(--muted);
font-size: 12px;
white-space: nowrap;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px var(--teal-soft);
}
main {
display: grid;
grid-template-columns: minmax(0, 1fr) 390px;
height: calc(100vh - 76px);
}
.viewport {
position: relative;
min-width: 0;
overflow: hidden;
background: #d9d4c8;
}
#canvas-host {
position: absolute;
inset: 0;
}
#canvas-host canvas {
width: 100%;
height: 100%;
display: block;
outline: none;
touch-action: none;
}
.scene-heading {
position: absolute;
top: 22px;
left: 24px;
z-index: 3;
width: min(340px, calc(100% - 48px));
pointer-events: none;
}
.scene-kicker {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--rust);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.scene-kicker::before {
content: "";
width: 26px;
height: 2px;
background: var(--rust);
}
#scene-year {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(31px, 4vw, 52px);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.04em;
}
#scene-title {
margin: 8px 0 0;
font-size: 14px;
font-weight: 750;
}
#scene-description {
max-width: 320px;
margin: 7px 0 0;
color: #45524e;
font-size: 12px;
line-height: 1.45;
}
.stage-switch {
position: absolute;
top: 22px;
right: 22px;
z-index: 5;
display: grid;
grid-template-columns: repeat(4, minmax(82px, 1fr));
overflow: hidden;
border: 1px solid rgba(25, 40, 38, 0.15);
border-radius: 8px;
background: rgba(255, 253, 248, 0.92);
box-shadow: 0 8px 30px rgba(25, 40, 38, 0.1);
backdrop-filter: blur(12px);
}
.stage-button {
min-height: 58px;
padding: 9px 12px;
border: 0;
border-right: 1px solid rgba(25, 40, 38, 0.11);
background: transparent;
cursor: pointer;
text-align: left;
transition:
background 160ms ease,
color 160ms ease;
}
.stage-button:last-child {
border-right: 0;
}
.stage-button:hover {
background: #f0eee5;
}
.stage-button.active {
color: #fff;
background: var(--ink);
}
.stage-button strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: 17px;
font-weight: 500;
}
.stage-button span {
display: block;
margin-top: 2px;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.07em;
opacity: 0.72;
text-transform: uppercase;
}
.scene-tools {
position: absolute;
left: 22px;
bottom: 22px;
z-index: 5;
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.tool-button {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 36px;
padding: 8px 11px;
border: 1px solid rgba(25, 40, 38, 0.15);
border-radius: 6px;
background: rgba(255, 253, 248, 0.92);
box-shadow: 0 5px 20px rgba(25, 40, 38, 0.08);
cursor: pointer;
font-size: 11px;
font-weight: 700;
backdrop-filter: blur(10px);
}
.tool-button:hover {
background: #fff;
}
.tool-button.active {
color: #fff;
border-color: var(--teal);
background: var(--teal);
}
.tool-button .mark {
width: 9px;
height: 9px;
border: 2px solid currentColor;
border-radius: 2px;
}
.legend {
position: absolute;
right: 22px;
bottom: 22px;
z-index: 4;
width: 210px;
padding: 13px 14px;
border: 1px solid rgba(25, 40, 38, 0.13);
border-radius: 8px;
background: rgba(255, 253, 248, 0.9);
box-shadow: 0 8px 30px rgba(25, 40, 38, 0.08);
pointer-events: none;
backdrop-filter: blur(10px);
}
.legend-title {
margin-bottom: 8px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 7px;
color: #43504c;
font-size: 10px;
}
.legend-line {
width: 24px;
height: 3px;
border-radius: 4px;
background: var(--teal);
}
.legend-line.route {
background: var(--gold);
}
.legend-line.gate {
height: 0;
border-top: 3px dashed var(--rust);
background: transparent;
}
.legend-box {
width: 24px;
height: 9px;
border: 1px solid rgba(22, 124, 112, 0.7);
background: rgba(22, 124, 112, 0.15);
}
.compass {
position: absolute;
top: 112px;
right: 28px;
z-index: 3;
display: grid;
place-items: center;
width: 44px;
height: 44px;
border: 1px solid rgba(25, 40, 38, 0.15);
border-radius: 50%;
background: rgba(255, 253, 248, 0.72);
color: var(--ink);
font-size: 10px;
font-weight: 850;
pointer-events: none;
}
.compass::after {
content: "";
position: absolute;
top: 6px;
border-right: 4px solid transparent;
border-bottom: 8px solid var(--rust);
border-left: 4px solid transparent;
}
.viewport-note {
position: absolute;
left: 24px;
bottom: 72px;
z-index: 3;
max-width: 330px;
color: #4e5b57;
font-size: 10px;
line-height: 1.4;
pointer-events: none;
text-shadow: 0 1px rgba(255, 255, 255, 0.7);
}
aside {
min-width: 0;
overflow: auto;
border-left: 1px solid var(--line);
background: var(--panel);
}
.panel-tabs {
position: sticky;
top: 0;
z-index: 10;
display: grid;
grid-template-columns: 1fr 1fr;
border-bottom: 1px solid var(--line);
background: var(--panel);
}
.panel-tab {
position: relative;
min-height: 56px;
padding: 13px 10px;
border: 0;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.03em;
}
.panel-tab::after {
content: "";
position: absolute;
right: 15px;
bottom: -1px;
left: 15px;
height: 3px;
background: transparent;
}
.panel-tab.active {
color: var(--ink);
}
.panel-tab.active::after {
background: var(--teal);
}
.panel-body {
padding: 20px;
}
.section-label {
margin: 0 0 6px;
color: var(--rust);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 24px;
font-weight: 500;
letter-spacing: -0.025em;
}
.intro {
margin: 10px 0 16px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.method-note {
margin-bottom: 18px;
padding: 11px 12px;
border-left: 3px solid var(--teal);
border-radius: 0 5px 5px 0;
background: #eef5f1;
color: #40504b;
font-size: 10px;
line-height: 1.5;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
}
.metric {
min-height: 106px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 7px;
background: #faf8f2;
}
.metric-label {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.07em;
line-height: 1.35;
text-transform: uppercase;
}
.metric-value {
margin-top: 8px;
font-family: Georgia, "Times New Roman", serif;
font-size: 27px;
font-weight: 500;
letter-spacing: -0.035em;
}
.metric-detail {
margin-top: 3px;
color: var(--muted);
font-size: 9px;
line-height: 1.35;
}
.delta-box {
display: flex;
justify-content: space-between;
gap: 10px;
margin: 10px 0 22px;
padding: 10px 12px;
border-radius: 5px;
background: var(--ink);
color: #f7f3e9;
font-size: 10px;
}
.delta-box strong {
color: #f3c46c;
font-weight: 750;
}
.comparison {
margin-top: 25px;
}
.comparison h3,
.interpret-card h3 {
margin: 0 0 8px;
font-size: 12px;
font-weight: 850;
}
.comparison p,
.interpret-card p {
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
table {
width: 100%;
margin-top: 12px;
border-collapse: collapse;
font-size: 10px;
}
th {
padding: 8px 5px;
border-bottom: 1px solid var(--line);
color: var(--muted);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.06em;
text-align: right;
text-transform: uppercase;
}
th:first-child,
td:first-child {
padding-left: 0;
text-align: left;
}
td {
padding: 10px 5px;
border-bottom: 1px solid #e7e5dc;
color: #3d4945;
text-align: right;
font-variant-numeric: tabular-nums;
}
tbody tr {
cursor: pointer;
transition: background 130ms ease;
}
tbody tr:hover {
background: #f3f1e9;
}
tbody tr.selected {
background: var(--teal-soft);
}
tbody tr.selected td {
color: var(--ink);
font-weight: 750;
}
.stage-name {
display: block;
font-weight: 750;
}
.stage-year {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8px;
}
.reading-key {
display: grid;
gap: 8px;
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid var(--line);
}
.reading-key div {
display: grid;
grid-template-columns: 90px 1fr;
gap: 10px;
color: var(--muted);
font-size: 9px;
line-height: 1.45;
}
.reading-key strong {
color: var(--ink);
}
.interpret-card {
padding: 16px;
border: 1px solid var(--line);
border-radius: 8px;
background: #faf8f2;
}
.interpret-card .context-tag {
display: inline-block;
margin-bottom: 10px;
padding: 5px 7px;
border-radius: 4px;
background: #f2e3d8;
color: var(--rust);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.interpret-card blockquote {
margin: 14px 0;
padding: 0 0 0 13px;
border-left: 2px solid var(--gold);
color: #34413e;
font-family: Georgia, "Times New Roman", serif;
font-size: 17px;
line-height: 1.42;
}
.separation-note {
margin-top: 17px;
padding: 13px;
border: 1px solid #e4cfc3;
border-radius: 7px;
background: #fbf0e8;
color: #5b4a42;
font-size: 10px;
line-height: 1.55;
}
.separation-note strong {
color: var(--rust);
}
.chronology {
margin: 21px 0 0;
padding: 0;
list-style: none;
}
.chronology li {
position: relative;
padding: 0 0 13px 18px;
border-left: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.chronology li:last-child {
padding-bottom: 0;
border-left-color: transparent;
}
.chronology li::before {
content: "";
position: absolute;
top: 4px;
left: -4px;
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--teal);
}
.chronology strong {
display: block;
color: var(--ink);
font-size: 10px;
}
[hidden] {
display: none !important;
}
@media (max-width: 1080px) {
main {
grid-template-columns: minmax(0, 1fr) 340px;
}
.stage-switch {
top: auto;
right: 18px;
bottom: 70px;
}
.legend {
display: none;
}
}
@media (max-width: 760px) {
body {
overflow: auto;
}
header {
height: 66px;
padding: 0 16px;
}
.brand {
display: block;
}
.brand .eyebrow {
margin-bottom: 3px;
}
h1 {
font-size: 20px;
}
.header-note {
display: none;
}
main {
display: block;
height: auto;
}
.viewport {
height: 67vh;
min-height: 520px;
}
aside {
border-top: 1px solid var(--line);
border-left: 0;
}
.panel-tabs {
position: sticky;
top: 0;
}
.scene-heading {
top: 18px;
left: 18px;
}
#scene-year {
font-size: 36px;
}
#scene-description {
max-width: 260px;
}
.stage-switch {
right: 12px;
bottom: 64px;
left: 12px;
grid-template-columns: repeat(4, 1fr);
}
.stage-button {
min-height: 51px;
padding: 7px;
}
.stage-button strong {
font-size: 14px;
}
.stage-button span {
font-size: 7px;
}
.scene-tools {
right: 12px;
bottom: 14px;
left: 12px;
}
.tool-button {
flex: 1 1 auto;
justify-content: center;
font-size: 9px;
}
.viewport-note {
display: none;
}
.compass {
top: 100px;
right: 18px;
}
}
</style>
</head>
<body>
<header>
<div class="brand">
<span class="eyebrow">Paris / Spatial history</span>
<h1>Bastille: changing access</h1>
</div>
<div class="header-note">
<span class="status-dot"></span>
Interactive low-poly reconstruction
</div>
</header>
<main>
<section class="viewport" aria-label="Interactive 3D comparison of the Bastille site">
<div id="canvas-host"></div>
<div class="scene-heading">
<div class="scene-kicker">Selected site model</div>
<h2 id="scene-year">1789</h2>
<div id="scene-title">Fortress and controlled thresholds</div>
<p id="scene-description"></p>
</div>
<nav class="stage-switch" id="stage-switch" aria-label="Select a historical stage"></nav>
<div class="compass" aria-hidden="true">N</div>
<div class="viewport-note">
Drag to orbit · Shift/right-drag to pan · Scroll to zoom ·
Double-click to reset
</div>
<div class="scene-tools" aria-label="Scene layers">
<button class="tool-button active" id="graph-toggle" aria-pressed="true">
<span class="mark"></span>
Access graph
</button>
<button class="tool-button" id="footprint-toggle" aria-pressed="false">
<span class="mark"></span>
Open footprint
</button>
<button class="tool-button" id="reference-toggle" aria-pressed="false">
<span class="mark"></span>
1789 outline
</button>
<button class="tool-button" id="reset-view">Reset view</button>
</div>
<div class="legend">
<div class="legend-title">Reading the model</div>
<div class="legend-row">
<span class="legend-line route"></span>
Animated west-to-east route
</div>
<div class="legend-row">
<span class="legend-line"></span>
Modeled pedestrian link
</div>
<div class="legend-row">
<span class="legend-line gate"></span>
Controlled threshold
</div>
<div class="legend-row">
<span class="legend-box"></span>
Open pedestrian footprint
</div>
</div>
</section>
<aside>
<div class="panel-tabs" role="tablist" aria-label="Evidence and interpretation">
<button
class="panel-tab active"
id="geometry-tab"
role="tab"
aria-selected="true"
aria-controls="geometry-panel"
>
Measured geometry
</button>
<button
class="panel-tab"
id="interpretation-tab"
role="tab"
aria-selected="false"
aria-controls="interpretation-panel"
>
Political interpretation
</button>
</div>
<div class="panel-body" id="geometry-panel" role="tabpanel">
<p class="section-label">Evidence / selected model</p>
<h2>Measured from the model</h2>
<p class="intro">
Compare how the displayed site changes pedestrian area, reachability,
and the shortest modeled passage.
</p>
<div class="method-note">
These values are calculated from the schematic geometry and access graph
shown here. They are model measurements, not survey-grade historical
measurements. Open area is rasterized at a 2 m grid.
</div>
<div class="metric-grid">
<article class="metric">
<div class="metric-label">Open-area footprint</div>
<div class="metric-value" id="area-value">—</div>
<div class="metric-detail">Square metres, rounded</div>
</article>
<article class="metric">
<div class="metric-label">Nodes reached from west</div>
<div class="metric-value" id="reach-value">—</div>
<div class="metric-detail">Share of modeled public nodes</div>
</article>
<article class="metric">
<div class="metric-label">West-to-east passage</div>
<div class="metric-value" id="cross-value">—</div>
<div class="metric-detail">Shortest modeled walking route</div>
</article>
<article class="metric">
<div class="metric-label">Passage detour</div>
<div class="metric-value" id="detour-value">—</div>
<div class="metric-detail">Route ÷ straight-line anchor distance</div>
</article>
</div>
<div class="delta-box">
<span>Change from the 1789 model</span>
<strong id="delta-value">—</strong>
</div>
<section class="comparison">
<h3>Stage comparison</h3>
<p>Select any row to rebuild the scene.</p>
<table>
<thead>
<tr>
<th>Model</th>
<th>Open m²</th>
<th>Reach</th>
<th>W–E</th>
<th>Detour</th>
</tr>
</thead>
<tbody id="comparison-body"></tbody>
</table>
</section>
<div class="reading-key">
<div>
<strong>Area</strong>
<span>Union of the stage’s modeled pedestrian polygons.</span>
</div>
<div>
<strong>Reach</strong>
<span>Connected nodes accessible from the western arrival anchor.</span>
</div>
<div>
<strong>Passage</strong>
<span>Shortest weighted path between west and east anchors.</span>
</div>
<div>
<strong>Detour</strong>
<span>Indicates how much the route deviates from a direct crossing.</span>
</div>
</div>
</div>
<div class="panel-body" id="interpretation-panel" role="tabpanel" hidden>
<p class="section-label">Context / narrative reading</p>
<h2>Interpretive context</h2>
<p class="intro">
These passages explain historical meaning. They are not measurements
generated by the 3D geometry.
</p>
<div class="interpret-card" id="interpret-card"></div>
<div class="separation-note">
<strong>Keep the evidence separate.</strong>
A shorter route does not itself demonstrate political liberty, popular
consent, crowd behavior, or revolutionary intent. Likewise, political
symbolism cannot be inferred from a footprint or path length alone.
</div>
<ul class="chronology">
<li>
<strong>1789</strong>
The storming of the Bastille became a major revolutionary event;
dismantling of the fortress began in its aftermath.
</li>
<li>
<strong>1791</strong>
The fortress was fully removed and the area was reorganized as open
urban ground.
</li>
<li>
<strong>1830s</strong>
The July Column added a later commemorative monument to the square.
</li>
<li>
<strong>Late 20th century</strong>
The Opera, Metro infrastructure, landscaping, cafés, and traffic
planning became defining layers of contemporary access.
</li>
</ul>
</div>
</aside>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const host = document.querySelector("#canvas-host");
const stageSwitch = document.querySelector("#stage-switch");
const comparisonBody = document.querySelector("#comparison-body");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd9d4c8);
scene.fog = new THREE.Fog(0xd9d4c8, 340, 650);
const camera = new THREE.PerspectiveCamera(
42,
1,
0.1,
1000
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
host.appendChild(renderer.domElement);
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Three-dimensional Bastille reconstruction. Drag to orbit and scroll to zoom."
);
const hemisphere = new THREE.HemisphereLight(0xfff9e9, 0x73827c, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1cf, 3.2);
sun.position.set(-150, 230, 100);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -230;
sun.shadow.camera.right = 230;
sun.shadow.camera.top = 200;
sun.shadow.camera.bottom = -200;
sun.shadow.camera.near = 20;
sun.shadow.camera.far = 600;
sun.shadow.bias = -0.0005;
scene.add(sun);
const modelRoot = new THREE.Group();
const graphRoot = new THREE.Group();
const footprintRoot = new THREE.Group();
const referenceRoot = new THREE.Group();
const routeRoot = new THREE.Group();
scene.add(
modelRoot,
graphRoot,
footprintRoot,
referenceRoot,
routeRoot
);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(1000, 1000),
new THREE.MeshStandardMaterial({
color: 0xd4cec1,
roughness: 1,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.35;
ground.receiveShadow = true;
scene.add(ground);
const cameraState = {
target: new THREE.Vector3(0, 0, 0),
radius: 270,
theta: 0.72,
phi: 0.88
};
function updateCamera() {
const { target, radius, theta, phi } = cameraState;
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
function resetCamera() {
cameraState.target.set(0, 0, 0);
cameraState.radius = 270;
cameraState.theta = 0.72;
cameraState.phi = 0.88;
updateCamera();
}
let dragState = null;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragState = {
x: event.clientX,
y: event.clientY,
pan: event.button === 2 || event.shiftKey
};
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragState) return;
const dx = event.clientX - dragState.x;
const dy = event.clientY - dragState.y;
dragState.x = event.clientX;
dragState.y = event.clientY;
if (dragState.pan) {
const right = new THREE.Vector3()
.setFromMatrixColumn(camera.matrixWorld, 0);
right.y = 0;
right.normalize();
const forward = new THREE.Vector3()
.subVectors(cameraState.target, camera.position);
forward.y = 0;
forward.normalize();
const scale = cameraState.radius * 0.0014;
cameraState.target
.addScaledVector(right, -dx * scale)
.addScaledVector(forward, dy * scale);
} else {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.3,
1.36
);
}
updateCamera();
});
function endDrag(event) {
dragState = null;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
125,
480
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") cameraState.theta += 0.08;
else if (key === "arrowright") cameraState.theta -= 0.08;
else if (key === "arrowup") cameraState.phi -= 0.06;
else if (key === "arrowdown") cameraState.phi += 0.06;
else if (key === "+" || key === "=") cameraState.radius -= 8;
else if (key === "-") cameraState.radius += 8;
else return;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi, 0.3, 1.36);
cameraState.radius = THREE.MathUtils.clamp(cameraState.radius, 125, 480);
updateCamera();
event.preventDefault();
});
function resize() {
const width = host.clientWidth;
const height = host.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(1, height);
camera.updateProjectionMatrix();
}
new ResizeObserver(resize).observe(host);
resize();
resetCamera();
function disposeGroup(group) {
while (group.children.length) {
const child = group.children.pop();
child.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
const materials = Array.isArray(object.material)
? object.material
: [object.material];
for (const material of materials) {
if (material.map) material.map.dispose();
material.dispose();
}
}
});
}
}
function polygonMesh(points, color, y = 0.04, options = {}) {
const shape = new THREE.Shape();
points.forEach(([x, z], index) => {
if (index === 0) shape.moveTo(x, -z);
else shape.lineTo(x, -z);
});
shape.closePath();
const geometry = new THREE.ShapeGeometry(shape);
geometry.rotateX(-Math.PI / 2);
const material = new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 1,
metalness: options.metalness ?? 0,
transparent: options.opacity !== undefined,
opacity: options.opacity ?? 1,
side: THREE.DoubleSide,
flatShading: true,
depthWrite: options.depthWrite ?? true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.y = y;
mesh.receiveShadow = true;
mesh.castShadow = options.castShadow ?? false;
return mesh;
}
function box(parent, x, z, width, height, depth, color, rotation = 0) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
new THREE.MeshStandardMaterial({
color,
roughness: 0.9,
flatShading: true
})
);
mesh.position.set(x, height / 2, z);
mesh.rotation.y = rotation;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
x,
z,
radius,
height,
color,
radialSegments = 8,
y = 0
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radius,
radius * 1.04,
height,
radialSegments
),
new THREE.MeshStandardMaterial({
color,
roughness: 0.95,
flatShading: true
})
);
mesh.position.set(x, y + height / 2, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addTree(parent, x, z, scale = 1) {
cylinder(parent, x, z, 0.75 * scale, 5 * scale, 0x75604c, 5);
const crown = new THREE.Mesh(
new THREE.ConeGeometry(4.6 * scale, 9 * scale, 7),
new THREE.MeshStandardMaterial({
color: 0x688765,
roughness: 1,
flatShading: true
})
);
crown.position.set(x, 8 * scale, z);
crown.castShadow = true;
parent.add(crown);
}
function addLamp(parent, x, z) {
cylinder(parent, x, z, 0.22, 7, 0x3c4a46, 6);
const lamp = new THREE.Mesh(
new THREE.OctahedronGeometry(1.15),
new THREE.MeshStandardMaterial({
color: 0xf3d58b,
emissive: 0x5d4320,
emissiveIntensity: 0.2,
flatShading: true
})
);
lamp.position.set(x, 7.5, z);
parent.add(lamp);
}
function textSprite(text, options = {}) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 112;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
if (options.background !== false) {
context.fillStyle = options.background ?? "rgba(255,253,248,0.88)";
context.beginPath();
context.roundRect(5, 10, 630, 90, 16);
context.fill();
}
context.fillStyle = options.color ?? "#26332f";
context.font = "700 30px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 320, 57);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: options.depthTest ?? false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
const width = options.width ?? 42;
sprite.scale.set(width, width * 0.175, 1);
return sprite;
}
function addStreetLabels(parent) {
const saintAntoine = textSprite("RUE SAINT-ANTOINE", {
width: 43
});
saintAntoine.position.set(0, 2.3, 29);
parent.add(saintAntoine);
const richardLenoir = textSprite("BOULEVARD RICHARD-LENOIR", {
width: 48
});
richardLenoir.position.set(0, 2.3, -61);
parent.add(richardLenoir);
const roquette = textSprite("RUE DE LA ROQUETTE", {
width: 43
});
roquette.position.set(-73, 2.3, 82);
parent.add(roquette);
}
function addFortress(parent) {
const moat = polygonMesh(
[
[-64, -40],
[64, -40],
[71, -29],
[71, 29],
[64, 40],
[-64, 40],
[-71, 29],
[-71, -29]
],
0x71877b,
0.1
);
parent.add(moat);
const innerGround = polygonMesh(
[
[-53, -32],
[53, -32],
[53, 32],
[-53, 32]
],
0x948b78,
0.16
);
parent.add(innerGround);
box(parent, 0, -30, 92, 10, 5, 0x9c6d55);
box(parent, 0, 30, 92, 10, 5, 0x9c6d55);
box(parent, -44, -16, 5, 10, 25, 0x9c6d55);
box(parent, -44, 16, 5, 10, 25, 0x9c6d55);
box(parent, 44, -16, 5, 10, 25, 0x9c6d55);
box(parent, 44, 16, 5, 10, 25, 0x9c6d55);
const towerPositions = [
[-44, -30],
[0, -30],
[44, -30],
[-44, 30],
[0, 30],
[44, 30]
];
towerPositions.forEach(([x, z]) => {
cylinder(parent, x, z, 7.3, 13, 0xa8785f, 8);
cylinder(parent, x, z, 7.8, 2.2, 0x815744, 8, 13);
});
box(parent, 0, 0, 31, 15, 25, 0xb18669);
box(parent, 0, 0, 35, 3, 29, 0x8e604c);
for (let i = 0; i < 14; i++) {
const angle = (i / 14) * Math.PI * 2;
addTree(
parent,
Math.cos(angle) * 104,
Math.sin(angle) * 78,
0.85
);
}
}
function addDemolitionWorks(parent) {
const workZone = polygonMesh(
[
[-38, -8],
[36, -8],
[40, 32],
[-34, 36]
],
0xa98c70,
0.18
);
parent.add(workZone);
const rubble = [
[-27, 6, 9, 3, 7],
[-11, 19, 7, 2, 6],
[8, 10, 10, 3, 5],
[25, 22, 8, 2, 6],
[-20, 27, 6, 2, 4],
[17, 1, 5, 2, 5],
[0, 28, 8, 2, 4]
];
rubble.forEach(([x, z, w, h, d]) => {
box(
parent,
x,
z,
w,
h,
d,
[0x8f725d, 0xb18c70, 0x776653][
Math.abs(Math.round(x + z)) % 3
],
(x % 5) * 0.08
);
});
box(parent, -44, -31, 24, 5, 5, 0x97705a);
box(parent, 44, 31, 21, 4, 5, 0x97705a);
cylinder(parent, -45, -30, 6, 6, 0x9e755d, 8);
cylinder(parent, 45, 30, 6, 5, 0x9e755d, 8);
const fencePoints = [
[-39, -9],
[37, -9],
[41, 33],
[-35, 37],
[-39, -9]
];
const fenceGeometry = new THREE.BufferGeometry().setFromPoints(
fencePoints.map(([x, z]) => new THREE.Vector3(x, 2.2, z))
);
const fence = new THREE.Line(
fenceGeometry,
new THREE.LineDashedMaterial({
color: 0xb9553f,
dashSize: 4,
gapSize: 2
})
);
fence.computeLineDistances();
parent.add(fence);
[
[-92, 31],
[91, 31],
[-75, -43],
[78, -43]
].forEach(([x, z]) => addTree(parent, x, z, 0.9));
}
function addOpenSquare(parent) {
const plaza = polygonMesh(
[
[-45, -21],
[-21, -45],
[21, -45],
[45, -21],
[45, 21],
[21, 45],
[-21, 45],
[-45, 21]
],
0xded6c5,
0.1
);
parent.add(plaza);
const radialPaths = [
[[-58, 8], [58, 8]],
[[0, -59], [0, 59]],
[[-48, -43], [48, 43]],
[[48, -43], [-48, 43]]
];
radialPaths.forEach(([a, b]) => {
const dx = b[0] - a[0];
const dz = b[1] - a[1];
const length = Math.hypot(dx, dz);
const angle = Math.atan2(dz, dx);
const strip = box(
parent,
(a[0] + b[0]) / 2,
(a[1] + b[1]) / 2,
length,
0.18,
7,
0xc5bba6,
-angle
);
strip.position.y = 0.13;
strip.castShadow = false;
});
const perimeterBuildings = [
[-98, -58, 26, 12, 20],
[-65, -75, 24, 15, 18],
[96, -58, 31, 16, 24],
[96, 64, 30, 14, 23],
[-98, 72, 27, 12, 19]
];
perimeterBuildings.forEach(([x, z, w, h, d]) => {
box(parent, x, z, w, h, d, 0xb5a58d);
box(parent, x, z, w + 1, 1.5, d + 1, 0x766e62);
});
[
[-75, 32],
[74, 32],
[-75, -30],
[74, -30]
].forEach(([x, z]) => addTree(parent, x, z));
}
function addJulyColumn(parent) {
cylinder(parent, 4, 0, 7, 3, 0xb9ad95, 8);
cylinder(parent, 4, 0, 5.4, 2, 0x9e947f, 8, 3);
cylinder(parent, 4, 0, 1.6, 22, 0xa8785b, 8, 5);
const statue = new THREE.Mesh(
new THREE.DodecahedronGeometry(2.6),
new THREE.MeshStandardMaterial({
color: 0xd2a449,
roughness: 0.7,
metalness: 0.2,
flatShading: true
})
);
statue.position.set(4, 29, 0);
statue.castShadow = true;
parent.add(statue);
}
function addMetroEntrance(parent, x, z, label) {
box(parent, x, z, 8, 0.35, 4, 0x59645f);
for (let i = -3; i <= 3; i += 2) {
box(parent, x + i, z + 2.6, 0.35, 3.2, 0.35, 0x3e4845);
}
const sign = textSprite(`M ${label}`, {
width: 12,
color: "#ffffff",
background: "rgba(25,40,38,0.92)"
});
sign.position.set(x, 5.7, z + 2.6);
sign.scale.y = 4.6;
parent.add(sign);
}
function addOpera(parent) {
box(parent, 78, -47, 49, 24, 34, 0xa79d8b);
box(parent, 78, -47, 52, 2.3, 37, 0x746e65);
box(parent, 78, -31.5, 39, 17, 1.1, 0x4f6d75, 0);
for (let i = -4; i <= 4; i++) {
cylinder(parent, 78 + i * 4.2, -30.6, 0.55, 13, 0xd3c8b2, 6);
}
box(parent, 78, -29.7, 43, 4, 1.4, 0x5e5a53);
const operaLabel = textSprite("OPERA BASTILLE", {
width: 30,
color: "#ffffff",
background: "rgba(25,40,38,0.88)"
});
operaLabel.position.set(78, 17, -29.2);
parent.add(operaLabel);
}
function addContemporaryScene(parent) {
const plaza = polygonMesh(
[
[-78, -48],
[-25, -67],
[40, -50],
[63, -18],
[58, 40],
[4, 58],
[-62, 42],
[-82, -4]
],
0xded5c2,
0.11
);
parent.add(plaza);
addJulyColumn(parent);
addOpera(parent);
addMetroEntrance(parent, -31, 29, "Bastille");
addMetroEntrance(parent, 39, -23, "Bastille");
const cafePositions = [
[-56, 22],
[-45, 30],
[40, 34],
[50, 24]
];
cafePositions.forEach(([x, z]) => {
box(parent, x, z, 10, 4, 7, 0xc0aa8d);
box(parent, x, z + 4, 11, 0.7, 4, 0x9f5f4b);
});
[
[-70, -29],
[-69, -8],
[-67, 14],
[48, 9],
[43, 25],
[18, 51],
[-36, 49]
].forEach(([x, z]) => addTree(parent, x, z, 1.05));
[-88, -24, 63, 3, 64].forEach((z) => addLamp(parent, -88, z));
[-88, -24, 63, 3, 64].forEach((z) => addLamp(parent, 61, z));
}
const roadNorth = [
[-135, -72],
[135, -72],
[135, -52],
[-135, -52]
];
const roadSouth = [
[-135, 52],
[135, 52],
[135, 72],
[-135, 72]
];
const roadRoquette = [
[-84, 52],
[-64, 52],
[-64, 112],
[-84, 112]
];
const roadEastWest = [
[-135, -2],
[135, -2],
[135, 18],
[-135, 18]
];
const roadWest = [
[-135, -2],
[-52, -2],
[-52, 18],
[-135, 18]
];
const roadEast = [
[52, -2],
[135, -2],
[135, 18],
[52, 18]
];
const stages = [
{
id: "fortress",
year: "1789",
name: "Fortress",
title: "Fortress and controlled thresholds",
description:
"The eight-tower enclosure interrupts direct movement; the modeled route bends around controlled approaches.",
roadPolys: [roadWest, roadEast, roadNorth, roadSouth, roadRoquette],
plazaPolys: [],
excludedPolys: [],
nodes: {
W: { x: -130, z: 8 },
w1: { x: -94, z: 8 },
wg: { x: -52, z: 8 },
ws: { x: -52, z: 58 },
s0: { x: 0, z: 64 },
se: { x: 52, z: 58 },
eg: { x: 52, z: 8 },
e1: { x: 94, z: 8 },
E: { x: 130, z: 8 },
nw: { x: -52, z: -60 },
n0: { x: 0, z: -64 },
ne: { x: 52, z: -60 }
},
edges: [
["W", "w1"],
["w1", "wg", true],
["wg", "ws"],
["ws", "s0"],
["s0", "se"],
["se", "eg"],
["eg", "e1", true],
["e1", "E"],
["wg", "nw"],
["nw", "n0"],
["n0", "ne"],
["ne", "eg"]
],
interpretation: `
<span class="context-tag">Context, not measurement</span>
<h3>Authority, thresholds, and the fortress</h3>
<p>
Before 14 July 1789, the Bastille was a royal fortress and a highly
controlled urban threshold. The geometry shows where movement was
forced to narrow or bend around architecture.
</p>
<blockquote>
A fortress can make authority visible through walls and gates, but
geometry alone cannot explain the crowd, the decision to storm it,
or what participants meant by resistance.
</blockquote>
<p>
The model's detours should therefore be read as one material
dimension of access—not as a measurement of political freedom.
</p>
`
},
{
id: "works",
year: "1790",
name: "Breach",
title: "Demolition and temporary works",
description:
"An irregular construction footprint creates a temporary interruption and a more direct but still constrained route.",
roadPolys: [roadEastWest, roadNorth, roadSouth, roadRoquette],
plazaPolys: [],
excludedPolys: [
[
[-38, -8],
[36, -8],
[40, 32],
[-34, 36]
]
],
nodes: {
W: { x: -130, z: 8 },
w1: { x: -94, z: 8 },
w2: { x: -62, z: 8 },
nw: { x: -42, z: -18 },
ne: { x: 42, z: -18 },
e2: { x: 62, z: 8 },
e1: { x: 94, z: 8 },
E: { x: 130, z: 8 },
sw: { x: -52, z: 48 },
s0: { x: 0, z: 55 },
se: { x: 52, z: 48 },
closed: { x: -12, z: 18 }
},
edges: [
["W", "w1"],
["w1", "w2"],
["w2", "nw"],
["nw", "ne"],
["ne", "e2"],
["e2", "e1"],
["e1", "E"],
["w2", "sw"],
["sw", "s0"],
["s0", "se"],
["se", "e2"]
],
interpretation: `
<span class="context-tag">Context, not measurement</span>
<h3>Demolition as a transitional public landscape</h3>
<p>
The dismantling of the fortress converted a controlled military
enclave into transitional urban ground. Construction logistics,
material removal, and uncertain boundaries could shape access
before a formal civic plan settled the site.
</p>
<blockquote>
Opening a wall is not the same thing as completing a public square.
The model records a moment of transition rather than a stable
revolutionary order.
</blockquote>
<p>
The isolated construction-side node illustrates temporary
interruption; it does not represent a political condition.
</p>
`
},
{
id: "square",
year: "1791",
name: "Open square",
title: "Open civic ground",
description:
"With the fortress removed, a broad square and radial approaches create the most direct modeled crossing.",
roadPolys: [roadEastWest, roadNorth, roadSouth, roadRoquette],
plazaPolys: [
[
[-45, -21],
[-21, -45],
[21, -45],
[45, -21],
[45, 21],
[21, 45],
[-21, 45],
[-45, 21]
]
],
excludedPolys: [],
nodes: {
W: { x: -130, z: 8 },
w1: { x: -94, z: 8 },
pw: { x: -42, z: 8 },
c: { x: 0, z: 8 },
pe: { x: 42, z: 8 },
e1: { x: 94, z: 8 },
E: { x: 130, z: 8 },
nw: { x: -26, z: -61 },
ne: { x: 26, z: -61 },
sw: { x: -28, z: 62 },
se: { x: 28, z: 62 }
},
edges: [
["W", "w1"],
["w1", "pw"],
["pw", "c"],
["c", "pe"],
["pe", "e1"],
["e1", "E"],
["pw", "nw"],
["nw", "ne"],
["ne", "pe"],
["pw", "sw"],
["sw", "se"],
["se", "pe"]
],
interpretation: `
<span class="context-tag">Context, not measurement</span>
<h3>The square as a new civic stage</h3>
<p>
After the fortress disappeared, the site could function as open
urban ground and as a setting for public gathering, ceremony,
circulation, and political display.
</p>
<blockquote>
An open square makes different uses imaginable, but its physical
openness does not by itself prove equality, public ownership, or
revolutionary consensus.
</blockquote>
<p>
The direct route shown here is a geometric comparison with 1789.
It should not be projected backward onto the moment of the storming.
</p>
`
},
{
id: "today",
year: "Today",
name: "Metropolitan plaza",
title: "Metropolitan plaza and transit access",
description:
"Later monuments, Metro entrances, the Opera, landscaping, and cafés layer a contemporary pedestrian network over the square.",
roadPolys: [roadEastWest, roadNorth, roadSouth, roadRoquette],
plazaPolys: [
[
[-78, -48],
[-25, -67],
[40, -50],
[63, -18],
[58, 40],
[4, 58],
[-62, 42],
[-82, -4]
]
],
excludedPolys: [],
nodes: {
W: { x: -130, z: 8 },
w1: { x: -94, z: 8 },
pw: { x: -48, z: 10 },
metroA: { x: -18, z: 14 },
c: { x: 4, z: 4 },
metroB: { x: 28, z: 2 },
pe: { x: 48, z: 12 },
e1: { x: 94, z: 8 },
E: { x: 130, z: 8 },
nw: { x: -20, z: -61 },
ne: { x: 30, z: -59 },
sw: { x: -28, z: 62 },
se: { x: 28, z: 62 }
},
edges: [
["W", "w1"],
["w1", "pw"],
["pw", "metroA"],
["metroA", "c"],
["c", "metroB"],
["metroB", "pe"],
["pe", "e1"],
["e1", "E"],
["pw", "nw"],
["nw", "ne"],
["ne", "pe"],
["pw", "sw"],
["sw", "se"],
["se", "pe"]
],
interpretation: `
<span class="context-tag">Context, not measurement</span>
<h3>Layers of commemoration, mobility, and consumption</h3>
<p>
The contemporary square is the product of layers much later than
1789: nineteenth-century commemoration, twentieth-century Metro
and cultural infrastructure, modern landscaping, traffic planning,
and everyday commercial use.
</p>
<blockquote>
A present-day route is evidence about the present. It cannot be
treated as a direct map of revolutionary-era pedestrian behavior.
</blockquote>
<p>
Monument, transit, and commercial references are historical
overlays; only the access graph and open footprint are computed from
the displayed model.
</p>
`
}
];
function pointInPolygon(x, z, polygon) {
let inside = false;
for (
let i = 0, j = polygon.length - 1;
i < polygon.length;
j = i++
) {
const [xi, zi] = polygon[i];
const [xj, zj] = polygon[j];
const intersects =
zi > z !== zj > z &&
x < ((xj - xi) * (z - zi)) / (zj - zi) + xi;
if (intersects) inside = !inside;
}
return inside;
}
function sampleArea(stage) {
const polygons = [...stage.roadPolys, ...stage.plazaPolys];
const exclusions = stage.excludedPolys;
const step = 2;
let minX = Infinity;
let maxX = -Infinity;
let minZ = Infinity;
let maxZ = -Infinity;
polygons.forEach((polygon) => {
polygon.forEach(([x, z]) => {
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minZ = Math.min(minZ, z);
maxZ = Math.max(maxZ, z);
});
});
let cells = 0;
for (let x = minX; x < maxX; x += step) {
for (let z = minZ; z < maxZ; z += step) {
const px = x + step / 2;
const pz = z + step / 2;
const included = polygons.some((polygon) =>
pointInPolygon(px, pz, polygon)
);
if (!included) continue;
const excluded = exclusions.some((polygon) =>
pointInPolygon(px, pz, polygon)
);
if (!excluded) cells++;
}
}
return cells * step * step;
}
function computeGraph(stage) {
const adjacency = new Map(
Object.keys(stage.nodes).map((id) => [id, []])
);
stage.edges.forEach(([a, b]) => {
const aNode = stage.nodes[a];
const bNode = stage.nodes[b];
const distance = Math.hypot(aNode.x - bNode.x, aNode.z - bNode.z);
adjacency.get(a).push({ node: b, distance });
adjacency.get(b).push({ node: a, distance });
});
const distances = new Map(
Object.keys(stage.nodes).map((id) => [id, Infinity])
);
const previous = new Map();
const visited = new Set();
distances.set("W", 0);
while (visited.size < distances.size) {
let current = null;
let currentDistance = Infinity;
for (const [id, distance] of distances) {
if (!visited.has(id) && distance < currentDistance) {
current = id;
currentDistance = distance;
}
}
if (current === null) break;
visited.add(current);
for (const edge of adjacency.get(current)) {
const candidate = currentDistance + edge.distance;
if (candidate < distances.get(edge.node)) {
distances.set(edge.node, candidate);
previous.set(edge.node, current);
}
}
}
const route = [];
let cursor = "E";
if (Number.isFinite(distances.get("E"))) {
while (cursor) {
route.unshift(cursor);
cursor = previous.get(cursor);
}
}
const directDistance = Math.hypot(
stage.nodes.W.x - stage.nodes.E.x,
stage.nodes.W.z - stage.nodes.E.z
);
const reachable = [...distances.entries()].filter(
([, distance]) => Number.isFinite(distance)
).length;
return {
area: sampleArea(stage),
reachable,
totalNodes: Object.keys(stage.nodes).length,
reachableRatio: reachable / Object.keys(stage.nodes).length,
crossingDistance: distances.get("E"),
directDistance,
detour:
Number.isFinite(distances.get("E"))
? distances.get("E") / directDistance
: Infinity,
route
};
}
stages.forEach((stage) => {
stage.metrics = computeGraph(stage);
});
function drawLine(parent, points, color, options = {}) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map(([x, z, y = 0.45]) => new THREE.Vector3(x, y, z))
);
const material = options.dashed
? new THREE.LineDashedMaterial({
color,
dashSize: options.dashSize ?? 4,
gapSize: options.gapSize ?? 2,
transparent: true,
opacity: options.opacity ?? 1
})
: new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: options.opacity ?? 1
});
const line = new THREE.Line(geometry, material);
if (options.dashed) line.computeLineDistances();
parent.add(line);
return line;
}
function drawGraph(stage) {
disposeGroup(graphRoot);
stage.edges.forEach(([a, b, restricted]) => {
const aNode = stage.nodes[a];
const bNode = stage.nodes[b];
drawLine(
graphRoot,
[
[aNode.x, aNode.z],
[bNode.x, bNode.z]
],
restricted ? 0xb9553f : 0x167c70,
{
dashed: Boolean(restricted),
dashSize: 4,
gapSize: 2
}
);
});
Object.entries(stage.nodes).forEach(([id, node]) => {
const isAnchor = id === "W" || id === "E";
const isClosed = id === "closed";
const marker = new THREE.Mesh(
new THREE.SphereGeometry(isAnchor ? 2 : 1.3, 8, 6),
new THREE.MeshStandardMaterial({
color: isClosed ? 0xb9553f : isAnchor ? 0xd6a23b : 0x167c70,
roughness: 0.7,
flatShading: true
})
);
marker.position.set(node.x, 0.9, node.z);
marker.castShadow = true;
graphRoot.add(marker);
});
const west = textSprite("W", {
width: 8,
color: "#ffffff",
background: "rgba(22,124,112,0.92)"
});
west.position.set(stage.nodes.W.x, 5, stage.nodes.W.z);
graphRoot.add(west);
const east = textSprite("E", {
width: 8,
color: "#ffffff",
background: "rgba(22,124,112,0.92)"
});
east.position.set(stage.nodes.E.x, 5, stage.nodes.E.z);
graphRoot.add(east);
}
function drawFootprint(stage) {
disposeGroup(footprintRoot);
[...stage.roadPolys, ...stage.plazaPolys].forEach((polygon) => {
footprintRoot.add(
polygonMesh(polygon, 0x36a99b, 0.2, {
opacity: 0.2,
depthWrite: false
})
);
});
}
function buildReference() {
disposeGroup(referenceRoot);
const outline = [
[-52, -39],
[52, -39],
[52, 39],
[-52, 39],
[-52, -39]
];
drawLine(referenceRoot, outline, 0xb9553f, {
dashed: true,
dashSize: 5,
gapSize: 3,
opacity: 0.9
});
const route = stages[0].metrics.route;
route.forEach((id, index) => {
if (index === route.length - 1) return;
const a = stages[0].nodes[id];
const b = stages[0].nodes[route[index + 1]];
drawLine(
referenceRoot,
[
[a.x, a.z],
[b.x, b.z]
],
0xb9553f,
{
dashed: true,
dashSize: 3,
gapSize: 3,
opacity: 0.6
}
);
});
}
let routeCurve = null;
let walker = null;
function drawRoute(stage) {
disposeGroup(routeRoot);
routeCurve = null;
walker = null;
const ids = stage.metrics.route;
if (ids.length < 2) return;
const path = new THREE.CurvePath();
for (let i = 0; i < ids.length - 1; i++) {
const a = stage.nodes[ids[i]];
const b = stage.nodes[ids[i + 1]];
path.add(
new THREE.LineCurve3(
new THREE.Vector3(a.x, 0.78, a.z),
new THREE.Vector3(b.x, 0.78, b.z)
)
);
}
routeCurve = path;
const tube = new THREE.Mesh(
new THREE.TubeGeometry(path, Math.max(40, ids.length * 9), 0.72, 6, false),
new THREE.MeshStandardMaterial({
color: 0xd6a23b,
emissive: 0x5f4214,
emissiveIntensity: 0.22,
roughness: 0.65,
transparent: true,
opacity: 0.92
})
);
tube.castShadow = true;
routeRoot.add(tube);
walker = new THREE.Mesh(
new THREE.IcosahedronGeometry(2.1, 1),
new THREE.MeshStandardMaterial({
color: 0xf0c75a,
emissive: 0x5f4214,
emissiveIntensity: 0.2,
flatShading: true
})
);
walker.castShadow = true;
routeRoot.add(walker);
}
function buildStage(stage) {
disposeGroup(modelRoot);
const roadColor = stage.id === "today" ? 0xd1c8b7 : 0xc4baa6;
stage.roadPolys.forEach((polygon) => {
modelRoot.add(polygonMesh(polygon, roadColor, 0.035));
});
stage.plazaPolys.forEach((polygon) => {
modelRoot.add(polygonMesh(polygon, 0xded6c5, 0.075));
});
if (stage.id === "fortress") addFortress(modelRoot);
if (stage.id === "works") addDemolitionWorks(modelRoot);
if (stage.id === "square") addOpenSquare(modelRoot);
if (stage.id === "today") addContemporaryScene(modelRoot);
addStreetLabels(modelRoot);
}
const formatArea = (value) =>
new Intl.NumberFormat("en", {
maximumFractionDigits: 0
}).format(Math.round(value / 10) * 10);
function updateComparison() {
comparisonBody.innerHTML = stages
.map((stage, index) => {
const metric = stage.metrics;
const crossing = Number.isFinite(metric.crossingDistance)
? `${Math.round(metric.crossingDistance / 5) * 5} m`
: "—";
return `
<tr data-index="${index}" class="${stage.id === selectedStage.id ? "selected" : ""}">
<td>
<span class="stage-name">${stage.name}</span>
<span class="stage-year">${stage.year}</span>
</td>
<td>${formatArea(metric.area)}</td>
<td>${Math.round(metric.reachableRatio * 100)}%</td>
<td>${crossing}</td>
<td>${Number.isFinite(metric.detour) ? metric.detour.toFixed(2) + "×" : "—"}</td>
</tr>
`;
})
.join("");
comparisonBody.querySelectorAll("tr").forEach((row) => {
row.addEventListener("click", () => {
selectStage(stages[Number(row.dataset.index)]);
});
});
}
function updateMetrics(stage) {
const metric = stage.metrics;
const base = stages[0].metrics;
document.querySelector("#area-value").textContent =
`≈${formatArea(metric.area)} m²`;
document.querySelector("#reach-value").textContent =
`${Math.round(metric.reachableRatio * 100)}%`;
document.querySelector("#cross-value").textContent = Number.isFinite(
metric.crossingDistance
)
? `${Math.round(metric.crossingDistance / 5) * 5} m`
: "No route";
document.querySelector("#detour-value").textContent =
`${Number.isFinite(metric.detour) ? metric.detour.toFixed(2) + "×" : "—"}`;
const areaDifference = metric.area - base.area;
const crossingDifference =
metric.crossingDistance - base.crossingDistance;
const signedArea =
areaDifference >= 0 ? "+" : "−";
const signedCross =
crossingDifference >= 0 ? "+" : "−";
document.querySelector("#delta-value").textContent =
`${signedArea}${formatArea(Math.abs(areaDifference))} m² · ` +
`${Number.isFinite(crossingDifference) ? signedCross + Math.round(Math.abs(crossingDifference) / 5) * 5 + " m" : "No route in one or both stages"}`;
}
let selectedStage = stages[0];
function selectStage(stage) {
selectedStage = stage;
document.querySelector("#scene-year").textContent = stage.year;
document.querySelector("#scene-title").textContent = stage.title;
document.querySelector("#scene-description").textContent =
stage.description;
document.querySelector("#interpret-card").innerHTML =
stage.interpretation;
document.querySelectorAll(".stage-button").forEach((button) => {
const active = button.dataset.index === String(stages.indexOf(stage));
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
buildStage(stage);
drawGraph(stage);
drawFootprint(stage);
drawRoute(stage);
updateMetrics(stage);
updateComparison();
}
stages.forEach((stage, index) => {
const button = document.createElement("button");
button.className = "stage-button";
button.dataset.index = index;
button.setAttribute("aria-pressed", String(index === 0));
button.innerHTML = `
<strong>${stage.year}</strong>
<span>${stage.name}</span>
`;
button.addEventListener("click", () => selectStage(stage));
stageSwitch.appendChild(button);
});
const graphToggle = document.querySelector("#graph-toggle");
const footprintToggle = document.querySelector("#footprint-toggle");
const referenceToggle = document.querySelector("#reference-toggle");
graphToggle.addEventListener("click", () => {
graphRoot.visible = !graphRoot.visible;
graphToggle.classList.toggle("active", graphRoot.visible);
graphToggle.setAttribute("aria-pressed", String(graphRoot.visible));
});
footprintToggle.addEventListener("click", () => {
footprintRoot.visible = !footprintRoot.visible;
footprintToggle.classList.toggle("active", footprintRoot.visible);
footprintToggle.setAttribute("aria-pressed", String(footprintRoot.visible));
});
referenceToggle.addEventListener("click", () => {
referenceRoot.visible = !referenceRoot.visible;
referenceToggle.classList.toggle("active", referenceRoot.visible);
referenceToggle.setAttribute("aria-pressed", String(referenceRoot.visible));
});
document.querySelector("#reset-view").addEventListener("click", resetCamera);
document.querySelectorAll(".panel-tab").forEach((tab) => {
tab.addEventListener("click", () => {
const geometryActive = tab.id === "geometry-tab";
document.querySelector("#geometry-tab").classList.toggle(
"active",
geometryActive
);
document.querySelector("#interpretation-tab").classList.toggle(
"active",
!geometryActive
);
document.querySelector("#geometry-tab").setAttribute(
"aria-selected",
String(geometryActive)
);
document.querySelector("#interpretation-tab").setAttribute(
"aria-selected",
String(!geometryActive)
);
document.querySelector("#geometry-panel").hidden = !geometryActive;
document.querySelector("#interpretation-panel").hidden = geometryActive;
});
});
buildReference();
selectStage(stages[0]);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
if (walker && routeCurve) {
const progress = (elapsed * 0.035) % 1;
walker.position.copy(routeCurve.getPointAt(progress));
walker.rotation.y = elapsed * 0.9;
}
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```