Prompt specification
Build or customize the Three.js 3D scene "Achaemenid-inspired relay courtyard" 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: Achaemenid-inspired relay courtyard
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/achaemenid-inspired-relay-courtyard-x2306
Scene Description Prompt:
Achaemenid-inspired relay courtyard. Create a referenced relay-stop courtyard with stable area, water trough, and messenger exchange point. Show a handover between riders without claiming an exact preserved station layout. Please build this with Three.js from cdnjs in one self-contained HTML file, using low-poly forms.
Working Three.js Starter (achaemenid-inspired-relay-courtyard-x2306):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Achaemenid-inspired Relay Courtyard</title>
<style>
:root {
color-scheme: dark;
--ink: #211a14;
--paper: #efe4cb;
--gold: #d9ad61;
--line: rgba(239, 228, 203, 0.28);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cbb998;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 5;
color: var(--paper);
background: rgba(33, 26, 20, 0.84);
border: 1px solid var(--line);
box-shadow: 0 12px 35px rgba(20, 14, 8, 0.18);
backdrop-filter: blur(8px);
}
#title {
top: 20px;
left: 20px;
max-width: 390px;
padding: 17px 19px 15px;
border-radius: 3px;
}
#title .eyebrow {
margin-bottom: 6px;
color: var(--gold);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(22px, 3vw, 32px);
font-weight: 500;
line-height: 1.08;
}
#title p {
margin: 10px 0 0;
color: rgba(239, 228, 203, 0.72);
font-size: 12px;
line-height: 1.45;
}
#legend {
right: 20px;
bottom: 20px;
width: 245px;
padding: 14px 16px;
border-radius: 3px;
font-size: 11px;
line-height: 1.55;
}
#legend strong {
display: block;
margin-bottom: 5px;
color: var(--gold);
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#legend span {
display: block;
margin-top: 4px;
color: rgba(239, 228, 203, 0.72);
}
#help {
left: 20px;
bottom: 20px;
padding: 10px 13px;
border-radius: 3px;
color: rgba(239, 228, 203, 0.76);
font-size: 10px;
letter-spacing: 0.03em;
}
#reset {
position: fixed;
z-index: 7;
top: 20px;
right: 20px;
padding: 10px 13px;
color: var(--paper);
background: rgba(33, 26, 20, 0.84);
border: 1px solid var(--line);
border-radius: 3px;
cursor: pointer;
font: inherit;
font-size: 11px;
}
#reset:hover { border-color: var(--gold); }
.marker {
position: fixed;
z-index: 4;
transform: translate(-50%, -100%);
padding: 5px 8px;
color: #fff4dd;
background: rgba(52, 35, 22, 0.78);
border: 1px solid rgba(239, 228, 203, 0.36);
border-radius: 2px;
pointer-events: none;
white-space: nowrap;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
opacity: 0;
transition: opacity 150ms ease;
}
.marker::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 15px;
background: rgba(239, 228, 203, 0.55);
}
@media (max-width: 700px) {
#title {
top: 12px;
left: 12px;
right: 78px;
max-width: none;
padding: 13px 14px;
}
#title p { font-size: 10px; }
#legend { display: none; }
#help { left: 12px; bottom: 12px; }
#reset { top: 12px; right: 12px; }
}
</style>
</head>
<body>
<div id="title" class="panel">
<div class="eyebrow">Interpretive low-poly reconstruction</div>
<h1>Achaemenid-inspired Relay Courtyard</h1>
<p>
A rider-to-rider dispatch handover beside a stable court, water trough,
and relay office. The arrangement is historically referenced rather than
an exact preserved station plan.
</p>
</div>
<div id="legend" class="panel">
<strong>Courtyard elements</strong>
<span>01 — Covered stable court</span>
<span>02 — Stone water trough</span>
<span>03 — Dispatch and messenger exchange</span>
<span>04 — Mounted rider handover</span>
</div>
<div id="help" class="panel">
Drag to orbit · Scroll to zoom · Arrow keys to rotate · R to reset
</div>
<button id="reset" type="button">Reset view</button>
<div class="marker" id="label-stable">Covered stables</div>
<div class="marker" id="label-trough">Water trough</div>
<div class="marker" id="label-exchange">Dispatch office</div>
<div class="marker" id="label-handover">Messenger handover</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Renderer, camera, lighting
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc8b797);
scene.fog = new THREE.Fog(0xc8b797, 25, 58);
const camera = new THREE.PerspectiveCamera(
43,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
document.body.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xffe8bd, 0x5f5140, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe4b3, 3.2);
sun.position.set(11, 18, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 22;
sun.shadow.camera.bottom = -22;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.0007;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x91b4c2, 0.55);
fill.position.set(-12, 7, -10);
scene.add(fill);
// ---------------------------------------------------------------------
// Materials and geometry helpers
// ---------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.85,
flatShading: true,
...options
});
const M = {
ground: material(0x9d8762),
courtyard: material(0xb9a17c),
paving: material(0xc8b38d),
pavingDark: material(0x9c8767),
limestone: material(0xc9b58d),
limestoneLight: material(0xdfcba2),
limestoneDark: material(0x8f795b),
mudbrick: material(0xa67e59),
plaster: material(0xd3bc91),
timber: material(0x60412b),
timberLight: material(0x8a5e36),
roof: material(0x5a4937),
reed: material(0xaa8a4e),
hay: material(0xc8a24e),
soil: material(0x67543e),
leather: material(0x4c3426),
iron: material(0x363536, { metalness: 0.45, roughness: 0.52 }),
horseBay: material(0x70452d),
horseDark: material(0x3e3028),
horseGray: material(0x8c8170),
mane: material(0x30231d),
skin: material(0xb77d55),
skinLight: material(0xd4a276),
robeBlue: material(0x315d6d),
robeRed: material(0x914635),
robeCream: material(0xd8c39b),
sash: material(0xb58846),
parchment: material(0xe5d19d),
seal: material(0x9d3129),
water: material(0x4c8b91, {
roughness: 0.22,
metalness: 0.08,
transparent: true,
opacity: 0.82
}),
foliage: material(0x42583c),
foliageLight: material(0x60714a),
cypress: material(0x344a36),
distant: material(0x9a8c71)
};
function box(parent, size, position, mat, rotation = [0, 0, 0]) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(...position);
mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
radiusTop,
radiusBottom,
height,
position,
mat,
segments = 8,
rotation = [0, 0, 0]
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat
);
mesh.position.set(...position);
mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function lowSphere(parent, radius, position, mat, width = 7, height = 5) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, width, height),
mat
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(parent, from, to, radius, mat, segments = 6) {
const a = new THREE.Vector3(...from);
const b = new THREE.Vector3(...to);
const direction = b.clone().sub(a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, segments),
mat
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cone(parent, radius, height, position, mat, segments = 7) {
const mesh = new THREE.Mesh(
new THREE.ConeGeometry(radius, height, segments),
mat
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function group(parent, position = [0, 0, 0], rotationY = 0) {
const g = new THREE.Group();
g.position.set(...position);
g.rotation.y = rotationY;
parent.add(g);
return g;
}
// ---------------------------------------------------------------------
// Ground, courtyard paving, walls, distant landscape
// ---------------------------------------------------------------------
const landscape = group(scene);
box(landscape, [80, 0.4, 80], [0, -0.28, 0], M.ground);
box(landscape, [20.2, 0.10, 15.4], [0, -0.02, 0], M.courtyard);
// Irregular slabs along the central approach.
for (let i = 0; i < 12; i++) {
const z = 6.4 - i * 0.86;
const width = 2.25 + (i % 3) * 0.12;
box(
landscape,
[width, 0.045, 0.69],
[(i % 2 ? 0.05 : -0.05), 0.055, z],
i % 4 === 0 ? M.pavingDark : M.paving
);
}
// Low southern boundary with a central gateway.
box(landscape, [6.8, 0.72, 0.48], [-5.3, 0.35, 7.6], M.mudbrick);
box(landscape, [6.8, 0.72, 0.48], [5.3, 0.35, 7.6], M.mudbrick);
box(landscape, [7.0, 0.18, 0.66], [-5.3, 0.78, 7.6], M.limestoneDark);
box(landscape, [7.0, 0.18, 0.66], [5.3, 0.78, 7.6], M.limestoneDark);
// Tall western wall and lower eastern boundary.
box(landscape, [0.52, 2.25, 15.8], [-10.1, 1.1, -0.1], M.mudbrick);
box(landscape, [0.68, 0.18, 16.0], [-10.1, 2.3, -0.1], M.limestoneDark);
box(landscape, [0.48, 0.82, 15.8], [10.1, 0.40, -0.1], M.mudbrick);
// Circular dispatch setting.
const dispatchRing = group(scene, [0, 0, 0.6]);
cylinder(dispatchRing, 2.35, 2.35, 0.07, [0, 0.075, 0], M.pavingDark, 24);
cylinder(dispatchRing, 2.10, 2.10, 0.08, [0, 0.085, 0], M.paving, 24);
for (let i = 0; i < 16; i++) {
const angle = (i / 16) * Math.PI * 2;
box(
dispatchRing,
[0.48, 0.065, 0.22],
[Math.sin(angle) * 2.25, 0.13, Math.cos(angle) * 2.25],
i % 2 ? M.limestoneLight : M.limestone,
[0, angle, 0]
);
}
// Distant faceted hills.
const hillGeometry = new THREE.ConeGeometry(7, 8, 5);
const hillPositions = [
[-24, 3.3, -24],
[-12, 2.7, -31],
[7, 3.8, -34],
[24, 3.0, -27]
];
hillPositions.forEach((p, index) => {
const hill = new THREE.Mesh(hillGeometry, M.distant);
hill.position.set(...p);
hill.scale.set(1 + index * 0.08, 1, 0.8);
hill.rotation.y = index * 0.71;
hill.receiveShadow = true;
landscape.add(hill);
});
// Cypress trees beyond the court.
function cypress(x, z, scale = 1) {
const g = group(landscape, [x, 0, z]);
cylinder(g, 0.15, 0.19, 1.5 * scale, [0, 0.75 * scale, 0], M.timber, 6);
cone(g, 0.8 * scale, 3.9 * scale, [0, 2.6 * scale, 0], M.cypress, 7);
}
cypress(-14, -10, 1.25);
cypress(-18, -5, 1.05);
cypress(14, -13, 1.2);
cypress(19, -8, 0.95);
// ---------------------------------------------------------------------
// North columned dispatch hall
// ---------------------------------------------------------------------
const hall = group(scene);
box(hall, [13.2, 0.34, 4.3], [0, 0.13, -6.4], M.limestoneDark);
box(hall, [4.75, 3.45, 0.48], [-3.82, 1.95, -8.25], M.mudbrick);
box(hall, [4.75, 3.45, 0.48], [3.82, 1.95, -8.25], M.mudbrick);
box(hall, [2.85, 0.72, 0.48], [0, 3.30, -8.25], M.mudbrick);
box(hall, [0.40, 3.45, 4.1], [-6.35, 1.95, -6.45], M.mudbrick);
box(hall, [0.40, 3.45, 4.1], [6.35, 1.95, -6.45], M.mudbrick);
// Dark recessed doorway.
box(hall, [2.45, 2.9, 0.12], [0, 1.68, -8.43], M.timber);
// Column bases, faceted shafts, capitals, and timber beam.
const columnXs = [-5.5, -3.65, -1.82, 0, 1.82, 3.65, 5.5];
columnXs.forEach((x) => {
cylinder(hall, 0.42, 0.48, 0.22, [x, 0.40, -4.45], M.limestoneDark, 10);
cylinder(hall, 0.26, 0.31, 3.12, [x, 2.03, -4.45], M.limestoneLight, 10);
cylinder(hall, 0.43, 0.29, 0.28, [x, 3.70, -4.45], M.limestone, 10);
box(hall, [0.92, 0.16, 0.90], [x, 3.90, -4.45], M.limestoneDark);
});
box(hall, [12.8, 0.32, 0.40], [0, 4.04, -4.45], M.timber);
box(hall, [13.3, 0.32, 4.55], [0, 4.28, -6.40], M.roof);
box(hall, [12.7, 0.10, 4.0], [0, 4.48, -6.40], M.timberLight);
// Colored awnings between selected columns.
for (const x of [-3.65, 0, 3.65]) {
box(
hall,
[1.62, 0.07, 2.8],
[x, 3.88, -6.25],
x === 0 ? M.robeRed : M.robeBlue
);
}
// ---------------------------------------------------------------------
// Covered stable court
// ---------------------------------------------------------------------
const stable = group(scene, [-7.1, 0, -0.15]);
box(stable, [5.8, 0.18, 7.2], [0, 0.07, -0.25], M.limestoneDark);
box(stable, [0.38, 2.65, 7.0], [-2.8, 1.45, -0.25], M.mudbrick);
box(stable, [0.38, 2.65, 7.0], [2.8, 1.45, -0.25], M.mudbrick);
box(stable, [5.8, 2.65, 0.38], [0, 1.45, -3.65], M.mudbrick);
// Front posts.
[-2.45, 0, 2.45].forEach((x) => {
box(stable, [0.24, 3.0, 0.24], [x, 1.60, 3.15], M.timber);
box(stable, [0.50, 0.18, 0.50], [x, 0.18, 3.15], M.limestoneDark);
});
box(stable, [5.65, 0.28, 0.30], [0, 3.16, 3.15], M.timber);
// Low-poly gable roof.
const roofAngle = Math.atan2(1.0, 2.9);
const roofLength = Math.sqrt(2.9 * 2.9 + 1.0 * 1.0);
box(stable, [roofLength, 0.18, 7.45], [-1.45, 3.68, -0.2], M.roof, [0, 0, roofAngle]);
box(stable, [roofLength, 0.18, 7.45], [1.45, 3.68, -0.2], M.roof, [0, 0, -roofAngle]);
box(stable, [0.28, 0.28, 7.55], [0, 4.17, -0.2], M.timberLight);
// Partition walls and tether posts.
[-1.45, 0, 1.45].forEach((x, index) => {
box(stable, [0.16, 1.25, 4.1], [x, 0.74, -0.65], M.mudbrick);
cylinder(stable, 0.08, 0.10, 1.30, [x + 0.72, 0.72, 1.25], M.timber, 6);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.13, 0.035, 4, 8),
M.iron
);
ring.position.set(x + 0.72, 1.25, 1.25);
ring.rotation.x = Math.PI / 2;
stable.add(ring);
});
// Hay bales and feed bins.
for (let i = 0; i < 9; i++) {
const bale = box(
stable,
[0.78, 0.48, 0.62],
[-2.25 + (i % 3) * 0.68, 0.42 + Math.floor(i / 3) * 0.48, -2.75],
i % 2 ? M.hay : M.reed,
[0, (i % 2) * 0.06, 0]
);
bale.scale.z = 0.82;
}
box(stable, [1.4, 0.62, 0.9], [2.15, 0.42, -2.55], M.timber);
box(stable, [1.2, 0.12, 0.72], [2.15, 0.75, -2.55], M.hay);
// ---------------------------------------------------------------------
// Water trough
// ---------------------------------------------------------------------
const trough = group(scene, [5.0, 0, 4.3]);
box(trough, [3.2, 0.58, 1.34], [0, 0.32, 0], M.limestoneDark);
box(trough, [2.75, 0.08, 0.91], [0, 0.65, 0], M.water);
box(trough, [3.45, 0.20, 0.23], [0, 0.72, -0.62], M.limestone);
box(trough, [3.45, 0.20, 0.23], [0, 0.72, 0.62], M.limestone);
box(trough, [0.23, 0.20, 1.05], [-1.58, 0.72, 0], M.limestone);
box(trough, [0.23, 0.20, 1.05], [1.58, 0.72, 0], M.limestone);
// Small faceted ripple rings.
for (let i = 0; i < 2; i++) {
const ripple = new THREE.Mesh(
new THREE.TorusGeometry(0.22 + i * 0.13, 0.015, 3, 12),
M.limestoneLight
);
ripple.rotation.x = Math.PI / 2;
ripple.position.set(-0.35 + i * 0.6, 0.705, 0.03);
trough.add(ripple);
}
// Bucket beside trough.
cylinder(trough, 0.25, 0.30, 0.48, [2.05, 0.25, 0.35], M.timber, 8);
cylinder(trough, 0.27, 0.27, 0.06, [2.05, 0.51, 0.35], M.iron, 8);
// ---------------------------------------------------------------------
// Horse and rider construction
// ---------------------------------------------------------------------
function createHorse(parent, position, rotationY, coat, withRider = false, riderMat = null) {
const horse = group(parent, position, rotationY);
horse.scale.setScalar(0.94);
// Torso and barrel.
box(horse, [0.78, 0.70, 1.62], [0, 1.25, 0], coat);
lowSphere(horse, 0.43, [0, 1.28, -0.58], coat, 7, 5);
// Neck and head.
beam(horse, [0, 1.46, 0.58], [0, 2.02, 0.96], 0.28, coat, 6);
box(horse, [0.42, 0.39, 0.75], [0, 2.08, 1.15], coat, [-0.08, 0, 0]);
box(horse, [0.34, 0.25, 0.27], [0, 1.92, 1.48], coat);
cone(horse, 0.075, 0.25, [-0.14, 2.36, 1.05], coat, 5);
cone(horse, 0.075, 0.25, [0.14, 2.36, 1.05], coat, 5);
// Mane and tail.
box(horse, [0.12, 0.48, 0.48], [0, 1.92, 0.79], M.mane, [-0.32, 0, 0]);
beam(horse, [0, 1.34, -0.74], [0, 0.89, -1.42], 0.12, M.mane, 5);
// Legs.
const legXs = [-0.28, 0.28];
const legZs = [-0.55, 0.56];
legXs.forEach((x) => {
legZs.forEach((z) => {
beam(horse, [x, 1.04, z], [x, 0.48, z + (z > 0 ? 0.04 : -0.03)], 0.105, coat, 5);
beam(horse, [x, 0.48, z + (z > 0 ? 0.04 : -0.03)], [x, 0.10, z], 0.085, coat, 5);
box(horse, [0.20, 0.13, 0.25], [x, 0.08, z + 0.02], M.iron);
});
});
// Tail and eyes.
lowSphere(horse, 0.045, [-0.19, 2.17, 1.36], M.iron, 5, 4);
lowSphere(horse, 0.045, [0.19, 2.17, 1.36], M.iron, 5, 4);
// Saddle blanket and saddle.
box(horse, [0.88, 0.10, 0.95], [0, 1.63, -0.02], riderMat || M.robeRed);
box(horse, [0.55, 0.18, 0.68], [0, 1.73, -0.02], M.leather);
if (withRider) {
const robe = riderMat || M.robeCream;
// Seated body.
cylinder(horse, 0.28, 0.39, 0.72, [0, 2.26, -0.03], robe, 7);
cylinder(horse, 0.31, 0.33, 0.22, [0, 1.88, -0.04], M.leather, 7);
box(horse, [0.76, 0.12, 0.55], [0, 2.12, -0.02], M.sash);
// Head, neck wrap, and nose.
cylinder(horse, 0.12, 0.14, 0.22, [0, 2.70, 0.02], M.skin, 6);
lowSphere(horse, 0.245, [0, 2.91, 0.06], M.skinLight, 7, 5);
box(horse, [0.11, 0.10, 0.12], [0, 2.91, 0.29], M.skin);
cylinder(horse, 0.23, 0.26, 0.16, [0, 3.08, 0.04], M.robeCream, 8);
// Forward handover arm.
beam(horse, [0, 2.54, 0.06], [0, 2.43, 0.82], 0.095, robe, 6);
beam(horse, [0, 2.43, 0.82], [0, 2.42, 1.62], 0.085, robe, 6);
lowSphere(horse, 0.10, [0, 2.42, 1.64], M.skinLight, 6, 4);
// Other arm holds the reins.
beam(horse, [-0.25, 2.51, 0.03], [-0.40, 2.23, 0.36], 0.09, robe, 6);
beam(horse, [-0.40, 2.23, 0.36], [-0.42, 1.92, 0.73], 0.08, robe, 6);
lowSphere(horse, 0.10, [-0.42, 1.92, 0.73], M.skinLight, 6, 4);
beam(horse, [-0.42, 1.92, 0.73], [-0.36, 2.16, 1.30], 0.018, M.leather, 4);
// Bent legs.
beam(horse, [-0.29, 1.89, -0.03], [-0.46, 1.47, 0.26], 0.13, robe, 6);
beam(horse, [-0.46, 1.47, 0.26], [-0.46, 1.02, 0.44], 0.11, M.leather, 6);
beam(horse, [0.29, 1.89, -0.03], [0.46, 1.47, 0.26], 0.13, robe, 6);
beam(horse, [0.46, 1.47, 0.26], [0.46, 1.02, 0.44], 0.11, M.leather, 6);
}
return horse;
}
// Main mounted pair, facing one another along the X axis.
createHorse(scene, [-2.35, 0, 0.60], Math.PI / 2, M.horseBay, true, M.robeBlue);
createHorse(scene, [2.35, 0, 0.60], -Math.PI / 2, M.horseDark, true, M.robeRed);
// Two unmounted horses in the stable court.
createHorse(stable, [-1.48, 0, 0.25], 0.08, M.horseGray, false);
createHorse(stable, [1.48, 0, 0.25], -0.05, M.horseBay, false);
// ---------------------------------------------------------------------
// Handover scroll and visual emphasis
// ---------------------------------------------------------------------
const handover = group(scene);
const scroll = cylinder(
handover,
0.105,
0.105,
1.55,
[0, 2.42, 0.60],
M.parchment,
10,
[0, 0, Math.PI / 2]
);
cylinder(
handover,
0.125,
0.125,
0.12,
[-0.70, 2.42, 0.60],
M.timberLight,
10,
[0, 0, Math.PI / 2]
);
cylinder(
handover,
0.125,
0.125,
0.12,
[0.70, 2.42, 0.60],
M.timberLight,
10,
[0, 0, Math.PI / 2]
);
lowSphere(handover, 0.14, [0.42, 2.42, 0.69], M.seal, 8, 5);
// A subtle red exchange cloth under the scroll.
box(handover, [2.1, 0.035, 1.25], [0, 0.145, 0.60], M.robeRed);
// ---------------------------------------------------------------------
// Dispatch office, table, messenger, signs, and records
// ---------------------------------------------------------------------
const exchange = group(scene);
// Writing table.
box(exchange, [3.2, 0.16, 1.15], [0, 1.08, -3.25], M.timberLight);
[-1.30, 1.30].forEach((x) => {
box(exchange, [0.16, 0.98, 0.82], [x, 0.50, -3.25], M.timber);
});
box(exchange, [2.8, 0.12, 0.15], [0, 0.43, -3.25], M.timber);
// Scrolls, tablet, seal, and writing implements.
cylinder(exchange, 0.09, 0.09, 1.1, [-0.88, 1.23, -3.26], M.parchment, 8, [0, 0, Math.PI / 2]);
box(exchange, [0.75, 0.10, 0.56], [0.20, 1.21, -3.30], M.limestoneDark);
box(exchange, [0.62, 0.035, 0.43], [0.20, 1.28, -3.30], M.parchment);
cylinder(exchange, 0.12, 0.15, 0.25, [1.05, 1.29, -3.28], M.seal, 8);
beam(exchange, [0.64, 1.30, -3.55], [0.87, 1.30, -3.18], 0.025, M.timber, 5);
// Standing messenger behind the desk.
const messenger = group(exchange, [0.25, 0, -4.25]);
cylinder(messenger, 0.26, 0.42, 1.15, [0, 0.76, 0], M.robeCream, 7);
box(messenger, [0.72, 0.13, 0.46], [0, 0.65, 0], M.robeRed);
cylinder(messenger, 0.12, 0.14, 0.19, [0, 1.42, 0], M.skin, 6);
lowSphere(messenger, 0.24, [0, 1.64, 0], M.skinLight, 7, 5);
cylinder(messenger, 0.23, 0.25, 0.15, [0, 1.81, 0], M.robeRed, 8);
beam(messenger, [-0.22, 1.28, 0], [-0.38, 0.92, 0.40], 0.09, M.robeCream, 6);
beam(messenger, [-0.38, 0.92, 0.40], [-0.25, 1.14, 0.80], 0.08, M.robeCream, 6);
beam(messenger, [0.22, 1.28, 0], [0.40, 1.05, 0.38], 0.09, M.robeCream, 6);
beam(messenger, [0.40, 1.05, 0.38], [0.18, 1.30, 0.78], 0.08, M.robeCream, 6);
lowSphere(messenger, 0.09, [0.18, 1.30, 0.78], M.skinLight, 6, 4);
// Canvas-generated sign texture.
function makeSignTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 320;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#33251a";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = "#d3ab65";
ctx.lineWidth = 10;
ctx.strokeRect(18, 18, canvas.width - 36, canvas.height - 36);
ctx.fillStyle = "#e5cf9a";
ctx.textAlign = "center";
ctx.font = "bold 68px Georgia";
ctx.fillText("RELAY DISPATCH", 512, 132);
ctx.fillStyle = "#bfa778";
ctx.font = "30px Georgia";
ctx.fillText("Interpretive reconstruction — not an exact station plan", 512, 205);
// Simple radial rosette.
ctx.strokeStyle = "#d3ab65";
ctx.lineWidth = 7;
ctx.beginPath();
ctx.arc(512, 264, 17, 0, Math.PI * 2);
ctx.stroke();
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
ctx.beginPath();
ctx.moveTo(512 + Math.cos(angle) * 24, 264 + Math.sin(angle) * 24);
ctx.lineTo(512 + Math.cos(angle) * 39, 264 + Math.sin(angle) * 39);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const signTexture = makeSignTexture();
const signMaterial = new THREE.MeshStandardMaterial({
map: signTexture,
roughness: 0.9
});
const sign = new THREE.Mesh(new THREE.PlaneGeometry(3.7, 1.16), signMaterial);
sign.position.set(0, 2.72, -4.25);
sign.castShadow = true;
exchange.add(sign);
// Clay vessels and a brazier.
function amphora(parent, position, scale = 1) {
const g = group(parent, position);
cylinder(g, 0.16, 0.36, 0.72, [0, 0.36, 0], M.roof, 7);
cylinder(g, 0.13, 0.19, 0.25, [0, 0.82, 0], M.roof, 7);
cylinder(g, 0.20, 0.12, 0.12, [0, 1.00, 0], M.roof, 7);
g.scale.setScalar(scale);
}
amphora(exchange, [-3.65, 0.05, -4.30], 1.05);
amphora(exchange, [-4.22, 0.05, -4.52], 0.72);
amphora(exchange, [3.55, 0.05, -4.42], 0.92);
const brazier = group(scene, [3.9, 0, -2.0]);
cylinder(brazier, 0.38, 0.25, 0.44, [0, 0.48, 0], M.iron, 8);
cylinder(brazier, 0.31, 0.35, 0.16, [0, 0.78, 0], M.iron, 8);
cone(brazier, 0.24, 0.48, [0, 1.02, 0], M.roof, 6);
// ---------------------------------------------------------------------
// Custom camera controls: drag orbit, wheel zoom, keyboard, touch
// ---------------------------------------------------------------------
const defaultView = {
yaw: 0.66,
pitch: 0.46,
radius: 23.5,
target: new THREE.Vector3(0, 1.25, -0.65)
};
const desired = {
yaw: defaultView.yaw,
pitch: defaultView.pitch,
radius: defaultView.radius
};
const current = {
yaw: defaultView.yaw,
pitch: defaultView.pitch,
radius: defaultView.radius
};
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desired.yaw -= dx * 0.006;
desired.pitch = THREE.MathUtils.clamp(
desired.pitch + dy * 0.0045,
0.17,
1.18
);
});
function stopDragging(event) {
dragging = false;
if (event && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener("contextmenu", (e) => e.preventDefault());
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius + event.deltaY * 0.015,
10,
37
);
}, { passive: false });
function resetView() {
desired.yaw = defaultView.yaw;
desired.pitch = defaultView.pitch;
desired.radius = defaultView.radius;
}
document.getElementById("reset").addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") desired.yaw += 0.09;
if (event.key === "ArrowRight") desired.yaw -= 0.09;
if (event.key === "ArrowUp") {
desired.pitch = THREE.MathUtils.clamp(desired.pitch + 0.07, 0.17, 1.18);
}
if (event.key === "ArrowDown") {
desired.pitch = THREE.MathUtils.clamp(desired.pitch - 0.07, 0.17, 1.18);
}
if (event.key.toLowerCase() === "r") resetView();
});
// ---------------------------------------------------------------------
// Projected labels
// ---------------------------------------------------------------------
const labels = [
{
element: document.getElementById("label-stable"),
position: new THREE.Vector3(-7.1, 4.35, 0.1)
},
{
element: document.getElementById("label-trough"),
position: new THREE.Vector3(5.0, 1.05, 4.3)
},
{
element: document.getElementById("label-exchange"),
position: new THREE.Vector3(0, 3.45, -4.2)
},
{
element: document.getElementById("label-handover"),
position: new THREE.Vector3(0, 3.15, 0.6)
}
];
function updateLabels() {
labels.forEach(({ element, position }) => {
const projected = position.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
if (!visible) {
element.style.opacity = "0";
return;
}
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity = x > -50 && x < innerWidth + 50 && y > 0 ? "1" : "0";
});
}
// ---------------------------------------------------------------------
// Resize and animation
// ---------------------------------------------------------------------
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
// Soft camera damping.
current.yaw = THREE.MathUtils.lerp(current.yaw, desired.yaw, 1 - Math.pow(0.001, delta));
current.pitch = THREE.MathUtils.lerp(current.pitch, desired.pitch, 1 - Math.pow(0.001, delta));
current.radius = THREE.MathUtils.lerp(current.radius, desired.radius, 1 - Math.pow(0.001, delta));
const cosPitch = Math.cos(current.pitch);
camera.position.set(
defaultView.target.x + Math.sin(current.yaw) * cosPitch * current.radius,
defaultView.target.y + Math.sin(current.pitch) * current.radius,
defaultView.target.z + Math.cos(current.yaw) * cosPitch * current.radius
);
camera.lookAt(defaultView.target);
// Very subtle movement in the exchange scroll.
scroll.rotation.x = Math.sin(clock.elapsedTime * 0.7) * 0.035;
renderer.render(scene, camera);
updateLabels();
}
animate();
</script>
</body>
</html>
```