Prompt specification
Build or customize the Three.js 3D scene "Dynamic route communication exhibit" 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: Dynamic route communication exhibit
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/dynamic-route-communication-exhibit-x0436
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring public-space wayfinding. Create a small graph-based building simulator where closures alter displayed paths; users verify that every active arrow leads to a reachable destination in this nonoperational demonstration. Low-poly.
Working Three.js Starter (dynamic-route-communication-exhibit-x0436):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Wayfinding Lab — Public Space Simulator</title>
<style>
:root {
--ink: #152b35;
--muted: #647680;
--paper: rgba(250, 252, 251, 0.94);
--line: rgba(21, 43, 53, 0.12);
--teal: #159b8a;
--teal-soft: #d9f0eb;
--orange: #f2673a;
--orange-soft: #ffe5da;
--red: #d64a45;
--red-soft: #fae2df;
--navy: #173744;
--shadow: 0 18px 50px rgba(31, 52, 61, 0.16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8eef0;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, select { font: inherit; }
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
#labels {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
overflow: hidden;
}
.node-label {
position: absolute;
display: flex;
align-items: center;
gap: 6px;
padding: 5px 8px;
border: 1px solid rgba(21, 43, 53, 0.10);
border-radius: 6px;
background: rgba(255, 255, 255, 0.88);
color: #243c47;
box-shadow: 0 4px 14px rgba(31, 52, 61, 0.10);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.025em;
white-space: nowrap;
will-change: transform;
}
.node-label::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: #78909a;
}
.node-label.origin {
color: #0b6e61;
border-color: rgba(21, 155, 138, 0.42);
background: rgba(235, 252, 248, 0.95);
}
.node-label.origin::before { background: var(--teal); }
.node-label.destination {
color: #a33d20;
border-color: rgba(242, 103, 58, 0.42);
background: rgba(255, 244, 239, 0.96);
}
.node-label.destination::before { background: var(--orange); }
.topbar {
position: fixed;
z-index: 10;
top: 18px;
left: 18px;
right: 18px;
display: flex;
align-items: center;
justify-content: space-between;
pointer-events: none;
}
.brand,
.nonop {
pointer-events: auto;
background: var(--paper);
border: 1px solid rgba(255,255,255,0.8);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 300px;
padding: 10px 14px 10px 10px;
border-radius: 12px;
}
.brand-mark {
width: 42px;
height: 42px;
display: grid;
place-items: center;
border-radius: 9px;
color: white;
background: var(--navy);
}
.brand-mark svg {
width: 27px;
height: 27px;
}
.brand-title {
display: block;
font-size: 13px;
font-weight: 850;
letter-spacing: 0.045em;
}
.brand-subtitle {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
font-weight: 650;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.nonop {
padding: 11px 14px;
border-radius: 10px;
color: #8c322a;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.nonop span {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 8px;
border-radius: 50%;
background: var(--red);
box-shadow: 0 0 0 4px var(--red-soft);
}
.panel {
position: fixed;
z-index: 12;
top: 84px;
left: 18px;
width: 338px;
max-height: calc(100vh - 102px);
overflow: auto;
padding: 18px;
border: 1px solid rgba(255,255,255,0.8);
border-radius: 15px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
scrollbar-width: thin;
scrollbar-color: #b5c2c6 transparent;
}
.eyebrow {
color: var(--teal);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.15em;
text-transform: uppercase;
}
h1 {
margin: 6px 0 5px;
font-size: 24px;
line-height: 1.05;
letter-spacing: -0.04em;
}
.intro {
margin: 0 0 15px;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.field-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-bottom: 12px;
}
label.field-label {
display: block;
margin-bottom: 5px;
color: #526872;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
select {
width: 100%;
height: 37px;
padding: 0 30px 0 10px;
border: 1px solid var(--line);
border-radius: 8px;
outline: none;
color: var(--ink);
background: white;
font-size: 11px;
font-weight: 700;
}
select:focus {
border-color: var(--teal);
box-shadow: 0 0 0 3px var(--teal-soft);
}
.route-card {
padding: 13px;
border: 1px solid rgba(21, 155, 138, 0.18);
border-radius: 11px;
background: linear-gradient(135deg, #f1fbf8, #ffffff);
}
.route-card.blocked {
border-color: rgba(214, 74, 69, 0.2);
background: linear-gradient(135deg, #fff5f3, #ffffff);
}
.route-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 8px;
}
.route-top strong {
font-size: 11px;
letter-spacing: 0.055em;
text-transform: uppercase;
}
.chip {
padding: 4px 7px;
border-radius: 999px;
color: #087165;
background: var(--teal-soft);
font-size: 9px;
font-weight: 850;
white-space: nowrap;
}
.chip.warn {
color: #a23c35;
background: var(--red-soft);
}
.route-chain {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 5px;
color: #29434e;
font-size: 10px;
font-weight: 700;
line-height: 1.45;
}
.route-chain .arrow {
color: var(--teal);
font-weight: 900;
}
.route-distance {
margin-top: 8px;
color: var(--muted);
font-size: 9px;
}
.metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
margin: 10px 0 14px;
}
.metric {
padding: 9px 8px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255,255,255,0.74);
}
.metric strong {
display: block;
font-size: 16px;
line-height: 1;
}
.metric span {
display: block;
margin-top: 5px;
color: var(--muted);
font-size: 8px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin: 15px 0 8px;
}
.section-head h2 {
margin: 0;
font-size: 10px;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.section-head small {
color: var(--muted);
font-size: 9px;
}
.closure-list {
max-height: 190px;
overflow: auto;
padding-right: 3px;
scrollbar-width: thin;
}
.closure-button {
width: 100%;
display: grid;
grid-template-columns: 10px 1fr auto;
align-items: center;
gap: 8px;
margin-bottom: 5px;
padding: 8px 9px;
border: 1px solid var(--line);
border-radius: 8px;
color: var(--ink);
background: rgba(255,255,255,0.7);
text-align: left;
cursor: pointer;
transition: 150ms ease;
}
.closure-button:hover {
transform: translateY(-1px);
border-color: rgba(21,155,138,0.35);
background: white;
}
.closure-button .status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 3px var(--teal-soft);
}
.closure-button.closed .status-dot {
background: var(--red);
box-shadow: 0 0 0 3px var(--red-soft);
}
.closure-name {
display: block;
font-size: 10px;
font-weight: 800;
}
.closure-meta {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8px;
}
.closure-state {
color: #478078;
font-size: 8px;
font-weight: 900;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.closure-button.closed .closure-state { color: var(--red); }
.closure-button.on-route .closure-state { color: var(--orange); }
.small-button,
.audit-button {
border: 0;
border-radius: 7px;
cursor: pointer;
font-weight: 800;
}
.small-button {
padding: 6px 8px;
color: #526872;
background: #eef2f3;
font-size: 8px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.small-button:hover { background: #e2e9eb; }
.audit-card {
margin-top: 14px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 11px;
background: white;
}
.audit-card.pass {
border-color: rgba(21, 155, 138, 0.28);
background: #f6fcfa;
}
.audit-card.warn {
border-color: rgba(214, 74, 69, 0.24);
background: #fff8f6;
}
.audit-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.audit-heading strong {
font-size: 10px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.audit-badge {
padding: 4px 7px;
border-radius: 999px;
color: #087165;
background: var(--teal-soft);
font-size: 8px;
font-weight: 900;
}
.audit-card.warn .audit-badge {
color: #a23c35;
background: var(--red-soft);
}
.audit-copy {
margin: 8px 0 10px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.audit-rows {
max-height: 128px;
overflow: auto;
margin-bottom: 9px;
}
.audit-row {
display: grid;
grid-template-columns: 22px 1fr auto;
align-items: center;
gap: 7px;
padding: 6px 0;
border-top: 1px solid rgba(21,43,53,0.07);
font-size: 9px;
}
.audit-index {
display: grid;
place-items: center;
width: 20px;
height: 20px;
border-radius: 5px;
color: #a33d20;
background: var(--orange-soft);
font-weight: 900;
}
.audit-target {
color: #334b56;
font-weight: 700;
}
.audit-check {
color: var(--teal);
font-weight: 900;
}
.audit-button {
width: 100%;
padding: 9px;
color: white;
background: var(--navy);
font-size: 9px;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.audit-button:hover { background: #214b59; }
.audit-button.flash {
animation: auditFlash 0.6s ease;
}
@keyframes auditFlash {
0%, 100% { transform: scale(1); }
45% { transform: scale(1.025); background: var(--teal); }
}
.disclaimer {
margin: 12px 2px 0;
color: #7a898f;
font-size: 8px;
line-height: 1.45;
}
.camera-help {
position: fixed;
z-index: 8;
right: 18px;
bottom: 18px;
display: flex;
gap: 12px;
padding: 10px 13px;
border: 1px solid rgba(255,255,255,0.8);
border-radius: 10px;
color: #526872;
background: rgba(250,252,251,0.90);
box-shadow: var(--shadow);
backdrop-filter: blur(10px);
font-size: 9px;
font-weight: 700;
}
.camera-help button {
padding: 4px 7px;
border: 0;
border-radius: 5px;
color: white;
background: var(--navy);
font-size: 8px;
font-weight: 800;
cursor: pointer;
}
#toast {
position: fixed;
z-index: 30;
left: 50%;
bottom: 26px;
max-width: min(420px, calc(100vw - 30px));
padding: 10px 14px;
border-radius: 8px;
color: white;
background: rgba(23,55,68,0.94);
box-shadow: var(--shadow);
font-size: 10px;
font-weight: 700;
opacity: 0;
pointer-events: none;
transform: translate(-50%, 8px);
transition: 180ms ease;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
@media (max-width: 760px) {
.topbar {
top: 10px;
left: 10px;
right: 10px;
}
.brand {
min-width: 0;
padding: 8px 10px 8px 8px;
}
.brand-mark {
width: 36px;
height: 36px;
}
.brand-subtitle { display: none; }
.nonop {
max-width: 115px;
padding: 9px;
font-size: 8px;
line-height: 1.35;
}
.panel {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 48vh;
padding: 14px;
}
.camera-help { display: none; }
h1 { font-size: 21px; }
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive low-poly public-space wayfinding scene"></div>
<div id="labels" aria-hidden="true"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<svg viewBox="0 0 32 32" fill="none">
<path d="M16 3 19.5 12.5 29 16l-9.5 3.5L16 29l-3.5-9.5L3 16l9.5-3.5L16 3Z"
stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>
<circle cx="16" cy="16" r="3.1" fill="currentColor"/>
</svg>
</div>
<div>
<span class="brand-title">WAYFINDING LAB</span>
<span class="brand-subtitle">Civic Pavilion / Graph Simulator</span>
</div>
</div>
<div class="nonop"><span></span>Non-operational demonstration</div>
</header>
<aside class="panel" aria-label="Simulation controls">
<div class="eyebrow">Public-space route model</div>
<h1>Wayfinding Lab</h1>
<p class="intro">
Close corridors to test route changes. Direction markers are published only
when the selected destination is reachable.
</p>
<div class="field-grid">
<div>
<label class="field-label" for="origin">Origin</label>
<select id="origin"></select>
</div>
<div>
<label class="field-label" for="destination">Destination</label>
<select id="destination"></select>
</div>
</div>
<section id="routeCard" class="route-card" aria-live="polite">
<div class="route-top">
<strong>Calculated route</strong>
<span id="routeStatus" class="chip">OPEN</span>
</div>
<div id="routeChain" class="route-chain"></div>
<div id="routeDistance" class="route-distance"></div>
</section>
<div class="metrics">
<div class="metric">
<strong id="reachableMetric">0/9</strong>
<span>Reachable nodes</span>
</div>
<div class="metric">
<strong id="arrowMetric">0</strong>
<span>Active arrows</span>
</div>
<div class="metric">
<strong id="closureMetric">0</strong>
<span>Closures</span>
</div>
</div>
<div class="section-head">
<h2>Corridor closures</h2>
<small id="graphMeta">9 nodes · 9 links</small>
</div>
<div id="closureList" class="closure-list"></div>
<section id="auditCard" class="audit-card pass" aria-live="polite">
<div class="audit-heading">
<strong>Arrow integrity audit</strong>
<span id="auditBadge" class="audit-badge">PASS</span>
</div>
<p id="auditCopy" class="audit-copy"></p>
<div id="auditRows" class="audit-rows"></div>
<button id="auditButton" class="audit-button">Run route verification</button>
</section>
<p class="disclaimer">
Illustrative model only. The graph, room names, closures, and routes are
simulated and must not be used for live navigation or emergency guidance.
</p>
</aside>
<div class="camera-help">
<span>Drag: orbit</span>
<span>Shift/right-drag: pan</span>
<span>Scroll: zoom</span>
<button id="cameraReset" type="button">Reset view</button>
</div>
<div id="toast" role="status"></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Graph model
// -------------------------------------------------------------------------
const nodes = [
{ id: "entry", label: "South Entrance", short: "Entrance", x: -8, z: 5.1 },
{ id: "lobby", label: "Welcome Lobby", short: "Lobby", x: -4, z: 5.1 },
{ id: "atrium", label: "Public Concourse", short: "Atrium", x: 0, z: 5.1 },
{ id: "westHub", label: "West Junction", short: "West Hub", x: -4, z: 1.1 },
{ id: "eastHub", label: "East Junction", short: "East Hub", x: 4, z: 1.1 },
{ id: "council", label: "Council Chamber", short: "Council", x: -8, z: -1.2 },
{ id: "studio", label: "Community Studio", short: "Studio", x: 0, z: -1.2 },
{ id: "cafe", label: "Café & Information", short: "Café", x: 5, z: -1.2 },
{ id: "exit", label: "East Public Exit", short: "Exit", x: 8, z: 1.1 }
];
const edges = [
{ id: "entry-lobby", a: "entry", b: "lobby", name: "Entry approach", initialClosed: false },
{ id: "lobby-atrium", a: "lobby", b: "atrium", name: "Main concourse", initialClosed: false },
{ id: "atrium-west", a: "atrium", b: "westHub", name: "West connector", initialClosed: false },
{ id: "atrium-east", a: "atrium", b: "eastHub", name: "East connector", initialClosed: false },
{ id: "west-council", a: "westHub", b: "council", name: "Council vestibule", initialClosed: false },
{ id: "west-studio", a: "westHub", b: "studio", name: "Studio west link", initialClosed: true },
{ id: "east-studio", a: "eastHub", b: "studio", name: "Studio east link", initialClosed: false },
{ id: "east-cafe", a: "eastHub", b: "cafe", name: "Café spur", initialClosed: false },
{ id: "east-exit", a: "eastHub", b: "exit", name: "East exit passage", initialClosed: false }
];
const nodeById = new Map(nodes.map(node => [node.id, node]));
const edgeById = new Map(edges.map(edge => [edge.id, edge]));
const closedEdges = new Set(edges.filter(edge => edge.initialClosed).map(edge => edge.id));
function edgeLength(edge) {
const a = nodeById.get(edge.a);
const b = nodeById.get(edge.b);
return Math.hypot(b.x - a.x, b.z - a.z);
}
function edgeKey(a, b) {
return [a, b].sort().join("|");
}
function findEdge(a, b) {
return edges.find(edge =>
(edge.a === a && edge.b === b) || (edge.a === b && edge.b === a)
);
}
function computeReachable(originId) {
const adjacency = new Map(nodes.map(node => [node.id, []]));
for (const edge of edges) {
if (closedEdges.has(edge.id)) continue;
adjacency.get(edge.a).push(edge.b);
adjacency.get(edge.b).push(edge.a);
}
const reachable = new Set([originId]);
const queue = [originId];
while (queue.length) {
const current = queue.shift();
for (const neighbor of adjacency.get(current) || []) {
if (!reachable.has(neighbor)) {
reachable.add(neighbor);
queue.push(neighbor);
}
}
}
return reachable;
}
function computeRoute(originId, destinationId) {
if (originId === destinationId) {
return { nodes: [originId], edges: [], length: 0 };
}
const adjacency = new Map(nodes.map(node => [node.id, []]));
for (const edge of edges) {
if (closedEdges.has(edge.id)) continue;
adjacency.get(edge.a).push({ to: edge.b, edge });
adjacency.get(edge.b).push({ to: edge.a, edge });
}
const distances = new Map(nodes.map(node => [node.id, Infinity]));
const previous = new Map();
const queue = [originId];
distances.set(originId, 0);
while (queue.length) {
queue.sort((a, b) => distances.get(a) - distances.get(b));
const current = queue.shift();
if (current === destinationId) break;
for (const connection of adjacency.get(current)) {
const candidate = distances.get(current) + edgeLength(connection.edge);
if (candidate < distances.get(connection.to)) {
distances.set(connection.to, candidate);
previous.set(connection.to, { node: current, edge: connection.edge });
queue.push(connection.to);
}
}
}
if (!Number.isFinite(distances.get(destinationId))) return null;
const routeNodes = [destinationId];
const routeEdges = [];
let cursor = destinationId;
while (cursor !== originId) {
const step = previous.get(cursor);
routeNodes.unshift(step.node);
routeEdges.unshift({
edge: step.edge,
from: step.node,
to: cursor
});
cursor = step.node;
}
return {
nodes: routeNodes,
edges: routeEdges,
length: routeEdges.reduce((sum, item) => sum + edgeLength(item.edge), 0)
};
}
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const stage = document.getElementById("stage");
const labelLayer = document.getElementById("labels");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8eef0);
scene.fog = new THREE.Fog(0xe8eef0, 31, 55);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.12;
stage.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xf7fcff, 0x7b8987, 2.3);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff4df, 3.0);
sun.position.set(-9, 18, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 17;
sun.shadow.camera.bottom = -17;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d8e8, 0.75);
fill.position.set(10, 9, -8);
scene.add(fill);
const material = (color, options = {}) => new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
function addBox(width, height, depth, color, x, y, z, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material(color, options)
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function addFloorLabel(text, x, z, width, color = "#5d7178") {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = color;
context.font = "800 58px Arial, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, canvas.width / 2, canvas.height / 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, width / 4),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
opacity: 0.82
})
);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, 0.145, z);
mesh.renderOrder = 2;
scene.add(mesh);
return mesh;
}
// Plaza and building shell.
addBox(30, 0.22, 21, 0xcbd7d8, 0, -0.35, 0, { roughness: 1 });
addBox(22, 0.30, 14, 0xe8e2d8, 0, -0.05, 0, { roughness: 1 });
// Colored room floor fields.
addBox(5.4, 0.035, 4.8, 0xcbdce3, -7.4, 0.12, -4.0, { roughness: 1 });
addBox(6.0, 0.035, 4.8, 0xe8d2b8, -0.1, 0.12, -4.0, { roughness: 1 });
addBox(6.2, 0.035, 4.8, 0xcbdcc9, 6.0, 0.12, -4.0, { roughness: 1 });
addBox(14.4, 0.025, 4.3, 0xdadfdc, -1.1, 0.115, 4.4, { roughness: 1 });
// Perimeter: intentionally low and cut away for legibility.
addBox(21.8, 1.35, 0.18, 0xf7f3eb, 0, 0.77, -6.55);
addBox(0.18, 1.05, 13.0, 0xf3efe7, -10.75, 0.63, 0);
addBox(0.18, 1.05, 13.0, 0xf3efe7, 10.75, 0.63, 0);
addBox(1.55, 0.58, 0.18, 0xf3efe7, -9.9, 0.39, 6.55);
addBox(16.5, 0.58, 0.18, 0xf3efe7, 1.2, 0.39, 6.55);
// Low interior partitions with door gaps.
addBox(4.6, 0.85, 0.16, 0xf0ece3, -8.1, 0.52, -1.55);
addBox(0.16, 0.85, 2.0, 0xf0ece3, -5.75, 0.52, -2.55);
addBox(4.8, 0.80, 0.16, 0xf0ece3, 0.1, 0.50, -1.55);
addBox(6.2, 0.80, 0.16, 0xf0ece3, 6.5, 0.50, -1.55);
addBox(0.16, 0.80, 2.7, 0xf0ece3, 3.35, 0.50, -2.85);
// Entrance threshold and exterior paving.
addBox(2.1, 0.06, 1.35, 0xd8c6a9, -8, 0.15, 6.2, { roughness: 1 });
addBox(3.2, 0.05, 1.3, 0xbcc9ca, -8, -0.20, 7.4, { roughness: 1 });
addFloorLabel("COUNCIL CHAMBER", -7.4, -5.45, 4.3, "#547481");
addFloorLabel("COMMUNITY STUDIO", -0.1, -5.45, 4.5, "#8b6848");
addFloorLabel("CAFÉ + INFORMATION", 6.0, -5.45, 4.9, "#53705b");
addFloorLabel("PUBLIC CONCOURSE", -1.0, 3.15, 4.3, "#62767c");
// Furniture helpers.
function addTable(x, z, width = 2.2, color = 0x8c7461) {
addBox(width, 0.13, 0.95, color, x, 0.77, z);
addBox(0.16, 0.65, 0.65, 0x5e686a, x - width * 0.36, 0.42, z);
addBox(0.16, 0.65, 0.65, 0x5e686a, x + width * 0.36, 0.42, z);
}
function addPlant(x, z, size = 1) {
const pot = new THREE.Mesh(
new THREE.CylinderGeometry(0.30 * size, 0.24 * size, 0.48 * size, 6),
material(0xb77d59)
);
pot.position.set(x, 0.36 * size, z);
pot.castShadow = true;
scene.add(pot);
const leaf = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.55 * size, 0),
material(0x4c886d, { roughness: 0.95 })
);
leaf.position.set(x, 0.95 * size, z);
leaf.scale.set(0.78, 1.15, 0.78);
leaf.castShadow = true;
scene.add(leaf);
}
function addPerson(x, z, color, angle = 0) {
const group = new THREE.Group();
group.position.set(x, 0.17, z);
group.rotation.y = angle;
const body = new THREE.Mesh(
new THREE.CylinderGeometry(0.15, 0.22, 0.72, 5),
material(color)
);
body.position.y = 0.42;
body.castShadow = true;
group.add(body);
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.17, 1),
material(0xd7a983)
);
head.position.y = 0.95;
head.castShadow = true;
group.add(head);
scene.add(group);
}
addTable(-7.4, -4.1, 2.7);
addTable(-1.1, -3.8, 1.7);
addTable(1.25, -4.5, 1.4);
addBox(2.8, 0.95, 0.75, 0x718e78, 6.4, 0.62, -5.25);
addBox(2.9, 0.10, 0.85, 0xc9b78e, 6.4, 1.14, -5.25);
addPlant(-9.5, 4.7);
addPlant(-6.0, 3.3, 0.8);
addPlant(2.9, 3.1, 0.85);
addPlant(9.5, 3.8);
addPlant(-2.8, -5.4, 0.75);
addPlant(8.6, -5.3, 0.8);
addPerson(-6.2, 4.1, 0xcc704d, -0.8);
addPerson(1.9, 2.9, 0x4f8b89, 0.4);
addPerson(6.3, -3.8, 0x697e9e, 1.8);
addPerson(-6.5, -2.3, 0xb8a35f, -1.1);
// -------------------------------------------------------------------------
// Corridor meshes, closures, and graph nodes
// -------------------------------------------------------------------------
const corridorMeshes = new Map();
const closureOverlays = new Map();
const barriers = new Map();
for (const edge of edges) {
const a = nodeById.get(edge.a);
const b = nodeById.get(edge.b);
const length = edgeLength(edge);
const midpointX = (a.x + b.x) / 2;
const midpointZ = (a.z + b.z) / 2;
const rotation = -Math.atan2(b.z - a.z, b.x - a.x);
const corridor = new THREE.Mesh(
new THREE.BoxGeometry(length, 0.055, 0.72),
material(0xb7c4c6, { roughness: 1 })
);
corridor.position.set(midpointX, 0.19, midpointZ);
corridor.rotation.y = rotation;
corridor.receiveShadow = true;
corridor.userData.edgeId = edge.id;
scene.add(corridor);
corridorMeshes.set(edge.id, corridor);
const lineGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(a.x, 0.225, a.z),
new THREE.Vector3(b.x, 0.225, b.z)
]);
const closureLine = new THREE.Line(
lineGeometry,
new THREE.LineDashedMaterial({
color: 0xd64a45,
dashSize: 0.34,
gapSize: 0.22,
linewidth: 2
})
);
closureLine.computeLineDistances();
closureLine.visible = false;
scene.add(closureLine);
closureOverlays.set(edge.id, closureLine);
const barrier = new THREE.Group();
barrier.position.set(midpointX, 0, midpointZ);
barrier.rotation.y = rotation;
const postGeometry = new THREE.BoxGeometry(0.10, 0.65, 0.10);
for (const z of [-0.43, 0.43]) {
const post = new THREE.Mesh(postGeometry, material(0xd64a45));
post.position.set(0, 0.46, z);
post.castShadow = true;
barrier.add(post);
}
const board = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 0.27, 0.96),
material(0xf3e5da)
);
board.position.set(0, 0.68, 0);
board.castShadow = true;
barrier.add(board);
const stripeGeometry = new THREE.BoxGeometry(0.14, 0.08, 0.58);
for (const rotationZ of [-0.55, 0.55]) {
const stripe = new THREE.Mesh(stripeGeometry, material(0xd64a45));
stripe.position.set(0, 0.69, 0);
stripe.rotation.x = rotationZ;
barrier.add(stripe);
}
barrier.visible = false;
scene.add(barrier);
barriers.set(edge.id, barrier);
}
const nodeMeshes = new Map();
const nodeRings = new Map();
const nodeLabels = new Map();
for (const node of nodes) {
const nodeMesh = new THREE.Mesh(
new THREE.CylinderGeometry(0.36, 0.44, 0.22, 8),
material(0x173744)
);
nodeMesh.position.set(node.x, 0.30, node.z);
nodeMesh.castShadow = true;
nodeMesh.receiveShadow = true;
scene.add(nodeMesh);
nodeMeshes.set(node.id, nodeMesh);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.53, 0.035, 4, 16),
new THREE.MeshBasicMaterial({
color: 0x159b8a,
transparent: true,
opacity: 0.48
})
);
ring.rotation.x = Math.PI / 2;
ring.position.set(node.x, 0.245, node.z);
scene.add(ring);
nodeRings.set(node.id, ring);
const label = document.createElement("div");
label.className = "node-label";
label.textContent = node.short;
labelLayer.appendChild(label);
nodeLabels.set(node.id, label);
}
// Shared low-poly arrow geometry, pointing toward local +Z.
const arrowShape = new THREE.Shape();
arrowShape.moveTo(0, -0.56);
arrowShape.lineTo(0.34, -0.10);
arrowShape.lineTo(0.14, -0.10);
arrowShape.lineTo(0.14, 0.46);
arrowShape.lineTo(-0.14, 0.46);
arrowShape.lineTo(-0.14, -0.10);
arrowShape.lineTo(-0.34, -0.10);
arrowShape.closePath();
const arrowGeometry = new THREE.ShapeGeometry(arrowShape);
arrowGeometry.rotateX(-Math.PI / 2);
const arrowMaterial = material(0xf2673a, {
roughness: 0.48,
emissive: 0x7a240f,
emissiveIntensity: 0.28,
side: THREE.DoubleSide
});
const routeArrowGroup = new THREE.Group();
scene.add(routeArrowGroup);
let activeArrows = [];
// -------------------------------------------------------------------------
// UI state and rendering
// -------------------------------------------------------------------------
const originSelect = document.getElementById("origin");
const destinationSelect = document.getElementById("destination");
const closureList = document.getElementById("closureList");
const routeCard = document.getElementById("routeCard");
const routeStatus = document.getElementById("routeStatus");
const routeChain = document.getElementById("routeChain");
const routeDistance = document.getElementById("routeDistance");
const reachableMetric = document.getElementById("reachableMetric");
const arrowMetric = document.getElementById("arrowMetric");
const closureMetric = document.getElementById("closureMetric");
const auditCard = document.getElementById("auditCard");
const auditBadge = document.getElementById("auditBadge");
const auditCopy = document.getElementById("auditCopy");
const auditRows = document.getElementById("auditRows");
const auditButton = document.getElementById("auditButton");
const toast = document.getElementById("toast");
for (const node of nodes) {
const originOption = document.createElement("option");
originOption.value = node.id;
originOption.textContent = node.label;
originSelect.appendChild(originOption);
const destinationOption = document.createElement("option");
destinationOption.value = node.id;
destinationOption.textContent = node.label;
destinationSelect.appendChild(destinationOption);
}
originSelect.value = "entry";
destinationSelect.value = "studio";
let toastTimer;
function showToast(message) {
toast.textContent = message;
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 2200);
}
function clearArrows() {
routeArrowGroup.clear();
activeArrows = [];
}
function buildArrows(route) {
clearArrows();
if (!route) return;
for (const routeEdge of route.edges) {
const from = nodeById.get(routeEdge.from);
const to = nodeById.get(routeEdge.to);
const length = edgeLength(routeEdge.edge);
const count = length > 4.4 ? 2 : 1;
for (let index = 0; index < count; index++) {
const t = (index + 1) / (count + 1);
const arrow = new THREE.Mesh(arrowGeometry, arrowMaterial);
arrow.position.set(
THREE.MathUtils.lerp(from.x, to.x, t),
0.30,
THREE.MathUtils.lerp(from.z, to.z, t)
);
arrow.rotation.y = Math.atan2(to.x - from.x, to.z - from.z);
arrow.castShadow = true;
arrow.userData = {
edgeId: routeEdge.edge.id,
from: routeEdge.from,
to: routeEdge.to,
fromName: nodeById.get(routeEdge.from).label,
toName: nodeById.get(routeEdge.to).label,
phase: index * 1.7 + route.edges.indexOf(routeEdge) * 0.8
};
routeArrowGroup.add(arrow);
activeArrows.push(arrow);
}
}
}
function renderClosureList(routeEdgeIds) {
closureList.innerHTML = edges.map(edge => {
const closed = closedEdges.has(edge.id);
const onRoute = routeEdgeIds.has(edge.id);
const state = closed ? "Closed" : onRoute ? "On route" : "Open";
const endpoints = `${nodeById.get(edge.a).short} ↔ ${nodeById.get(edge.b).short}`;
return `
<button
type="button"
class="closure-button ${closed ? "closed" : ""} ${onRoute ? "on-route" : ""}"
data-edge="${edge.id}"
aria-pressed="${closed}"
title="${closed ? "Reopen" : "Close"} this corridor"
>
<span class="status-dot"></span>
<span>
<span class="closure-name">${edge.name}</span>
<span class="closure-meta">${endpoints}</span>
</span>
<span class="closure-state">${state}</span>
</button>
`;
}).join("");
}
function renderAll() {
const originId = originSelect.value;
const destinationId = destinationSelect.value;
const reachable = computeReachable(originId);
const route = computeRoute(originId, destinationId);
const routeEdgeIds = new Set(route ? route.edges.map(item => item.edge.id) : []);
for (const edge of edges) {
const closed = closedEdges.has(edge.id);
const onRoute = routeEdgeIds.has(edge.id);
const corridor = corridorMeshes.get(edge.id);
const overlay = closureOverlays.get(edge.id);
const barrier = barriers.get(edge.id);
corridor.material.color.setHex(
closed ? 0xd3d7d6 : onRoute ? 0x55b7aa : 0xb7c4c6
);
corridor.material.emissive.setHex(onRoute && !closed ? 0x0b3934 : 0x000000);
corridor.material.emissiveIntensity = onRoute && !closed ? 0.16 : 0;
overlay.visible = closed;
barrier.visible = closed;
}
for (const node of nodes) {
const isOrigin = node.id === originId;
const isDestination = node.id === destinationId;
const isReachable = reachable.has(node.id);
nodeMeshes.get(node.id).material.color.setHex(
isOrigin ? 0x159b8a : isDestination ? 0xf2673a : 0x173744
);
const ring = nodeRings.get(node.id);
ring.material.color.setHex(isReachable ? 0x159b8a : 0xa5afb2);
ring.material.opacity = isReachable ? 0.48 : 0.18;
const label = nodeLabels.get(node.id);
label.classList.toggle("origin", isOrigin);
label.classList.toggle("destination", isDestination && !isOrigin);
}
buildArrows(route);
if (route) {
routeCard.classList.remove("blocked");
routeStatus.classList.remove("warn");
routeStatus.textContent = route.edges.length ? "OPEN ROUTE" : "AT ORIGIN";
routeChain.innerHTML = route.nodes.map((nodeId, index) => {
const node = nodeById.get(nodeId);
return `${index ? '<span class="arrow">→</span>' : ""}<span>${node.short}</span>`;
}).join("");
routeDistance.textContent = route.edges.length
? `${route.edges.length} open corridors · ${route.length.toFixed(1)} m modeled distance`
: "Origin and destination are the same node.";
} else {
routeCard.classList.add("blocked");
routeStatus.classList.add("warn");
routeStatus.textContent = "BLOCKED";
routeChain.innerHTML = `
<span>No open path to ${nodeById.get(destinationId).short}.</span>
`;
routeDistance.textContent = "Guidance arrows are suppressed while the destination is unreachable.";
}
reachableMetric.textContent = `${reachable.size}/${nodes.length}`;
arrowMetric.textContent = activeArrows.length;
closureMetric.textContent = closedEdges.size;
renderClosureList(routeEdgeIds);
const allArrowTargetsReachable = activeArrows.every(arrow => reachable.has(arrow.userData.to));
if (route) {
auditCard.classList.remove("warn");
auditBadge.textContent = "PASS";
if (activeArrows.length === 0) {
auditCopy.textContent =
`No guidance markers are required because the origin is already the destination. The node is reachable.`;
auditRows.innerHTML = "";
} else {
auditCopy.textContent =
`${activeArrows.length} active direction markers checked. Every marker follows the open-edge chain toward ${nodeById.get(destinationId).label}, and every arrow target is reachable.`;
auditRows.innerHTML = activeArrows.map((arrow, index) => `
<div class="audit-row">
<span class="audit-index">${index + 1}</span>
<span class="audit-target">${arrow.userData.fromName} → ${arrow.userData.toName}</span>
<span class="audit-check">✓ reachable</span>
</div>
`).join("");
}
} else {
auditCard.classList.add("warn");
auditBadge.textContent = "BLOCKED";
auditCopy.textContent =
`${nodeById.get(destinationId).label} is not reachable from ${nodeById.get(originId).label}. No misleading guidance arrows are published.`;
auditRows.innerHTML = `
<div class="audit-row">
<span class="audit-index">0</span>
<span class="audit-target">No active arrows</span>
<span class="audit-check">✓ suppressed</span>
</div>
`;
}
if (!allArrowTargetsReachable) {
auditCard.classList.add("warn");
auditBadge.textContent = "FAIL";
auditCopy.textContent = "One or more arrow targets failed the reachability check.";
}
}
function toggleClosure(edgeId) {
const edge = edgeById.get(edgeId);
if (!edge) return;
if (closedEdges.has(edgeId)) {
closedEdges.delete(edgeId);
showToast(`Reopened: ${edge.name}`);
} else {
closedEdges.add(edgeId);
showToast(`Closed: ${edge.name}`);
}
renderAll();
}
closureList.addEventListener("click", event => {
const button = event.target.closest("[data-edge]");
if (button) toggleClosure(button.dataset.edge);
});
originSelect.addEventListener("change", renderAll);
destinationSelect.addEventListener("change", renderAll);
auditButton.addEventListener("click", () => {
renderAll();
auditButton.classList.remove("flash");
void auditButton.offsetWidth;
auditButton.classList.add("flash");
showToast("Arrow-to-reachable-destination verification completed.");
});
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, zoom, touch pinch
// -------------------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(0, 0, 0),
radius: 26,
theta: 0.56,
phi: 0.88
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
camera.updateMatrixWorld();
}
function resetCamera() {
cameraState.target.set(0, 0, 0);
cameraState.radius = 26;
cameraState.theta = 0.56;
cameraState.phi = 0.88;
updateCamera();
}
document.getElementById("cameraReset").addEventListener("click", resetCamera);
const pointers = new Map();
let pinchDistance = 0;
const canvas = renderer.domElement;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
startX: event.clientX,
startY: event.clientY,
moved: 0,
button: event.button
});
if (pointers.size === 2) {
const points = [...pointers.values()];
pinchDistance = Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y);
}
});
canvas.addEventListener("pointermove", event => {
const pointer = pointers.get(event.pointerId);
if (!pointer) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
pointer.moved += Math.hypot(dx, dy);
if (pointers.size === 1) {
const wantsPan = event.shiftKey || pointer.button === 2;
if (wantsPan) {
const right = new THREE.Vector3()
.setFromMatrixColumn(camera.matrixWorld, 0);
right.y = 0;
right.normalize();
const forward = new THREE.Vector3()
.setFromMatrixColumn(camera.matrixWorld, 2);
forward.y = 0;
forward.normalize();
const panScale = cameraState.radius * 0.0016;
cameraState.target.addScaledVector(right, -dx * panScale);
cameraState.target.addScaledVector(forward, dy * panScale);
cameraState.target.x = THREE.MathUtils.clamp(cameraState.target.x, -9, 9);
cameraState.target.z = THREE.MathUtils.clamp(cameraState.target.z, -7, 7);
} else {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - dy * 0.005, 0.34, 1.35);
}
} else if (pointers.size === 2) {
const points = [...pointers.values()];
const nextDistance = Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y);
if (pinchDistance > 0 && nextDistance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * (pinchDistance / nextDistance),
15,
39
);
}
pinchDistance = nextDistance;
}
updateCamera();
});
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
function pickCorridor(event) {
const rect = canvas.getBoundingClientRect();
pointerNDC.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointerNDC.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
const hits = raycaster.intersectObjects([...corridorMeshes.values()], false);
return hits.length ? hits[0].object.userData.edgeId : null;
}
canvas.addEventListener("pointerup", event => {
const pointer = pointers.get(event.pointerId);
if (!pointer) return;
const wasSinglePointer = pointers.size === 1;
pointers.delete(event.pointerId);
if (wasSinglePointer && pointer.moved < 6 && pointer.button === 0) {
const edgeId = pickCorridor(event);
if (edgeId) toggleClosure(edgeId);
}
if (pointers.size < 2) pinchDistance = 0;
});
canvas.addEventListener("pointercancel", event => {
pointers.delete(event.pointerId);
pinchDistance = 0;
});
canvas.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
15,
39
);
updateCamera();
}, { passive: false });
// -------------------------------------------------------------------------
// Label projection and render loop
// -------------------------------------------------------------------------
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const node of nodes) {
projected.set(node.x, 0.92, node.z).project(camera);
const label = nodeLabels.get(node.id);
if (projected.z < -1 || projected.z > 1) {
label.style.display = "none";
continue;
}
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.style.display = "flex";
label.style.transform = `translate(${x}px, ${y}px) translate(-50%, -100%)`;
}
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
function animate(time) {
requestAnimationFrame(animate);
for (const arrow of activeArrows) {
const pulse = 1 + Math.sin(time * 0.004 + arrow.userData.phase) * 0.07;
arrow.scale.setScalar(pulse);
arrow.position.y = 0.30 + Math.sin(time * 0.003 + arrow.userData.phase) * 0.012;
}
updateLabels();
renderer.render(scene, camera);
}
resize();
updateCamera();
renderAll();
requestAnimationFrame(animate);
</script>
</body>
</html>
```