Prompt specification
Build or customize the Three.js 3D scene "Air corridors and city supply distribution" 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: Air corridors and city supply distribution
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/air-corridors-and-city-supply-distribution-x2415
Scene Description Prompt:
A low-poly Berlin Airlift display connecting air corridors, unloading, warehouses, and deliveries; label cargo quantities illustrative. Three.js from cdnjs, one HTML file.
Working Three.js Starter (air-corridors-and-city-supply-distribution-x2415):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#17201f" />
<title>Berlin Airlift — Low-Poly Logistics Display</title>
<style>
:root {
--ink: #17201f;
--paper: #f2eddf;
--muted: #66716b;
--line: rgba(23, 32, 31, 0.18);
--signal: #e65332;
--signal-dark: #a73320;
--teal: #2b7d78;
--gold: #d9a441;
--panel: rgba(246, 242, 231, 0.91);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--ink);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
.screen-wash {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
background:
radial-gradient(circle at 52% 44%, transparent 42%, rgba(17, 26, 25, 0.11) 100%),
linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 22%);
}
.ui {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.ui button,
.ui a {
pointer-events: auto;
}
.masthead {
position: absolute;
top: 28px;
left: 32px;
width: min(420px, calc(100vw - 64px));
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: var(--signal-dark);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 3px;
content: "";
background: var(--signal);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(40px, 5.1vw, 76px);
font-weight: 700;
line-height: 0.88;
letter-spacing: -0.055em;
}
h1 span {
display: block;
margin-top: 10px;
color: var(--teal);
font-family: inherit;
font-size: 0.43em;
font-style: italic;
font-weight: 500;
letter-spacing: -0.02em;
}
.subtitle {
max-width: 360px;
margin: 18px 0 0;
color: #4d5954;
font-size: 13px;
line-height: 1.55;
}
.top-controls {
position: absolute;
top: 26px;
right: 28px;
display: flex;
align-items: center;
gap: 8px;
}
.control-button {
display: grid;
width: 42px;
height: 42px;
padding: 0;
place-items: center;
border: 1px solid rgba(23, 32, 31, 0.2);
border-radius: 50%;
background: rgba(246, 242, 231, 0.84);
color: var(--ink);
box-shadow: 0 8px 24px rgba(20, 30, 28, 0.09);
cursor: pointer;
backdrop-filter: blur(8px);
transition:
transform 150ms ease,
background 150ms ease;
}
.control-button:hover {
transform: translateY(-2px);
background: var(--paper);
}
.control-button svg {
width: 17px;
height: 17px;
fill: none;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.8;
}
.illustrative-badge {
position: absolute;
top: 82px;
right: 28px;
display: flex;
align-items: center;
gap: 8px;
padding: 8px 11px;
border: 1px solid rgba(23, 32, 31, 0.17);
border-radius: 2px;
background: rgba(246, 242, 231, 0.76);
color: #49554f;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.illustrative-badge::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--signal);
content: "";
box-shadow: 0 0 0 4px rgba(230, 83, 50, 0.13);
}
.story-card {
position: absolute;
top: 132px;
right: 28px;
width: 294px;
padding: 21px 22px 19px;
border: 1px solid rgba(23, 32, 31, 0.15);
border-top: 4px solid var(--signal);
background: var(--panel);
box-shadow: 0 20px 45px rgba(20, 30, 28, 0.11);
backdrop-filter: blur(12px);
}
.story-kicker {
margin-bottom: 10px;
color: var(--signal-dark);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.story-card h2 {
margin: 0 0 9px;
font-family: Georgia, "Times New Roman", serif;
font-size: 23px;
line-height: 1.08;
letter-spacing: -0.025em;
}
.story-card p {
min-height: 68px;
margin: 0;
color: #59635e;
font-size: 12px;
line-height: 1.55;
}
.story-metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
margin-top: 17px;
padding-top: 15px;
border-top: 1px solid var(--line);
}
.metric strong {
display: block;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
font-size: 20px;
line-height: 1;
}
.metric span {
display: block;
margin-top: 5px;
color: #747d77;
font-size: 8px;
font-weight: 700;
line-height: 1.25;
text-transform: uppercase;
}
.phase-nav {
position: absolute;
bottom: 25px;
left: 50%;
display: grid;
grid-template-columns: repeat(5, minmax(108px, 1fr));
overflow: hidden;
border: 1px solid rgba(23, 32, 31, 0.17);
border-radius: 3px;
background: rgba(246, 242, 231, 0.91);
box-shadow: 0 16px 40px rgba(20, 30, 28, 0.14);
transform: translateX(-50%);
backdrop-filter: blur(12px);
}
.phase-button {
position: relative;
min-height: 63px;
padding: 12px 15px 11px 42px;
border: 0;
border-right: 1px solid var(--line);
background: transparent;
color: #66716b;
text-align: left;
cursor: pointer;
transition:
color 150ms ease,
background 150ms ease;
}
.phase-button:last-child {
border-right: 0;
}
.phase-button::after {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 3px;
background: var(--signal);
content: "";
transform: scaleX(0);
transform-origin: left;
transition: transform 180ms ease;
}
.phase-button:hover {
background: rgba(23, 32, 31, 0.045);
color: var(--ink);
}
.phase-button.active {
background: rgba(230, 83, 50, 0.08);
color: var(--ink);
}
.phase-button.active::after {
transform: scaleX(1);
}
.phase-number {
position: absolute;
top: 14px;
left: 15px;
color: var(--signal-dark);
font-family: Georgia, "Times New Roman", serif;
font-size: 15px;
}
.phase-name {
display: block;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.phase-detail {
display: block;
margin-top: 5px;
color: #818982;
font-size: 9px;
}
.helper {
position: absolute;
bottom: 29px;
left: 30px;
color: rgba(23, 32, 31, 0.68);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.helper span {
display: block;
margin-top: 7px;
color: rgba(23, 32, 31, 0.48);
font-size: 8px;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: none;
}
.disclaimer {
position: absolute;
right: 28px;
bottom: 29px;
max-width: 220px;
color: rgba(23, 32, 31, 0.56);
font-size: 8px;
font-weight: 700;
line-height: 1.45;
letter-spacing: 0.06em;
text-align: right;
text-transform: uppercase;
}
#labels {
position: fixed;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.map-label {
position: absolute;
min-width: 115px;
max-width: 170px;
padding: 8px 10px 9px;
border: 1px solid rgba(23, 32, 31, 0.2);
border-left: 3px solid var(--signal);
border-radius: 2px;
background: rgba(247, 243, 233, 0.91);
color: var(--ink);
box-shadow: 0 7px 20px rgba(22, 31, 29, 0.1);
text-align: left;
transform: translate(-50%, -100%);
transform-origin: center bottom;
cursor: pointer;
pointer-events: auto;
backdrop-filter: blur(7px);
transition:
opacity 180ms ease,
filter 180ms ease,
transform 180ms ease;
}
.map-label::after {
position: absolute;
bottom: -12px;
left: 50%;
width: 1px;
height: 12px;
background: rgba(23, 32, 31, 0.55);
content: "";
}
.map-label:hover {
z-index: 8;
transform: translate(-50%, calc(-100% - 4px));
filter: saturate(1.1);
}
.map-label.muted {
opacity: 0.35;
filter: grayscale(0.55);
}
.map-label .label-title {
display: block;
font-size: 8px;
font-weight: 900;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.map-label .label-value {
display: block;
margin-top: 4px;
color: #5f6963;
font-family: Georgia, "Times New Roman", serif;
font-size: 12px;
line-height: 1.15;
}
.map-label .label-note {
display: block;
margin-top: 4px;
color: var(--signal-dark);
font-size: 7px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.status-dot {
display: inline-block;
width: 6px;
height: 6px;
margin-right: 6px;
border-radius: 50%;
background: #3b8b68;
box-shadow: 0 0 0 3px rgba(59, 139, 104, 0.13);
animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse {
50% {
box-shadow: 0 0 0 6px rgba(59, 139, 104, 0);
}
}
@media (max-width: 980px) {
.story-card {
top: auto;
right: 20px;
bottom: 104px;
width: 270px;
}
.story-card p {
min-height: 0;
}
.story-metrics {
margin-top: 12px;
padding-top: 11px;
}
.helper,
.disclaimer {
display: none;
}
}
@media (max-width: 720px) {
.masthead {
top: 18px;
left: 18px;
}
h1 {
font-size: 42px;
}
.subtitle {
display: none;
}
.top-controls {
top: 17px;
right: 17px;
}
.illustrative-badge {
top: 69px;
right: 17px;
}
.story-card {
display: none;
}
.phase-nav {
right: 12px;
bottom: 12px;
left: 12px;
grid-template-columns: repeat(5, 1fr);
transform: none;
}
.phase-button {
min-height: 54px;
padding: 10px 5px 8px;
text-align: center;
}
.phase-number {
position: static;
display: block;
margin-bottom: 3px;
font-size: 12px;
}
.phase-name {
font-size: 7px;
}
.phase-detail {
display: none;
}
.map-label {
min-width: 95px;
max-width: 125px;
padding: 6px 7px;
}
.map-label .label-title {
font-size: 6px;
}
.map-label .label-value {
font-size: 10px;
}
.map-label .label-note {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.status-dot {
animation: none;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive low-poly model of the Berlin Airlift"></div>
<div class="screen-wash"></div>
<div id="labels"></div>
<main class="ui">
<header class="masthead">
<div class="eyebrow">Berlin · 1948–49</div>
<h1>
Berlin Airlift
<span>Operation Vittlese</span>
</h1>
<p class="subtitle">
A low-poly view of an extraordinary logistical chain: western air
corridors, Tempelhof transfer, city warehouses, and last-mile delivery.
</p>
</header>
<div class="top-controls">
<button id="pauseButton" class="control-button" aria-label="Pause animation" title="Pause animation">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M8 5v14M16 5v14"></path>
</svg>
</button>
<button id="resetButton" class="control-button" aria-label="Reset view" title="Reset view">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M4 12a8 8 0 1 0 2.35-5.65L4 8.7"></path>
<path d="M4 4v4.7h4.7"></path>
</svg>
</button>
</div>
<div class="illustrative-badge">Cargo values illustrative</div>
<aside class="story-card" aria-live="polite">
<div id="storyKicker" class="story-kicker">System overview · 01 / 04</div>
<h2 id="storyTitle">The city is the final destination.</h2>
<p id="storyBody">
Airlift cargo moved through four connected stages: western air corridors,
apron transfer at Tempelhof, warehouse sorting, and distribution across
the city.
</p>
<div id="storyMetrics" class="story-metrics"></div>
</aside>
<nav class="phase-nav" aria-label="Logistics phases">
<button class="phase-button active" data-phase="all" aria-pressed="true">
<span class="phase-number">00</span>
<span class="phase-name">Overview</span>
<span class="phase-detail">Full network</span>
</button>
<button class="phase-button" data-phase="corridors" aria-pressed="false">
<span class="phase-number">01</span>
<span class="phase-name">Corridors</span>
<span class="phase-detail">West → Berlin</span>
</button>
<button class="phase-button" data-phase="unload" aria-pressed="false">
<span class="phase-number">02</span>
<span class="phase-name">Unload</span>
<span class="phase-detail">Tempelhof apron</span>
</button>
<button class="phase-button" data-phase="warehouse" aria-pressed="false">
<span class="phase-number">03</span>
<span class="phase-name">Warehouses</span>
<span class="phase-detail">Transfer depots</span>
</button>
<button class="phase-button" data-phase="delivery" aria-pressed="false">
<span class="phase-number">04</span>
<span class="phase-name">Deliveries</span>
<span class="phase-detail">City last mile</span>
</button>
</nav>
<div class="helper">
Drag to orbit · Scroll to zoom
<span>Shift-drag to pan · Double-click to reset</span>
</div>
<div class="disclaimer">
All cargo quantities and route totals are illustrative, not historical
shipment records.
</div>
</main>
<noscript>This display requires JavaScript and WebGL.</noscript>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
/* ------------------------------------------------------------------ */
/* Renderer, scene, camera, and lighting */
/* ------------------------------------------------------------------ */
const host = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color("#bcc7ba");
scene.fog = new THREE.Fog("#bcc7ba", 82, 150);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
host.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
41,
window.innerWidth / window.innerHeight,
0.1,
250
);
const hemisphere = new THREE.HemisphereLight(
"#fff4dc",
"#52665d",
2.05
);
scene.add(hemisphere);
const sunlight = new THREE.DirectionalLight("#fff1d2", 3.15);
sunlight.position.set(-28, 46, 23);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -58;
sunlight.shadow.camera.right = 58;
sunlight.shadow.camera.top = 48;
sunlight.shadow.camera.bottom = -48;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 120;
sunlight.shadow.bias = -0.0008;
scene.add(sunlight);
const fillLight = new THREE.DirectionalLight("#a8d4d1", 0.7);
fillLight.position.set(35, 18, -32);
scene.add(fillLight);
const world = new THREE.Group();
scene.add(world);
const phaseGroups = {
corridors: new THREE.Group(),
unload: new THREE.Group(),
warehouse: new THREE.Group(),
delivery: new THREE.Group()
};
Object.values(phaseGroups).forEach((group) => world.add(group));
const warehouseRoofMaterials = [];
const routeLines = [];
const deliveryLines = [];
const aircraft = [];
const trucks = [];
const propellers = [];
const clouds = [];
const highlightRings = [];
const palette = {
ground: "#9aa78f",
groundEdge: "#657467",
road: "#c5bca7",
roadEdge: "#8e897b",
runway: "#747b76",
runwayMark: "#d6d0bc",
building: ["#c8c2b2", "#b5b9ae", "#d0c7b3", "#aeb9b2", "#b7a99b"],
roof: ["#68716d", "#7c8178", "#5f6e68"],
warehouse: ["#cf6a43", "#3f8580", "#c7933f", "#647d78"],
signal: "#e65332",
teal: "#2b7d78",
gold: "#d9a441",
river: "#4c9291",
cargo: "#b8894e"
};
function standard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0.02,
flatShading: true,
...options
});
}
function box(
width,
height,
depth,
color,
position,
parent = world,
options = {}
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
standard(color, options)
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
radiusTop,
radiusBottom,
height,
color,
position,
parent = world,
segments = 8,
options = {}
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
standard(color, options)
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeRibbon(curve, width, color, height = 0.045, parent = world) {
const segments = 90;
const positions = [];
const indices = [];
for (let i = 0; i <= segments; i++) {
const t = i / segments;
const point = curve.getPointAt(t);
const tangent = curve.getTangentAt(t);
const side = new THREE.Vector3(-tangent.z, 0, tangent.x)
.normalize()
.multiplyScalar(width / 2);
positions.push(
point.x - side.x,
height,
point.z - side.z,
point.x + side.x,
height,
point.z + side.z
);
if (i < segments) {
const a = i * 2;
indices.push(a, a + 2, a + 1, a + 1, a + 2, a + 3);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(
geometry,
standard(color, { side: THREE.DoubleSide })
);
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function horizontalCurve(x1, z1, x2, z2, y = 0) {
return new THREE.CatmullRomCurve3([
new THREE.Vector3(x1, y, z1),
new THREE.Vector3((x1 + x2) / 2, y, (z1 + z2) / 2),
new THREE.Vector3(x2, y, z2)
]);
}
function dashedLine(curve, color, parent, opacity = 0.85, dash = 1.1) {
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(140)
);
const material = new THREE.LineDashedMaterial({
color,
dashSize: dash,
gapSize: dash * 0.62,
transparent: true,
opacity,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
parent.add(line);
return line;
}
function addRing(position, radius, parent = world) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(radius, 0.075, 6, 64),
new THREE.MeshBasicMaterial({
color: palette.signal,
transparent: true,
opacity: 0.75,
depthWrite: false
})
);
ring.rotation.x = Math.PI / 2;
ring.position.set(...position);
parent.add(ring);
highlightRings.push(ring);
return ring;
}
/* ------------------------------------------------------------------ */
/* Terrain, roads, river, and airfield */
/* ------------------------------------------------------------------ */
const base = box(
96,
1.2,
72,
palette.groundEdge,
[0, -0.66, 0],
world,
{ roughness: 1 }
);
base.castShadow = false;
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(96, 72),
standard(palette.ground, { roughness: 1 })
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.04;
ground.receiveShadow = true;
world.add(ground);
const grid = new THREE.GridHelper(92, 23, "#81917e", "#81917e");
grid.position.y = 0.006;
grid.material.transparent = true;
grid.material.opacity = 0.12;
world.add(grid);
// River through the eastern city.
const riverCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(0, 0, -34),
new THREE.Vector3(7, 0, -22),
new THREE.Vector3(12, 0, -10),
new THREE.Vector3(9, 0, 2),
new THREE.Vector3(16, 0, 12),
new THREE.Vector3(13, 0, 24),
new THREE.Vector3(19, 0, 34)
]);
makeRibbon(riverCurve, 2.5, palette.river, 0.075);
// Major city roads.
for (let x = 3; x <= 33; x += 6) {
makeRibbon(
horizontalCurve(x, -29, x, 29),
x === 3 ? 1.65 : 1.1,
palette.road,
0.055
);
}
for (let z = -22; z <= 26; z += 8) {
makeRibbon(
horizontalCurve(0, z, 37, z),
z === 2 ? 1.55 : 0.95,
palette.road,
0.06
);
}
// Tempelhof-style runways.
box(38, 0.1, 3.25, palette.runway, [-7, 0.12, 0]);
box(3.25, 0.1, 34, palette.runway, [-7, 0.13, -5]);
for (let x = -24; x <= 10; x += 5) {
box(2.25, 0.025, 0.16, palette.runwayMark, [x, 0.19, 0]);
}
for (let z = -21; z <= 11; z += 5) {
box(0.16, 0.025, 2.25, palette.runwayMark, [-7, 0.2, z]);
}
// Curved terminal building.
const terminalGroup = new THREE.Group();
phaseGroups.unload.add(terminalGroup);
for (let i = 0; i <= 8; i++) {
const angle = (i / 8) * Math.PI;
const radius = 6.2;
const x = -8 + Math.cos(angle) * radius;
const z = -13 + Math.sin(angle) * radius;
box(
3.2,
2.8,
2.45,
"#c8bca8",
[x, 1.42, z],
terminalGroup
);
box(
2.75,
0.25,
2.2,
"#857d6e",
[x, 2.94, z],
terminalGroup
);
}
box(3.6, 2.4, 2.5, "#b6aa97", [-8, 1.22, -13], terminalGroup);
cylinder(0.9, 1.1, 1.3, "#d4c9b5", [-8, 2.95, -13], terminalGroup);
cylinder(1.15, 1.15, 0.22, "#596b68", [-8, 3.7, -13], terminalGroup);
// Apron and unloading ramp.
box(9, 0.08, 7, "#9a9c92", [-1, 0.18, -4], phaseGroups.unload);
box(2.3, 0.18, 3.6, "#676d67", [-4.1, 0.4, -4.1], phaseGroups.unload);
box(1.2, 1.5, 2.4, "#9a998c", [-5.2, 1, -4.1], phaseGroups.unload);
const unloadRing = addRing([-1.5, 0.3, -4], 5.4, phaseGroups.unload);
unloadRing.visible = false;
/* ------------------------------------------------------------------ */
/* Low-poly city blocks */
/* ------------------------------------------------------------------ */
let seed = 1948;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function riverApproxX(z) {
if (z < -22) return 7 + (z + 22) * 0.5;
if (z < -10) return 7 + (z + 22) * 0.42;
if (z < 2) return 12 + (z + 10) * 0.27;
if (z < 12) return 9 + (z - 2) * 0.7;
return 16 - (z - 12) * 0.25;
}
const cityGroup = new THREE.Group();
phaseGroups.delivery.add(cityGroup);
for (let gx = 0; gx < 5; gx++) {
for (let gz = 0; gz < 5; gz++) {
const blockX = 6 + gx * 6;
const blockZ = -18 + gz * 8;
if (Math.abs(blockX - riverApproxX(blockZ)) < 3.1) continue;
// Leave a clear zone around the warehouse district.
if (blockX < 25 && blockZ > 1 && blockZ < 13) continue;
// Park block.
if (gx === 2 && gz === 2) {
box(4.4, 0.12, 5.8, "#708a63", [blockX, 0.12, blockZ], cityGroup);
for (let t = 0; t < 5; t++) {
const tree = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.55 + random() * 0.25, 0),
standard("#547257")
);
tree.position.set(
blockX + (random() - 0.5) * 3,
0.7,
blockZ + (random() - 0.5) * 4.5
);
tree.castShadow = true;
cityGroup.add(tree);
}
continue;
}
for (let bx = 0; bx < 2; bx++) {
for (let bz = 0; bz < 2; bz++) {
if (random() < 0.16) continue;
const width = 1.25 + random() * 1.25;
const depth = 1.3 + random() * 1.35;
const height = 1.1 + random() * 3.3;
const x = blockX + (bx - 0.5) * 2.35;
const z = blockZ + (bz - 0.5) * 2.65;
const color =
palette.building[Math.floor(random() * palette.building.length)];
box(width, height, depth, color, [x, height / 2 + 0.12, z], cityGroup);
const roof = box(
width + 0.08,
0.16,
depth + 0.08,
palette.roof[Math.floor(random() * palette.roof.length)],
[x, height + 0.2, z],
cityGroup
);
roof.castShadow = true;
if (height > 3.1) {
box(
0.45,
0.75,
0.45,
"#9b9484",
[x, height + 0.56, z],
cityGroup
);
}
}
}
}
}
// Small park and civic building details.
box(5.8, 0.12, 4.2, "#708765", [29, 0.14, 22], cityGroup);
cylinder(0.16, 0.2, 2.8, "#695c47", [28, 1.5, 22], cityGroup, 6);
cylinder(0.16, 0.2, 2.8, "#695c47", [30, 1.5, 22], cityGroup, 6);
// Stylized Brandenburg Gate.
const gate = new THREE.Group();
gate.position.set(27.5, 0, 10);
cityGroup.add(gate);
for (let i = 0; i < 6; i++) {
box(0.48, 3.6, 0.48, "#c5bda9", [-2.3 + i * 0.92, 1.8, 0], gate);
}
box(5.9, 0.55, 0.72, "#c5bda9", [0, 3.85, 0], gate);
box(4.7, 0.28, 0.58, "#b1a990", [0, 3.34, 0], gate);
box(1.3, 0.7, 0.5, "#b1a990", [0, 4.45, 0], gate);
/* ------------------------------------------------------------------ */
/* Warehouses */
/* ------------------------------------------------------------------ */
function createWarehouse(x, z, index) {
const group = new THREE.Group();
group.position.set(x, 0.15, z);
phaseGroups.warehouse.add(group);
const width = 5.1;
const depth = 4.0;
const height = 3.1;
const color = palette.warehouse[index];
box(
width,
height,
depth,
"#c3bbaa",
[0, height / 2, 0],
group
);
const roofMaterial = standard(color, {
emissive: color,
emissiveIntensity: 0.025
});
warehouseRoofMaterials.push(roofMaterial);
const roof = new THREE.Mesh(
new THREE.ConeGeometry(width * 0.72, 1.45, 4),
roofMaterial
);
roof.rotation.y = Math.PI / 4;
roof.scale.z = depth / (width * 0.72 * Math.SQRT2);
roof.position.y = height + 0.72;
roof.castShadow = true;
group.add(roof);
box(0.08, 1.9, 1.6, "#5b625d", [-width / 2 - 0.04, 0.95, 0], group);
box(0.12, 0.26, 2.6, "#f1d896", [-width / 2 - 0.09, 2.35, 0], group);
// Stacked cargo outside each depot.
for (let p = 0; p < 5; p++) {
box(
0.7,
0.48,
0.65,
p % 2 ? "#b98a50" : "#c9a669",
[
width / 2 + 0.7 + (p % 2) * 0.85,
0.38 + Math.floor(p / 3) * 0.52,
-1 + (p % 3) * 0.85
],
group
);
}
const beacon = new THREE.Mesh(
new THREE.SphereGeometry(0.11, 8, 6),
new THREE.MeshBasicMaterial({ color: palette.signal })
);
beacon.position.set(0, height + 1.55, 0);
group.add(beacon);
return group;
}
createWarehouse(8, 5, 0);
createWarehouse(15, 7, 1);
createWarehouse(22, 5, 2);
createWarehouse(18, -5, 3);
const warehouseRing = addRing([15.5, 0.3, 4.5], 12, phaseGroups.warehouse);
warehouseRing.visible = false;
/* ------------------------------------------------------------------ */
/* Air corridors and aircraft */
/* ------------------------------------------------------------------ */
function createAircraft(color = "#d6d0bc") {
const group = new THREE.Group();
const fuselage = new THREE.Mesh(
new THREE.CylinderGeometry(0.3, 0.43, 3.1, 8),
standard(color)
);
fuselage.rotation.z = Math.PI / 2;
fuselage.castShadow = true;
group.add(fuselage);
const nose = new THREE.Mesh(
new THREE.ConeGeometry(0.31, 0.75, 8),
standard("#9ca9a3")
);
nose.rotation.z = -Math.PI / 2;
nose.position.x = 1.91;
nose.castShadow = true;
group.add(nose);
box(0.75, 0.12, 3.9, "#b8b4a5", [0.05, -0.04, 0], group);
box(0.55, 0.11, 1.75, "#8c9790", [-1.25, 0.02, 0], group);
box(0.7, 0.7, 0.1, "#3d7876", [-1.3, 0.34, 0], group);
for (const side of [-1, 1]) {
const engine = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.22, 0.8, 7),
standard("#66746f")
);
engine.rotation.z = Math.PI / 2;
engine.position.set(0.52, -0.2, side * 1.08);
engine.castShadow = true;
group.add(engine);
const prop = new THREE.Group();
prop.position.set(0.96, -0.2, side * 1.08);
const disc = new THREE.Mesh(
new THREE.CircleGeometry(0.42, 12),
new THREE.MeshBasicMaterial({
color: "#4e5b57",
transparent: true,
opacity: 0.18,
side: THREE.DoubleSide,
depthWrite: false
})
);
disc.rotation.y = Math.PI / 2;
prop.add(disc);
box(0.05, 0.83, 0.08, "#374541", [0, 0, 0], prop);
box(0.05, 0.08, 0.83, "#374541", [0, 0, 0], prop);
group.add(prop);
propellers.push(prop);
}
group.scale.setScalar(0.72);
phaseGroups.corridors.add(group);
return group;
}
const corridorDefinitions = [
{
color: palette.signal,
points: [
[-42, 14, -23],
[-31, 12.5, -18],
[-21, 8.5, -10],
[-10, 3.1, -4.5],
[-2.8, 1.25, -3.3]
],
offset: 0.1,
speed: 0.046
},
{
color: palette.teal,
points: [
[-43, 15, -2],
[-31, 13, -1],
[-20, 8, 0],
[-9, 3.1, -1.5],
[-3.4, 1.2, -2]
],
offset: 0.44,
speed: 0.041
},
{
color: palette.gold,
points: [
[-40, 16, 20],
[-30, 13, 15],
[-19, 8.2, 8],
[-9, 3.2, 1],
[-3.2, 1.3, -1]
],
offset: 0.72,
speed: 0.038
}
];
corridorDefinitions.forEach((definition, index) => {
const curve = new THREE.CatmullRomCurve3(
definition.points.map((point) => new THREE.Vector3(...point)),
false,
"catmullrom",
0.45
);
const line = dashedLine(
curve,
definition.color,
phaseGroups.corridors,
0.9,
1.2
);
routeLines.push(line.material);
for (const t of [0.3, 0.62]) {
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.36, 0.95, 4),
new THREE.MeshBasicMaterial({ color: definition.color })
);
const point = curve.getPointAt(t);
const tangent = curve.getTangentAt(t).normalize();
arrow.position.copy(point);
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
tangent
);
phaseGroups.corridors.add(arrow);
}
const plane = createAircraft(
index === 0 ? "#d4cbb8" : index === 1 ? "#c3d0c8" : "#d6bd8e"
);
const entryPoint = curve.getPointAt(0);
const entryRing = addRing(
[entryPoint.x, 0.25, entryPoint.z],
2.15,
phaseGroups.corridors
);
entryRing.userData.corridor = true;
entryRing.visible = false;
aircraft.push({
mesh: plane,
curve,
offset: definition.offset,
speed: definition.speed
});
});
/* ------------------------------------------------------------------ */
/* Apron cargo, forklift, and moving pallet */
/* ------------------------------------------------------------------ */
function createPallet() {
const group = new THREE.Group();
box(1.25, 0.16, 0.9, "#79634b", [0, 0.08, 0], group);
box(1.08, 0.7, 0.76, "#bd955f", [0, 0.5, 0], group);
box(0.1, 0.72, 0.78, "#dfc48f", [-0.28, 0.5, 0], group);
box(0.1, 0.72, 0.78, "#dfc48f", [0.28, 0.5, 0], group);
group.traverse((object) => {
if (object.isMesh) object.castShadow = true;
});
return group;
}
for (let i = 0; i < 7; i++) {
const pallet = createPallet();
pallet.position.set(
-0.2 + (i % 4) * 1.15,
0.28,
-6.1 + Math.floor(i / 4) * 1.1
);
pallet.rotation.y = (random() - 0.5) * 0.16;
phaseGroups.unload.add(pallet);
}
const movingPallet = createPallet();
phaseGroups.unload.add(movingPallet);
const forklift = new THREE.Group();
forklift.position.set(2.8, 0.3, -2.7);
forklift.rotation.y = -0.4;
phaseGroups.unload.add(forklift);
box(1.05, 0.62, 0.75, palette.signal, [0, 0.48, 0], forklift);
box(0.7, 0.62, 0.68, "#d9b94f", [0.25, 1.02, 0], forklift);
box(0.12, 1.85, 0.13, "#4e5955", [-0.56, 1.05, 0.25], forklift);
box(0.12, 1.85, 0.13, "#4e5955", [-0.56, 1.05, -0.25], forklift);
box(1.15, 0.1, 0.16, "#4e5955", [-1.05, 0.24, 0.25], forklift);
box(1.15, 0.1, 0.16, "#4e5955", [-1.05, 0.24, -0.25], forklift);
for (const x of [-0.35, 0.38]) {
for (const z of [-0.43, 0.43]) {
const wheel = cylinder(
0.22,
0.22,
0.16,
"#303b38",
[x, 0.24, z],
forklift,
8
);
wheel.rotation.x = Math.PI / 2;
}
}
/* ------------------------------------------------------------------ */
/* Last-mile trucks and delivery routes */
/* ------------------------------------------------------------------ */
function createTruck(color) {
const group = new THREE.Group();
box(1.25, 0.72, 0.92, color, [0.72, 0.57, 0], group);
box(0.55, 0.5, 0.83, "#c7d1c9", [1.04, 1.05, 0], group);
box(1.45, 0.82, 0.95, "#c5b79d", [-0.45, 0.63, 0], group);
box(0.9, 0.12, 0.98, "#8d8069", [-0.45, 1.08, 0], group);
for (const x of [-0.75, 0.72]) {
for (const z of [-0.55, 0.55]) {
const wheel = cylinder(
0.22,
0.22,
0.14,
"#293532",
[x, 0.25, z],
group,
8
);
wheel.rotation.x = Math.PI / 2;
}
}
group.scale.setScalar(0.78);
phaseGroups.delivery.add(group);
return group;
}
const deliveryDefinitions = [
{
color: "#d6603f",
points: [
[8, 0.16, 5],
[11, 0.16, 10],
[17, 0.16, 10],
[17, 0.16, 18],
[23, 0.16, 18]
],
offset: 0.05,
speed: 0.032
},
{
color: "#3f817a",
points: [
[22, 0.16, 5],
[23, 0.16, 10],
[29, 0.16, 10],
[29, 0.16, 18],
[35, 0.16, 18]
],
offset: 0.37,
speed: 0.029
},
{
color: "#d09b42",
points: [
[15, 0.16, 7],
[17, 0.16, 2],
[23, 0.16, 2],
[29, 0.16, 2],
[35, 0.16, 2]
],
offset: 0.68,
speed: 0.026
},
{
color: "#6b807a",
points: [
[18, 0.16, -5],
[18, 0.16, -6],
[12, 0.16, -6],
[6, 0.16, -6],
[6, 0.16, -14]
],
offset: 0.82,
speed: 0.024
}
];
deliveryDefinitions.forEach((definition) => {
const curve = new THREE.CatmullRomCurve3(
definition.points.map((point) => new THREE.Vector3(...point)),
false,
"catmullrom",
0.3
);
makeRibbon(curve, 1.0, "#d0c6b1", 0.09, phaseGroups.delivery);
const line = dashedLine(
curve,
definition.color,
phaseGroups.delivery,
0.55,
0.75
);
deliveryLines.push(line.material);
trucks.push({
mesh: createTruck(definition.color),
curve,
offset: definition.offset,
speed: definition.speed
});
});
const deliveryRing = addRing([22, 0.3, 11], 12, phaseGroups.delivery);
deliveryRing.visible = false;
/* ------------------------------------------------------------------ */
/* Clouds, windsock, and small scene details */
/* ------------------------------------------------------------------ */
function createCloud(x, y, z, scale) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
const material = standard("#eef1e9", {
roughness: 1,
transparent: true,
opacity: 0.86
});
const pieces = [
[-1.2, 0, 0, 1.25],
[0, 0.35, 0, 1.6],
[1.3, -0.05, 0.2, 1.1],
[0.55, -0.2, -0.4, 1.25]
];
pieces.forEach(([px, py, pz, radius]) => {
const cloud = new THREE.Mesh(
new THREE.DodecahedronGeometry(radius, 0),
material
);
cloud.position.set(px, py, pz);
group.add(cloud);
});
world.add(group);
clouds.push({ group, originX: x, speed: 0.08 + random() * 0.07 });
}
createCloud(-33, 23, -27, 1.1);
createCloud(30, 24, -27, 1.25);
createCloud(35, 27, 16, 0.95);
// Tempelhof approach lights.
for (let i = 0; i < 7; i++) {
const light = new THREE.Mesh(
new THREE.SphereGeometry(0.09, 6, 4),
new THREE.MeshBasicMaterial({ color: "#f2cf66" })
);
light.position.set(-18 + i * 2.7, 0.28, 1.85);
phaseGroups.unload.add(light);
}
// Small windsock.
cylinder(0.06, 0.09, 3.2, "#6c746f", [-3.4, 1.7, 7.8], phaseGroups.unload, 6);
const windsock = new THREE.Mesh(
new THREE.ConeGeometry(0.24, 1.3, 6, 1, true),
standard(palette.signal, { side: THREE.DoubleSide })
);
windsock.rotation.z = -Math.PI / 2;
windsock.position.set(-2.55, 3.1, 7.8);
phaseGroups.unload.add(windsock);
/* ------------------------------------------------------------------ */
/* Map labels */
/* ------------------------------------------------------------------ */
const labelDefinitions = [
{
title: "West corridor 01",
value: "1,240 t · flour",
note: "Illustrative load",
phase: "corridors",
position: new THREE.Vector3(-28, 12, -16)
},
{
title: "West corridor 02",
value: "980 t · coal",
note: "Illustrative load",
phase: "corridors",
position: new THREE.Vector3(-25, 12, -1)
},
{
title: "West corridor 03",
value: "760 t · machinery",
note: "Illustrative load",
phase: "corridors",
position: new THREE.Vector3(-24, 12, 13)
},
{
title: "Tempelhof apron",
value: "2,350 t transferred",
note: "Illustrative flow",
phase: "unload",
position: new THREE.Vector3(-1, 4.8, -5.8)
},
{
title: "Transfer depot",
value: "4 city warehouses",
note: "Illustrative network",
phase: "warehouse",
position: new THREE.Vector3(15.5, 6.1, 6)
},
{
title: "Last-mile delivery",
value: "640 t to districts",
note: "Illustrative total",
phase: "delivery",
position: new THREE.Vector3(28, 3.5, 18)
}
];
const labelElements = [];
labelDefinitions.forEach((definition) => {
const button = document.createElement("button");
button.className = "map-label";
button.type = "button";
button.setAttribute("aria-label", `${definition.title}, ${definition.value}`);
button.innerHTML = `
<span class="label-title">${definition.title}</span>
<span class="label-value">${definition.value}</span>
<span class="label-note">${definition.note}</span>
`;
button.addEventListener("click", () => setPhase(definition.phase));
document.getElementById("labels").appendChild(button);
labelElements.push({
element: button,
position: definition.position,
phase: definition.phase
});
});
/* ------------------------------------------------------------------ */
/* Custom camera controls */
/* ------------------------------------------------------------------ */
const controlState = {
theta: 0.78,
phi: 0.77,
radius: 78,
target: new THREE.Vector3(0, 0, 0),
dragging: false,
mode: "rotate",
pointerX: 0,
pointerY: 0
};
let cameraTween = null;
function updateCamera() {
const sinPhi = Math.sin(controlState.phi);
camera.position.set(
controlState.target.x +
controlState.radius * sinPhi * Math.cos(controlState.theta),
controlState.target.y +
controlState.radius * Math.cos(controlState.phi),
controlState.target.z +
controlState.radius * sinPhi * Math.sin(controlState.theta)
);
camera.lookAt(controlState.target);
}
function startCameraTween(configuration) {
cameraTween = {
start: performance.now(),
duration: 1100,
from: {
theta: controlState.theta,
phi: controlState.phi,
radius: controlState.radius,
target: controlState.target.clone()
},
to: {
theta: configuration.theta,
phi: configuration.phi,
radius: configuration.radius,
target: new THREE.Vector3(...configuration.target)
}
};
}
function shortAngleDifference(from, to) {
let difference = (to - from) % (Math.PI * 2);
if (difference > Math.PI) difference -= Math.PI * 2;
if (difference < -Math.PI) difference += Math.PI * 2;
return difference;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
cameraTween = null;
controlState.dragging = true;
controlState.mode = event.shiftKey ? "pan" : "rotate";
controlState.pointerX = event.clientX;
controlState.pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controlState.dragging) return;
const dx = event.clientX - controlState.pointerX;
const dy = event.clientY - controlState.pointerY;
controlState.pointerX = event.clientX;
controlState.pointerY = event.clientY;
if (controlState.mode === "rotate") {
controlState.theta -= dx * 0.006;
controlState.phi = THREE.MathUtils.clamp(
controlState.phi - dy * 0.005,
0.32,
1.34
);
} else {
const right = new THREE.Vector3();
const up = new THREE.Vector3();
camera.matrixWorld.extractBasis(right, up, new THREE.Vector3());
const scale = controlState.radius * 0.0011;
controlState.target.addScaledVector(right, -dx * scale);
controlState.target.addScaledVector(up, dy * scale);
controlState.target.x = THREE.MathUtils.clamp(
controlState.target.x,
-40,
40
);
controlState.target.z = THREE.MathUtils.clamp(
controlState.target.z,
-35,
35
);
}
updateCamera();
});
function stopDragging(event) {
controlState.dragging = false;
if (event.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {
// Pointer may already be released.
}
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraTween = null;
controlState.radius = THREE.MathUtils.clamp(
controlState.radius * Math.exp(event.deltaY * 0.001),
26,
112
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("dblclick", () => {
setPhase("all");
});
/* ------------------------------------------------------------------ */
/* Phase storytelling and visual emphasis */
/* ------------------------------------------------------------------ */
const phaseContent = {
all: {
kicker: "System overview · 01 / 04",
title: "The city is the final destination.",
body:
"Airlift cargo moved through four connected stages: western air corridors, apron transfer at Tempelhof, warehouse sorting, and distribution across the city.",
metrics: [
["3", "air corridors"],
["4", "transfer depots"],
["12", "city routes"]
],
camera: {
target: [0, 0, 0],
theta: 0.78,
phi: 0.77,
radius: 78
}
},
corridors: {
kicker: "Phase 01 · Air corridors",
title: "Western skies become supply lines.",
body:
"Transport aircraft converge on Berlin from several western entry points. Dashed paths mark the corridor structure rather than exact historical flight tracks.",
metrics: [
["3", "illustrative paths"],
["24/7", "air operations"],
["1,240 t", "sample corridor"]
],
camera: {
target: [-15, 1, -2],
theta: 0.42,
phi: 0.78,
radius: 66
}
},
unload: {
kicker: "Phase 02 · Apron transfer",
title: "Every aircraft becomes a moving warehouse.",
body:
"At the airfield, cargo is transferred from aircraft to pallets and ground vehicles. The animated load shows the handoff from flight to surface transport.",
metrics: [
["2,350 t", "illustrative flow"],
["06", "active pallet groups"],
["24/7", "continuous transfer"]
],
camera: {
target: [-3, 0.5, -4],
theta: 0.7,
phi: 0.72,
radius: 35
}
},
warehouse: {
kicker: "Phase 03 · Warehousing",
title: "Distribution begins with sorting.",
body:
"Four stylized depots collect incoming loads, organize palletized cargo, and prepare outbound vehicles for the final stage of the journey.",
metrics: [
["4", "city depots"],
["1,420 t", "illustrative stored"],
["06", "sorting bays"]
],
camera: {
target: [15, 1, 5],
theta: 0.82,
phi: 0.73,
radius: 39
}
},
delivery: {
kicker: "Phase 04 · City delivery",
title: "The last mile reaches the neighborhood.",
body:
"Trucks leave the depots and follow the street grid toward receiving districts. The delivery network turns an aerial operation into thousands of local deliveries.",
metrics: [
["12", "illustrative routes"],
["640 t", "sample delivered"],
["18", "receiving blocks"]
],
camera: {
target: [22, 0.5, 10],
theta: 1.0,
phi: 0.76,
radius: 53
}
}
};
const phaseButtons = Array.from(
document.querySelectorAll(".phase-button")
);
const storyKicker = document.getElementById("storyKicker");
const storyTitle = document.getElementById("storyTitle");
const storyBody = document.getElementById("storyBody");
const storyMetrics = document.getElementById("storyMetrics");
let currentPhase = "all";
function setPhase(phase) {
if (!phaseContent[phase]) return;
currentPhase = phase;
phaseButtons.forEach((button) => {
const active = button.dataset.phase === phase;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
labelElements.forEach((label) => {
label.element.classList.toggle(
"muted",
phase !== "all" && label.phase !== phase
);
});
routeLines.forEach((material) => {
material.opacity = phase === "all" || phase === "corridors" ? 0.9 : 0.18;
});
deliveryLines.forEach((material) => {
material.opacity = phase === "all" || phase === "delivery" ? 0.65 : 0.18;
});
warehouseRoofMaterials.forEach((material) => {
material.emissiveIntensity =
phase === "all" || phase === "warehouse" ? 0.12 : 0.015;
});
highlightRings.forEach((ring) => {
const belongsToPhase = ring.parent === phaseGroups[phase];
ring.visible = phase === "all" || belongsToPhase;
});
const content = phaseContent[phase];
storyKicker.textContent = content.kicker;
storyTitle.textContent = content.title;
storyBody.textContent = content.body;
storyMetrics.innerHTML = content.metrics
.map(
([value, label]) => `
<div class="metric">
<strong>${value}</strong>
<span>${label}</span>
</div>
`
)
.join("");
startCameraTween(content.camera);
}
phaseButtons.forEach((button) => {
button.addEventListener("click", () => setPhase(button.dataset.phase));
});
/* ------------------------------------------------------------------ */
/* Animation */
/* ------------------------------------------------------------------ */
const clock = new THREE.Clock();
let simulationTime = 0;
let paused = false;
const pauseButton = document.getElementById("pauseButton");
const resetButton = document.getElementById("resetButton");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.innerHTML = paused
? `
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M8 5l11 7-11 7z"></path>
</svg>
`
: `
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M8 5v14M16 5v14"></path>
</svg>
`;
pauseButton.setAttribute(
"aria-label",
paused ? "Resume animation" : "Pause animation"
);
pauseButton.setAttribute(
"title",
paused ? "Resume animation" : "Pause animation"
);
});
resetButton.addEventListener("click", () => setPhase("all"));
const forwardAxis = new THREE.Vector3(1, 0, 0);
const projected = new THREE.Vector3();
function animateAircraft(item) {
const t = (simulationTime * item.speed + item.offset) % 1;
const point = item.curve.getPointAt(t);
const tangent = item.curve.getTangentAt(t).normalize();
item.mesh.position.copy(point);
item.mesh.quaternion.setFromUnitVectors(forwardAxis, tangent);
let fade = 1;
if (t < 0.055) fade = t / 0.055;
if (t > 0.95) fade = (1 - t) / 0.05;
item.mesh.scale.setScalar(Math.max(0.001, 0.72 * fade));
}
function animateTruck(item) {
const t = (simulationTime * item.speed + item.offset) % 1;
const point = item.curve.getPointAt(t);
const tangent = item.curve.getTangentAt(t).normalize();
item.mesh.position.copy(point);
item.mesh.quaternion.setFromUnitVectors(forwardAxis, tangent);
}
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (!paused) {
simulationTime += delta;
aircraft.forEach(animateAircraft);
trucks.forEach(animateTruck);
propellers.forEach((propeller, index) => {
propeller.rotation.x = simulationTime * (22 + index * 0.15);
});
const palletProgress = (simulationTime / 8.5) % 1;
movingPallet.visible = palletProgress < 0.9;
movingPallet.position.set(
THREE.MathUtils.lerp(-1.2, 3.7, palletProgress),
0.32 + Math.abs(Math.sin(palletProgress * Math.PI * 8)) * 0.06,
THREE.MathUtils.lerp(-4.2, -2.8, palletProgress)
);
movingPallet.rotation.y = -0.08;
forklift.position.x = 2.8 + Math.sin(simulationTime * 0.32) * 0.18;
forklift.position.z = -2.7 + Math.sin(simulationTime * 0.23) * 0.12;
clouds.forEach((cloud) => {
cloud.group.position.x =
cloud.originX + ((simulationTime * cloud.speed) % 9);
});
windsock.rotation.y = Math.sin(simulationTime * 1.7) * 0.12;
}
if (cameraTween) {
const now = performance.now();
const raw = Math.min((now - cameraTween.start) / cameraTween.duration, 1);
const eased =
raw < 0.5
? 4 * raw * raw * raw
: 1 - Math.pow(-2 * raw + 2, 3) / 2;
controlState.theta =
cameraTween.from.theta +
shortAngleDifference(
cameraTween.from.theta,
cameraTween.to.theta
) *
eased;
controlState.phi = THREE.MathUtils.lerp(
cameraTween.from.phi,
cameraTween.to.phi,
eased
);
controlState.radius = THREE.MathUtils.lerp(
cameraTween.from.radius,
cameraTween.to.radius,
eased
);
controlState.target.lerpVectors(
cameraTween.from.target,
cameraTween.to.target,
eased
);
if (raw >= 1) cameraTween = null;
}
updateCamera();
highlightRings.forEach((ring, index) => {
if (!ring.visible) return;
const pulse = 1 + Math.sin(simulationTime * 2 + index * 0.8) * 0.025;
ring.scale.setScalar(pulse);
ring.material.opacity = 0.52 + Math.sin(simulationTime * 2 + index) * 0.12;
});
// Project labels from their 3D anchors.
const width = window.innerWidth;
const height = window.innerHeight;
labelElements.forEach((label) => {
projected.copy(label.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.15 &&
projected.x < 1.15 &&
projected.y > -1.15 &&
projected.y < 1.15;
label.element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
});
renderer.render(scene, camera);
}
/* ------------------------------------------------------------------ */
/* Responsive resize */
/* ------------------------------------------------------------------ */
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", onResize);
updateCamera();
setPhase("all");
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```