Prompt specification
Build or customize the Three.js 3D scene "Track one object through multiple exchanges" 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: Track one object through multiple exchanges
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/track-one-object-through-multiple-exchanges-x2620
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows caravan stages and exchange along the Silk Roads. Let users follow a documented class of trade object across selected route nodes. Separate sourced connections from hypothetical individual transactions and display each change of carrier. Voxel style.
Working Three.js Starter (track-one-object-through-multiple-exchanges-x2620):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Silk Roads — Documented Silk, Reconstructed Carriers</title>
<style>
:root {
--ink: #e8edda;
--muted: #9dab9e;
--panel: rgba(10, 24, 26, 0.92);
--panel-soft: rgba(13, 31, 33, 0.82);
--line: #38514d;
--cyan: #6de4d1;
--cyan-soft: rgba(109, 228, 209, 0.14);
--amber: #f2b75e;
--amber-soft: rgba(242, 183, 94, 0.14);
--red: #df765c;
--shadow: rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #091719;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
color: inherit;
border: 1px solid var(--line);
background: rgba(15, 37, 38, 0.9);
cursor: pointer;
}
button:hover {
border-color: var(--cyan);
color: #fff;
}
button:focus-visible {
outline: 2px solid var(--amber);
outline-offset: 2px;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.topbar {
position: fixed;
z-index: 20;
top: 0;
left: 0;
right: 0;
min-height: 74px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 12px 18px;
background: linear-gradient(180deg, rgba(6, 18, 20, 0.97), rgba(6, 18, 20, 0.82));
border-bottom: 1px solid var(--line);
box-shadow: 0 8px 24px var(--shadow);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
min-width: 0;
}
.brand-cube {
position: relative;
width: 35px;
height: 35px;
flex: 0 0 auto;
border: 2px solid var(--cyan);
box-shadow:
inset -7px -7px 0 rgba(109, 228, 209, 0.12),
5px 5px 0 rgba(0, 0, 0, 0.3);
}
.brand-cube::before,
.brand-cube::after {
content: "";
position: absolute;
background: var(--cyan);
}
.brand-cube::before {
width: 2px;
height: 28px;
left: 15px;
top: 2px;
}
.brand-cube::after {
width: 28px;
height: 2px;
left: 2px;
top: 15px;
}
.eyebrow {
margin: 0 0 3px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(16px, 2vw, 24px);
line-height: 1;
letter-spacing: -0.03em;
white-space: nowrap;
}
.subtitle {
margin: 5px 0 0;
color: var(--muted);
font-size: 11px;
}
.top-actions {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
justify-content: flex-end;
}
.top-actions button,
.small-button {
padding: 8px 10px;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.04em;
box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.23);
}
.top-actions button[aria-pressed="true"] {
color: var(--cyan);
border-color: var(--cyan);
background: var(--cyan-soft);
}
.top-actions #hypothesisToggle[aria-pressed="true"] {
color: var(--amber);
border-color: var(--amber);
background: var(--amber-soft);
}
.legend {
position: fixed;
z-index: 10;
left: 18px;
top: 94px;
width: 235px;
padding: 14px;
background: var(--panel-soft);
border: 1px solid var(--line);
box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.2);
backdrop-filter: blur(8px);
}
.legend h2,
.panel h2,
.modal h2 {
margin: 0;
font-size: 15px;
letter-spacing: -0.02em;
}
.legend-row {
display: grid;
grid-template-columns: 25px 1fr;
gap: 9px;
align-items: start;
margin-top: 12px;
font-size: 11px;
line-height: 1.35;
}
.legend-row strong {
display: block;
color: var(--ink);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend-row span:last-child {
color: var(--muted);
}
.swatch {
width: 24px;
height: 8px;
margin-top: 3px;
background: var(--cyan);
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.swatch.dashed {
height: 4px;
background: repeating-linear-gradient(
90deg,
var(--amber) 0 6px,
transparent 6px 10px
);
}
.legend-note {
margin: 14px 0 0;
padding-top: 11px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.camera-controls {
position: fixed;
z-index: 11;
left: 18px;
bottom: 154px;
display: flex;
gap: 5px;
}
.camera-controls button {
width: 36px;
height: 34px;
font-size: 16px;
box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.25);
}
.panel {
position: fixed;
z-index: 15;
top: 94px;
right: 18px;
bottom: 154px;
width: 360px;
overflow: auto;
padding: 17px;
background: var(--panel);
border: 1px solid var(--line);
box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.23);
backdrop-filter: blur(10px);
scrollbar-width: thin;
scrollbar-color: var(--line) transparent;
}
.panel-topline {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.status-chip {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 7px;
border: 1px solid rgba(109, 228, 209, 0.5);
color: var(--cyan);
background: var(--cyan-soft);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
.status-chip.amber {
border-color: rgba(242, 183, 94, 0.55);
color: var(--amber);
background: var(--amber-soft);
}
.panel h2 {
margin-top: 12px;
font-size: 25px;
line-height: 1.05;
}
.place-meta {
margin: 6px 0 15px;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.section-label {
margin: 17px 0 7px;
color: var(--cyan);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.evidence-block {
margin: 7px 0;
padding: 10px;
background: rgba(109, 228, 209, 0.055);
border-left: 3px solid var(--cyan);
font-size: 11px;
line-height: 1.5;
}
.handoff {
margin: 8px 0 0;
padding: 11px;
border: 1px solid rgba(242, 183, 94, 0.45);
background: var(--amber-soft);
}
.handoff-label {
color: var(--amber);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.handoff-flow {
display: grid;
grid-template-columns: 1fr 20px 1fr;
gap: 6px;
align-items: center;
margin-top: 9px;
text-align: center;
}
.handoff-flow div {
padding: 7px 5px;
background: rgba(7, 18, 19, 0.68);
font-size: 10px;
font-weight: 750;
line-height: 1.25;
}
.handoff-flow .arrow {
color: var(--amber);
font-size: 17px;
}
.handoff p {
margin: 9px 0 0;
color: #d4c29d;
font-size: 10px;
line-height: 1.4;
}
.cite-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.cite {
padding: 5px 7px;
color: var(--cyan);
border-color: rgba(109, 228, 209, 0.38);
background: var(--cyan-soft);
font-size: 10px;
font-weight: 800;
}
.edge-card {
margin-top: 8px;
padding: 10px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.025);
font-size: 10px;
line-height: 1.45;
}
.edge-card strong {
display: block;
margin-bottom: 4px;
color: var(--cyan);
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.edge-card span {
color: var(--muted);
}
.panel-footer {
margin-top: 17px;
padding-top: 12px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 9px;
line-height: 1.45;
}
.timeline {
position: fixed;
z-index: 18;
left: 18px;
right: 396px;
bottom: 16px;
min-height: 122px;
padding: 11px 12px 9px;
background: var(--panel);
border: 1px solid var(--line);
box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.24);
backdrop-filter: blur(10px);
}
.timeline-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
margin-bottom: 8px;
}
.journey-status {
min-width: 0;
}
.journey-status strong {
display: block;
font-size: 11px;
letter-spacing: 0.03em;
}
.journey-status span {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.playback {
display: flex;
flex: 0 0 auto;
gap: 5px;
}
.playback button {
min-width: 32px;
height: 30px;
padding: 0 9px;
font-size: 11px;
font-weight: 800;
box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.23);
}
#playButton {
color: #102322;
background: var(--cyan);
border-color: var(--cyan);
}
.progress-track {
position: relative;
height: 3px;
margin: 0 4px 8px;
background: #263d3c;
}
#progressFill {
position: absolute;
inset: 0 auto 0 0;
width: 0;
background: var(--amber);
}
.stage-strip {
display: flex;
gap: 6px;
overflow-x: auto;
padding-bottom: 4px;
scrollbar-width: thin;
scrollbar-color: var(--line) transparent;
}
.stage {
position: relative;
min-width: 116px;
flex: 1 0 116px;
padding: 7px 8px 7px 25px;
text-align: left;
border-color: #314846;
background: #102527;
}
.stage::before {
content: "";
position: absolute;
left: 9px;
top: 9px;
width: 8px;
height: 8px;
background: #46605b;
box-shadow: 0 0 0 3px #102527;
}
.stage.active {
border-color: var(--cyan);
background: var(--cyan-soft);
}
.stage.active::before {
background: var(--cyan);
}
.stage.passed::before {
background: var(--amber);
}
.stage-number {
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.1em;
}
.stage-name {
display: block;
margin-top: 2px;
font-size: 10px;
font-weight: 850;
}
.stage-carrier {
display: block;
margin-top: 3px;
overflow: hidden;
color: var(--amber);
font-size: 8px;
text-overflow: ellipsis;
white-space: nowrap;
}
.node-label {
position: fixed;
z-index: 5;
pointer-events: none;
padding: 4px 6px;
color: #dce7d7;
background: rgba(7, 19, 20, 0.78);
border: 1px solid rgba(109, 228, 209, 0.35);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.05em;
text-transform: uppercase;
transform: translate(-50%, -100%);
white-space: nowrap;
box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.22);
}
.node-label.active {
color: #102322;
background: var(--cyan);
border-color: #b5fff3;
}
.node-label small {
display: block;
margin-top: 2px;
color: var(--amber);
font-size: 7px;
letter-spacing: 0.08em;
}
.modal {
position: fixed;
z-index: 50;
inset: 0;
display: none;
align-items: center;
justify-content: center;
padding: 24px;
background: rgba(2, 10, 11, 0.78);
backdrop-filter: blur(7px);
}
.modal.open { display: flex; }
.modal-card {
position: relative;
width: min(760px, 100%);
max-height: 82vh;
overflow: auto;
padding: 24px;
background: #0c2022;
border: 1px solid #45615d;
box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.34);
}
.modal-card h2 {
margin-bottom: 8px;
font-size: 23px;
}
.modal-intro {
margin: 0 0 18px;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
}
.source-item {
margin-top: 10px;
padding: 12px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.025);
}
.source-item strong {
display: block;
font-size: 12px;
}
.source-item p {
margin: 6px 0;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.source-item a {
color: var(--cyan);
font-size: 10px;
font-weight: 800;
text-decoration: none;
}
.source-item a:hover { text-decoration: underline; }
.modal-close {
position: absolute;
top: 14px;
right: 14px;
width: 34px;
height: 34px;
font-size: 18px;
}
.method-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-top: 18px;
}
.method-grid section {
padding: 13px;
border: 1px solid var(--line);
font-size: 11px;
line-height: 1.55;
}
.method-grid h3 {
margin: 0 0 8px;
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.method-grid p {
margin: 0;
color: var(--muted);
}
#panelToggle {
display: none;
}
@media (max-width: 1050px) {
.legend {
width: 205px;
}
.panel {
width: 330px;
}
.timeline {
right: 366px;
}
.top-actions .optional {
display: none;
}
}
@media (max-width: 780px) {
.topbar {
min-height: 65px;
padding: 10px 12px;
}
.subtitle,
.brand-cube {
display: none;
}
.top-actions button {
padding: 7px;
font-size: 9px;
}
.legend {
top: 78px;
left: 10px;
width: 190px;
padding: 10px;
}
.legend-note {
display: none;
}
.panel {
top: auto;
right: 10px;
bottom: 127px;
width: min(340px, calc(100% - 20px));
max-height: 54vh;
transform: translateX(calc(100% + 24px));
transition: transform 180ms ease;
}
.panel.open {
transform: translateX(0);
}
#panelToggle {
display: block;
}
.camera-controls {
left: 10px;
bottom: 137px;
}
.timeline {
left: 10px;
right: 10px;
bottom: 10px;
min-height: 108px;
padding: 9px;
}
.timeline-head {
margin-bottom: 6px;
}
.journey-status span {
display: none;
}
.stage {
min-width: 112px;
flex-basis: 112px;
}
.method-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 500px) {
.legend {
width: 170px;
}
.legend-row {
margin-top: 8px;
}
.top-actions #evidenceToggle,
.top-actions #hypothesisToggle {
max-width: 84px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive voxel map of Silk Roads caravan stages"></div>
<header class="topbar">
<div class="brand">
<div class="brand-cube" aria-hidden="true"></div>
<div>
<p class="eyebrow">Documented object class / reconstructed exchange</p>
<h1>SILK ROADS: CARRIER</h1>
<p class="subtitle">Follow silk textiles across a composite western corridor, c. 200 BCE–900 CE.</p>
</div>
</div>
<div class="top-actions">
<button id="evidenceToggle" aria-pressed="true" title="Show source-backed corridor links">
DOCUMENTED
</button>
<button id="hypothesisToggle" aria-pressed="true" title="Show the illustrative single-caravan reconstruction">
RECONSTRUCTED
</button>
<button id="sourcesButton" class="optional">SOURCES</button>
<button id="aboutButton" class="optional">METHOD</button>
<button id="panelToggle" aria-pressed="false">STAGE</button>
</div>
</header>
<aside class="legend" aria-label="Map legend">
<h2>Read the map</h2>
<div class="legend-row">
<div class="swatch"></div>
<div>
<strong>Documented corridor</strong>
<span>Source-backed route and object-class context.</span>
</div>
</div>
<div class="legend-row">
<div class="swatch dashed"></div>
<div>
<strong>Reconstructed transaction</strong>
<span>An illustrative handoff of one hypothetical parcel.</span>
</div>
</div>
<div class="legend-row">
<div class="swatch" style="background:var(--amber);width:10px;margin-left:7px"></div>
<div>
<strong>Carrier change</strong>
<span>Composite historical roles, not named people.</span>
</div>
</div>
<p class="legend-note">
The nodes belong to different centuries. This is a synoptic evidence map,
not proof that one bale made the complete journey in a single transaction.
</p>
</aside>
<div class="camera-controls" aria-label="Camera controls">
<button id="zoomIn" title="Zoom in">+</button>
<button id="zoomOut" title="Zoom out">−</button>
<button id="resetCamera" title="Reset camera">⌂</button>
<button id="topCamera" title="Top-down camera">▦</button>
</div>
<aside id="details" class="panel" aria-live="polite"></aside>
<section class="timeline" aria-label="Journey timeline">
<div class="timeline-head">
<div class="journey-status">
<strong id="journeyTitle">STAGE 01 — CHANG’AN</strong>
<span id="journeySubtitle">Select a stage or play the illustrative transaction.</span>
</div>
<div class="playback">
<button id="restartButton" title="Restart">↺</button>
<button id="prevButton" title="Previous stage">‹</button>
<button id="playButton">▶ PLAY</button>
<button id="nextButton" title="Next stage">›</button>
</div>
</div>
<div class="progress-track" aria-hidden="true">
<div id="progressFill"></div>
</div>
<div id="stageStrip" class="stage-strip"></div>
</section>
<div id="sourcesModal" class="modal" role="dialog" aria-modal="true" aria-labelledby="sourcesTitle">
<div class="modal-card">
<button class="modal-close" data-close="sourcesModal" aria-label="Close sources">×</button>
<p class="eyebrow">Evidence register</p>
<h2 id="sourcesTitle">Sources and scope</h2>
<p class="modal-intro">
The interface separates two different propositions:
<strong style="color:var(--cyan)">documented corridors and object classes</strong>
from
<strong style="color:var(--amber)">a hypothetical individual transaction</strong>.
The references below support the historical setting, routes, production,
mediation, and textile circulation described by the map.
</p>
<div id="sourceList"></div>
</div>
</div>
<div id="aboutModal" class="modal" role="dialog" aria-modal="true" aria-labelledby="aboutTitle">
<div class="modal-card">
<button class="modal-close" data-close="aboutModal" aria-label="Close method">×</button>
<p class="eyebrow">Reading protocol</p>
<h2 id="aboutTitle">What is evidence and what is reconstruction?</h2>
<p class="modal-intro">
“Silk textiles” is a documented object class with evidence for production,
consumption, exchange, and reworking across parts of Eurasia. No surviving
record traces the fictional parcel used in this animation from Chang’an to
Constantinople. Every named carrier is therefore a composite role used to
explain likely transfer points.
</p>
<div class="method-grid">
<section>
<h3 style="color:var(--cyan)">Documented layer</h3>
<p>
Cyan blocks show historically attested route corridors and places where
silk textiles were produced, consumed, mediated, or reworked. Citation
cards identify the supporting source collection or scholarly overview.
</p>
</section>
<section>
<h3 style="color:var(--amber)">Reconstructed layer</h3>
<p>
Amber dashes and the moving camel represent one imagined transaction.
Carrier names are role labels such as “Sogdian broker” or “oasis broker,”
not attested individuals. Handoffs are explanatory hypotheses, not facts.
</p>
</section>
<section>
<h3>Chronology</h3>
<p>
The route is deliberately composite. Chang’an and Dunhuang are associated
with Han–Tang periods; Sasanian Ctesiphon ended in 637 CE; Samarkand,
Merv, and Rey became especially important under the Sogdians and later
Islamic dynasties.
</p>
</section>
<section>
<h3>Controls</h3>
<p>
Drag to orbit. Shift-drag or right-drag to pan. Use the mouse wheel to
zoom. Select a city marker or timeline card to inspect its evidence and
proposed carrier change.
</p>
</section>
</div>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Data: documented route/object-class evidence and clearly separate hypotheses
// -------------------------------------------------------------------------
const sources = {
S1: {
title: "UNESCO — Silk Roads Programme: Routes Network of the Chang’an–Tianshan Corridor",
note: "Primary institutional documentation of oasis cities, corridor geography, caravan movement, and the Chang’an–Tianshan route system.",
url: "https://en.unesco.org/silkroad/"
},
S2: {
title: "The Metropolitan Museum of Art — “The Silk Road”",
note: "Museum overview of silk production, Silk Road exchange, Central Asian mediation, and the reinterpretation of imported textiles.",
url: "https://www.metmuseum.org/essays/the-silk-road"
},
S3: {
title: "International Dunhuang Project — digital collection catalogue",
note: "Joint British Library and Bodleian Libraries project documenting manuscripts, paintings, textiles, and material culture from Dunhuang.",
url: "https://idp.bl.uk/"
},
S4: {
title: "Susan Whitfield — Life Along the Silk Road, 2nd edition",
note: "Scholarly overview of oasis cities and Sogdian commercial networks across Central Asia, including Samarkand, Merv, and Rey.",
url: "https://books.google.com/books?q=Life+Along+the+Silk+Road+Susan+Whitfield"
},
S5: {
title: "Valerie Hansen — The Silk Road: A New History",
note: "Historical synthesis of Chinese silk production, imperial demand, exchange networks, and the limits of popular Silk Road narratives.",
url: "https://books.google.com/books?q=The+Silk+Road+A+New+History+Valerie+Hansen"
},
S6: {
title: "The Metropolitan Museum of Art — Textiles of the Islamic World",
note: "Museum context for the development of textile industries and luxury textile exchange in Islamic-period West and Central Asia.",
url: "https://www.metmuseum.org/exhibitions/listings/2013/textiles-of-the-islamic-world"
},
S7: {
title: "The Metropolitan Museum of Art — Byzantine Art, 4th to 7th Century",
note: "Museum overview of Byzantine court and workshop culture, luxury materials, and the reuse or adaptation of eastern textile designs.",
url: "https://www.metmuseum.org/essays/byzantine-art-4th-to-7th-century"
}
};
const nodes = [
{
id: "changan",
name: "Chang’an",
subtitle: "Han–Tang imperial capital · China",
period: "Principal eastern production and dispatch center",
route: "Chang’an anchored the eastern end of the overland exchange network. Court demand, tribute, gifts, and elite consumption supported the movement of silk away from the capital.",
object: "Chinese silk was among the most sought-after luxury cargoes. Production and distribution were embedded in state and elite systems rather than a single free market.",
from: "Workshop / state supplier",
to: "Supply agent",
carrier: "Supply agent",
sourceIds: ["S1", "S2", "S5"]
},
{
id: "dunhuang",
name: "Dunhuang",
subtitle: "Gansu frontier oasis · China",
period: "Frontier gateway and major caravan entrepôt",
route: "Dunhuang guarded the Hexi Corridor and connected the Chinese interior with the Tarim Basin. It was a military-administrative stop as well as a busy commercial and devotional center.",
object: "The Dunhuang manuscripts and material collections attest to a cosmopolitan society that consumed luxury textiles. They do not identify the hypothetical parcel animated here.",
from: "Supply agent",
to: "Oasis broker",
carrier: "Oasis broker",
sourceIds: ["S1", "S3"]
},
{
id: "khotan",
name: "Khotan",
subtitle: "Tarim Basin oasis · modern Xinjiang",
period: "Textile center and southern Tarim caravan node",
route: "Khotan stood beside the southern routes of the Tarim Basin. Its oasis agriculture, workshops, and caravan position supported long-distance exchange.",
object: "Khotan was renowned for locally woven silk. Imported Chinese models and Central Asian design traditions circulated through production and trade, although particular finds are not one continuous chain of custody.",
from: "Oasis broker",
to: "Weaver-dealer",
carrier: "Weaver-dealer",
sourceIds: ["S1", "S2", "S4"]
},
{
id: "kashgar",
name: "Kashgar",
subtitle: "Western Tarim Basin junction",
period: "Caravan junction joining mountain and desert routes",
route: "Routes from the Tarim Basin converged near Kashgar before crossing into Central Asia. The city linked oasis economies with Sogdian commercial networks.",
object: "High-value textiles moved among markets serving local, regional, and long-distance demand. Historical evidence supports the corridor and textile traffic, not this parcel’s itinerary.",
from: "Weaver-dealer",
to: "Caravan master",
carrier: "Caravan master",
sourceIds: ["S1", "S2", "S4"]
},
{
id: "samarkand",
name: "Samarkand",
subtitle: "Zeravshan valley · Sogdiana",
period: "Sogdian commercial and cultural center",
route: "Samarkand became a principal center of Sogdian merchants, whose family and trading networks linked China, the steppe, India, Iran, and the Mediterranean.",
object: "Chinese silk entered Central Asian markets and was exchanged, tailored, or reinterpreted. Sogdian merchants are strongly documented as mediators, although no single merchant can be assigned to this parcel.",
from: "Caravan master",
to: "Sogdian broker",
carrier: "Sogdian broker",
sourceIds: ["S2", "S4", "S5"]
},
{
id: "merv",
name: "Merv",
subtitle: "Murghab oasis · Khorasan",
period: "Iranian metropolis and translation center",
route: "Merv linked Transoxiana with Iran and the routes toward Mesopotamia. Its markets supported merchants, artisans, translators, and long-distance exchange.",
object: "Merv’s elite culture and textile finds show the circulation and adaptation of precious fabrics. Specific textile attributions and production histories often remain debated.",
from: "Sogdian broker",
to: "Merv merchant",
carrier: "Merv merchant",
sourceIds: ["S4", "S6"]
},
{
id: "rey",
name: "Rey",
subtitle: "Rhages · medieval Iran",
period: "West-Central Iranian commercial and manuscript center",
route: "Rey lay on routes linking Iran, Mesopotamia, and Central Asia. Sogdian communities and later urban markets made it an important node in western exchange.",
object: "Imported silk and Chinese-derived decorative motifs attest to the movement of textile designs. Local tailoring and reuse complicate simple claims about original place of manufacture.",
from: "Merv merchant",
to: "Sogdian-Iranian broker",
carrier: "Sogdian-Iranian broker",
sourceIds: ["S2", "S4", "S6"]
},
{
id: "ctesiphon",
name: "Ctesiphon",
subtitle: "Sasanian capital · Mesopotamia",
period: "Sasanian royal metropolis and post-637 Abbasid city",
route: "Ctesiphon stood opposite the Tigris and connected Iranian, Central Asian, Arabian, and Mediterranean commercial worlds. Sasanian rule ended in 637, but the urban center continued.",
object: "Royal and elite demand drew eastern silks into Mesopotamia. Imperial and court workshops could redistribute, redesign, or incorporate imported fabrics into new luxury objects.",
from: "Sogdian-Iranian broker",
to: "Court dealer",
carrier: "Court dealer",
sourceIds: ["S2", "S4", "S6"]
},
{
id: "constantinople",
name: "Constantinople",
subtitle: "Byzantine capital · Bosporus",
period: "Western imperial terminus and textile workshop center",
route: "Constantinople stood at a maritime and overland crossroads connecting the Black Sea, Mediterranean, Europe, and Asia. Merchants and embassies connected it to eastern producers.",
object: "Byzantine luxury workshops used imported silk, including Chinese examples, and transformed motifs into distinctive court and ecclesiastical textiles. This ends the documented class, not a proven parcel history.",
from: "Court dealer",
to: "Workshop / court buyer",
carrier: "Workshop / court buyer",
sourceIds: ["S2", "S6", "S7"]
}
];
const connections = [
{
from: "Chang’an", to: "Dunhuang",
title: "Hexi Corridor connection",
text: "Attested imperial road and frontier corridor connecting the capital region with Dunhuang.",
sources: ["S1", "S5"]
},
{
from: "Dunhuang", to: "Khotan",
title: "Tarim gateway connection",
text: "Documented desert-corridor geography linking Dunhuang with southern Tarim oasis routes.",
sources: ["S1", "S4"]
},
{
from: "Khotan", to: "Kashgar",
title: "Southern Tarim connection",
text: "Attested oasis route and textile-production landscape between Khotan and the western Tarim Basin.",
sources: ["S1", "S2"]
},
{
from: "Kashgar", to: "Samarkand",
title: "Central Asian caravan connection",
text: "Documented route across the Pamir region into Sogdian commercial networks.",
sources: ["S2", "S4"]
},
{
from: "Samarkand", to: "Merv",
title: "Transoxiana–Khorasan connection",
text: "Attested commercial corridor linking the Zarafshan valley with the Murghab oasis.",
sources: ["S4"]
},
{
from: "Merv", to: "Rey",
title: "Iranian urban connection",
text: "Documented movement of merchants and goods between major Iranian urban centers.",
sources: ["S4", "S6"]
},
{
from: "Rey", to: "Ctesiphon",
title: "Iran–Mesopotamia connection",
text: "Historical route and textile-commerce context between Iranian markets and the Mesopotamian capital.",
sources: ["S2", "S6"]
},
{
from: "Ctesiphon", to: "Constantinople",
title: "Near Eastern–Byzantine connection",
text: "Documented commercial and diplomatic channels through which eastern luxury textiles reached Byzantine markets and workshops.",
sources: ["S2", "S6", "S7"]
}
];
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x091719);
scene.fog = new THREE.Fog(0x091719, 30, 70);
const camera = new THREE.PerspectiveCamera(43, innerWidth / innerHeight, 0.1, 150);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.2;
sceneHost.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xbce6dc, 0x28372d, 2.2);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe3b4, 3.2);
sun.position.set(-10, 22, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.00035;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x65d8cf, 1.1);
rim.position.set(16, 8, -14);
scene.add(rim);
const material = {
ground: new THREE.MeshStandardMaterial({ color: 0x152a29, roughness: 1 }),
earth: new THREE.MeshStandardMaterial({ color: 0x32443b, roughness: 1 }),
earthLight: new THREE.MeshStandardMaterial({ color: 0x415449, roughness: 1 }),
sand: new THREE.MeshStandardMaterial({ color: 0x9a8158, roughness: 1 }),
sandLight: new THREE.MeshStandardMaterial({ color: 0xb49a68, roughness: 1 }),
building: new THREE.MeshStandardMaterial({ color: 0x8a6d50, roughness: 0.95 }),
buildingLight: new THREE.MeshStandardMaterial({ color: 0xb49369, roughness: 0.95 }),
buildingDark: new THREE.MeshStandardMaterial({ color: 0x574d43, roughness: 1 }),
cyan: new THREE.MeshStandardMaterial({
color: 0x6de4d1,
emissive: 0x1b665d,
emissiveIntensity: 0.9,
roughness: 0.5
}),
amber: new THREE.MeshStandardMaterial({
color: 0xf2b75e,
emissive: 0x74400d,
emissiveIntensity: 0.75,
roughness: 0.55
}),
red: new THREE.MeshStandardMaterial({ color: 0xb85d4c, roughness: 0.9 }),
camel: new THREE.MeshStandardMaterial({ color: 0xb8834d, roughness: 1 }),
camelDark: new THREE.MeshStandardMaterial({ color: 0x674733, roughness: 1 }),
cargo: new THREE.MeshStandardMaterial({
color: 0xd39b47,
emissive: 0x5d330b,
emissiveIntensity: 0.45,
roughness: 0.7
})
};
const boxGeometry = new THREE.BoxGeometry(1, 1, 1);
const documentedGroup = new THREE.Group();
const hypothesisGroup = new THREE.Group();
scene.add(documentedGroup, hypothesisGroup);
const base = new THREE.Mesh(boxGeometry, material.ground);
base.scale.set(33, 0.8, 33);
base.position.set(0, -0.48, 2.5);
base.receiveShadow = true;
scene.add(base);
// Deterministic voxel terrain.
let randomSeed = 9147;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
const tileGeo = new THREE.BoxGeometry(1, 1, 1);
const tileMesh = new THREE.InstancedMesh(tileGeo, material.earth, 31 * 31);
tileMesh.receiveShadow = true;
const dummy = new THREE.Object3D();
const tileColor = new THREE.Color();
let tileIndex = 0;
for (let x = -15; x <= 15; x++) {
for (let z = -13; z <= 17; z++) {
const edge = x < -13 || x > 13 || z < -11 || z > 15;
const h = edge ? 0.22 + random() * 0.8 : 0.07 + random() * 0.16;
dummy.position.set(x, h / 2, z);
dummy.scale.set(0.96, h, 0.96);
dummy.updateMatrix();
tileMesh.setMatrixAt(tileIndex, dummy.matrix);
tileColor.setHex(random() > 0.65 ? 0x3c5147 : 0x2c4039);
tileMesh.setColorAt(tileIndex, tileColor);
tileIndex++;
}
}
tileMesh.instanceMatrix.needsUpdate = true;
if (tileMesh.instanceColor) tileMesh.instanceColor.needsUpdate = true;
scene.add(tileMesh);
// Blocky perimeter mountains.
const mountainPalette = [
new THREE.MeshStandardMaterial({ color: 0x243c37, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x31483e, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x3c5042, roughness: 1 })
];
for (let i = 0; i < 48; i++) {
const side = i % 4;
let x, z;
if (side === 0) { x = -15 + random() * 2; z = -11 + random() * 27; }
else if (side === 1) { x = 13 + random() * 2; z = -11 + random() * 27; }
else if (side === 2) { x = -14 + random() * 28; z = -12 + random() * 2; }
else { x = -14 + random() * 28; z = 15 + random() * 2; }
const height = 0.7 + random() * 2.4;
const mountain = new THREE.Mesh(
boxGeometry,
mountainPalette[Math.floor(random() * mountainPalette.length)]
);
mountain.position.set(x, height / 2 - 0.1, z);
mountain.scale.set(0.7 + random() * 1.2, height, 0.7 + random() * 1.2);
mountain.castShadow = true;
mountain.receiveShadow = true;
scene.add(mountain);
}
const nodePositions = [
new THREE.Vector3(-11, 0.52, 9),
new THREE.Vector3(-8.4, 0.52, 5.1),
new THREE.Vector3(-4.2, 0.52, 1.0),
new THREE.Vector3(-1.0, 0.52, -2.7),
new THREE.Vector3(3.0, 0.52, -4.8),
new THREE.Vector3(7.0, 0.52, -1.8),
new THREE.Vector3(8.4, 0.52, 4.0),
new THREE.Vector3(4.5, 0.52, 8.2),
new THREE.Vector3(-1.5, 0.52, 11.0)
];
const routeCurve = new THREE.CatmullRomCurve3(
nodePositions,
false,
"catmullrom",
0.16
);
const clickableMeshes = [];
const nodeLabels = [];
function makeBox(parent, mat, x, y, z, sx, sy, sz, clickableId = null) {
const mesh = new THREE.Mesh(boxGeometry, mat);
mesh.position.set(x, y, z);
mesh.scale.set(sx, sy, sz);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (clickableId) {
mesh.userData.nodeId = clickableId;
clickableMeshes.push(mesh);
}
return mesh;
}
function addCity(node, index) {
const group = new THREE.Group();
group.position.copy(nodePositions[index]);
scene.add(group);
makeBox(group, material.sandDark || material.sand, 0, 0.12, 0, 2.25, 0.24, 2.25, node.id);
makeBox(group, material.buildingDark, 0, 0.38, 0, 0.58, 0.58, 0.58, node.id);
makeBox(group, material.cyan, 0, 0.83, 0, 0.38, 0.38, 0.38, node.id);
const count = 5 + Math.floor(random() * 5);
for (let b = 0; b < count; b++) {
const angle = (b / count) * Math.PI * 2 + random() * 0.35;
const radius = 0.62 + random() * 0.55;
const height = 0.22 + random() * 0.68;
const width = 0.25 + random() * 0.25;
const depth = 0.25 + random() * 0.25;
const buildingMat = [material.building, material.buildingLight, material.buildingDark][
Math.floor(random() * 3)
];
makeBox(
group,
buildingMat,
Math.cos(angle) * radius,
0.24 + height / 2,
Math.sin(angle) * radius,
width,
height,
depth,
node.id
);
}
// Four square frame pieces keep the visual language voxel-based.
makeBox(group, material.cyan, -1.0, 0.39, 0, 0.48, 0.08, 0.08, node.id);
makeBox(group, material.cyan, 1.0, 0.39, 0, 0.48, 0.08, 0.08, node.id);
makeBox(group, material.cyan, 0, 0.39, -1.0, 0.08, 0.08, 0.48, node.id);
makeBox(group, material.cyan, 0, 0.39, 1.0, 0.08, 0.08, 0.48, node.id);
const label = document.createElement("div");
label.className = "node-label";
label.innerHTML = `${String(index + 1).padStart(2, "0")} ${node.name}<small>${node.carrier}</small>`;
document.body.appendChild(label);
nodeLabels.push(label);
}
nodes.forEach(addCity);
// Documented corridor: continuous cyan voxel track.
const routePoints = routeCurve.getPoints(280);
const routeBlocks = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.19, 0.09, 0.19),
material.cyan,
routePoints.length
);
routeBlocks.castShadow = true;
routePoints.forEach((p, i) => {
dummy.position.copy(p);
dummy.position.y += 0.03;
dummy.scale.set(1, 1, 1);
dummy.rotation.set(0, (i % 4) * Math.PI / 2, 0);
dummy.updateMatrix();
routeBlocks.setMatrixAt(i, dummy.matrix);
});
routeBlocks.instanceMatrix.needsUpdate = true;
documentedGroup.add(routeBlocks);
// Reconstructed transaction: separated amber dashes above the evidence track.
const dashGeometry = new THREE.BoxGeometry(0.12, 0.07, 0.32);
const dashCount = Math.floor(routePoints.length / 6);
const dashMesh = new THREE.InstancedMesh(dashGeometry, material.amber, dashCount);
dashMesh.castShadow = true;
for (let i = 0; i < dashCount; i++) {
const p = routePoints[Math.min(i * 6 + 2, routePoints.length - 1)];
const tangent = routeCurve.getTangent(i / (dashCount - 1));
dummy.position.copy(p);
dummy.position.y += 0.13;
dummy.rotation.set(0, Math.atan2(tangent.x, tangent.z), 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
dashMesh.setMatrixAt(i, dummy.matrix);
}
dashMesh.instanceMatrix.needsUpdate = true;
hypothesisGroup.add(dashMesh);
// Moving voxel caravan.
const caravan = new THREE.Group();
scene.add(caravan);
makeBox(caravan, material.camel, 0, 0.62, 0, 0.56, 0.34, 0.9);
makeBox(caravan, material.camelLight || material.camel, 0, 0.81, 0.12, 0.4, 0.24, 0.32);
makeBox(caravan, material.camel, 0, 0.97, -0.42, 0.22, 0.68, 0.24);
makeBox(caravan, material.camelDark, 0, 1.25, -0.5, 0.34, 0.22, 0.38);
makeBox(caravan, material.camelDark, -0.11, 1.39, -0.63, 0.1, 0.13, 0.1);
makeBox(caravan, material.camelDark, 0.11, 1.39, -0.63, 0.1, 0.13, 0.1);
makeBox(caravan, material.camel, -0.2, 0.27, 0.28, 0.13, 0.48, 0.14);
makeBox(caravan, material.camel, 0.2, 0.27, 0.28, 0.13, 0.48, 0.14);
makeBox(caravan, material.camel, -0.2, 0.27, -0.28, 0.13, 0.48, 0.14);
makeBox(caravan, material.camel, 0.2, 0.27, -0.28, 0.13, 0.48, 0.14);
makeBox(caravan, material.camelDark, 0, 1.2, 0.18, 0.46, 0.14, 0.24);
makeBox(caravan, material.cargo, 0, 1.34, 0.18, 0.34, 0.34, 0.34);
caravan.scale.setScalar(0.78);
caravan.traverse(child => {
if (child.isMesh) child.castShadow = true;
});
// Selected-node square frame.
const selectionFrame = new THREE.Group();
makeBox(selectionFrame, material.amber, -1.42, 0.47, 0, 0.62, 0.12, 0.1);
makeBox(selectionFrame, material.amber, 1.42, 0.47, 0, 0.62, 0.12, 0.1);
makeBox(selectionFrame, material.amber, 0, 0.47, -1.42, 0.1, 0.12, 0.62);
makeBox(selectionFrame, material.amber, 0, 0.47, 1.42, 0.1, 0.12, 0.62);
scene.add(selectionFrame);
// -------------------------------------------------------------------------
// Interface state
// -------------------------------------------------------------------------
const state = {
active: 0,
segment: 0,
progress: 0,
playing: false,
holdUntil: 0,
documented: true,
hypothesis: true
};
const details = document.getElementById("details");
const stageStrip = document.getElementById("stageStrip");
const progressFill = document.getElementById("progressFill");
const journeyTitle = document.getElementById("journeyTitle");
const journeySubtitle = document.getElementById("journeySubtitle");
const playButton = document.getElementById("playButton");
function sourceButton(id) {
return `<button class="cite" data-source="${id}" title="${sources[id].title}">[${id}]</button>`;
}
function renderStageStrip() {
stageStrip.innerHTML = nodes.map((node, i) => `
<button
class="stage ${i === state.active ? "active" : ""} ${i < state.active ? "passed" : ""}"
data-stage="${i}"
aria-label="Select ${node.name}"
>
<span class="stage-number">${String(i + 1).padStart(2, "0")}</span>
<span class="stage-name">${node.name}</span>
<span class="stage-carrier">→ ${node.carrier}</span>
</button>
`).join("");
}
function renderDetails() {
const i = state.active;
const node = nodes[i];
const previousEdge = i > 0 ? connections[i - 1] : null;
const nextEdge = i < connections.length ? connections[i] : null;
details.innerHTML = `
<div class="panel-topline">
<p class="eyebrow">Stage ${String(i + 1).padStart(2, "0")} / ${String(nodes.length).padStart(2, "0")}</p>
<span class="status-chip">Class attested</span>
</div>
<h2>${node.name}</h2>
<p class="place-meta">
${node.subtitle}<br>
${node.period}
</p>
<div class="section-label">Documented route context</div>
<div class="evidence-block">${node.route}</div>
<div class="section-label">Documented object-class context</div>
<div class="evidence-block">${node.object}</div>
<div class="section-label">Reconstructed carrier change</div>
<div class="handoff">
<div class="handoff-label">Handover ${String(i + 1).padStart(2, "0")} · hypothesis</div>
<div class="handoff-flow">
<div>${node.from}</div>
<div class="arrow">→</div>
<div>${node.to}</div>
</div>
<p>
Composite role, not a named individual. The parcel and this exact handoff
are illustrative and cannot establish a surviving chain of custody.
</p>
</div>
<div class="section-label">Node sources</div>
<div class="cite-list">
${node.sourceIds.map(sourceButton).join("")}
</div>
<div class="section-label">Adjacent documented corridors</div>
${
previousEdge
? `<div class="edge-card">
<strong>← ${previousEdge.from} — ${previousEdge.to}</strong>
${previousEdge.text}
<div class="cite-list" style="margin-top:7px">
${previousEdge.sources.map(sourceButton).join("")}
</div>
</div>`
: ""
}
${
nextEdge
? `<div class="edge-card">
<strong>${nextEdge.from} — ${nextEdge.to} →</strong>
${nextEdge.text}
<div class="cite-list" style="margin-top:7px">
${nextEdge.sources.map(sourceButton).join("")}
</div>
</div>`
: ""
}
<p class="panel-footer">
Evidence supports the corridor and the continued presence of silk textiles
as a trade object. It does not prove that this hypothetical parcel made
the full journey.
</p>
`;
selectionFrame.position.copy(nodePositions[i]);
selectionFrame.position.y = 0;
nodeLabels.forEach((label, index) => {
label.classList.toggle("active", index === state.active);
});
journeyTitle.textContent =
`STAGE ${String(i + 1).padStart(2, "0")} — ${node.name.toUpperCase()}`;
journeySubtitle.textContent =
`Reconstructed carrier: ${node.carrier} · composite chronology`;
renderStageStrip();
updateProgress();
}
function updateProgress() {
const globalProgress = (state.active + state.progress) / (nodes.length - 1);
progressFill.style.width = `${Math.max(0, Math.min(1, globalProgress)) * 100}%`;
}
function selectStage(index, manual = true) {
state.active = THREE.MathUtils.clamp(index, 0, nodes.length - 1);
if (manual) {
state.playing = false;
state.holdUntil = 0;
state.progress = 0;
state.segment = Math.min(state.active, nodes.length - 2);
if (state.active === nodes.length - 1) {
state.segment = nodes.length - 2;
state.progress = 1;
}
const u = state.active / (nodes.length - 1);
caravan.position.copy(routeCurve.getPoint(u));
const tangent = routeCurve.getTangent(u);
caravan.rotation.y = Math.atan2(tangent.x, tangent.z);
}
playButton.textContent = state.playing ? "❚❚ PAUSE" : "▶ PLAY";
renderDetails();
}
stageStrip.addEventListener("click", event => {
const button = event.target.closest("[data-stage]");
if (button) selectStage(Number(button.dataset.stage), true);
});
details.addEventListener("click", event => {
const citation = event.target.closest("[data-source]");
if (citation) openModal("sourcesModal");
});
function openModal(id) {
document.getElementById(id).classList.add("open");
}
function closeModal(id) {
document.getElementById(id).classList.remove("open");
}
document.querySelectorAll("[data-close]").forEach(button => {
button.addEventListener("click", () => closeModal(button.dataset.close));
});
document.querySelectorAll(".modal").forEach(modal => {
modal.addEventListener("click", event => {
if (event.target === modal) modal.classList.remove("open");
});
});
document.addEventListener("keydown", event => {
if (event.key === "Escape") {
document.querySelectorAll(".modal.open").forEach(modal => modal.classList.remove("open"));
}
});
document.getElementById("sourcesButton").addEventListener("click", () => openModal("sourcesModal"));
document.getElementById("aboutButton").addEventListener("click", () => openModal("aboutModal"));
document.getElementById("sourceList").innerHTML = Object.entries(sources).map(([id, source]) => `
<article class="source-item" id="source-${id}">
<strong>[${id}] ${source.title}</strong>
<p>${source.note}</p>
<a href="${source.url}" target="_blank" rel="noopener noreferrer">Open source ↗</a>
</article>
`).join("");
const evidenceToggle = document.getElementById("evidenceToggle");
const hypothesisToggle = document.getElementById("hypothesisToggle");
evidenceToggle.addEventListener("click", () => {
state.documented = !state.documented;
documentedGroup.visible = state.documented;
evidenceToggle.setAttribute("aria-pressed", String(state.documented));
});
hypothesisToggle.addEventListener("click", () => {
state.hypothesis = !state.hypothesis;
hypothesisGroup.visible = state.hypothesis;
hypothesisToggle.setAttribute("aria-pressed", String(state.hypothesis));
});
function setPlaying(value) {
state.playing = value;
playButton.textContent = value ? "❚❚ PAUSE" : "▶ PLAY";
if (value && state.active === nodes.length - 1 && state.progress >= 1) {
selectStage(0, true);
state.playing = true;
playButton.textContent = "❚❚ PAUSE";
}
}
playButton.addEventListener("click", () => setPlaying(!state.playing));
document.getElementById("restartButton").addEventListener("click", () => {
selectStage(0, true);
setPlaying(true);
});
document.getElementById("prevButton").addEventListener("click", () => {
setPlaying(false);
selectStage(state.active - 1, true);
});
document.getElementById("nextButton").addEventListener("click", () => {
setPlaying(false);
selectStage(state.active + 1, true);
});
document.getElementById("panelToggle").addEventListener("click", event => {
const open = details.classList.toggle("open");
event.currentTarget.setAttribute("aria-pressed", String(open));
});
// -------------------------------------------------------------------------
// Direct camera controls — no addons or examples modules
// -------------------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(-0.1, 0, 3.0),
radius: 37,
theta: 0.56,
phi: 0.78
};
function updateCamera() {
const { target, radius, theta, phi } = cameraState;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
}
function resetCamera() {
cameraState.target.set(-0.1, 0, 3.0);
cameraState.radius = 37;
cameraState.theta = 0.56;
cameraState.phi = 0.78;
updateCamera();
}
function topCamera() {
cameraState.target.set(-0.1, 0, 3.0);
cameraState.radius = 36;
cameraState.theta = 0;
cameraState.phi = 0.18;
updateCamera();
}
updateCamera();
document.getElementById("resetCamera").addEventListener("click", resetCamera);
document.getElementById("topCamera").addEventListener("click", topCamera);
document.getElementById("zoomIn").addEventListener("click", () => {
cameraState.radius = THREE.MathUtils.clamp(cameraState.radius * 0.84, 15, 62);
updateCamera();
});
document.getElementById("zoomOut").addEventListener("click", () => {
cameraState.radius = THREE.MathUtils.clamp(cameraState.radius * 1.16, 15, 62);
updateCamera();
});
const pointer = {
id: null,
x: 0,
y: 0,
startX: 0,
startY: 0,
moved: false,
button: 0
};
const raycaster = new THREE.Raycaster();
const pointerNdc = new THREE.Vector2();
renderer.domElement.addEventListener("pointerdown", event => {
pointer.id = event.pointerId;
pointer.x = pointer.startX = event.clientX;
pointer.y = pointer.startY = event.clientY;
pointer.moved = false;
pointer.button = event.button;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (pointer.id !== event.pointerId) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (Math.hypot(event.clientX - pointer.startX, event.clientY - pointer.startY) > 5) {
pointer.moved = true;
}
const panMode = event.shiftKey || pointer.button === 2;
if (panMode) {
const scale = cameraState.radius * 0.0014;
const right = new THREE.Vector3(Math.cos(cameraState.theta), 0, -Math.sin(cameraState.theta));
const forward = new THREE.Vector3(-Math.sin(cameraState.theta), 0, -Math.cos(cameraState.theta));
cameraState.target.addScaledVector(right, -dx * scale);
cameraState.target.addScaledVector(forward, -dy * scale);
} else {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - dy * 0.005, 0.16, 1.38);
}
updateCamera();
});
renderer.domElement.addEventListener("pointerup", event => {
if (pointer.id !== event.pointerId) return;
if (!pointer.moved) {
const rect = renderer.domElement.getBoundingClientRect();
pointerNdc.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointerNdc.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNdc, camera);
const hits = raycaster.intersectObjects(clickableMeshes, false);
if (hits.length) {
const id = hits[0].object.userData.nodeId;
const index = nodes.findIndex(node => node.id === id);
if (index >= 0) selectStage(index, true);
}
}
pointer.id = null;
});
renderer.domElement.addEventListener("pointercancel", () => pointer.id = null);
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
15,
62
);
updateCamera();
}, { passive: false });
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
const projected = new THREE.Vector3();
const segmentDuration = 3.2;
let pulseTime = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
pulseTime += dt;
if (state.playing) {
const now = performance.now();
if (now >= state.holdUntil) {
state.progress += dt / segmentDuration;
if (state.progress >= 1) {
state.progress = 1;
state.active = Math.min(state.active + 1, nodes.length - 1);
state.segment = Math.min(state.active, nodes.length - 2);
if (state.active === nodes.length - 1) {
state.playing = false;
state.holdUntil = 0;
playButton.textContent = "▶ REPLAY";
journeySubtitle.textContent = "Hypothetical transaction complete · composite chronology";
renderDetails();
} else {
state.holdUntil = now + 1250;
journeySubtitle.textContent =
`Carrier change: ${nodes[state.active].from} → ${nodes[state.active].to}`;
renderDetails();
}
}
}
const u = (state.active + state.progress) / (nodes.length - 1);
const clampedU = THREE.MathUtils.clamp(u, 0, 1);
caravan.position.copy(routeCurve.getPoint(clampedU));
const tangent = routeCurve.getTangent(clampedU);
caravan.rotation.y = Math.atan2(tangent.x, tangent.z);
const bob = Math.sin(pulseTime * 7) * 0.035;
caravan.position.y += bob;
}
const selectionPulse = 1 + Math.sin(pulseTime * 3.3) * 0.035;
selectionFrame.scale.setScalar(selectionPulse);
selectionFrame.rotation.y = Math.sin(pulseTime * 0.35) * 0.025;
// Project HTML node labels into screen space.
nodes.forEach((node, index) => {
projected.copy(nodePositions[index]);
projected.y += 1.55;
projected.project(camera);
const visible = projected.z > -1 && projected.z < 1;
const label = nodeLabels[index];
label.style.display = visible ? "block" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
label.style.left = `${x}px`;
label.style.top = `${y}px`;
}
});
renderer.render(scene, camera);
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
addEventListener("resize", resize);
renderDetails();
selectStage(0, true);
animate();
</script>
</body>
</html>
```