Prompt specification
Build or customize the Three.js 3D scene "Road stages across a regional landscape" 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: Road stages across a regional landscape
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/road-stages-across-a-regional-landscape-x2307
Scene Description Prompt:
I'd like to see this as a low-poly Three.js scene: Road stages across a regional landscape. Build a schematic Achaemenid road segment with several relay stops and terrain changes. Animate a message moving station by station and clearly label distances as illustrative. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (road-stages-across-a-regional-landscape-x2307):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Achaemenid Royal Road — Schematic Relay Dispatch</title>
<style>
:root {
--ink: #273129;
--muted: #667063;
--paper: rgba(246, 239, 216, 0.94);
--paper-solid: #f6efd8;
--gold: #b77924;
--gold-light: #e3b65e;
--red: #a94c35;
--green: #526c52;
--line: rgba(55, 65, 49, 0.22);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d9e1d2;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#scene {
position: fixed;
inset: 0;
}
#labels {
position: fixed;
inset: 0;
pointer-events: none;
overflow: hidden;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(74, 79, 57, 0.24);
background: var(--paper);
box-shadow: 0 10px 35px rgba(39, 49, 41, 0.15);
backdrop-filter: blur(8px);
}
#titlePanel {
top: 18px;
left: 18px;
width: min(430px, calc(100vw - 36px));
padding: 17px 19px 15px;
border-radius: 4px 18px 18px 18px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 6px;
color: var(--red);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 25px;
height: 2px;
background: var(--red);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(24px, 3vw, 37px);
font-weight: 600;
line-height: 1.02;
letter-spacing: -0.025em;
}
.subtitle {
margin: 8px 0 13px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.badges {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.badge {
padding: 5px 8px;
border: 1px solid var(--line);
border-radius: 999px;
color: #4e594b;
background: rgba(255, 255, 255, 0.35);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.badge.warning {
border-color: rgba(169, 76, 53, 0.28);
color: #8a3e2d;
background: rgba(169, 76, 53, 0.08);
}
#dispatchPanel {
top: 18px;
right: 18px;
width: min(320px, calc(100vw - 36px));
padding: 15px;
border-radius: 16px 4px 16px 16px;
}
.dispatch-heading {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 12px;
margin-bottom: 10px;
}
.dispatch-heading strong {
font-size: 11px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
#distanceReadout {
color: var(--gold);
font-family: Georgia, serif;
font-size: 18px;
font-weight: 700;
}
#status {
min-height: 36px;
margin-bottom: 10px;
color: #505b4d;
font-size: 12px;
line-height: 1.45;
}
.progress-track {
height: 5px;
overflow: hidden;
border-radius: 10px;
background: rgba(47, 59, 43, 0.13);
}
#progressFill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--red), var(--gold-light));
transition: width 80ms linear;
}
.control-row {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 12px;
}
button,
select {
min-height: 34px;
border: 1px solid rgba(64, 72, 53, 0.28);
border-radius: 8px;
color: var(--ink);
background: rgba(255, 255, 255, 0.48);
font: inherit;
font-size: 11px;
font-weight: 700;
}
button {
padding: 0 12px;
cursor: pointer;
}
button:hover,
select:hover {
background: rgba(255, 255, 255, 0.82);
}
button.primary {
color: #fff8e8;
border-color: var(--green);
background: var(--green);
}
button.primary:hover {
background: #435a44;
}
select {
padding: 0 8px;
}
.hint {
margin-top: 10px;
color: #737b70;
font-size: 9px;
line-height: 1.45;
letter-spacing: 0.03em;
}
#timeline {
right: 18px;
bottom: 18px;
left: 18px;
padding: 13px 15px 12px;
border-radius: 14px;
}
.timeline-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 10px;
}
.timeline-title {
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.timeline-note {
color: var(--muted);
font-size: 9px;
letter-spacing: 0.05em;
}
#stops {
display: grid;
grid-template-columns: repeat(7, minmax(100px, 1fr));
gap: 6px;
overflow-x: auto;
padding-bottom: 2px;
}
.stop {
position: relative;
min-width: 100px;
padding: 8px 8px 8px 18px;
border-color: rgba(64, 72, 53, 0.18);
border-radius: 8px;
text-align: left;
background: rgba(255, 255, 255, 0.26);
}
.stop::before {
content: "";
position: absolute;
top: 50%;
left: 7px;
width: 7px;
height: 7px;
border: 2px solid #8d927d;
border-radius: 50%;
background: var(--paper-solid);
transform: translateY(-50%);
}
.stop.current {
border-color: rgba(183, 121, 36, 0.65);
background: rgba(227, 182, 94, 0.17);
}
.stop.current::before {
border-color: var(--gold);
background: var(--gold-light);
box-shadow: 0 0 0 4px rgba(227, 182, 94, 0.22);
}
.stop.visited::before {
border-color: var(--green);
background: var(--green);
}
.stop-name {
display: block;
font-size: 10px;
font-weight: 800;
}
.stop-distance {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.04em;
}
.station-label,
.region-label,
.courier-label {
position: absolute;
left: 0;
top: 0;
white-space: nowrap;
transform-origin: center bottom;
will-change: transform;
}
.station-label {
padding: 6px 9px 5px;
border: 1px solid rgba(53, 60, 45, 0.25);
border-radius: 7px;
color: var(--ink);
background: rgba(248, 242, 222, 0.93);
box-shadow: 0 4px 12px rgba(42, 47, 36, 0.14);
text-align: center;
}
.station-label::after {
content: "";
position: absolute;
left: 50%;
bottom: -6px;
width: 9px;
height: 9px;
border-right: 1px solid rgba(53, 60, 45, 0.25);
border-bottom: 1px solid rgba(53, 60, 45, 0.25);
background: rgba(248, 242, 222, 0.93);
transform: translateX(-50%) rotate(45deg);
}
.station-label strong {
display: block;
font-family: Georgia, serif;
font-size: 13px;
line-height: 1;
}
.station-label span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 7px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.station-label.active {
border-color: var(--gold);
background: #fff2c9;
box-shadow: 0 0 0 3px rgba(227, 182, 94, 0.22);
}
.region-label {
color: rgba(53, 67, 50, 0.64);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
text-transform: uppercase;
}
.courier-label {
padding: 4px 7px;
border-radius: 5px;
color: #fff9e9;
background: rgba(169, 76, 53, 0.9);
font-size: 8px;
font-weight: 900;
letter-spacing: 0.12em;
box-shadow: 0 4px 12px rgba(60, 42, 30, 0.18);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
color: #4d5948;
background: #e1e5d6;
font-family: Georgia, serif;
font-size: 18px;
transition: opacity 400ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
#titlePanel {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 13px 15px;
}
#dispatchPanel {
top: auto;
right: 10px;
bottom: 126px;
width: calc(100vw - 20px);
}
#timeline {
right: 10px;
bottom: 10px;
left: 10px;
padding: 10px;
}
.timeline-note,
.hint {
display: none;
}
.station-label {
padding: 4px 6px;
}
.station-label strong {
font-size: 10px;
}
.station-label span {
font-size: 6px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="labels"></div>
<section id="titlePanel" class="panel">
<div class="eyebrow">Achaemenid Persia · Royal Road</div>
<h1>Anatolia to Susa</h1>
<p class="subtitle">
A schematic low-poly landscape of relay stations, changing terrain, and a
royal dispatch moving from station to station.
</p>
<div class="badges">
<span class="badge">Schematic route</span>
<span class="badge">7 relay stages</span>
<span class="badge warning">Distances illustrative</span>
</div>
</section>
<section id="dispatchPanel" class="panel">
<div class="dispatch-heading">
<strong>Royal dispatch</strong>
<span id="distanceReadout">0 km</span>
</div>
<div id="status">The sealed message is ready at Sardis.</div>
<div class="progress-track"><div id="progressFill"></div></div>
<div class="control-row">
<button id="playButton" class="primary" type="button">Pause</button>
<button id="nextButton" type="button">Next stop</button>
<button id="restartButton" type="button">Restart</button>
<select id="speedSelect" aria-label="Animation speed">
<option value="0.65">0.65×</option>
<option value="1" selected>1×</option>
<option value="1.5">1.5×</option>
<option value="2">2×</option>
</select>
</div>
<div class="hint">
Drag to orbit · wheel to zoom · right-drag to pan · click a stop to focus
</div>
</section>
<section id="timeline" class="panel">
<div class="timeline-head">
<span class="timeline-title">Relay sequence</span>
<span class="timeline-note">Route-distance values are illustrative, not surveyed</span>
</div>
<div id="stops"></div>
</section>
<div id="loading">Preparing the royal road…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce3d5);
scene.fog = new THREE.Fog(0xdce3d5, 112, 245);
const camera = new THREE.PerspectiveCamera(
48,
innerWidth / innerHeight,
0.1,
400
);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
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.08;
document.getElementById("scene").appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xf6f0da, 0x5d674a, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe4aa, 3.4);
sun.position.set(-48, 82, 38);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -105;
sun.shadow.camera.right = 105;
sun.shadow.camera.top = 65;
sun.shadow.camera.bottom = -65;
sun.shadow.camera.near = 5;
sun.shadow.camera.far = 220;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9fb8c7, 0.65);
fill.position.set(55, 35, -60);
scene.add(fill);
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
const lerp = (a, b, t) => a + (b - a) * t;
const smoothstep = (a, b, x) => {
const t = clamp((x - a) / (b - a), 0, 1);
return t * t * (3 - 2 * t);
};
let seed = 41027;
function random() {
seed |= 0;
seed = (seed + 0x6D2B79F5) | 0;
let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
}
function terrainHeight(x, z) {
const plateau = 5.8 * smoothstep(-47, -27, x);
const easternDrop = -5.7 * smoothstep(43, 64, x);
const mountainBand =
13.5 *
Math.exp(-Math.pow((x - 25) / 10.5, 2)) *
(0.84 + 0.16 * Math.cos(z * 0.13));
const secondaryRidge =
6.2 *
Math.exp(-Math.pow((x - 14) / 8, 2)) *
(0.55 + 0.45 * Math.cos((z + 9) * 0.17));
const zagros = 11.8 * smoothstep(64, 83, x);
const rolling =
1.05 * Math.sin(x * 0.13 + z * 0.075) +
0.58 * Math.sin(x * 0.27 - z * 0.16) +
0.35 * Math.cos(z * 0.31 + x * 0.07);
const northernSlope = 2.0 * smoothstep(8, 40, -z);
return 0.8 + plateau + easternDrop + mountainBand + secondaryRidge + zagros + rolling + northernSlope;
}
const terrainGeometry = new THREE.PlaneGeometry(180, 90, 80, 40);
terrainGeometry.rotateX(-Math.PI / 2);
const terrainPosition = terrainGeometry.attributes.position;
const terrainColors = new Float32Array(terrainPosition.count * 3);
const cWestLow = new THREE.Color(0x78865c);
const cWestHigh = new THREE.Color(0x969765);
const cPlateau = new THREE.Color(0xb29a68);
const cRock = new THREE.Color(0x817565);
const cMountain = new THREE.Color(0x706c61);
const cEast = new THREE.Color(0x829166);
const cPlain = new THREE.Color(0xa3aa76);
const cZagros = new THREE.Color(0x9b7956);
for (let i = 0; i < terrainPosition.count; i++) {
const x = terrainPosition.getX(i);
const z = terrainPosition.getZ(i);
const y = terrainHeight(x, z);
terrainPosition.setY(i, y);
let color;
if (x < -47) {
color = cWestLow.clone().lerp(cWestHigh, smoothstep(-82, -47, x));
} else if (x < 8) {
color = cWestHigh.clone().lerp(cPlateau, smoothstep(-47, 8, x));
} else if (x < 43) {
color = cPlateau.clone().lerp(cRock, smoothstep(8, 29, x));
color.lerp(cMountain, smoothstep(7, 16, y));
} else if (x < 64) {
color = cEast.clone().lerp(cPlain, smoothstep(43, 64, x));
} else {
color = cPlain.clone().lerp(cZagros, smoothstep(64, 84, x));
}
const variation = (Math.sin(x * 4.17 + z * 2.33) * 0.5) * 0.045;
color.offsetHSL(0, 0, variation);
terrainColors[i * 3] = color.r;
terrainColors[i * 3 + 1] = color.g;
terrainColors[i * 3 + 2] = color.b;
}
terrainGeometry.setAttribute("color", new THREE.BufferAttribute(terrainColors, 3));
const flatTerrainGeometry = terrainGeometry.toNonIndexed();
flatTerrainGeometry.computeVertexNormals();
const terrainMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
flatShading: true,
roughness: 1,
metalness: 0
});
const terrain = new THREE.Mesh(flatTerrainGeometry, terrainMaterial);
terrain.receiveShadow = true;
scene.add(terrain);
const plinth = new THREE.Mesh(
new THREE.BoxGeometry(180, 5, 90),
new THREE.MeshStandardMaterial({ color: 0x79644d, roughness: 1, flatShading: true })
);
plinth.position.y = -2.55;
plinth.receiveShadow = true;
scene.add(plinth);
const stations = [
{ name: "Sardis", x: -77, z: 7, km: 0, region: "Lydia" },
{ name: "Celaenae", x: -54, z: -5, km: 180, region: "Phrygia" },
{ name: "Iconium", x: -29, z: 7, km: 360, region: "Cappadocia" },
{ name: "Tyana", x: -7, z: -5, km: 520, region: "Cappadocia" },
{ name: "Melitene", x: 15, z: 6, km: 700, region: "Armenia" },
{ name: "Thapsakos", x: 40, z: -7, km: 880, region: "Mesopotamia" },
{ name: "Susa", x: 76, z: -3, km: 1080, region: "Susiana" }
];
const routePoints = stations.map(
(s) => new THREE.Vector3(s.x, terrainHeight(s.x, s.z), s.z)
);
const routeCurve = new THREE.CatmullRomCurve3(routePoints, false, "centripetal", 0.45);
const routeLength = routeCurve.getLength();
const sampleCount = 2400;
const arcLengths = new Float32Array(sampleCount + 1);
const routeSamples = [];
for (let i = 0; i <= sampleCount; i++) {
const point = routeCurve.getPoint(i / sampleCount);
routeSamples.push(point.clone());
if (i > 0) {
arcLengths[i] = arcLengths[i - 1] + point.distanceTo(routeSamples[i - 1]);
}
}
const stationArc = stations.map((station, index) => arcLengths[index * 400] / arcLengths[sampleCount]);
function createRoad() {
const count = 520;
const positions = [];
const indices = [];
for (let i = 0; i <= count; i++) {
const t = i / count;
const point = routeCurve.getPointAt(t);
const before = routeCurve.getPointAt(Math.max(0, t - 0.002));
const after = routeCurve.getPointAt(Math.min(1, t + 0.002));
const tangent = after.clone().sub(before).normalize();
const normal = new THREE.Vector3(-tangent.z, 0, tangent.x).normalize();
const halfWidth = 0.78 + Math.sin(t * 47) * 0.08;
for (const side of [-1, 1]) {
const x = point.x + normal.x * halfWidth * side;
const z = point.z + normal.z * halfWidth * side;
positions.push(x, terrainHeight(x, z) + 0.18, z);
}
if (i < count) {
const a = i * 2;
indices.push(a, a + 1, a + 2, a + 1, a + 3, a + 2);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
const road = new THREE.Mesh(
geometry,
new THREE.MeshStandardMaterial({
color: 0x806346,
roughness: 1,
side: THREE.DoubleSide,
flatShading: true
})
);
road.receiveShadow = true;
scene.add(road);
const markerMaterial = new THREE.MeshStandardMaterial({
color: 0xd6c69a,
roughness: 1,
flatShading: true
});
for (let i = 0; i < 92; i++) {
const t = (i + 0.5) / 92;
const point = routeCurve.getPointAt(t);
const marker = new THREE.Mesh(
new THREE.BoxGeometry(0.22, 0.35, 0.9),
markerMaterial
);
marker.position.set(point.x, terrainHeight(point.x, point.z) + 0.3, point.z);
marker.rotation.y = Math.atan2(
routeCurve.getTangentAt(t).x,
routeCurve.getTangentAt(t).z
);
marker.castShadow = true;
scene.add(marker);
}
}
createRoad();
const stoneMaterial = new THREE.MeshStandardMaterial({
color: 0xc3b38d,
roughness: 0.95,
flatShading: true
});
const paleStoneMaterial = new THREE.MeshStandardMaterial({
color: 0xd7c9a8,
roughness: 0.92,
flatShading: true
});
const roofMaterial = new THREE.MeshStandardMaterial({
color: 0x9e5038,
roughness: 0.92,
flatShading: true
});
const bannerMaterial = new THREE.MeshStandardMaterial({
color: 0xad4935,
side: THREE.DoubleSide,
roughness: 1,
flatShading: true
});
const goldMaterial = new THREE.MeshStandardMaterial({
color: 0xd3a342,
emissive: 0x5e3510,
emissiveIntensity: 0.32,
roughness: 0.7,
flatShading: true
});
const beaconRings = [];
function createRelayStation(station, index) {
const group = new THREE.Group();
group.position.set(station.x, terrainHeight(station.x, station.z), station.z);
const tangent = routeCurve.getTangentAt(stationArc[index]);
group.rotation.y = Math.atan2(tangent.x, tangent.z);
const isTerminus = index === 0 || index === stations.length - 1;
if (isTerminus) {
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(5.4, 5.9, 0.55, 8),
stoneMaterial
);
platform.position.y = 0.24;
platform.castShadow = true;
platform.receiveShadow = true;
group.add(platform);
for (const side of [-1, 1]) {
const tower = new THREE.Mesh(
new THREE.BoxGeometry(1.8, 4.8, 1.8),
paleStoneMaterial
);
tower.position.set(side * 3.25, 2.65, 0);
tower.castShadow = true;
group.add(tower);
const cap = new THREE.Mesh(
new THREE.CylinderGeometry(1.25, 1.35, 0.75, 8),
roofMaterial
);
cap.position.set(side * 3.25, 5.35, 0);
cap.castShadow = true;
group.add(cap);
}
const lintel = new THREE.Mesh(
new THREE.BoxGeometry(5.2, 0.8, 1.1),
paleStoneMaterial
);
lintel.position.y = 4.75;
lintel.castShadow = true;
group.add(lintel);
} else {
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(3.7, 4.05, 0.5, 8),
stoneMaterial
);
platform.position.y = 0.22;
platform.castShadow = true;
platform.receiveShadow = true;
group.add(platform);
const columnGeometry = new THREE.CylinderGeometry(0.22, 0.29, 3.1, 6);
for (const x of [-1.35, 1.35]) {
for (const z of [-1.25, 1.25]) {
const column = new THREE.Mesh(columnGeometry, paleStoneMaterial);
column.position.set(x, 1.9, z);
column.castShadow = true;
group.add(column);
}
}
const roof = new THREE.Mesh(
new THREE.BoxGeometry(3.8, 0.55, 3.5),
roofMaterial
);
roof.position.y = 3.6;
roof.rotation.y = Math.PI / 4;
roof.castShadow = true;
group.add(roof);
const roofCap = new THREE.Mesh(
new THREE.ConeGeometry(2.6, 1.25, 4),
roofMaterial
);
roofCap.position.y = 4.45;
roofCap.rotation.y = Math.PI / 4;
roofCap.castShadow = true;
group.add(roofCap);
}
const pole = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.07, 3.6, 6),
goldMaterial
);
pole.position.set(isTerminus ? 4.6 : 2.7, 2.2, 0.5);
pole.castShadow = true;
group.add(pole);
const banner = new THREE.Mesh(
new THREE.PlaneGeometry(1.25, 1.55),
bannerMaterial
);
banner.position.set(isTerminus ? 5.22 : 3.32, 3.05, 0.5);
banner.rotation.y = Math.PI / 2;
group.add(banner);
const seal = new THREE.Mesh(
new THREE.CircleGeometry(0.28, 8),
goldMaterial
);
seal.position.set(isTerminus ? 5.24 : 3.34, 3.03, 0.5);
seal.rotation.y = Math.PI / 2;
group.add(seal);
const beacon = new THREE.Mesh(
new THREE.TorusGeometry(2.7, 0.08, 4, 28),
new THREE.MeshBasicMaterial({
color: 0xf0b34b,
transparent: true,
opacity: 0,
depthWrite: false
})
);
beacon.rotation.x = Math.PI / 2;
beacon.position.y = 0.62;
group.add(beacon);
beaconRings.push(beacon);
scene.add(group);
return group;
}
stations.forEach(createRelayStation);
function createTree(x, z, scale) {
const group = new THREE.Group();
const y = terrainHeight(x, z);
group.position.set(x, y, z);
group.rotation.y = random() * Math.PI * 2;
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.21, 1.4, 5),
new THREE.MeshStandardMaterial({ color: 0x66503a, roughness: 1, flatShading: true })
);
trunk.position.y = 0.7;
trunk.castShadow = true;
group.add(trunk);
const crownMaterial = new THREE.MeshStandardMaterial({
color: random() > 0.3 ? 0x526946 : 0x68764d,
roughness: 1,
flatShading: true
});
const lower = new THREE.Mesh(
new THREE.ConeGeometry(1.05, 2.6, 6),
crownMaterial
);
lower.position.y = 2.05;
lower.castShadow = true;
group.add(lower);
const upper = new THREE.Mesh(
new THREE.ConeGeometry(0.72, 2.15, 6),
crownMaterial
);
upper.position.y = 3.12;
upper.castShadow = true;
group.add(upper);
group.scale.setScalar(scale);
scene.add(group);
}
function distanceToRoute(x, z) {
let minimum = Infinity;
for (let i = 0; i < stations.length - 1; i++) {
const a = stations[i];
const b = stations[i + 1];
const dx = b.x - a.x;
const dz = b.z - a.z;
const t = clamp(((x - a.x) * dx + (z - a.z) * dz) / (dx * dx + dz * dz), 0, 1);
const px = a.x + dx * t;
const pz = a.z + dz * t;
minimum = Math.min(minimum, Math.hypot(x - px, z - pz));
}
return minimum;
}
let treeCount = 0;
for (let attempt = 0; attempt < 700 && treeCount < 105; attempt++) {
const x = random() * 174 - 87;
const z = random() * 78 - 39;
if (distanceToRoute(x, z) < 4.1) continue;
if (x > -38 && x < 47 && random() > 0.34) continue;
createTree(x, z, 0.65 + random() * 0.75);
treeCount++;
}
const rockMaterial = new THREE.MeshStandardMaterial({
color: 0x817d70,
roughness: 1,
flatShading: true
});
for (let i = 0; i < 72; i++) {
const x = random() * 174 - 87;
const z = random() * 78 - 39;
if (distanceToRoute(x, z) < 2.8) continue;
const height = terrainHeight(x, z);
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.5 + random() * 1.2, 0),
rockMaterial
);
rock.position.set(x, height + 0.3, z);
rock.scale.set(1, 0.65 + random() * 0.5, 0.8 + random() * 0.7);
rock.rotation.set(random(), random() * Math.PI, random());
rock.castShadow = true;
rock.receiveShadow = true;
scene.add(rock);
}
const cloudMaterial = new THREE.MeshLambertMaterial({
color: 0xf4f0dc,
transparent: true,
opacity: 0.82,
depthWrite: false,
flatShading: true
});
for (let i = 0; i < 8; i++) {
const cloud = new THREE.Group();
cloud.position.set(-85 + i * 24 + random() * 8, 24 + random() * 9, -30 - random() * 13);
for (let j = 0; j < 4; j++) {
const puff = new THREE.Mesh(
new THREE.IcosahedronGeometry(1.7 + random() * 1.6, 0),
cloudMaterial
);
puff.position.set(j * 1.8, random() * 0.8, random() * 0.7);
puff.scale.y = 0.55 + random() * 0.25;
cloud.add(puff);
}
scene.add(cloud);
}
function createCourier() {
const root = new THREE.Group();
const model = new THREE.Group();
root.add(model);
const horseMaterial = new THREE.MeshStandardMaterial({
color: 0x6f4c32,
roughness: 0.9,
flatShading: true
});
const darkHorseMaterial = new THREE.MeshStandardMaterial({
color: 0x47362d,
roughness: 0.95,
flatShading: true
});
const riderMaterial = new THREE.MeshStandardMaterial({
color: 0x9f4633,
roughness: 0.9,
flatShading: true
});
const skinMaterial = new THREE.MeshStandardMaterial({
color: 0xb77c51,
roughness: 1,
flatShading: true
});
const body = new THREE.Mesh(new THREE.BoxGeometry(0.78, 0.72, 2.05), horseMaterial);
body.position.y = 1.18;
body.castShadow = true;
model.add(body);
const chest = new THREE.Mesh(new THREE.BoxGeometry(0.72, 0.95, 0.62), horseMaterial);
chest.position.set(0, 1.45, 0.62);
chest.rotation.x = -0.28;
chest.castShadow = true;
model.add(chest);
const head = new THREE.Mesh(new THREE.BoxGeometry(0.5, 0.52, 0.88), horseMaterial);
head.position.set(0, 1.91, 1.25);
head.rotation.x = 0.22;
head.castShadow = true;
model.add(head);
const mane = new THREE.Mesh(new THREE.BoxGeometry(0.18, 0.68, 1.2), darkHorseMaterial);
mane.position.set(0, 1.68, 0.94);
mane.rotation.x = -0.25;
model.add(mane);
const legGeometry = new THREE.BoxGeometry(0.14, 0.9, 0.14);
for (const x of [-0.27, 0.27]) {
for (const z of [-0.7, 0.68]) {
const leg = new THREE.Mesh(legGeometry, darkHorseMaterial);
leg.position.set(x, 0.48, z);
leg.castShadow = true;
model.add(leg);
}
}
const tail = new THREE.Mesh(new THREE.ConeGeometry(0.22, 1.15, 5), darkHorseMaterial);
tail.position.set(0, 1.2, -1.22);
tail.rotation.x = -1.05;
model.add(tail);
const riderBody = new THREE.Mesh(new THREE.ConeGeometry(0.46, 1.25, 6), riderMaterial);
riderBody.position.set(0, 2.2, 0.02);
riderBody.castShadow = true;
model.add(riderBody);
const riderHead = new THREE.Mesh(new THREE.DodecahedronGeometry(0.29, 0), skinMaterial);
riderHead.position.set(0, 2.9, 0.05);
riderHead.castShadow = true;
model.add(riderHead);
const helmet = new THREE.Mesh(
new THREE.ConeGeometry(0.38, 0.42, 6),
goldMaterial
);
helmet.position.set(0, 3.13, 0.05);
model.add(helmet);
const dispatch = new THREE.Mesh(
new THREE.BoxGeometry(0.48, 0.38, 0.62),
new THREE.MeshStandardMaterial({
color: 0xf3d37d,
emissive: 0xb96d19,
emissiveIntensity: 0.75,
roughness: 0.55,
flatShading: true
})
);
dispatch.position.set(0.48, 2.05, 0.05);
dispatch.castShadow = true;
model.add(dispatch);
const dispatchLight = new THREE.PointLight(0xffa93d, 2.6, 8);
dispatchLight.position.copy(dispatch.position);
model.add(dispatchLight);
const groundRing = new THREE.Mesh(
new THREE.TorusGeometry(1.65, 0.07, 4, 24),
new THREE.MeshBasicMaterial({
color: 0xe9a63f,
transparent: true,
opacity: 0.75,
depthWrite: false
})
);
groundRing.rotation.x = Math.PI / 2;
groundRing.position.y = 0.08;
root.add(groundRing);
root.scale.setScalar(0.82);
scene.add(root);
return { root, model, groundRing, dispatchLight };
}
const courier = createCourier();
const labelLayer = document.getElementById("labels");
const labelEntries = [];
function addLabel(element, position) {
labelLayer.appendChild(element);
labelEntries.push({ element, position });
return element;
}
const stationLabelElements = [];
stations.forEach((station, index) => {
const label = document.createElement("div");
label.className = "station-label";
label.innerHTML = `<strong>${station.name}</strong><span>${station.km.toLocaleString()} km · illustrative</span>`;
const position = new THREE.Vector3(
station.x,
terrainHeight(station.x, station.z) + (index === 0 || index === stations.length - 1 ? 10 : 8.2),
station.z
);
addLabel(label, position);
stationLabelElements.push(label);
});
const regionData = [
["Lydia / Phrygia", -66, 22],
["Anatolian Plateau", -21, -21],
["Armenian Highlands", 21, 19],
["Mesopotamian Plain", 54, 20],
["Zagros Foothills", 78, -24]
];
regionData.forEach(([name, x, z]) => {
const label = document.createElement("div");
label.className = "region-label";
label.textContent = name;
addLabel(label, new THREE.Vector3(x, terrainHeight(x, z) + 2.2, z));
});
const courierLabel = document.createElement("div");
courierLabel.className = "courier-label";
courierLabel.textContent = "SEALED DISPATCH";
addLabel(courierLabel, new THREE.Vector3());
const stopsElement = document.getElementById("stops");
const stopButtons = [];
stations.forEach((station, index) => {
const button = document.createElement("button");
button.className = "stop";
button.type = "button";
button.innerHTML = `
<span class="stop-name">${station.name}</span>
<span class="stop-distance">${station.km.toLocaleString()} km · illustrative</span>
`;
button.addEventListener("click", () => focusStation(index));
stopsElement.appendChild(button);
stopButtons.push(button);
});
// Custom orbit/pan/zoom controls, implemented without Three.js addons.
const controls = {
target: new THREE.Vector3(0, 4, 0),
radius: 132,
theta: 0.72,
phi: 0.98,
desiredTarget: new THREE.Vector3(0, 4, 0),
desiredRadius: 132,
desiredTheta: 0.72,
desiredPhi: 0.98
};
function updateCamera() {
controls.theta = lerp(controls.theta, controls.desiredTheta, 0.09);
controls.phi = lerp(controls.phi, controls.desiredPhi, 0.09);
controls.radius = lerp(controls.radius, controls.desiredRadius, 0.09);
controls.target.lerp(controls.desiredTarget, 0.09);
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
updateCamera();
const pointer = new THREE.Vector2();
let dragging = false;
let dragButton = 0;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
dragButton = event.button;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (dragButton === 0) {
controls.desiredTheta -= dx * 0.005;
controls.desiredPhi = clamp(controls.desiredPhi - dy * 0.005, 0.35, 1.38);
} else {
const panScale = controls.desiredRadius * 0.00125;
const right = new THREE.Vector3(Math.cos(controls.desiredTheta), 0, -Math.sin(controls.desiredTheta));
controls.desiredTarget.addScaledVector(right, -dx * panScale);
controls.desiredTarget.y = clamp(
controls.desiredTarget.y + dy * panScale * 0.65,
-2,
30
);
}
});
function endDrag(event) {
dragging = 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(
"wheel",
(event) => {
event.preventDefault();
controls.desiredRadius = clamp(
controls.desiredRadius * Math.exp(event.deltaY * 0.001),
34,
190
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
controls.desiredTarget.set(0, 4, 0);
controls.desiredRadius = 132;
controls.desiredTheta = 0.72;
controls.desiredPhi = 0.98;
});
function focusStation(index) {
const station = stations[index];
controls.desiredTarget.set(
station.x,
terrainHeight(station.x, station.z) + 2,
station.z
);
controls.desiredRadius = 47;
controls.desiredPhi = 0.96;
}
const playButton = document.getElementById("playButton");
const nextButton = document.getElementById("nextButton");
const restartButton = document.getElementById("restartButton");
const speedSelect = document.getElementById("speedSelect");
const statusElement = document.getElementById("status");
const distanceReadout = document.getElementById("distanceReadout");
const progressFill = document.getElementById("progressFill");
let playing = true;
let speed = 1;
let currentStation = 0;
let phase = "dwell";
let phaseElapsed = 0;
let travelDuration = 4;
let progressArc = 0;
let complete = false;
let courierHeading = 0;
function updateStationClasses() {
stopButtons.forEach((button, index) => {
button.classList.toggle("current", index === currentStation && !complete);
button.classList.toggle("visited", index < currentStation || complete);
});
stationLabelElements.forEach((label, index) => {
label.classList.toggle("active", index === currentStation && !complete);
});
}
function resetSimulation(startPlaying = true) {
currentStation = 0;
phase = "dwell";
phaseElapsed = 0;
progressArc = 0;
complete = false;
playing = startPlaying;
playButton.textContent = "Pause";
setCourierAtArc(0);
updateStationClasses();
updateStatus();
}
function setCourierAtArc(arc) {
progressArc = clamp(arc, 0, 1);
const point = routeCurve.getPointAt(progressArc);
const tangent = routeCurve.getTangentAt(progressArc);
const targetHeading = Math.atan2(tangent.x, tangent.z);
let headingDelta = targetHeading - courierHeading;
headingDelta = Math.atan2(Math.sin(headingDelta), Math.cos(headingDelta));
courierHeading += headingDelta * 0.16;
courier.root.position.set(
point.x,
terrainHeight(point.x, point.z) + 0.26,
point.z
);
courier.root.rotation.y = courierHeading;
courier.model.position.y = phase === "travel" ? Math.sin(performance.now() * 0.012) * 0.06 : 0;
courier.groundRing.scale.setScalar(1 + Math.sin(performance.now() * 0.004) * 0.08);
courier.dispatchLight.intensity = 2.3 + Math.sin(performance.now() * 0.007) * 0.45;
labelEntries[labelEntries.length - 1].position.set(
point.x,
terrainHeight(point.x, point.z) + 4.6,
point.z
);
}
function updateStatus() {
if (complete) {
statusElement.textContent = "The sealed message has reached Susa.";
distanceReadout.textContent = "1,080 km";
} else if (phase === "travel") {
statusElement.textContent = `Dispatch moving from ${stations[currentStation].name} to ${stations[currentStation + 1].name}.`;
} else {
statusElement.textContent = `Message held at ${stations[currentStation].name} for relay handover.`;
}
}
function arriveAtStation(index) {
currentStation = index;
phase = "dwell";
phaseElapsed = 0;
progressArc = stationArc[index];
setCourierAtArc(progressArc);
updateStationClasses();
updateStatus();
}
function startTravel() {
if (currentStation >= stations.length - 1) return;
phase = "travel";
phaseElapsed = 0;
const distanceDifference =
stations[currentStation + 1].km - stations[currentStation].km;
travelDuration = 3.5 + distanceDifference * 0.006;
updateStatus();
}
playButton.addEventListener("click", () => {
if (complete) {
resetSimulation(true);
return;
}
playing = !playing;
playButton.textContent = playing ? "Pause" : "Play";
});
nextButton.addEventListener("click", () => {
if (complete) {
resetSimulation(true);
return;
}
if (currentStation >= stations.length - 1) return;
const next = currentStation + 1;
const nextArc = stationArc[next];
progressArc = nextArc;
arriveAtStation(next);
});
restartButton.addEventListener("click", () => resetSimulation(true));
speedSelect.addEventListener("change", () => {
speed = Number(speedSelect.value);
});
resetSimulation(true);
function updateSimulation(delta) {
if (!playing || complete) return;
phaseElapsed += delta * speed;
if (phase === "dwell") {
if (phaseElapsed >= 1.35) {
if (currentStation < stations.length - 1) {
startTravel();
} else {
complete = true;
phase = "complete";
playButton.textContent = "Replay";
updateStationClasses();
updateStatus();
}
}
} else if (phase === "travel") {
const t = clamp(phaseElapsed / travelDuration, 0, 1);
const eased = t * t * (3 - 2 * t);
const arc = lerp(stationArc[currentStation], stationArc[currentStation + 1], eased);
setCourierAtArc(arc);
if (t >= 1) {
arriveAtStation(currentStation + 1);
}
}
}
function updateReadouts() {
let kilometers = stations[currentStation].km;
if (phase === "travel") {
const t = clamp(phaseElapsed / travelDuration, 0, 1);
kilometers = lerp(
stations[currentStation].km,
stations[currentStation + 1].km,
t * t * (3 - 2 * t)
);
}
distanceReadout.textContent = `${Math.round(kilometers).toLocaleString()} km`;
progressFill.style.width = `${progressArc * 100}%`;
}
const projected = new THREE.Vector3();
function updateLabels() {
for (const entry of labelEntries) {
projected.copy(entry.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.25 &&
projected.x < 1.25 &&
projected.y > -1.25 &&
projected.y < 1.25;
entry.element.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;
entry.element.style.transform = `translate(${x}px, ${y}px) translate(-50%, -100%)`;
}
}
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
updateSimulation(delta);
updateCamera();
updateReadouts();
beaconRings.forEach((ring, index) => {
const active = index === currentStation && !complete;
const destination = phase === "travel" && index === currentStation + 1;
const visible = active || destination;
ring.material.opacity = visible ? (active ? 0.88 : 0.42) : 0;
const pulse = 1 + Math.sin(performance.now() * 0.005 + index) * 0.09;
ring.scale.setScalar(pulse);
});
renderer.render(scene, camera);
updateLabels();
}
animate();
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
});
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
setTimeout(() => document.getElementById("loading").remove(), 450);
});
</script>
</body>
</html>
```