Prompt specification
Build or customize the Three.js 3D scene "Elevator Outage Changes Transfer Feasibility" 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: Elevator Outage Changes Transfer Feasibility
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/elevator-outage-changes-transfer-feasibility-x2152
Scene Description Prompt:
Elevator outage changes transfer feasibility. Create a schematic interchange where one accessible route becomes unavailable. Recompute reachable platform paths for different mobility proxies without assuming stairs are usable by everyone. Please build this with Three.js from cdnjs in one self-contained HTML file, using low-poly forms.
Working Three.js Starter (elevator-outage-changes-transfer-feasibility-x2152):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Interchange Access — Outage Routing</title>
<style>
:root {
--ink: #173039;
--muted: #64777b;
--line: #d9e4e2;
--paper: #f4f7f6;
--panel: #ffffff;
--accent: #08776f;
--accent-soft: #e3f3f0;
--blue: #3268d6;
--red: #df654f;
--green: #2a9969;
--warning: #e87843;
--shadow: 0 14px 36px rgba(22, 52, 57, .12);
}
* { box-sizing: border-box; }
html, body {
margin: 0;
min-height: 100%;
background: var(--paper);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button { font: inherit; }
.app {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 28px;
padding: 22px 28px;
border-bottom: 1px solid var(--line);
background: rgba(255, 255, 255, .88);
backdrop-filter: blur(16px);
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
width: 43px;
height: 43px;
flex: 0 0 auto;
display: grid;
place-items: center;
border-radius: 13px;
color: white;
background: var(--ink);
box-shadow: 0 6px 18px rgba(23, 48, 57, .18);
}
.eyebrow {
margin: 0 0 5px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .15em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(21px, 2.1vw, 31px);
line-height: 1.08;
letter-spacing: -.035em;
}
.top-status {
display: flex;
align-items: center;
gap: 10px;
flex: 0 0 auto;
padding: 10px 14px;
border: 1px solid #f0cbb9;
border-radius: 999px;
background: #fff6f0;
color: #9d4927;
font-size: 12px;
font-weight: 750;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--warning);
box-shadow: 0 0 0 5px rgba(232, 120, 67, .12);
}
.layout {
flex: 1;
min-height: 0;
display: grid;
grid-template-columns: minmax(0, 1fr) 370px;
}
.viewport {
position: relative;
min-width: 0;
min-height: 650px;
overflow: hidden;
background:
radial-gradient(circle at 30% 15%, rgba(255,255,255,.9), transparent 35%),
linear-gradient(145deg, #edf3f1, #e6eeec);
}
canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.scene-heading {
position: absolute;
z-index: 4;
top: 22px;
left: 24px;
pointer-events: none;
}
.scene-chip {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 11px;
border: 1px solid rgba(255,255,255,.8);
border-radius: 9px;
background: rgba(255,255,255,.78);
box-shadow: 0 5px 18px rgba(33, 59, 64, .07);
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
backdrop-filter: blur(12px);
}
.scene-chip .mini-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--warning);
}
.scene-heading p {
margin: 10px 0 0;
color: #5e7478;
font-size: 12px;
}
.camera-tools {
position: absolute;
z-index: 5;
right: 20px;
top: 20px;
display: flex;
gap: 7px;
}
.tool-button {
width: 38px;
height: 38px;
display: grid;
place-items: center;
border: 1px solid rgba(255,255,255,.9);
border-radius: 10px;
background: rgba(255,255,255,.82);
color: var(--ink);
cursor: pointer;
box-shadow: 0 5px 18px rgba(33, 59, 64, .07);
backdrop-filter: blur(12px);
}
.tool-button:hover { background: white; }
.tool-button svg {
width: 17px;
height: 17px;
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
}
.legend {
position: absolute;
z-index: 4;
left: 22px;
bottom: 20px;
display: flex;
flex-wrap: wrap;
gap: 8px;
max-width: calc(100% - 44px);
pointer-events: none;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 10px;
border: 1px solid rgba(255,255,255,.8);
border-radius: 9px;
background: rgba(255,255,255,.78);
color: #586d72;
font-size: 10px;
font-weight: 700;
backdrop-filter: blur(10px);
}
.legend-line {
width: 18px;
height: 3px;
border-radius: 4px;
background: #839598;
}
.legend-line.stairs {
background: repeating-linear-gradient(
90deg, #839598 0 4px, transparent 4px 7px
);
}
.legend-line.lift { background: #45a59c; }
.legend-line.ramp { background: #77a85c; }
.legend-line.out { background: var(--warning); }
.camera-hint {
position: absolute;
z-index: 4;
right: 20px;
bottom: 21px;
padding: 8px 10px;
border-radius: 8px;
color: #718287;
background: rgba(255,255,255,.64);
font-size: 10px;
pointer-events: none;
}
#labels {
position: absolute;
inset: 0;
z-index: 3;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
min-width: 112px;
padding: 8px 10px 8px 11px;
border: 1px solid rgba(255,255,255,.92);
border-left: 4px solid var(--platform-color, #789);
border-radius: 8px;
background: rgba(255,255,255,.9);
box-shadow: 0 8px 22px rgba(25, 51, 57, .13);
transform: translate(-50%, -50%);
backdrop-filter: blur(10px);
transition: opacity .2s ease;
}
.world-label strong {
display: block;
font-size: 11px;
line-height: 1.15;
}
.world-label small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: .07em;
text-transform: uppercase;
}
.world-label.unreachable {
border-left-color: var(--warning);
opacity: .8;
}
.world-label.unreachable small { color: #b5572f; }
.world-label.callout {
min-width: 145px;
border-left-color: var(--warning);
background: rgba(255,247,242,.95);
}
.world-label.callout.restored {
border-left-color: var(--green);
background: rgba(241,251,246,.95);
}
.world-label.callout strong {
color: #a14d29;
font-size: 10px;
letter-spacing: .06em;
text-transform: uppercase;
}
.world-label.callout.restored strong { color: #267753; }
.panel {
position: relative;
z-index: 6;
min-width: 0;
overflow-y: auto;
border-left: 1px solid var(--line);
background: rgba(255,255,255,.97);
box-shadow: -10px 0 30px rgba(30, 55, 60, .04);
}
.panel-inner {
padding: 24px;
}
.panel-title {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 18px;
}
.panel-title h2 {
margin: 0;
font-size: 20px;
letter-spacing: -.025em;
}
.panel-title p {
margin: 6px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.count-badge {
flex: 0 0 auto;
padding: 7px 9px;
border-radius: 9px;
color: var(--accent);
background: var(--accent-soft);
font-size: 11px;
font-weight: 800;
}
.section {
padding: 18px 0;
border-top: 1px solid var(--line);
}
.section:first-of-type { border-top: 0; padding-top: 0; }
.section-label {
margin: 0 0 10px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .13em;
text-transform: uppercase;
}
.outage-toggle {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
padding: 13px;
border: 1px solid #efc9b7;
border-radius: 12px;
background: #fff7f2;
color: #8f4527;
text-align: left;
cursor: pointer;
}
.outage-toggle:hover { border-color: #dfa586; }
.outage-toggle strong {
display: block;
font-size: 13px;
}
.outage-toggle small {
display: block;
margin-top: 4px;
color: #a56a50;
font-size: 10px;
line-height: 1.35;
}
.switch {
position: relative;
width: 39px;
height: 23px;
flex: 0 0 auto;
border-radius: 999px;
background: var(--warning);
box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.switch::after {
content: "";
position: absolute;
top: 3px;
right: 3px;
width: 17px;
height: 17px;
border-radius: 50%;
background: white;
box-shadow: 0 2px 5px rgba(0,0,0,.2);
transition: transform .2s ease;
}
.outage-toggle.restored {
border-color: #bfe1d2;
background: #f1fbf6;
color: #286f50;
}
.outage-toggle.restored small { color: #5c8a72; }
.outage-toggle.restored .switch { background: var(--green); }
.outage-toggle.restored .switch::after { transform: translateX(-16px); }
.profiles {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.profile-button {
min-height: 72px;
padding: 10px;
border: 1px solid var(--line);
border-radius: 11px;
background: #fbfcfc;
color: var(--ink);
text-align: left;
cursor: pointer;
transition: border-color .15s ease, background .15s ease;
}
.profile-button:hover { border-color: #aac6c1; }
.profile-button.active {
border-color: var(--accent);
background: var(--accent-soft);
box-shadow: inset 0 0 0 1px rgba(8,119,111,.08);
}
.profile-button .profile-icon {
display: block;
margin-bottom: 5px;
color: var(--accent);
font-size: 17px;
font-weight: 800;
}
.profile-button strong {
display: block;
font-size: 11px;
}
.profile-button small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.capabilities {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.capability {
padding: 5px 7px;
border-radius: 6px;
background: #f1f5f4;
color: #597075;
font-size: 9px;
font-weight: 750;
}
.capability.blocked {
color: #ad5735;
background: #fff0e8;
text-decoration: line-through;
}
.profile-note {
margin: 10px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.result-summary {
margin: 0 0 12px;
padding: 12px;
border-radius: 10px;
background: #f4f8f7;
color: #536a6f;
font-size: 11px;
line-height: 1.45;
}
.result-summary.warning {
color: #8d512f;
background: #fff5ee;
}
.routes {
display: grid;
gap: 8px;
}
.route-row {
width: 100%;
display: grid;
grid-template-columns: 10px minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
padding: 11px;
border: 1px solid var(--line);
border-radius: 10px;
background: white;
color: var(--ink);
text-align: left;
cursor: pointer;
}
.route-row:hover { border-color: #abc7c2; }
.route-row.selected {
border-color: var(--accent);
box-shadow: 0 0 0 2px rgba(8,119,111,.08);
}
.route-row.unavailable {
background: #fafafa;
color: #8b9598;
}
.route-color {
width: 9px;
height: 32px;
border-radius: 99px;
background: var(--route-color);
}
.route-row.unavailable .route-color { background: #b6bec0; }
.route-name {
display: block;
font-size: 11px;
font-weight: 800;
}
.route-path {
display: block;
margin-top: 3px;
overflow: hidden;
color: var(--muted);
font-size: 9px;
line-height: 1.35;
text-overflow: ellipsis;
white-space: nowrap;
}
.route-time {
color: #38545a;
font-size: 10px;
font-weight: 800;
text-align: right;
white-space: nowrap;
}
.route-time.unreachable {
color: #ae5b37;
font-size: 9px;
}
.selected-detail {
margin-top: 11px;
padding: 13px;
border: 1px solid #d8e7e3;
border-radius: 11px;
background: #f8fbfa;
}
.selected-detail h3 {
margin: 0;
font-size: 12px;
}
.selected-detail p {
margin: 6px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.route-chips {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin-top: 9px;
}
.route-chip {
padding: 4px 6px;
border-radius: 5px;
color: #42635f;
background: #e5f2ef;
font-size: 8px;
font-weight: 800;
letter-spacing: .03em;
text-transform: uppercase;
}
.route-chip.stairs {
color: #835b30;
background: #f7eadb;
}
.method {
color: #77878b;
font-size: 9px;
line-height: 1.55;
}
.method strong { color: #526970; }
@media (max-width: 960px) {
.layout { grid-template-columns: 1fr; }
.viewport { min-height: 610px; }
.panel { border-left: 0; border-top: 1px solid var(--line); }
.panel-inner { max-width: 680px; margin: 0 auto; }
}
@media (max-width: 620px) {
.topbar { padding: 17px; align-items: flex-start; }
.top-status { display: none; }
.viewport { min-height: 540px; }
.scene-heading { left: 16px; top: 16px; }
.scene-heading p { display: none; }
.camera-tools { right: 14px; top: 14px; }
.camera-hint { display: none; }
.legend { left: 14px; bottom: 14px; }
.panel-inner { padding: 20px 16px; }
.profiles { grid-template-columns: 1fr 1fr; }
.world-label { min-width: 94px; padding: 6px 8px; }
.world-label strong { font-size: 9px; }
.world-label small { font-size: 7px; }
}
@media (prefers-reduced-motion: reduce) {
* { transition: none !important; }
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<svg width="27" height="27" viewBox="0 0 27 27">
<path d="M5 8h7v5h10v6H12v-5H5z" fill="none" stroke="currentColor" stroke-width="2.4"/>
<circle cx="5" cy="8" r="2.4" fill="currentColor"/>
<circle cx="22" cy="19" r="2.4" fill="currentColor"/>
<circle cx="12" cy="13" r="2.4" fill="currentColor"/>
</svg>
</div>
<div>
<p class="eyebrow">Access Network / Scenario 04</p>
<h1>One lift out changes the interchange.</h1>
</div>
</div>
<div class="top-status" id="topStatus">
<span class="status-dot"></span>
<span id="topStatusText">Blue lift out of service</span>
</div>
</header>
<main class="layout">
<section class="viewport" id="viewport" aria-label="Interactive schematic interchange">
<canvas
id="scene"
role="img"
aria-label="Three-dimensional schematic showing the entrance, concourse, Blue, Red, and Green platforms. Drag to orbit and scroll to zoom."
></canvas>
<div id="labels" aria-hidden="true"></div>
<div class="scene-heading">
<div class="scene-chip">
<span class="mini-dot"></span>
Live outage simulation
</div>
<p>Schematic geometry · vertical separation is exaggerated</p>
</div>
<div class="camera-tools" aria-label="Camera controls">
<button class="tool-button" id="resetCamera" title="Reset camera" aria-label="Reset camera">
<svg viewBox="0 0 24 24">
<path d="M4 9a8 8 0 1 1 .9 7.1"/>
<path d="M4 4v5h5"/>
</svg>
</button>
<button class="tool-button" id="topCamera" title="Top view" aria-label="Top view">
<svg viewBox="0 0 24 24">
<path d="m4 8 8-4 8 4-8 4z"/>
<path d="m4 12 8 4 8-4M4 16l8 4 8-4"/>
</svg>
</button>
</div>
<div class="legend" aria-label="Route legend">
<span class="legend-item"><span class="legend-line lift"></span>Elevator</span>
<span class="legend-item"><span class="legend-line ramp"></span>Ramp</span>
<span class="legend-item"><span class="legend-line stairs"></span>Stairs</span>
<span class="legend-item"><span class="legend-line out"></span>Outage</span>
</div>
<div class="camera-hint">Drag to orbit · scroll to zoom</div>
</section>
<aside class="panel">
<div class="panel-inner">
<div class="panel-title">
<div>
<p class="eyebrow">Journey simulator</p>
<h2>Reachable platforms</h2>
<p>From the street entrance, under current conditions.</p>
</div>
<span class="count-badge" id="reachableCount">2 / 3</span>
</div>
<section class="section">
<p class="section-label">Network disruption</p>
<button class="outage-toggle" id="outageToggle" aria-pressed="true">
<span>
<strong id="outageTitle">Blue lift unavailable</strong>
<small id="outageSubtitle">Remove the step-free Hall ↔ Blue connection.</small>
</span>
<span class="switch" aria-hidden="true"></span>
</button>
</section>
<section class="section">
<p class="section-label">Mobility proxy</p>
<div class="profiles" id="profiles"></div>
<div class="capabilities" id="capabilities"></div>
<p class="profile-note" id="profileNote"></p>
</section>
<section class="section">
<p class="section-label">Recomputed paths</p>
<div class="result-summary" id="resultSummary" aria-live="polite"></div>
<div class="routes" id="routes"></div>
<div class="selected-detail" id="selectedDetail"></div>
</section>
<section class="section method">
<p class="section-label">Routing assumptions</p>
<strong>Inaccessible edges are removed before routing.</strong>
Elevator wait time, proxy walking speed, vertical travel, and stair effort are
included in route estimates. Stairs are never assumed to be usable by
wheelchair or pushchair proxies. This is a schematic rather than a surveyed
station plan.
</section>
</div>
</aside>
</main>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (selector) => document.querySelector(selector);
const viewport = $("#viewport");
const canvas = $("#scene");
const labelsRoot = $("#labels");
const OUTAGE_EDGE = "hall-blue-lift";
const state = {
outage: true,
profileId: "wheelchair",
selectedPlatform: "green",
results: {}
};
const platformMeta = {
blue: {
name: "Blue platform",
shortName: "Blue",
color: "#3268d6",
level: "Lower level"
},
red: {
name: "Red platform",
shortName: "Red",
color: "#df654f",
level: "Upper level"
},
green: {
name: "Green platform",
shortName: "Green",
color: "#2a9969",
level: "Street level"
}
};
const profiles = [
{
id: "wheelchair",
label: "Wheelchair",
icon: "♿",
tag: "Step-free",
speed: 1.0,
liftWait: 24,
stairPenalty: 0,
allowed: ["walkway", "elevator", "ramp"],
capabilities: ["Level walk", "Elevator", "Ramp"],
note: "Requires a continuous step-free route. Stairs are excluded from the graph."
},
{
id: "pushchair",
label: "Pushchair",
icon: "▣",
tag: "No stairs",
speed: 0.72,
liftWait: 20,
stairPenalty: 0,
allowed: ["walkway", "elevator", "ramp"],
capabilities: ["Level walk", "Elevator", "Ramp"],
note: "Uses step-free links only and carries a lower walking-speed allowance."
},
{
id: "limited-steps",
label: "Limited steps",
icon: "◒",
tag: "Stairs difficult",
speed: 0.65,
liftWait: 28,
stairPenalty: 12,
allowed: ["walkway", "elevator", "ramp", "stairs"],
capabilities: ["Level walk", "Elevator", "Ramp", "Stairs"],
note: "Can manage stairs, but they carry a substantial time and effort penalty."
},
{
id: "standard",
label: "Standard walker",
icon: "→",
tag: "Unrestricted",
speed: 1.25,
liftWait: 20,
stairPenalty: 6,
allowed: ["walkway", "elevator", "ramp", "stairs"],
capabilities: ["Level walk", "Elevator", "Ramp", "Stairs"],
note: "Can use all modeled links. Faster stair traversal makes stairs competitive."
}
];
const nodes = {
entrance: new THREE.Vector3(-6.2, 0.65, 0),
hall: new THREE.Vector3(0, 0, 0),
blue: new THREE.Vector3(0, -2.2, -4.2),
red: new THREE.Vector3(0, 2.2, 4.0),
green: new THREE.Vector3(5.4, -0.7, 0)
};
const edges = [
{
id: "entrance-hall",
from: "entrance",
to: "hall",
type: "walkway",
label: "Street walk",
waypoints: [
nodes.entrance.clone(),
new THREE.Vector3(-3.2, 0.3, 0),
nodes.hall.clone()
]
},
{
id: "hall-blue-lift",
from: "hall",
to: "blue",
type: "elevator",
label: "Blue lift",
waypoints: [
nodes.hall.clone(),
new THREE.Vector3(1.1, 0, -1.2),
new THREE.Vector3(1.1, -2.2, -1.2),
nodes.blue.clone()
]
},
{
id: "hall-blue-stairs",
from: "hall",
to: "blue",
type: "stairs",
label: "Blue stairs",
waypoints: [
nodes.hall.clone(),
new THREE.Vector3(-1.0, 0, -1.2),
new THREE.Vector3(-1.0, -2.2, -3.2),
nodes.blue.clone()
]
},
{
id: "hall-red-lift",
from: "hall",
to: "red",
type: "elevator",
label: "Red lift",
waypoints: [
nodes.hall.clone(),
new THREE.Vector3(1.1, 0, 1.2),
new THREE.Vector3(1.1, 2.2, 1.2),
nodes.red.clone()
]
},
{
id: "hall-red-stairs",
from: "hall",
to: "red",
type: "stairs",
label: "Red stairs",
waypoints: [
nodes.hall.clone(),
new THREE.Vector3(-1.05, 0, 1.2),
new THREE.Vector3(-1.05, 2.2, 3.0),
nodes.red.clone()
]
},
{
id: "hall-green-ramp",
from: "hall",
to: "green",
type: "ramp",
label: "Green ramp",
waypoints: [
nodes.hall.clone(),
new THREE.Vector3(2.4, 0, -1.05),
new THREE.Vector3(4.1, -0.7, -1.05),
nodes.green.clone()
]
},
{
id: "hall-green-stairs",
from: "hall",
to: "green",
type: "stairs",
label: "Green stairs",
waypoints: [
nodes.hall.clone(),
new THREE.Vector3(2.4, 0, 1.05),
new THREE.Vector3(4.1, -0.7, 1.05),
nodes.green.clone()
]
}
];
const edgeById = new Map(edges.map((edge) => [edge.id, edge]));
const adjacency = new Map();
for (const id of Object.keys(nodes)) adjacency.set(id, []);
for (const edge of edges) {
adjacency.get(edge.from).push({ node: edge.to, edge });
adjacency.get(edge.to).push({ node: edge.from, edge });
}
// ---------------------------------------------------------------------
// Routing model
// ---------------------------------------------------------------------
function edgeBlocked(edge, profile) {
if (state.outage && edge.id === OUTAGE_EDGE) return true;
return !profile.allowed.includes(edge.type);
}
function edgeMetrics(edge) {
let horizontal = 0;
let vertical = 0;
let total = 0;
for (let i = 1; i < edge.waypoints.length; i++) {
const a = edge.waypoints[i - 1];
const b = edge.waypoints[i];
const dx = b.x - a.x;
const dy = b.y - a.y;
const dz = b.z - a.z;
horizontal += Math.hypot(dx, dz);
vertical += Math.abs(dy);
total += Math.hypot(dx, dy, dz);
}
return { horizontal, vertical, total };
}
function edgeCost(edge, profile) {
const m = edgeMetrics(edge);
switch (edge.type) {
case "elevator":
return m.horizontal / profile.speed + m.vertical / 0.65 + profile.liftWait;
case "stairs":
return m.horizontal / profile.speed + m.vertical * 4 + profile.stairPenalty;
case "ramp":
return m.total / profile.speed + m.vertical * 2;
default:
return m.total / profile.speed;
}
}
function shortestPath(target, profile) {
const distances = new Map();
const previous = new Map();
const queue = [];
for (const id of Object.keys(nodes)) distances.set(id, Infinity);
distances.set("entrance", 0);
queue.push({ id: "entrance", cost: 0 });
while (queue.length) {
queue.sort((a, b) => a.cost - b.cost);
const current = queue.shift();
if (current.cost !== distances.get(current.id)) continue;
if (current.id === target) break;
for (const connection of adjacency.get(current.id)) {
const { edge, node } = connection;
if (edgeBlocked(edge, profile)) continue;
const nextCost = current.cost + edgeCost(edge, profile);
if (nextCost < distances.get(node)) {
distances.set(node, nextCost);
previous.set(node, { node: current.id, edge: edge.id });
queue.push({ id: node, cost: nextCost });
}
}
}
if (!Number.isFinite(distances.get(target))) return null;
const pathNodes = [];
const pathEdges = [];
let cursor = target;
while (cursor !== "entrance") {
const step = previous.get(cursor);
if (!step) return null;
pathNodes.push(cursor);
pathEdges.push(step.edge);
cursor = step.node;
}
pathNodes.push("entrance");
pathNodes.reverse();
pathEdges.reverse();
return {
cost: distances.get(target),
nodes: pathNodes,
edges: pathEdges
};
}
function computeAllRoutes(profile) {
const results = {};
for (const platform of Object.keys(platformMeta)) {
results[platform] = shortestPath(platform, profile);
}
return results;
}
function pathDescription(path) {
if (!path) return "No permitted route";
return path.edges.map((id) => edgeById.get(id).label).join(" → ");
}
// ---------------------------------------------------------------------
// Three.js scene
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color("#eaf1ef");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const camera = new THREE.OrthographicCamera(-10, 10, 8, -8, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, -0.1, 0);
const cameraState = {
theta: 0.72,
phi: 0.79,
zoom: 1
};
const ambient = new THREE.HemisphereLight(0xffffff, 0x6e8584, 2.0);
scene.add(ambient);
const sun = new THREE.DirectionalLight(0xfffbf4, 3.2);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x93c8cf, 1.1);
fill.position.set(9, 4, -8);
scene.add(fill);
const worldGroup = new THREE.Group();
const equipmentGroup = new THREE.Group();
const routeGroup = new THREE.Group();
const markerGroup = new THREE.Group();
scene.add(worldGroup, equipmentGroup, routeGroup, markerGroup);
const liftVisuals = new Map();
const platformMarkers = new Map();
const material = {
ground: new THREE.MeshStandardMaterial({ color: 0xdde7e4, roughness: 0.92 }),
concrete: new THREE.MeshStandardMaterial({ color: 0xb8c4c2, roughness: 0.8 }),
concreteLight: new THREE.MeshStandardMaterial({ color: 0xd5deda, roughness: 0.75 }),
dark: new THREE.MeshStandardMaterial({ color: 0x31474c, roughness: 0.62 }),
rail: new THREE.MeshStandardMaterial({ color: 0x607174, roughness: 0.52 }),
glass: new THREE.MeshStandardMaterial({
color: 0x69aaa5,
transparent: true,
opacity: 0.24,
depthWrite: false,
roughness: 0.2
})
};
function addBox(parent, size, position, mat, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(...size), mat);
mesh.position.set(...position);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinderBetween(parent, a, b, radius, mat) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
if (length < 0.001) return null;
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 8),
mat
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
mesh.castShadow = false;
parent.add(mesh);
return mesh;
}
function addBeamBetween(parent, a, b, width, thickness, mat) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
if (length < 0.001) return null;
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, thickness, length),
mat
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 0, 1),
direction.clone().normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addGround() {
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(38, 38),
material.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -3.12;
ground.receiveShadow = true;
worldGroup.add(ground);
const grid = new THREE.GridHelper(34, 34, 0xc5d3cf, 0xd3dfdc);
grid.position.y = -3.10;
grid.material.transparent = true;
grid.material.opacity = 0.42;
worldGroup.add(grid);
}
function addPlatform(center, size, color, orientation) {
const base = addBox(
worldGroup,
[size.x, 0.28, size.z],
[center.x, center.y - 0.14, center.z],
material.concrete
);
base.receiveShadow = true;
const colorMat = new THREE.MeshStandardMaterial({
color,
roughness: 0.58,
metalness: 0.05
});
if (orientation === "x") {
addBox(
worldGroup,
[size.x, 0.055, 0.16],
[center.x, center.y + 0.025, center.z + size.z * 0.38],
colorMat,
false
);
addBox(
worldGroup,
[size.x, 0.055, 0.08],
[center.x, center.y + 0.025, center.z - size.z * 0.37],
material.dark,
false
);
} else {
addBox(
worldGroup,
[0.16, 0.055, size.z],
[center.x + size.x * 0.38, center.y + 0.025, center.z],
colorMat,
false
);
addBox(
worldGroup,
[0.08, 0.055, size.z],
[center.x - size.x * 0.37, center.y + 0.025, center.z],
material.dark,
false
);
}
}
function addTrain(position, rotation, color) {
const group = new THREE.Group();
group.position.set(...position);
group.rotation.y = rotation;
const bodyMat = new THREE.MeshStandardMaterial({
color,
roughness: 0.45,
metalness: 0.12
});
const windowMat = new THREE.MeshStandardMaterial({
color: 0x1f3942,
roughness: 0.28,
metalness: 0.25
});
addBox(group, [2.4, 0.66, 0.78], [0, 0, 0], bodyMat);
addBox(group, [2.15, 0.16, 0.81], [0, 0.18, 0], windowMat);
for (const x of [-0.78, -0.27, 0.27, 0.78]) {
addBox(group, [0.34, 0.30, 0.035], [x, 0.12, 0.405], windowMat, false);
addBox(group, [0.34, 0.30, 0.035], [x, 0.12, -0.405], windowMat, false);
}
worldGroup.add(group);
}
function addConcourseAndEntrance() {
const hall = new THREE.Mesh(
new THREE.CylinderGeometry(1.55, 1.65, 0.36, 8),
material.concreteLight
);
hall.position.y = -0.18;
hall.castShadow = true;
hall.receiveShadow = true;
worldGroup.add(hall);
const hallRing = new THREE.Mesh(
new THREE.TorusGeometry(1.16, 0.055, 6, 32),
new THREE.MeshStandardMaterial({ color: 0x719f9b, roughness: 0.45 })
);
hallRing.rotation.x = Math.PI / 2;
hallRing.position.y = 0.025;
worldGroup.add(hallRing);
addBox(worldGroup, [1.6, 0.22, 1.8], [-6.8, 0.28, 0], material.concreteLight);
const entranceMat = new THREE.MeshStandardMaterial({
color: 0x334b51,
roughness: 0.6
});
addBox(worldGroup, [0.9, 1.7, 1.8], [-7.25, 1.12, 0], entranceMat);
addBox(worldGroup, [0.94, 0.16, 1.95], [-7.25, 2.04, 0], material.dark);
for (const z of [-0.52, 0, 0.52]) {
addBox(
worldGroup,
[0.025, 0.62, 0.25],
[-6.78, 1.12, z],
new THREE.MeshStandardMaterial({
color: 0xa6d4d0,
emissive: 0x376d6b,
emissiveIntensity: 0.15,
roughness: 0.25
}),
false
);
}
}
function addSupports() {
const supportMat = new THREE.MeshStandardMaterial({
color: 0x8c9b99,
roughness: 0.8
});
for (const x of [-4.4, 0, 4.4]) {
addBox(worldGroup, [0.3, 4.95, 0.3], [x, -0.62, 4.4], supportMat);
}
for (const z of [-6.1, -4.2]) {
addBox(worldGroup, [0.3, 0.75, 0.3], [-4.2, -2.7, z], supportMat);
addBox(worldGroup, [0.3, 0.75, 0.3], [4.2, -2.7, z], supportMat);
}
for (const x of [2.2, 7.2]) {
addBox(worldGroup, [0.28, 2.1, 0.28], [x, -1.95, 0], supportMat);
}
}
function buildStairs(edge) {
const points = edge.waypoints;
const lengths = [];
let total = 0;
for (let i = 1; i < points.length; i++) {
const length = points[i].distanceTo(points[i - 1]);
lengths.push(length);
total += length;
}
const stepMat = new THREE.MeshStandardMaterial({
color: 0x9da9a5,
roughness: 0.88
});
const edgeMat = new THREE.MeshStandardMaterial({
color: 0xd5b06b,
roughness: 0.7
});
const steps = 14;
for (let i = 0; i < steps; i++) {
const distance = total * ((i + 0.5) / steps);
let accumulated = 0;
let segment = lengths.length - 1;
for (let j = 0; j < lengths.length; j++) {
if (distance <= accumulated + lengths[j]) {
segment = j;
break;
}
accumulated += lengths[j];
}
const t = (distance - accumulated) / lengths[segment];
const a = points[segment];
const b = points[segment + 1];
const p = a.clone().lerp(b, THREE.MathUtils.clamp(t, 0, 1));
const direction = b.clone().sub(a);
direction.y = 0;
if (direction.lengthSq() < 0.0001) direction.set(0, 0, 1);
direction.normalize();
const step = new THREE.Mesh(
new THREE.BoxGeometry(0.78, 0.14, Math.max(0.27, total / steps * 1.08)),
stepMat
);
step.position.copy(p);
step.position.y += 0.035;
step.rotation.y = Math.atan2(direction.x, direction.z);
step.castShadow = true;
step.receiveShadow = true;
equipmentGroup.add(step);
const nose = new THREE.Mesh(
new THREE.BoxGeometry(0.78, 0.025, 0.035),
edgeMat
);
nose.position.copy(step.position);
nose.position.y += 0.085;
nose.position.addScaledVector(direction, 0.13);
nose.rotation.y = step.rotation.y;
equipmentGroup.add(nose);
}
}
function buildElevator(edge) {
let verticalA = null;
let verticalB = null;
for (let i = 1; i < edge.waypoints.length; i++) {
const a = edge.waypoints[i - 1];
const b = edge.waypoints[i];
if (Math.abs(b.y - a.y) > 1) {
verticalA = a;
verticalB = b;
break;
}
}
if (!verticalA) return;
const center = verticalA.clone().add(verticalB).multiplyScalar(0.5);
const height = Math.abs(verticalB.y - verticalA.y);
const frameMat = new THREE.MeshStandardMaterial({
color: 0x4d918b,
roughness: 0.4,
metalness: 0.25
});
const carMat = new THREE.MeshStandardMaterial({
color: 0x65ada7,
roughness: 0.34,
metalness: 0.2
});
const beaconMat = new THREE.MeshStandardMaterial({
color: 0xe87843,
emissive: 0xe87843,
emissiveIntensity: 0.8,
roughness: 0.3
});
const shaft = new THREE.Mesh(
new THREE.BoxGeometry(0.82, height + 0.22, 0.82),
material.glass
);
shaft.position.copy(center);
shaft.renderOrder = 2;
equipmentGroup.add(shaft);
for (const dx of [-0.42, 0.42]) {
for (const dz of [-0.42, 0.42]) {
addBox(
equipmentGroup,
[0.075, height + 0.18, 0.075],
[center.x + dx, center.y, center.z + dz],
frameMat,
false
);
}
}
const car = addBox(
equipmentGroup,
[0.65, 0.28, 0.65],
[center.x, center.y + height * 0.28, center.z],
carMat,
false
);
for (let i = 1; i < edge.waypoints.length; i++) {
const a = edge.waypoints[i - 1];
const b = edge.waypoints[i];
if (Math.abs(a.y - b.y) < 0.1) {
addBeamBetween(equipmentGroup, a, b, 0.68, 0.12, material.concreteLight);
}
}
const beacon = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.105, 0),
beaconMat
);
beacon.position.set(
center.x,
Math.max(verticalA.y, verticalB.y) + 0.23,
center.z
);
equipmentGroup.add(beacon);
liftVisuals.set(edge.id, {
frameMat,
carMat,
beacon,
beaconMat
});
}
function buildPhysicalEdges() {
for (const edge of edges) {
if (edge.type === "stairs") {
buildStairs(edge);
} else if (edge.type === "elevator") {
buildElevator(edge);
} else {
const mat = edge.type === "ramp"
? new THREE.MeshStandardMaterial({ color: 0x8fb579, roughness: 0.78 })
: material.concreteLight;
for (let i = 1; i < edge.waypoints.length; i++) {
addBeamBetween(
equipmentGroup,
edge.waypoints[i - 1],
edge.waypoints[i],
edge.type === "ramp" ? 1.02 : 0.9,
0.13,
mat
);
}
}
}
}
function addNodeMarker(id, color) {
const marker = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.22, 1),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.13,
roughness: 0.38
})
);
marker.position.copy(nodes[id]);
marker.position.y += 0.12;
marker.castShadow = true;
worldGroup.add(marker);
platformMarkers.set(id, marker);
}
function buildScene() {
addGround();
addPlatform(
new THREE.Vector3(0, -2.2, -4.2),
{ x: 11.6, z: 1.8 },
platformMeta.blue.color,
"x"
);
addPlatform(
new THREE.Vector3(0, 2.2, 4.0),
{ x: 1.8, z: 9.2 },
platformMeta.red.color,
"z"
);
addPlatform(
new THREE.Vector3(5.1, -0.7, 0),
{ x: 7.8, z: 1.8 },
platformMeta.green.color,
"x"
);
addConcourseAndEntrance();
addSupports();
buildPhysicalEdges();
addTrain(new THREE.Vector3(2.3, -1.69, -4.65), 0, platformMeta.blue.color);
addTrain(new THREE.Vector3(0.63, 2.61, 2.7), Math.PI / 2, platformMeta.red.color);
addTrain(new THREE.Vector3(3.4, -0.19, 0.62), 0, platformMeta.green.color);
addNodeMarker("blue", platformMeta.blue.color);
addNodeMarker("red", platformMeta.red.color);
addNodeMarker("green", platformMeta.green.color);
addNodeMarker("hall", 0x4b8d87);
addNodeMarker("entrance", 0x53686d);
}
buildScene();
// ---------------------------------------------------------------------
// World labels
// ---------------------------------------------------------------------
const worldLabels = new Map();
function makeWorldLabel(id, title, subtitle, color, anchor, offset = [0, 0]) {
const element = document.createElement("div");
element.className = "world-label";
element.style.setProperty("--platform-color", color);
element.innerHTML = `<strong>${title}</strong><small>${subtitle}</small>`;
labelsRoot.appendChild(element);
worldLabels.set(id, {
element,
anchor: anchor.clone(),
offset
});
}
makeWorldLabel(
"entrance",
"Street entrance",
"Starting point",
"#53686d",
nodes.entrance.clone().add(new THREE.Vector3(0, 0.8, 0)),
[0, -8]
);
makeWorldLabel(
"hall",
"Central concourse",
"Transfer level",
"#4b8d87",
nodes.hall.clone().add(new THREE.Vector3(0, 0.72, 0)),
[0, 10]
);
makeWorldLabel(
"blue",
"Blue platform",
"Lower level",
platformMeta.blue.color,
nodes.blue.clone().add(new THREE.Vector3(0, 0.55, 0)),
[0, -12]
);
makeWorldLabel(
"red",
"Red platform",
"Upper level",
platformMeta.red.color,
nodes.red.clone().add(new THREE.Vector3(0, 0.65, 0)),
[0, -8]
);
makeWorldLabel(
"green",
"Green platform",
"Street level",
platformMeta.green.color,
nodes.green.clone().add(new THREE.Vector3(0, 0.55, 0)),
[0, -12]
);
const outageCallout = document.createElement("div");
outageCallout.className = "world-label callout";
outageCallout.innerHTML = `
<strong id="calloutTitle">Blue lift out</strong>
<small id="calloutSubtitle">Step-free link unavailable</small>
`;
labelsRoot.appendChild(outageCallout);
const calloutAnchor = new THREE.Vector3(1.1, 0.28, -1.2);
worldLabels.set("outage-callout", {
element: outageCallout,
anchor: calloutAnchor,
offset: [34, -8]
});
function updateLabelStatuses() {
for (const platform of Object.keys(platformMeta)) {
const label = worldLabels.get(platform);
const reachable = Boolean(state.results[platform]);
label.element.classList.toggle("unreachable", !reachable);
label.element.querySelector("small").textContent = reachable
? "Reachable"
: "Unreachable";
}
const calloutTitle = $("#calloutTitle");
const calloutSubtitle = $("#calloutSubtitle");
outageCallout.classList.toggle("restored", !state.outage);
calloutTitle.textContent = state.outage ? "Blue lift out" : "Blue lift in service";
calloutSubtitle.textContent = state.outage
? "Step-free link unavailable"
: "Connection restored";
}
function projectLabels() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
for (const label of worldLabels.values()) {
const projected = label.anchor.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.display = visible ? "block" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width + label.offset[0];
const y = (-projected.y * 0.5 + 0.5) * height + label.offset[1];
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
// ---------------------------------------------------------------------
// Route highlighting and status markers
// ---------------------------------------------------------------------
const profileAccent = new THREE.Color("#14867d");
function renderEdgeRoute(edge, color, radius, opacity) {
const routeMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity,
depthWrite: false
});
for (let i = 1; i < edge.waypoints.length; i++) {
addCylinderBetween(
routeGroup,
edge.waypoints[i - 1],
edge.waypoints[i],
radius,
routeMaterial
);
}
}
function clearGroup(group) {
while (group.children.length) {
const child = group.children.pop();
child.geometry?.dispose();
if (Array.isArray(child.material)) {
child.material.forEach((m) => m.dispose());
} else {
child.material?.dispose();
}
}
}
function addUnavailableMarker(position) {
const group = new THREE.Group();
group.position.copy(position);
group.position.y += 0.48;
const mat = new THREE.MeshBasicMaterial({ color: 0xe87843 });
const a = new THREE.Mesh(new THREE.BoxGeometry(0.55, 0.09, 0.09), mat);
const b = new THREE.Mesh(new THREE.BoxGeometry(0.09, 0.55, 0.09), mat);
a.rotation.z = Math.PI / 4;
b.rotation.z = Math.PI / 4;
group.add(a, b);
markerGroup.add(group);
}
function rebuildRouteHighlights() {
clearGroup(routeGroup);
clearGroup(markerGroup);
const selected = state.selectedPlatform;
const selectedResult = state.results[selected];
// Draw all other reachable paths in the active profile color.
for (const platform of Object.keys(platformMeta)) {
if (platform === selected) continue;
const path = state.results[platform];
if (!path) continue;
const seen = new Set();
for (const edgeId of path.edges) {
if (seen.has(edgeId)) continue;
seen.add(edgeId);
renderEdgeRoute(edgeById.get(edgeId), profileAccent, 0.045, 0.64);
}
}
// The selected route is emphasized in its destination color.
if (selectedResult) {
for (const edgeId of selectedResult.edges) {
renderEdgeRoute(
edgeById.get(edgeId),
new THREE.Color(platformMeta[selected].color),
0.082,
0.98
);
}
}
for (const platform of Object.keys(platformMeta)) {
if (!state.results[platform]) {
addUnavailableMarker(nodes[platform]);
}
}
}
function updateLiftVisuals() {
for (const [id, visual] of liftVisuals) {
const isOut = state.outage && id === OUTAGE_EDGE;
visual.frameMat.color.set(isOut ? 0xd47a50 : 0x4d918b);
visual.carMat.color.set(isOut ? 0xe39a73 : 0x65ada7);
visual.beaconMat.color.set(isOut ? 0xe87843 : 0x44aa73);
visual.beaconMat.emissive.set(isOut ? 0xe87843 : 0x44aa73);
visual.beaconMat.emissiveIntensity = isOut ? 0.9 : 0.3;
}
}
// ---------------------------------------------------------------------
// UI
// ---------------------------------------------------------------------
const profilesRoot = $("#profiles");
for (const profile of profiles) {
const button = document.createElement("button");
button.className = "profile-button";
button.dataset.profile = profile.id;
button.setAttribute("aria-pressed", "false");
button.innerHTML = `
<span class="profile-icon" aria-hidden="true">${profile.icon}</span>
<strong>${profile.label}</strong>
<small>${profile.tag}</small>
`;
button.addEventListener("click", () => {
state.profileId = profile.id;
refresh();
});
profilesRoot.appendChild(button);
}
function activeProfile() {
return profiles.find((profile) => profile.id === state.profileId);
}
function formatTime(seconds) {
const rounded = Math.max(1, Math.round(seconds));
if (rounded < 60) return `${rounded} sec`;
const minutes = Math.floor(rounded / 60);
const rest = rounded % 60;
return rest ? `${minutes}m ${rest}s` : `${minutes}m`;
}
function typeLabel(type) {
return {
walkway: "Level walk",
elevator: "Elevator",
stairs: "Stairs",
ramp: "Ramp"
}[type];
}
function renderCapabilities(profile) {
const root = $("#capabilities");
root.innerHTML = "";
const allTypes = ["walkway", "elevator", "ramp", "stairs"];
for (const type of allTypes) {
const chip = document.createElement("span");
chip.className = "capability";
chip.textContent = typeLabel(type);
if (!profile.allowed.includes(type)) {
chip.classList.add("blocked");
}
root.appendChild(chip);
}
$("#profileNote").textContent = profile.note;
}
function renderResultSummary(profile) {
const summary = $("#resultSummary");
const reachableCount = Object.values(state.results).filter(Boolean).length;
$("#reachableCount").textContent = `${reachableCount} / 3`;
summary.classList.remove("warning");
if (!state.results.blue) {
summary.classList.add("warning");
summary.textContent = state.outage
? "Blue is unreachable for this proxy. Its lift is out and stairs are not permitted under the selected mobility assumptions."
: "Blue is unreachable for this proxy under the current modeled network.";
} else if (state.outage && profile.allowed.includes("stairs")) {
summary.classList.add("warning");
summary.textContent = "All platforms remain reachable, but Blue now requires the stairs because its lift is out of service.";
} else if (state.outage) {
summary.textContent = "Blue is reachable through the stairs for this proxy. The lift outage does not remove the platform from the graph.";
} else {
summary.textContent = "The Blue lift is restored. All three platforms are reachable under the selected mobility assumptions.";
}
}
function renderRoutes() {
const root = $("#routes");
root.innerHTML = "";
for (const platform of Object.keys(platformMeta)) {
const meta = platformMeta[platform];
const path = state.results[platform];
const row = document.createElement("button");
row.className = "route-row";
row.classList.toggle("selected", state.selectedPlatform === platform);
row.classList.toggle("unavailable", !path);
row.style.setProperty("--route-color", meta.color);
row.setAttribute("aria-pressed", state.selectedPlatform === platform ? "true" : "false");
row.innerHTML = `
<span class="route-color" aria-hidden="true"></span>
<span>
<span class="route-name">${meta.name}</span>
<span class="route-path">${pathDescription(path)}</span>
</span>
<span class="route-time ${path ? "" : "unreachable"}">
${path ? formatTime(path.cost) : "No route"}
</span>
`;
row.addEventListener("click", () => {
state.selectedPlatform = platform;
refresh();
});
root.appendChild(row);
}
}
function renderSelectedDetail() {
const root = $("#selectedDetail");
const platform = state.selectedPlatform;
const meta = platformMeta[platform];
const path = state.results[platform];
if (!path) {
const stairsPermitted = activeProfile().allowed.includes("stairs");
root.innerHTML = `
<h3>No permitted route to ${meta.shortName}</h3>
<p>
${
state.outage
? "The Blue lift is out of service"
: "No permitted connection is available"
}.
${
stairsPermitted
? "Stairs are modeled as available for this proxy, so this state is unlikely unless the link set changes."
: "Stairs are excluded for this proxy, leaving no continuous route."
}
</p>
<div class="route-chips">
<span class="route-chip stairs">Unreachable</span>
</div>
`;
return;
}
const edgeTypes = path.edges.map((id) => edgeById.get(id).type);
const chips = [...new Set(edgeTypes)].map((type) => {
const chipClass = type === "stairs" ? "route-chip stairs" : "route-chip";
return `<span class="${chipClass}">${typeLabel(type)}</span>`;
}).join("");
const usesStairs = edgeTypes.includes("stairs");
const usesLift = edgeTypes.includes("elevator");
root.innerHTML = `
<h3>Street entrance → ${meta.name}</h3>
<p>
${pathDescription(path)} · approximately ${formatTime(path.cost)}.
${
usesStairs
? "This itinerary includes stairs."
: usesLift
? "This itinerary uses a lift and remains step-free."
: "This itinerary remains step-free."
}
</p>
<div class="route-chips">${chips}</div>
`;
}
function renderProfileButtons() {
for (const button of profilesRoot.querySelectorAll(".profile-button")) {
const selected = button.dataset.profile === state.profileId;
button.classList.toggle("active", selected);
button.setAttribute("aria-pressed", selected ? "true" : "false");
}
}
function renderOutageControl() {
const toggle = $("#outageToggle");
toggle.classList.toggle("restored", !state.outage);
toggle.setAttribute("aria-pressed", state.outage ? "true" : "false");
$("#outageTitle").textContent = state.outage
? "Blue lift unavailable"
: "Blue lift restored";
$("#outageSubtitle").textContent = state.outage
? "Remove the step-free Hall ↔ Blue connection."
: "Return the step-free Hall ↔ Blue connection to service.";
$("#topStatusText").textContent = state.outage
? "Blue lift out of service"
: "All modeled connections in service";
}
function refresh() {
const profile = activeProfile();
state.results = computeAllRoutes(profile);
renderProfileButtons();
renderCapabilities(profile);
renderOutageControl();
renderResultSummary(profile);
renderRoutes();
renderSelectedDetail();
updateLabelStatuses();
updateLiftVisuals();
rebuildRouteHighlights();
}
$("#outageToggle").addEventListener("click", () => {
state.outage = !state.outage;
refresh();
});
// ---------------------------------------------------------------------
// Direct camera controls — no addons
// ---------------------------------------------------------------------
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.25,
1.42
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("pointerleave", (event) => {
if (dragging && event.buttons === 0) endDrag(event);
});
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * Math.exp(-event.deltaY * 0.001),
0.65,
1.75
);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
function resetCamera() {
cameraState.theta = 0.72;
cameraState.phi = 0.79;
cameraState.zoom = 1;
updateCamera();
}
function topCamera() {
cameraState.theta = 0;
cameraState.phi = 0.28;
cameraState.zoom = 1.08;
updateCamera();
}
$("#resetCamera").addEventListener("click", resetCamera);
$("#topCamera").addEventListener("click", topCamera);
function updateCamera() {
const radius = 23;
const sinPhi = Math.sin(cameraState.phi);
const cosPhi = Math.cos(cameraState.phi);
camera.position.set(
cameraTarget.x + radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y + radius * cosPhi,
cameraTarget.z + radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
function resize() {
const width = Math.max(1, viewport.clientWidth);
const height = Math.max(1, viewport.clientHeight);
const aspect = width / height;
const halfHeight = 8.6;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(viewport);
resize();
updateCamera();
refresh();
// ---------------------------------------------------------------------
// Render loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const blueLift = liftVisuals.get(OUTAGE_EDGE);
if (blueLift && state.outage) {
const pulse = 1 + Math.sin(elapsed * 4.2) * 0.12;
blueLift.beacon.scale.setScalar(pulse);
}
camera.updateMatrixWorld();
projectLabels();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```