Prompt specification
Build or customize the Three.js 3D scene "Compare standardized and incompatible cargo interfaces" 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: Compare standardized and incompatible cargo interfaces
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/compare-standardized-and-incompatible-cargo-interfaces-x2532
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing standardized shipping containers and transfer interfaces. Let users route equal cargo through two fictional terminals, one using compatible units and one requiring repacking. Show handling steps and stated timing assumptions separately. Low-poly.
Working Three.js Starter (compare-standardized-and-incompatible-cargo-interfaces-x2532):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Equal Cargo — Two Terminal Transfer Models</title>
<style>
:root {
--ink: #172321;
--muted: #65716d;
--paper: #f4f1e8;
--panel: #fffdf7;
--line: #d9ddd5;
--teal: #087f73;
--teal-soft: #d8eee9;
--orange: #c9663d;
--orange-soft: #f5e1d7;
--navy: #243b43;
--shadow: 0 18px 48px rgba(20, 35, 31, 0.12);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce4df;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input,
select {
font: inherit;
}
button {
color: inherit;
}
.app {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: 370px minmax(0, 1fr);
}
.sidebar {
position: relative;
z-index: 10;
height: 100%;
overflow-y: auto;
padding: 26px 24px 34px;
background:
linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(248, 246, 239, 0.98));
border-right: 1px solid rgba(23, 35, 33, 0.12);
box-shadow: var(--shadow);
scrollbar-width: thin;
scrollbar-color: #bcc5bf transparent;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 13px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 2px;
content: "";
background: currentColor;
}
h1 {
max-width: 310px;
margin: 0;
font-size: clamp(30px, 3vw, 43px);
font-weight: 760;
letter-spacing: -0.055em;
line-height: 0.98;
}
.intro {
margin: 16px 0 20px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.invariant {
position: relative;
overflow: hidden;
padding: 16px;
border: 1px solid #cddbd3;
border-radius: 15px;
background:
radial-gradient(circle at 100% 0, rgba(8, 127, 115, 0.13), transparent 44%),
#f7fbf7;
}
.invariant::after {
position: absolute;
right: -17px;
bottom: -28px;
width: 86px;
height: 86px;
content: "";
border: 18px solid rgba(8, 127, 115, 0.08);
border-radius: 50%;
}
.invariant-label {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.invariant-row {
display: flex;
align-items: flex-end;
gap: 22px;
margin-top: 8px;
}
.metric strong {
display: block;
font-size: 25px;
font-weight: 800;
letter-spacing: -0.04em;
line-height: 1;
}
.metric span {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 10px;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin: 25px 0 10px;
}
.section-title h2 {
margin: 0;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.section-title small {
color: var(--muted);
font-size: 10px;
}
.route-list {
display: grid;
gap: 8px;
}
.route-card {
position: relative;
width: 100%;
padding: 13px 13px 13px 15px;
overflow: hidden;
text-align: left;
cursor: pointer;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.7);
transition:
transform 160ms ease,
border-color 160ms ease,
background 160ms ease;
}
.route-card:hover {
transform: translateY(-1px);
border-color: #aebbb3;
}
.route-card.active {
border-color: var(--route-color);
background: var(--route-soft);
}
.route-card::before {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 4px;
content: "";
background: var(--route-color);
}
.route-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.route-name {
font-size: 13px;
font-weight: 800;
}
.route-code {
padding: 3px 7px;
border: 1px solid rgba(23, 35, 33, 0.12);
border-radius: 999px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
}
.route-type {
margin-top: 5px;
color: var(--muted);
font-size: 11px;
}
.route-geometry {
margin-top: 9px;
color: var(--ink);
font-size: 10px;
font-weight: 700;
}
.focus-actions {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 6px;
margin-top: 8px;
}
.focus-actions button {
padding: 8px 4px;
cursor: pointer;
border: 1px solid var(--line);
border-radius: 8px;
background: #fff;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.04em;
}
.focus-actions button:hover,
.focus-actions button.active {
color: #fff;
border-color: var(--navy);
background: var(--navy);
}
.playback {
margin-top: 20px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.68);
}
.playback-top {
display: flex;
align-items: center;
gap: 8px;
}
.play-button {
display: grid;
width: 35px;
height: 35px;
flex: 0 0 auto;
place-items: center;
cursor: pointer;
color: #fff;
border: 0;
border-radius: 50%;
background: var(--navy);
}
.play-button span {
margin-left: 2px;
font-size: 12px;
}
.timeline-wrap {
min-width: 0;
flex: 1;
}
.timeline-meta {
display: flex;
justify-content: space-between;
margin-bottom: 6px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
}
input[type="range"] {
width: 100%;
height: 4px;
cursor: pointer;
accent-color: var(--teal);
}
.speed {
width: 54px;
padding: 6px 4px;
border: 1px solid var(--line);
border-radius: 7px;
background: #fff;
font-size: 10px;
}
.restart {
padding: 6px;
cursor: pointer;
color: var(--muted);
border: 0;
background: transparent;
font-size: 16px;
}
.handling {
margin-top: 14px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: #fff;
}
.handling-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.handling-head strong {
font-size: 12px;
}
.handling-head span {
color: var(--muted);
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.step-list {
display: grid;
gap: 0;
}
.step {
position: relative;
display: grid;
grid-template-columns: 22px 1fr;
gap: 8px;
min-height: 47px;
color: #8a938f;
}
.step:not(:last-child)::before {
position: absolute;
top: 18px;
bottom: -3px;
left: 8px;
width: 1px;
content: "";
background: #dfe3de;
}
.step-dot {
position: relative;
z-index: 1;
width: 17px;
height: 17px;
margin-top: 1px;
border: 1px solid #c9d0cb;
border-radius: 50%;
background: #fff;
}
.step.done .step-dot {
border-color: var(--teal);
background: var(--teal);
}
.step.current {
color: var(--ink);
}
.step.current .step-dot {
border: 5px solid var(--teal);
background: #fff;
}
.step-name {
display: block;
padding-top: 1px;
font-size: 11px;
font-weight: 800;
}
.step-note {
display: block;
margin-top: 3px;
font-size: 10px;
line-height: 1.35;
}
.interface {
margin-top: 10px;
padding: 13px;
border: 1px solid #c8d9d3;
border-radius: 12px;
background: var(--teal-soft);
}
.interface-kicker {
color: var(--teal);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.interface h3 {
margin: 5px 0 4px;
font-size: 13px;
}
.interface p {
margin: 0;
color: #52645f;
font-size: 10px;
line-height: 1.45;
}
.interface-chips {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin-top: 10px;
}
.interface-chips button {
padding: 5px 7px;
cursor: pointer;
border: 1px solid rgba(8, 127, 115, 0.23);
border-radius: 999px;
background: rgba(255, 255, 255, 0.55);
color: var(--teal);
font-size: 9px;
font-weight: 800;
}
.interface-chips button.active {
color: #fff;
background: var(--teal);
}
.assumptions {
margin-top: 24px;
padding-top: 17px;
border-top: 1px solid var(--line);
}
.assumption-note {
margin: -4px 0 11px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.timing-table {
width: 100%;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 10px;
border-collapse: separate;
border-spacing: 0;
background: #fff;
font-size: 9px;
}
.timing-table th,
.timing-table td {
padding: 7px 8px;
text-align: right;
border-bottom: 1px solid #e6e8e3;
}
.timing-table th:first-child,
.timing-table td:first-child {
text-align: left;
}
.timing-table thead th {
color: var(--muted);
background: #f2f3ee;
font-size: 8px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.timing-table tr:last-child td {
border-bottom: 0;
}
.timing-table .total {
font-weight: 850;
background: #f8f8f3;
}
.disclaimer {
margin: 13px 0 0;
color: #7b8580;
font-size: 9px;
line-height: 1.5;
}
.stage {
position: relative;
min-width: 0;
height: 100%;
overflow: hidden;
background: #dce4df;
}
#scene {
position: absolute;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
.stage-top {
position: absolute;
z-index: 4;
top: 22px;
right: 24px;
left: 24px;
display: flex;
align-items: flex-start;
justify-content: space-between;
pointer-events: none;
}
.stage-badge {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 9px 11px;
border: 1px solid rgba(23, 35, 33, 0.12);
border-radius: 9px;
background: rgba(255, 253, 247, 0.86);
box-shadow: 0 8px 25px rgba(30, 50, 44, 0.08);
backdrop-filter: blur(8px);
color: #52605b;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.stage-badge::before {
width: 7px;
height: 7px;
content: "";
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(8, 127, 115, 0.12);
}
.cargo-chip {
display: flex;
gap: 20px;
padding: 10px 13px;
border: 1px solid rgba(23, 35, 33, 0.12);
border-radius: 9px;
background: rgba(255, 253, 247, 0.86);
box-shadow: 0 8px 25px rgba(30, 50, 44, 0.08);
backdrop-filter: blur(8px);
}
.cargo-chip span {
display: block;
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.cargo-chip strong {
display: block;
margin-top: 2px;
font-size: 12px;
}
#labels {
position: absolute;
z-index: 3;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.terminal-label {
position: absolute;
min-width: 145px;
padding: 9px 11px;
transform: translate(-50%, -50%);
border: 1px solid rgba(23, 35, 33, 0.12);
border-left: 4px solid var(--route-color);
border-radius: 8px;
background: rgba(255, 253, 247, 0.91);
box-shadow: 0 10px 25px rgba(26, 42, 37, 0.12);
backdrop-filter: blur(8px);
}
.terminal-label strong {
display: block;
font-size: 11px;
}
.terminal-label span {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8px;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.hotspot {
position: absolute;
display: grid;
width: 25px;
height: 25px;
padding: 0;
transform: translate(-50%, -50%);
place-items: center;
pointer-events: auto;
cursor: pointer;
color: #fff;
border: 2px solid rgba(255, 255, 255, 0.95);
border-radius: 50%;
background: var(--route-color);
box-shadow:
0 0 0 5px color-mix(in srgb, var(--route-color) 18%, transparent),
0 6px 14px rgba(20, 35, 31, 0.24);
font-size: 8px;
font-weight: 900;
}
.hotspot.selected {
box-shadow:
0 0 0 8px color-mix(in srgb, var(--route-color) 23%, transparent),
0 6px 14px rgba(20, 35, 31, 0.24);
}
.hotspot::after {
position: absolute;
top: 31px;
left: 50%;
width: max-content;
max-width: 130px;
padding: 4px 6px;
transform: translateX(-50%);
content: attr(data-label);
opacity: 0;
pointer-events: none;
color: #fff;
border-radius: 5px;
background: rgba(23, 35, 33, 0.88);
font-size: 8px;
transition: opacity 150ms ease;
}
.hotspot:hover::after {
opacity: 1;
}
.stage-bottom {
position: absolute;
z-index: 4;
right: 22px;
bottom: 20px;
left: 22px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 13px;
padding: 9px 11px;
border: 1px solid rgba(23, 35, 33, 0.12);
border-radius: 9px;
background: rgba(255, 253, 247, 0.87);
box-shadow: 0 8px 25px rgba(30, 50, 44, 0.08);
backdrop-filter: blur(8px);
color: #586660;
font-size: 8px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.legend-item {
display: flex;
align-items: center;
gap: 5px;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 2px;
}
.controls-hint {
color: #5d6964;
font-size: 9px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}
.layer-toggle {
position: absolute;
z-index: 5;
top: 73px;
right: 24px;
display: flex;
align-items: center;
gap: 7px;
padding: 8px 10px;
pointer-events: auto;
border: 1px solid rgba(23, 35, 33, 0.12);
border-radius: 8px;
background: rgba(255, 253, 247, 0.88);
color: #52605b;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.layer-toggle input {
accent-color: var(--teal);
}
@media (max-width: 980px) {
html,
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100%;
grid-template-columns: 1fr;
}
.sidebar {
height: auto;
overflow: visible;
border-right: 0;
border-bottom: 1px solid rgba(23, 35, 33, 0.12);
}
.stage {
height: 68vh;
min-height: 520px;
}
.stage-top {
top: 15px;
right: 15px;
left: 15px;
}
.cargo-chip {
gap: 10px;
}
.layer-toggle {
top: 62px;
right: 15px;
}
}
@media (max-width: 560px) {
.sidebar {
padding: 22px 18px 30px;
}
.stage {
height: 62vh;
min-height: 450px;
}
.stage-badge {
display: none;
}
.stage-top {
justify-content: flex-end;
}
.stage-bottom {
right: 12px;
bottom: 12px;
left: 12px;
}
.controls-hint {
display: none;
}
}
</style>
</head>
<body>
<div class="app">
<aside class="sidebar">
<div class="eyebrow">Intermodal study 04</div>
<h1>One cargo.<br />Two handoffs.</h1>
<p class="intro">
Compare an ISO-compatible terminal with a fictional terminal that must
break and rebuild container loads. Cargo volume is conserved in both routes.
</p>
<div class="invariant">
<div class="invariant-label">Equal cargo presented to both terminals</div>
<div class="invariant-row">
<div class="metric">
<strong>24 TEU</strong>
<span>12 × 40 ft ISO units</span>
</div>
<div class="metric">
<strong>18.0 t</strong>
<span>Declared cargo mass</span>
</div>
<div class="metric">
<strong>0</strong>
<span>TEU lost in transfer</span>
</div>
</div>
</div>
<div class="section-title">
<h2>Fictional terminals</h2>
<small>Select to inspect</small>
</div>
<div class="route-list">
<button
class="route-card active"
data-route="A"
style="--route-color: var(--teal); --route-soft: var(--teal-soft)"
>
<div class="route-top">
<span class="route-name">Kestrel Quay</span>
<span class="route-code">ROUTE A</span>
</div>
<div class="route-type">Compatible units · direct rail handoff</div>
<div class="route-geometry">40 ft in → 40 ft out · no repack</div>
</button>
<button
class="route-card"
data-route="B"
style="--route-color: var(--orange); --route-soft: var(--orange-soft)"
>
<div class="route-top">
<span class="route-name">Marrow Point</span>
<span class="route-code">ROUTE B</span>
</div>
<div class="route-type">Incompatible handling · repack required</div>
<div class="route-geometry">40 ft in → 24 × 20 ft out</div>
</button>
</div>
<div class="focus-actions" aria-label="Camera focus">
<button data-focus="A">Kestrel</button>
<button data-focus="B">Marrow</button>
<button data-focus="compare" class="active">Compare</button>
</div>
<div class="section-title">
<h2>Flow playback</h2>
<small>Schematic, not to scale</small>
</div>
<div class="playback">
<div class="playback-top">
<button class="play-button" id="play" aria-label="Pause animation">
<span id="play-icon">Ⅱ</span>
</button>
<div class="timeline-wrap">
<div class="timeline-meta">
<span id="phase-label">Vessel arrival</span>
<span id="progress-label">0%</span>
</div>
<input
id="timeline"
type="range"
min="0"
max="1000"
value="0"
aria-label="Transfer progress"
/>
</div>
<select class="speed" id="speed" aria-label="Playback speed">
<option value="0.5">0.5×</option>
<option value="1" selected>1×</option>
<option value="2">2×</option>
</select>
<button class="restart" id="restart" aria-label="Restart">↺</button>
</div>
</div>
<div class="section-title">
<h2>Handling steps</h2>
<small id="handling-route">Route A</small>
</div>
<div class="handling">
<div class="handling-head">
<strong id="handling-title">Kestrel Quay</strong>
<span>Operational sequence</span>
</div>
<div class="step-list" id="steps"></div>
</div>
<div class="interface">
<div class="interface-kicker">Transfer interface</div>
<h3 id="interface-title">Sea → quay</h3>
<p id="interface-copy"></p>
<div class="interface-chips" id="interface-chips"></div>
</div>
<div class="assumptions">
<div class="section-title">
<h2>Stated timing assumptions</h2>
<small>Illustrative only</small>
</div>
<p class="assumption-note">
These planning assumptions describe the modeled sequence. They are
deliberately separate from the handling steps above and are not
measured terminal performance.
</p>
<table class="timing-table">
<thead>
<tr>
<th>Activity</th>
<th>Kestrel</th>
<th>Marrow</th>
</tr>
</thead>
<tbody>
<tr>
<td>Gate + document check</td>
<td>3 min</td>
<td>3 min</td>
</tr>
<tr>
<td>Vessel discharge</td>
<td>30 min</td>
<td>30 min</td>
</tr>
<tr>
<td>Direct interface</td>
<td>18 min</td>
<td>—</td>
</tr>
<tr>
<td>Unpack + split</td>
<td>—</td>
<td>12 min</td>
</tr>
<tr>
<td>Repack + validate</td>
<td>—</td>
<td>18 min</td>
</tr>
<tr>
<td>Outbound load</td>
<td>12 min</td>
<td>10 min</td>
</tr>
<tr class="total">
<td>Modeled total</td>
<td>63 min</td>
<td>73 min</td>
</tr>
</tbody>
</table>
<p class="disclaimer">
Fictional names and data. The visualization compares container geometry
and handling logic; it does not represent an operational terminal,
safety plan, or performance forecast.
</p>
</div>
</aside>
<main class="stage">
<div id="scene" aria-label="Interactive low-poly terminal comparison"></div>
<div class="stage-top">
<div class="stage-badge">Concept model · cargo-conserving comparison</div>
<div class="cargo-chip">
<div>
<span>Input</span>
<strong>12 × 40 ft</strong>
</div>
<div>
<span>Mass</span>
<strong>18.0 t</strong>
</div>
<div>
<span>Output</span>
<strong>24 TEU</strong>
</div>
</div>
</div>
<label class="layer-toggle">
<input id="show-hotspots" type="checkbox" checked />
Show interfaces
</label>
<div id="labels"></div>
<div class="stage-bottom">
<div class="legend">
<span class="legend-item">
<i class="swatch" style="background: #087f73"></i> Direct / compatible
</span>
<span class="legend-item">
<i class="swatch" style="background: #c9663d"></i> Repack / conversion
</span>
<span class="legend-item">
<i class="swatch" style="background: #243b43"></i> Infrastructure
</span>
<span class="legend-item">Container bodies are schematic</span>
</div>
<div class="controls-hint">Drag to orbit · Shift-drag to pan · Wheel to zoom</div>
</div>
</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 ROUTES = {
A: {
name: "Kestrel Quay",
color: 0x087f73,
css: "#087f73",
steps: [
{
at: 0,
name: "Vessel arrival",
note: "12 compatible 40 ft ISO units are staged aboard.",
interface: "A1"
},
{
at: 0.16,
name: "Sea → quay lift",
note: "The quay gantry lifts each unit without opening it.",
interface: "A1"
},
{
at: 0.42,
name: "Quay buffer",
note: "Unchanged 40 ft units wait in the marshalling area.",
interface: "A1"
},
{
at: 0.65,
name: "Quay → rail",
note: "The same ISO units are placed directly onto rail wagons.",
interface: "A2"
},
{
at: 0.92,
name: "Outbound verified",
note: "24 TEU remains on one compatible unit geometry.",
interface: "A2"
}
],
interfaces: {
A1: {
title: "Sea → quay",
copy:
"Direct gantry lift. The 40 ft ISO shell is the transfer unit; cargo is neither opened nor repacked.",
position: [-13, 4.4, -4.0]
},
A2: {
title: "Quay → rail",
copy:
"Rail-compatible handoff. The 40 ft unit remains unchanged from vessel departure to wagon loading.",
position: [-6, 2.2, 4.5]
}
}
},
B: {
name: "Marrow Point",
color: 0xc9663d,
css: "#c9663d",
steps: [
{
at: 0,
name: "Vessel arrival",
note: "The same 12 × 40 ft ISO units arrive with equal cargo.",
interface: "B1"
},
{
at: 0.16,
name: "Sea → quay lift",
note: "Units are temporarily landed in the inbound buffer.",
interface: "B1"
},
{
at: 0.40,
name: "Quay → repack",
note: "The terminal opens units to redistribute cargo.",
interface: "B2"
},
{
at: 0.56,
name: "40 ft → 20 ft rebuild",
note: "Each original unit becomes two compatible 20 ft units.",
interface: "B2"
},
{
at: 0.72,
name: "Repack → road",
note: "The rebuilt 20 ft units move onto outbound chassis.",
interface: "B3"
},
{
at: 0.93,
name: "Outbound verified",
note: "24 TEU and 18.0 t are conserved after repacking.",
interface: "B3"
}
],
interfaces: {
B1: {
title: "Sea → quay",
copy:
"Temporary direct lift into an inbound buffer. Unit geometry still matches here, but it is not the terminal's outbound format.",
position: [13, 4.4, -4.0]
},
B2: {
title: "Quay → repack interface",
copy:
"Conversion interface. Cargo is removed from twelve 40 ft shells and redistributed into twenty-four 20 ft ISO shells.",
position: [13, 5.0, 0.2]
},
B3: {
title: "Repack → road",
copy:
"Outbound interface. The terminal's rebuilt 20 ft units are accepted directly by road chassis.",
position: [18, 2.1, 6.5]
}
}
}
};
const sceneElement = document.querySelector("#scene");
const labelsElement = document.querySelector("#labels");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
sceneElement.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce4df);
scene.fog = new THREE.Fog(0xdce4df, 54, 92);
const camera = new THREE.OrthographicCamera(-30, 30, 21, -21, 0.1, 160);
camera.position.set(8, 32, 43);
const cameraState = {
yaw: -0.05,
pitch: 0.59,
distance: 57,
target: new THREE.Vector3(1, 0.5, 0),
desiredTarget: new THREE.Vector3(1, 0.5, 0),
zoom: 1,
desiredZoom: 1
};
const ambient = new THREE.HemisphereLight(0xf7fbf4, 0x73847e, 2.15);
scene.add(ambient);
const sun = new THREE.DirectionalLight(0xfff3d7, 3.1);
sun.position.set(-18, 34, 23);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -42;
sun.shadow.camera.right = 42;
sun.shadow.camera.top = 30;
sun.shadow.camera.bottom = -30;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 90;
sun.shadow.bias = -0.00035;
scene.add(sun);
const rimLight = new THREE.DirectionalLight(0xb8d7e2, 1.0);
rimLight.position.set(25, 14, -28);
scene.add(rimLight);
const materialCache = new Map();
function material(color, options = {}) {
const key = `${color}-${options.flatShading !== false}-${options.opacity ?? 1}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.78,
metalness: options.metalness ?? 0.02,
flatShading: options.flatShading !== false,
transparent: (options.opacity ?? 1) < 1,
opacity: options.opacity ?? 1
})
);
}
return materialCache.get(key);
}
function box(parent, size, position, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material(color, options)
);
mesh.position.set(...position);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
parent.add(mesh);
return mesh;
}
function cylinder(parent, radius, height, position, color, segments = 8, options = {}) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, height, segments),
material(color, options)
);
mesh.position.set(...position);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function line(parent, points, color, opacity = 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map((p) => new THREE.Vector3(...p))
);
const mesh = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({ color, transparent: opacity < 1, opacity })
);
parent.add(mesh);
return mesh;
}
function makeLabelTexture(text, background = "#243b43", foreground = "#fffdf7") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 112;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = foreground;
context.font = "700 34px system-ui";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, canvas.width / 2, canvas.height / 2 + 1);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
function makeSign(parent, text, position, width = 5, color = "#243b43") {
const texture = makeLabelTexture(text, color);
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({ map: texture, transparent: true })
);
sprite.position.set(...position);
sprite.scale.set(width, width * 0.22, 1);
parent.add(sprite);
return sprite;
}
function makeContainer(length = 40, bodyColor = 0x087f73) {
const group = new THREE.Group();
const lengthMeters = length === 40 ? 4.25 : 2.12;
const height = 1.24;
const depth = 1.12;
const body = box(
group,
[lengthMeters, height, depth],
[0, 0, 0],
bodyColor,
{ roughness: 0.82 }
);
body.userData.isContainerBody = true;
const frameColor = 0x40504d;
const ribCount = length === 40 ? 5 : 3;
for (let i = 0; i < ribCount; i++) {
const x = -lengthMeters * 0.38 + (i * lengthMeters * 0.76) / (ribCount - 1);
box(group, [0.035, height * 0.91, depth * 1.015], [x, 0, 0], frameColor, {
roughness: 0.9
});
}
box(
group,
[lengthMeters * 0.98, 0.065, depth * 0.88],
[0, height * 0.51, 0],
bodyColor,
{ roughness: 0.72 }
);
box(
group,
[0.055, height * 0.93, depth * 1.03],
[-lengthMeters * 0.49, 0, 0],
frameColor
);
box(
group,
[0.055, height * 0.93, depth * 1.03],
[lengthMeters * 0.49, 0, 0],
frameColor
);
return group;
}
function createShip(x, z, accentColor) {
const ship = new THREE.Group();
ship.position.set(x, 0, z);
const shape = new THREE.Shape();
shape.moveTo(-5, -1.45);
shape.lineTo(3.75, -1.45);
shape.lineTo(5, 0);
shape.lineTo(3.75, 1.45);
shape.lineTo(-5, 1.45);
shape.closePath();
const hullGeometry = new THREE.ExtrudeGeometry(shape, {
depth: 0.9,
bevelEnabled: false
});
hullGeometry.rotateX(Math.PI / 2);
const hull = new THREE.Mesh(
hullGeometry,
material(0x304a52, { roughness: 0.72 })
);
hull.position.y = 1.05;
hull.castShadow = true;
hull.receiveShadow = true;
ship.add(hull);
box(ship, [9.5, 0.14, 2.65], [-0.3, 1.08, 0], 0xa5b1aa);
box(ship, [1.25, 1.45, 2.25], [-4.1, 1.88, 0], 0xd8ddd4);
box(ship, [1.05, 0.42, 1.85], [-4.1, 2.8, 0], 0x607b83);
box(ship, [4.6, 0.16, 0.25], [0, 1.26, 1.15], accentColor);
cylinder(ship, 0.24, 2.2, [-4.12, 3.25, 0], 0x415a60, 8);
box(ship, [0.12, 0.12, 3.2], [-4.12, 4.25, 0], 0x415a60);
scene.add(ship);
return ship;
}
function createCrane(x, z, color, label) {
const crane = new THREE.Group();
crane.position.set(x, 0, z);
const steel = 0x3d555b;
const accent = color;
box(crane, [0.35, 6.2, 0.35], [-3.35, 3.1, 0], steel);
box(crane, [0.35, 6.2, 0.35], [3.35, 3.1, 0], steel);
box(crane, [7.25, 0.42, 0.45], [0, 6.05, 0], accent);
box(crane, [0.3, 0.3, 3.8], [-3.35, 5.0, 0], steel);
box(crane, [0.3, 0.3, 3.8], [3.35, 5.0, 0], steel);
const trolley = box(crane, [1.2, 0.45, 1.0], [0, 5.55, 0], 0xe8d9ac);
line(crane, [[-0.18, 5.35, 0], [-0.18, 2.1, 0]], 0x263b40);
line(crane, [[0.18, 5.35, 0], [0.18, 2.1, 0]], 0x263b40);
box(crane, [0.55, 0.35, 0.9], [0, 2.05, 0], steel);
makeSign(crane, label, [0, 6.7, 0], 4.8, `#${new THREE.Color(color).getHexString()}`);
scene.add(crane);
return { group: crane, trolley };
}
function createRailTrain() {
const train = new THREE.Group();
for (const x of [-20, -16, -12, -8, -4, 0]) {
box(train, [3.65, 0.3, 1.7], [x, 0.76, 4.6], 0x465b60);
box(train, [3.4, 0.15, 1.45], [x, 0.98, 4.6], 0x788783);
for (const dx of [-1.05, 1.05]) {
for (const dz of [-0.55, 0.55]) {
cylinder(
train,
0.24,
0.16,
[x + dx, 0.53, 4.6 + dz],
0x283b40,
10,
{ rotation: [Math.PI / 2, 0, 0] }
);
}
}
}
for (const z of [4.02, 5.18]) {
box(train, [25.5, 0.1, 0.09], [-10, 0.47, z], 0x2a3d42);
}
for (let x = -22; x <= 2; x += 0.75) {
box(train, [0.18, 0.08, 1.5], [x, 0.4, 4.6], 0x596a65);
}
makeSign(train, "RAIL INTERFACE", [-6, 2.85, 4.6], 4.4, "#243b43");
scene.add(train);
return train;
}
function createTruck(x, z, rowIndex, truckIndex) {
const truck = new THREE.Group();
truck.position.set(x, 0, z);
const trailer = box(
truck,
[8.65, 0.26, 1.58],
[-0.15, 0.72, 0],
0x657772
);
trailer.receiveShadow = true;
for (const dx of [-3.25, -0.8, 1.5, 3.15]) {
cylinder(
truck,
0.29,
0.2,
[dx, 0.42, -0.78],
0x253a40,
10,
{ rotation: [Math.PI / 2, 0, 0] }
);
cylinder(
truck,
0.29,
0.2,
[dx, 0.42, 0.78],
0x253a40,
10,
{ rotation: [Math.PI / 2, 0, 0] }
);
}
box(truck, [1.45, 1.05, 1.55], [4.7, 1.15, 0], 0xc9663d);
box(truck, [0.75, 0.55, 1.62], [4.55, 1.52, 0], 0x91b3b7);
box(truck, [0.15, 0.32, 1.42], [5.39, 1.55, 0], 0x39535a);
scene.add(truck);
return truck;
}
function createGround() {
const waterGeometry = new THREE.PlaneGeometry(76, 23, 18, 7);
const position = waterGeometry.attributes.position;
for (let i = 0; i < position.count; i++) {
const x = position.getX(i);
const y = position.getY(i);
position.setZ(i, Math.sin(x * 0.45) * 0.12 + Math.cos(y * 0.7) * 0.06);
}
waterGeometry.computeVertexNormals();
waterGeometry.rotateX(-Math.PI / 2);
const water = new THREE.Mesh(
waterGeometry,
material(0x6c9da5, { roughness: 0.65, flatShading: true })
);
water.position.set(1, -0.12, -10);
water.receiveShadow = true;
scene.add(water);
for (let i = 0; i < 11; i++) {
const z = -19 + i * 1.8;
line(
scene,
[
[-34 + (i % 3) * 2, -0.03, z],
[-23 + (i % 3) * 2, -0.03, z + 0.15]
],
0xb2cbc9,
0.38
);
}
box(scene, [25, 0.65, 12.8], [-11.7, 0.22, 0.3], 0xb8b8a9);
box(scene, [27, 0.65, 14.0], [15.0, 0.22, 0.4], 0xc0b8a7);
box(scene, [76, 0.32, 8], [1, -0.15, 11.2], 0xa5aaa0);
for (let x = -22; x <= 1; x += 3) {
box(scene, [0.08, 0.035, 7.8], [x, 0.57, 0.2], 0xe0d6b7);
}
for (let z = -3; z <= 3; z += 1.5) {
box(scene, [6.8, 0.035, 0.08], [-13, 0.57, z], 0xe0d6b7);
}
for (let x = 3; x <= 27; x += 3) {
box(scene, [0.08, 0.035, 9.8], [x, 0.57, 0.2], 0xe5cfb5);
}
for (const x of [-22, -16, -10, -4, 4, 10, 16, 22, 28]) {
box(scene, [0.2, 0.9, 0.2], [x, 0.95, -4.15], 0x687773);
}
box(scene, [52, 0.14, 0.18], [3, 1.38, -4.15], 0xe2c78c);
}
function createRepackShed() {
const shed = new THREE.Group();
shed.position.set(13, 0, 0.2);
for (const x of [-6.5, -2.2, 2.2, 6.5]) {
for (const z of [-2.55, 2.55]) {
box(shed, [0.22, 4.8, 0.22], [x, 2.4, z], 0x725b4e);
}
}
box(shed, [13.5, 0.22, 5.8], [0, 4.82, 0], 0xc97850);
box(shed, [13.8, 0.13, 0.22], [0, 4.55, -2.8], 0x7a5b4d);
box(shed, [13.8, 0.13, 0.22], [0, 4.55, 2.8], 0x7a5b4d);
const scanFrame = new THREE.Mesh(
new THREE.TorusGeometry(1.5, 0.08, 6, 24),
material(0xe89c63, { emissive: 0x4d1608, emissiveIntensity: 0.25 })
);
scanFrame.rotation.x = Math.PI / 2;
scanFrame.position.set(0, 0.75, 0);
shed.add(scanFrame);
makeSign(shed, "REPACK 40' → 20'", [0, 5.35, 0], 7.4, "#a64f30");
scene.add(shed);
return { group: shed, scanFrame };
}
createGround();
createShip(-13, -8.4, 0x087f73);
createShip(13, -8.4, 0xc9663d);
const craneA = createCrane(-13, -2.7, 0x087f73, "DIRECT LIFT");
const craneB = createCrane(13, -2.7, 0xc9663d, "INBOUND LIFT");
const repackShed = createRepackShed();
createRailTrain();
const truckCenters = [6.5, 15.0, 23.5];
for (let row = 0; row < 2; row++) {
for (let index = 0; index < 3; index++) {
createTruck(truckCenters[index], 4.6 + row * 2.8, row, index);
}
}
const containerColorsA = [
0x087f73, 0x2e7e91, 0x9a8257, 0x355b65, 0x527d71, 0x6b8f88
];
const containerColorsB = [
0xc9663d, 0xa95539, 0xb28a56, 0x7c6555, 0xd08359, 0x94654f
];
const outgoingColors = [
0xc9663d, 0xd48759, 0xad5e3d, 0xdc9b72, 0xb9744f, 0xca7449
];
const cargoA = [];
const cargoBLong = [];
const cargoBShort = [];
for (let i = 0; i < 12; i++) {
const layer = Math.floor(i / 6);
const slot = i % 6;
const shipX = slot < 3 ? -1.8 : 2.8;
const shipZ = -8.4 + ((slot % 3) - 1) * 0.92;
const shipY = 1.83 + layer * 1.28;
const containerA = makeContainer(40, containerColorsA[i % containerColorsA.length]);
containerA.position.set(-13 + shipX, shipY, shipZ);
scene.add(containerA);
const yardColumn = slot % 3;
const yardRow = Math.floor(slot / 3);
cargoA.push({
mesh: containerA,
start: containerA.position.clone(),
crane: new THREE.Vector3(
-13 + (yardColumn - 1) * 1.05,
3.1,
-2.55 + yardRow * 0.2
),
yard: new THREE.Vector3(
-18.2 + yardColumn * 4.55,
1.13 + layer * 1.29,
-1.15 + yardRow * 1.5
),
end: new THREE.Vector3(
-20 + slot * 4,
1.48 + layer * 1.28,
4.6
)
});
const containerB = makeContainer(40, containerColorsB[i % containerColorsB.length]);
containerB.position.set(13 + shipX, shipY, shipZ);
scene.add(containerB);
const unpackColumn = slot % 3;
const unpackRow = Math.floor(slot / 3);
cargoBLong.push({
mesh: containerB,
start: containerB.position.clone(),
crane: new THREE.Vector3(
13 + (unpackColumn - 1) * 1.05,
3.1,
-2.55 + unpackRow * 0.2
),
unpack: new THREE.Vector3(
8.5 + unpackColumn * 4.45,
1.12 + layer * 1.28,
-0.7 + unpackRow * 1.42
)
});
}
for (let i = 0; i < 24; i++) {
const container = makeContainer(20, outgoingColors[i % outgoingColors.length]);
const column = i % 6;
const row = Math.floor(i / 6);
const start = new THREE.Vector3(
7.4 + column * 2.28,
1.02,
-0.9 + row * 0.64
);
container.position.copy(start);
container.visible = false;
scene.add(container);
const trailerRow = Math.floor(i / 12);
const withinRow = i % 12;
const truckIndex = Math.floor(withinRow / 4);
const slot = withinRow % 4;
const truckCenter = truckCenters[truckIndex];
const end = new THREE.Vector3(
truckCenter - 0.15 + (slot - 1.5) * 2.13,
1.5,
4.6 + trailerRow * 2.8
);
cargoBShort.push({ mesh: container, start, end });
}
const interfacePads = [];
for (const routeKey of ["A", "B"]) {
const route = ROUTES[routeKey];
for (const [id, data] of Object.entries(route.interfaces)) {
const pad = new THREE.Mesh(
new THREE.TorusGeometry(0.64, 0.09, 6, 24),
material(route.color, { emissive: route.color, emissiveIntensity: 0.1 })
);
pad.rotation.x = Math.PI / 2;
pad.position.set(...data.position);
scene.add(pad);
interfacePads.push({ id, route: routeKey, mesh: pad });
}
}
const terminalLabels = [
{
route: "A",
position: new THREE.Vector3(-13, 7.5, -3.5),
element: null
},
{
route: "B",
position: new THREE.Vector3(13, 7.5, -3.5),
element: null
}
];
for (const item of terminalLabels) {
const route = ROUTES[item.route];
const element = document.createElement("div");
element.className = "terminal-label";
element.style.setProperty("--route-color", route.css);
element.innerHTML = `
<strong>${route.name}</strong>
<span>${
item.route === "A"
? "Compatible chain · no repack"
: "Conversion chain · repack required"
}</span>
`;
labelsElement.appendChild(element);
item.element = element;
}
const hotspotElements = [];
for (const routeKey of ["A", "B"]) {
const route = ROUTES[routeKey];
for (const [id, data] of Object.entries(route.interfaces)) {
const element = document.createElement("button");
element.className = "hotspot";
element.style.setProperty("--route-color", route.css);
element.textContent = id.endsWith("1") ? "01" : id.endsWith("2") ? "02" : "03";
element.dataset.label = data.title;
element.setAttribute("aria-label", `${route.name}: ${data.title}`);
element.addEventListener("click", (event) => {
event.stopPropagation();
activeRoute = routeKey;
activeInterface = id;
updateRouteUI();
updateInterfaceUI();
});
labelsElement.appendChild(element);
hotspotElements.push({
id,
route: routeKey,
element,
position: new THREE.Vector3(...data.position)
});
}
}
let activeRoute = "A";
let activeInterface = "A1";
let focusMode = "compare";
let progress = 0.02;
let playing = !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
let playbackSpeed = 1;
let currentStepKey = "";
let viewportWidth = 1;
let viewportHeight = 1;
const timeline = document.querySelector("#timeline");
const playButton = document.querySelector("#play");
const playIcon = document.querySelector("#play-icon");
const speedSelect = document.querySelector("#speed");
const restartButton = document.querySelector("#restart");
const progressLabel = document.querySelector("#progress-label");
const phaseLabel = document.querySelector("#phase-label");
const stepsElement = document.querySelector("#steps");
const handlingTitle = document.querySelector("#handling-title");
const handlingRoute = document.querySelector("#handling-route");
const interfaceTitle = document.querySelector("#interface-title");
const interfaceCopy = document.querySelector("#interface-copy");
const interfaceChips = document.querySelector("#interface-chips");
const hotspotToggle = document.querySelector("#show-hotspots");
function getCurrentStep(route) {
let selected = route.steps[0];
for (const step of route.steps) {
if (progress >= step.at) selected = step;
}
return selected;
}
function updateRouteUI() {
const route = ROUTES[activeRoute];
handlingTitle.textContent = route.name;
handlingRoute.textContent = `Route ${activeRoute}`;
currentStepKey = "";
document.querySelectorAll(".route-card").forEach((card) => {
card.classList.toggle("active", card.dataset.route === activeRoute);
});
}
function updateInterfaceUI() {
const route = ROUTES[activeRoute];
const data = route.interfaces[activeInterface];
interfaceTitle.textContent = data.title;
interfaceCopy.textContent = data.copy;
interfaceChips.innerHTML = "";
for (const [id, item] of Object.entries(route.interfaces)) {
const button = document.createElement("button");
button.textContent = id;
button.classList.toggle("active", id === activeInterface);
button.addEventListener("click", () => {
activeInterface = id;
updateInterfaceUI();
});
interfaceChips.appendChild(button);
}
hotspotElements.forEach((item) => {
item.element.classList.toggle(
"selected",
item.id === activeInterface && item.route === activeRoute
);
});
}
function updateTimelineUI() {
const route = ROUTES[activeRoute];
const step = getCurrentStep(route);
const key = `${activeRoute}-${step.name}`;
timeline.value = Math.round(progress * 1000);
progressLabel.textContent = `${Math.round(progress * 100)}%`;
phaseLabel.textContent = step.name;
if (key !== currentStepKey) {
currentStepKey = key;
stepsElement.innerHTML = "";
route.steps.forEach((item) => {
const row = document.createElement("div");
const isCurrent = item.name === step.name;
const isDone = progress > item.at && !isCurrent;
row.className = `step${isCurrent ? " current" : ""}${isDone ? " done" : ""}`;
row.innerHTML = `
<span class="step-dot"></span>
<span>
<span class="step-name">${item.name}</span>
<span class="step-note">${item.note}</span>
</span>
`;
stepsElement.appendChild(row);
});
if (step.interface) {
activeInterface = step.interface;
updateInterfaceUI();
}
}
}
function updatePlaybackButton() {
playIcon.textContent = playing ? "Ⅱ" : "▶";
playButton.setAttribute("aria-label", playing ? "Pause animation" : "Play animation");
}
function focusTerminal(mode) {
focusMode = mode;
if (mode === "A") {
cameraState.desiredTarget.set(-12.5, 1.1, -0.2);
cameraState.desiredZoom = 1.45;
} else if (mode === "B") {
cameraState.desiredTarget.set(14.5, 1.1, 0);
cameraState.desiredZoom = 1.38;
} else {
cameraState.desiredTarget.set(1, 0.5, 0);
cameraState.desiredZoom = 1;
}
document.querySelectorAll("[data-focus]").forEach((button) => {
button.classList.toggle("active", button.dataset.focus === mode);
});
}
document.querySelectorAll(".route-card").forEach((card) => {
card.addEventListener("click", () => {
activeRoute = card.dataset.route;
activeInterface = activeRoute === "A" ? "A1" : "B1";
updateRouteUI();
updateInterfaceUI();
focusTerminal(activeRoute);
});
});
document.querySelectorAll("[data-focus]").forEach((button) => {
button.addEventListener("click", () => focusTerminal(button.dataset.focus));
});
playButton.addEventListener("click", () => {
playing = !playing;
updatePlaybackButton();
});
restartButton.addEventListener("click", () => {
progress = 0;
updateTimelineUI();
});
speedSelect.addEventListener("click", (event) => {
event.stopPropagation();
});
speedSelect.addEventListener("change", () => {
playbackSpeed = Number(speedSelect.value);
});
timeline.addEventListener("input", () => {
progress = Number(timeline.value) / 1000;
updateTimelineUI();
});
hotspotToggle.addEventListener("change", () => {
hotspotElements.forEach((item) => {
item.element.style.display = hotspotToggle.checked ? "" : "none";
});
});
const clamp = THREE.MathUtils.clamp;
const smooth = (value) => {
const t = clamp(value, 0, 1);
return t * t * (3 - 2 * t);
};
function samplePath(a, b, c, t) {
if (t < 0.55) {
const local = smooth(t / 0.55);
return a.clone().lerp(b, local);
}
const local = smooth((t - 0.55) / 0.45);
return b.clone().lerp(c, local);
}
function updateCargo() {
cargoA.forEach((item, index) => {
const delay = index * 0.006;
const local = clamp((progress - 0.13 - delay) / 0.83, 0, 1);
const position = samplePath(item.start, item.crane, item.yard, local);
if (local > 0.55) {
const outgoing = smooth((local - 0.55) / 0.45);
position.lerp(item.end, outgoing);
position.y += Math.sin(outgoing * Math.PI) * 0.45;
}
item.mesh.position.copy(position);
item.mesh.rotation.z = 0;
});
cargoBLong.forEach((item, index) => {
const delay = index * 0.006;
const local = clamp((progress - 0.12 - delay) / 0.42, 0, 1);
const position = samplePath(item.start, item.crane, item.unpack, local);
item.mesh.position.copy(position);
item.mesh.visible = progress < 0.585;
if (progress > 0.54 && progress < 0.60) {
const shrink = 1 - (progress - 0.54) / 0.06;
item.mesh.scale.y = Math.max(0.04, shrink);
} else {
item.mesh.scale.y = 1;
}
});
cargoBShort.forEach((item, index) => {
const local = clamp((progress - 0.56 - index * 0.0025) / 0.39, 0, 1);
item.mesh.visible = progress >= 0.56;
item.mesh.position.copy(item.start).lerp(item.end, smooth(local));
item.mesh.position.y += Math.sin(smooth(local) * Math.PI) * 2.0;
const appear = clamp((progress - 0.56 - index * 0.001) / 0.05, 0, 1);
item.mesh.scale.set(1, Math.max(0.03, appear), 1);
});
craneA.trolley.position.x = -13 + Math.sin(progress * Math.PI * 8) * 0.7;
craneB.trolley.position.x = 13 + Math.sin(progress * Math.PI * 8) * 0.7;
const scan = (progress - 0.43) / 0.22;
repackShed.scanFrame.visible = progress > 0.42 && progress < 0.68;
repackShed.scanFrame.rotation.z = progress * 18;
repackShed.scanFrame.scale.setScalar(1 + Math.sin(progress * 35) * 0.08);
for (const pad of interfacePads) {
const selected = pad.id === activeInterface && pad.route === activeRoute;
const pulse = 1 + Math.sin(performance.now() * 0.004 + pad.mesh.position.x) * 0.08;
pad.mesh.scale.setScalar(selected ? pulse * 1.22 : pulse);
}
}
function updateCamera() {
cameraState.target.lerp(cameraState.desiredTarget, 0.07);
cameraState.zoom += (cameraState.desiredZoom - cameraState.zoom) * 0.08;
camera.zoom = cameraState.zoom;
const horizontal = cameraState.distance * Math.cos(cameraState.pitch);
camera.position.set(
cameraState.target.x + Math.sin(cameraState.yaw) * horizontal,
cameraState.target.y + Math.sin(cameraState.pitch) * cameraState.distance,
cameraState.target.z + Math.cos(cameraState.yaw) * horizontal
);
camera.lookAt(cameraState.target);
camera.updateProjectionMatrix();
}
function projectElement(element, position, visible = true) {
if (!visible) {
element.style.display = "none";
return;
}
const projected = position.clone().project(camera);
const inView =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.08 &&
projected.x < 1.08 &&
projected.y > -1.08 &&
projected.y < 1.08;
if (!inView) {
element.style.display = "none";
return;
}
element.style.display = "";
element.style.left = `${(projected.x * 0.5 + 0.5) * viewportWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * viewportHeight}px`;
}
function updateLabels() {
const compare = focusMode === "compare";
for (const item of terminalLabels) {
const visible = compare || item.route === activeRoute;
projectElement(item.element, item.position, visible);
}
for (const item of hotspotElements) {
const routeVisible = compare || item.route === activeRoute;
const checked = hotspotToggle.checked;
projectElement(item.element, item.position, routeVisible && checked);
}
}
let dragging = false;
let panning = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
panning = event.shiftKey || event.button === 2;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (panning) {
const scale = 0.045 / cameraState.zoom;
const right = new THREE.Vector3(Math.cos(cameraState.yaw), 0, -Math.sin(cameraState.yaw));
const forward = new THREE.Vector3(Math.sin(cameraState.yaw), 0, Math.cos(cameraState.yaw));
cameraState.desiredTarget.addScaledVector(right, -deltaX * scale);
cameraState.desiredTarget.addScaledVector(forward, -deltaY * scale);
} else {
cameraState.yaw -= deltaX * 0.006;
cameraState.pitch = clamp(cameraState.pitch + deltaY * 0.004, 0.26, 1.05);
}
});
function endDrag(event) {
dragging = false;
panning = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.desiredZoom = clamp(
cameraState.desiredZoom * (event.deltaY > 0 ? 0.9 : 1.1),
0.72,
2.25
);
},
{ passive: false }
);
function resize() {
const rect = sceneElement.getBoundingClientRect();
viewportWidth = Math.max(1, rect.width);
viewportHeight = Math.max(1, rect.height);
renderer.setSize(viewportWidth, viewportHeight, false);
const aspect = viewportWidth / viewportHeight;
const frustumHeight = 42;
camera.left = (-frustumHeight * aspect) / 2;
camera.right = (frustumHeight * aspect) / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
updateRouteUI();
updateInterfaceUI();
updatePlaybackButton();
updateTimelineUI();
focusTerminal("compare");
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (playing) {
progress += delta * 0.027 * playbackSpeed;
if (progress > 1) progress -= 1;
updateTimelineUI();
}
updateCargo();
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```