Prompt specification
Build or customize the Three.js 3D scene "Ancient quay loading amphora cargo" 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: Ancient quay loading amphora cargo
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/ancient-quay-loading-amphora-cargo-x2606
Scene Description Prompt:
Create a standalone voxel scene in one HTML file using Three.js from cdnjs. Create a historically informed Mediterranean quay with ship hold opening and amphora stacks. Animate one protected loading path while keeping workers and suspended cargo separated.
Working Three.js Starter (ancient-quay-loading-amphora-cargo-x2606):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mare — Voxel Mediterranean Quay</title>
<style>
:root {
color-scheme: dark;
--ink: #f7efd9;
--muted: #c6c2b5;
--panel: rgba(24, 34, 37, 0.88);
--border: rgba(255, 255, 255, 0.16);
--gold: #efbd58;
--green: #8fd0a3;
--red: #dc8d75;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #a9c8ca;
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;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
color: var(--ink);
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
box-shadow: 0 12px 35px rgba(20, 28, 29, 0.2);
backdrop-filter: blur(12px);
}
#title-card {
position: absolute;
top: 20px;
left: 20px;
width: min(430px, calc(100vw - 40px));
padding: 18px 20px 16px;
border-radius: 14px;
}
.eyebrow {
color: var(--gold);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 5px 0 4px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 42px);
font-weight: 500;
letter-spacing: 0.035em;
}
.subtitle {
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.status-row {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 13px;
}
.status {
display: flex;
align-items: center;
gap: 7px;
padding: 7px 9px;
border: 1px solid var(--border);
border-radius: 7px;
background: rgba(255, 255, 255, 0.035);
color: #ece9df;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.075em;
text-transform: uppercase;
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 10px rgba(143, 208, 163, 0.65);
}
.dot.amber {
background: var(--gold);
box-shadow: 0 0 10px rgba(239, 189, 88, 0.65);
}
#legend {
position: absolute;
bottom: 20px;
left: 20px;
width: min(330px, calc(100vw - 40px));
padding: 14px 16px;
border-radius: 12px;
}
.legend-title {
margin-bottom: 10px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 10px;
margin: 8px 0;
font-size: 12px;
color: #eee9dc;
}
.swatch {
width: 24px;
height: 8px;
border-radius: 2px;
flex: 0 0 auto;
}
.swatch.path {
background: var(--gold);
}
.swatch.exclusion {
background: repeating-linear-gradient(
135deg,
#b45f4f 0,
#b45f4f 4px,
#5b3530 4px,
#5b3530 8px
);
}
.swatch.hold {
background: #354f55;
border: 1px solid #6e8c8e;
}
#controls {
position: absolute;
right: 20px;
bottom: 20px;
width: 238px;
padding: 12px;
border-radius: 12px;
pointer-events: auto;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 7px;
padding: 9px 8px;
background: rgba(255, 255, 255, 0.075);
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
}
button:hover {
background: rgba(255, 255, 255, 0.14);
border-color: rgba(255, 255, 255, 0.3);
}
button:focus-visible {
outline: 2px solid var(--gold);
outline-offset: 2px;
}
#pause-button {
grid-column: 1 / -1;
background: rgba(239, 189, 88, 0.15);
border-color: rgba(239, 189, 88, 0.35);
}
.help {
margin-top: 10px;
color: var(--muted);
font-size: 10px;
line-height: 1.5;
text-align: center;
}
#note {
position: absolute;
top: 20px;
right: 20px;
width: min(305px, calc(100vw - 40px));
padding: 15px 17px;
border-radius: 12px;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
#note strong {
display: block;
margin-bottom: 6px;
color: var(--ink);
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#note p {
margin: 7px 0 0;
}
.scene-label {
position: absolute;
left: 0;
top: 0;
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.25);
border-radius: 6px;
background: rgba(22, 31, 33, 0.84);
color: #fff4d9;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
white-space: nowrap;
transform: translate(-50%, -100%);
box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
}
.scene-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 17px;
background: rgba(255, 244, 217, 0.7);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #a9c8ca;
color: #26383a;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 0.5s ease;
}
@media (max-width: 760px) {
#title-card {
top: 10px;
left: 10px;
}
#note {
display: none;
}
#legend {
left: 10px;
bottom: 10px;
width: 225px;
}
#controls {
right: 10px;
bottom: 10px;
width: 178px;
}
.help {
display: none;
}
}
</style>
</head>
<body>
<div id="loading">Building the quay…</div>
<div class="hud">
<section id="title-card" class="panel">
<div class="eyebrow">Interpretive reconstruction · c. 100 BCE</div>
<h1>MARE · QUAY VII</h1>
<div class="subtitle">
A limestone Mediterranean commercial quay, with a timber merchant ship,
an open cargo hold, pointed amphorae, and a timber sheer crane.
</div>
<div class="status-row">
<div class="status">
<span class="dot"></span>
<span id="route-status">Protected route open</span>
</div>
<div class="status">
<span class="dot amber"></span>
<span id="hoist-status">Hoist over Hold I</span>
</div>
</div>
</section>
<aside id="note" class="panel">
<strong>Reading the scene</strong>
The masonry quay, stepped hull, amphora forms, warehouses, and timber lifting
gear are modeled on Hellenistic/Roman Mediterranean practice.
<p>
The gold walkway and exclusion boundary are interpretive safety overlays,
not ancient painted markings. Workers remain inside the landward corridor;
the suspended load moves vertically only over the open hold.
</p>
</aside>
<section id="legend" class="panel">
<div class="legend-title">Operational zones</div>
<div class="legend-row">
<span class="swatch path"></span>
One protected loading path
</div>
<div class="legend-row">
<span class="swatch exclusion"></span>
Hoist exclusion apron
</div>
<div class="legend-row">
<span class="swatch hold"></span>
Open ship hold
</div>
</section>
<section id="controls" class="panel">
<div class="button-row">
<button id="pause-button">Pause</button>
<button id="route-view">Route view</button>
<button id="top-view">Top view</button>
<button id="reset-view">Reset camera</button>
</div>
<div class="help">Drag to orbit · wheel to zoom · space to pause</div>
</section>
<div id="label-path" class="scene-label">Protected loading path</div>
<div id="label-hold" class="scene-label">Hold I · vertical lift only</div>
<div id="label-store" class="scene-label">Amphora staging</div>
</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, and lighting
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xa9c8ca);
scene.fog = new THREE.Fog(0xa9c8ca, 48, 105);
const camera = new THREE.PerspectiveCamera(
47,
innerWidth / innerHeight,
0.1,
180
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
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.08;
document.body.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xcce8ee, 0x806b50, 1.8);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe2ad, 3.4);
sun.position.set(-18, 31, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -34;
sun.shadow.camera.right = 34;
sun.shadow.camera.top = 34;
sun.shadow.camera.bottom = -34;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 85;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9ccbd4, 0.55);
fill.position.set(20, 12, -24);
scene.add(fill);
// ---------------------------------------------------------------------
// Shared voxel and material utilities
// ---------------------------------------------------------------------
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
const staticBoxes = [];
const dynamicMaterialCache = new Map();
const palette = {
limestone: 0xc5b994,
limestoneLight: 0xd6ccaa,
limestoneDark: 0x9d947b,
path: 0xd7a84f,
pathLight: 0xe8bd69,
pathDark: 0xb98538,
exclusion: 0x704238,
exclusionLight: 0x9a5848,
wood: 0x735037,
woodLight: 0x946d45,
woodDark: 0x463326,
deck: 0x9a7149,
deckLight: 0xb28555,
hull: 0x5b4030,
hold: 0x25363a,
terracotta: 0x9d4d35,
terracottaLight: 0xba6844,
roof: 0x9f4933,
plaster: 0xd4c5a3,
plasterDark: 0xb9a989,
rope: 0x59442e,
dark: 0x242b2c
};
function B(
w, h, d, x, y, z, color,
rx = 0, ry = 0, rz = 0
) {
staticBoxes.push({ w, h, d, x, y, z, color, rx, ry, rz });
}
function dynamicMaterial(color) {
if (!dynamicMaterialCache.has(color)) {
dynamicMaterialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0
})
);
}
return dynamicMaterialCache.get(color);
}
function D(parent, w, h, d, x, y, z, color) {
const mesh = new THREE.Mesh(cubeGeometry, dynamicMaterial(color));
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeLine(points, color = palette.rope, opacity = 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map((p) => new THREE.Vector3(p[0], p[1], p[2]))
);
const material = new THREE.LineBasicMaterial({
color,
transparent: opacity < 1,
opacity
});
const line = new THREE.Line(geometry, material);
scene.add(line);
return line;
}
function commitStaticBoxes() {
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.86,
metalness: 0
});
const mesh = new THREE.InstancedMesh(
geometry,
material,
staticBoxes.length
);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
staticBoxes.forEach((b, index) => {
dummy.position.set(b.x, b.y, b.z);
dummy.rotation.set(b.rx, b.ry, b.rz);
dummy.scale.set(b.w, b.h, b.d);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
color.set(b.color);
mesh.setColorAt(index, color);
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.computeBoundingSphere();
scene.add(mesh);
}
// ---------------------------------------------------------------------
// Sea and land
// ---------------------------------------------------------------------
const sea = new THREE.Mesh(
new THREE.PlaneGeometry(150, 120),
new THREE.MeshStandardMaterial({
color: 0x4d8e9b,
roughness: 0.34,
metalness: 0.08,
transparent: true,
opacity: 0.94
})
);
sea.rotation.x = -Math.PI / 2;
sea.position.set(0, -0.03, -35);
sea.receiveShadow = true;
scene.add(sea);
B(90, 1.1, 38, 0, -0.28, 38, 0x9f9472);
B(46, 2.25, 18, 0, 0.52, 10, palette.limestoneDark);
// Ashlar paving.
for (let x = -22; x <= 22; x += 2) {
for (let z = 2.2; z <= 18; z += 1.48) {
const tint = [palette.limestone, palette.limestoneLight, palette.limestoneDark];
const color = tint[Math.floor(Math.random() * tint.length)];
B(1.94, 0.3, 1.42, x, 1.69, z, color);
}
}
// Heavy coping blocks along the water.
for (let x = -22; x <= 22; x += 2) {
B(1.95, 0.5, 0.85, x, 1.72, 1.55, palette.limestoneLight);
}
// Mooring bollards.
for (const x of [-18, -10, 7.5, 17]) {
B(0.58, 0.9, 0.58, x, 2.18, 1.55, palette.woodDark);
B(0.78, 0.18, 0.78, x, 2.58, 1.55, palette.wood);
}
// ---------------------------------------------------------------------
// Exactly one protected loading path
// ---------------------------------------------------------------------
const PATH_Y = 1.89;
const PATH_Z = 9.15;
const PATH_START = -18;
const PATH_END = 18;
for (let x = PATH_START; x < PATH_END; x += 0.9) {
const tone = Math.floor((x - PATH_START) / 0.9) % 2
? palette.path
: palette.pathLight;
B(0.86, 0.1, 3.25, x + 0.45, PATH_Y, PATH_Z, tone);
}
// Low curbs make the corridor visibly continuous.
for (let x = PATH_START; x < PATH_END; x += 1.8) {
B(1.75, 0.28, 0.22, x + 0.9, 1.97, 7.39, palette.pathDark);
B(1.75, 0.28, 0.22, x + 0.9, 1.97, 10.91, palette.pathDark);
}
// Timber posts and double rope rails on both sides.
for (let x = PATH_START; x <= PATH_END; x += 3) {
for (const z of [7.28, 11.02]) {
B(0.18, 1.38, 0.18, x, 2.51, z, palette.woodDark);
B(0.28, 0.14, 0.28, x, 3.18, z, palette.woodLight);
}
}
for (const z of [7.28, 11.02]) {
makeLine(
[
[PATH_START, 2.68, z],
[PATH_END, 2.68, z]
],
0x6d5034
);
makeLine(
[
[PATH_START, 3.03, z],
[PATH_END, 3.03, z]
],
0x8b6840
);
}
// Hoist exclusion apron on the waterward side of the path.
for (let x = -3.5; x < 7; x += 1.35) {
for (let z = 2; z < 7; z += 1.25) {
const color = (Math.round(x + z) % 2 === 0)
? palette.exclusion
: palette.exclusionLight;
B(1.28, 0.08, 1.18, x + 0.65, 1.88, z, color);
}
}
// Animated markers reinforce the single route without adding another path.
const routeMarkers = [];
const routeMarkerGeometry = new THREE.BoxGeometry(0.5, 0.035, 0.16);
const routeMarkerMaterial = new THREE.MeshBasicMaterial({
color: 0xffd977,
transparent: true,
opacity: 0.72,
depthWrite: false
});
for (let i = 0; i < 12; i++) {
const marker = new THREE.Mesh(routeMarkerGeometry, routeMarkerMaterial);
marker.position.set(PATH_START, PATH_Y + 0.075, PATH_Z);
scene.add(marker);
routeMarkers.push(marker);
}
// ---------------------------------------------------------------------
// Merchant ship with an actual open hold
// ---------------------------------------------------------------------
const shipCenterX = -4;
const shipCenterZ = -6.5;
// Hull bottom.
B(34, 1.05, 9, shipCenterX, -0.12, shipCenterZ, palette.hull);
// Long side walls and visible horizontal planking.
for (const z of [-11, -2]) {
B(34, 1.85, 0.42, shipCenterX, 0.8, z, palette.woodDark);
for (let y = 0.12; y <= 1.75; y += 0.32) {
B(
33.8, 0.11, 0.15, shipCenterX, y,
z + (z < -6 ? -0.24 : 0.24),
y % 0.64 < 0.2 ? palette.wood : palette.woodLight
);
}
for (let x = -20; x <= 12; x += 2.1) {
B(0.2, 1.95, 0.22, x, 0.83, z + (z < -6 ? -0.3 : 0.3), palette.wood);
}
}
// Deck segments leave x=-3..5 and z=-10..-3 open.
B(17, 0.24, 9, -11.5, 1.3, shipCenterZ, palette.deck);
B(9, 0.24, 9, 9.5, 1.3, shipCenterZ, palette.deck);
B(8, 0.24, 1, 1, 1.3, -10.5, palette.deck);
B(8, 0.24, 1, 1, 1.3, -2.5, palette.deck);
// Deck plank seams.
for (let z = -10.7; z <= -2.2; z += 0.72) {
if (z > -10.05 && z < -2.95) {
B(17, 0.035, 0.07, -11.5, 1.44, z, palette.deckLight);
B(9, 0.035, 0.07, 9.5, 1.44, z, palette.deckLight);
} else {
B(34, 0.035, 0.07, -4, 1.44, z, palette.deckLight);
}
}
// Dark hold floor and inner walls.
B(7.75, 0.22, 6.65, 1, 0.08, shipCenterZ, palette.hold);
B(0.35, 1.65, 7, -3.08, 0.86, shipCenterZ, palette.woodDark);
B(0.35, 1.65, 7, 5.08, 0.86, shipCenterZ, palette.woodDark);
B(8, 1.5, 0.25, 1, 0.78, -10.03, palette.woodDark);
B(8, 1.2, 0.25, 1, 0.63, -2.97, palette.woodDark);
// Hold ladder.
for (const x of [3.65, 4.05]) {
B(0.09, 1.3, 0.09, x, 0.76, -3.2, palette.woodLight);
}
for (let y = 0.25; y <= 1.35; y += 0.3) {
B(0.5, 0.08, 0.09, 3.85, y, -3.2, palette.woodLight);
}
// Stepped bow.
for (let i = 0; i < 5; i++) {
const width = 9 - i * 1.25;
B(
1.02, 0.48 + i * 0.08, width,
14 + i * 0.9, 1.43 + i * 0.08, shipCenterZ,
i % 2 ? palette.wood : palette.woodLight
);
}
// Raised stern platform.
B(5.6, 1.25, 7.8, -17.3, 1.9, shipCenterZ, palette.woodDark);
B(5.7, 0.18, 7.9, -17.3, 2.58, shipCenterZ, palette.deck);
// Mast, yard, furled sail, and rigging.
B(0.4, 10.8, 0.4, -10, 6.95, shipCenterZ, palette.woodDark);
B(0.36, 0.36, 9, -10, 10.8, shipCenterZ, palette.wood);
B(0.55, 0.52, 7.4, -10, 10.45, shipCenterZ, 0xc4b18a);
B(0.2, 7.8, 0.2, -10, 4.6, shipCenterZ, palette.wood);
makeLine([[-10, 12.3, -6.5], [15.5, 2.5, -6.5]], 0x5f4934, 0.9);
makeLine([[-10, 12.3, -6.5], [-20, 2.5, -6.5]], 0x5f4934, 0.9);
makeLine([[-10, 12.3, -6.5], [-10, 2.4, -11]], 0x5f4934, 0.85);
makeLine([[-10, 12.3, -6.5], [-10, 2.4, -2]], 0x5f4934, 0.85);
// Steering oar.
B(0.18, 0.18, 6.4, -20.5, 2.4, -3.5, palette.woodDark, 0, 0, 0.3);
B(0.4, 1.35, 1.8, -20.5, 2.1, -6.1, palette.deck, 0, 0, 0.3);
// Moorings from the ship to the quay.
makeLine([[-17, 2.0, -2.3], [-18, 2.55, 1.5]], 0x4e3c2d);
makeLine([[8, 2.0, -2.3], [7.5, 2.55, 1.5]], 0x4e3c2d);
// ---------------------------------------------------------------------
// Timber sheer crane / hoist
// ---------------------------------------------------------------------
const craneX = 1;
const craneZ = 2.15;
B(0.5, 8.7, 0.5, -0.35, 6.05, craneZ, palette.woodDark, 0, 0, -0.12);
B(0.5, 8.7, 0.5, 2.35, 6.05, craneZ, palette.woodDark, 0, 0, 0.12);
B(3.8, 0.5, 0.55, craneX, 9.75, craneZ, palette.wood);
B(0.55, 0.55, 9.7, craneX, 10.02, -2.72, palette.woodDark);
B(0.44, 3.8, 0.44, craneX, 8.0, 1.15, palette.wood, 0.42, 0, 0);
B(2.8, 1.7, 1.8, craneX, 2.55, 3.8, palette.woodDark);
// Block-and-tackle housing.
B(0.85, 0.85, 0.85, craneX, 10.15, -6.5, palette.woodLight);
B(0.55, 0.55, 1.05, craneX, 10.15, -6.5, palette.woodDark);
// ---------------------------------------------------------------------
// Amphorae and staging
// ---------------------------------------------------------------------
function amphoraB(x, y, z, scale = 1, color = palette.terracotta) {
const s = scale;
// Pointed toe, tapered lower body, broad body, shoulder, neck, lip.
B(0.22 * s, 0.28 * s, 0.22 * s, x, y + 0.14 * s, z, color);
B(0.48 * s, 0.46 * s, 0.48 * s, x, y + 0.48 * s, z, color);
B(0.72 * s, 0.86 * s, 0.72 * s, x, y + 1.12 * s, z, color);
B(0.58 * s, 0.25 * s, 0.58 * s, x, y + 1.67 * s, z, color);
B(0.29 * s, 0.44 * s, 0.29 * s, x, y + 2.0 * s, z, color);
B(0.4 * s, 0.13 * s, 0.4 * s, x, y + 2.27 * s, z, color);
// Two blocky loop handles.
for (const side of [-1, 1]) {
B(
0.13 * s, 0.42 * s, 0.14 * s,
x, y + 1.88 * s, z + side * 0.38 * s,
color
);
B(
0.13 * s, 0.14 * s, 0.26 * s,
x, y + 2.04 * s, z + side * 0.31 * s,
color
);
}
}
function pallet(cx, cz, width = 4.2, depth = 2.7) {
for (let i = 0; i < 5; i++) {
B(
width / 5 - 0.08, 0.16, depth,
cx - width / 2 + (i + 0.5) * width / 5,
1.98, cz, palette.wood
);
}
for (const z of [cz - depth * 0.34, cz + depth * 0.34]) {
B(width, 0.18, 0.23, cx, 1.8, z, palette.woodDark);
}
}
// Staging group near the hoist.
pallet(10.2, 4.2, 4.4, 2.6);
for (let ix = 0; ix < 4; ix++) {
for (let iz = 0; iz < 2; iz++) {
amphoraB(
8.75 + ix * 0.95,
2.08,
3.65 + iz * 1.05,
0.62,
(ix + iz) % 3 === 0
? palette.terracottaLight
: palette.terracotta
);
}
}
for (let ix = 0; ix < 2; ix++) {
amphoraB(9.2 + ix * 1.0, 3.05, 3.65, 0.62, palette.terracottaLight);
}
// A second staging group on the opposite side of the quay.
pallet(-13.5, 4.0, 3.8, 2.5);
for (let ix = 0; ix < 3; ix++) {
for (let iz = 0; iz < 2; iz++) {
amphoraB(
-14.6 + ix * 1.05,
2.08,
3.45 + iz * 1.05,
0.59,
(ix + iz) % 2 ? palette.terracottaLight : palette.terracotta
);
}
}
// Wooden shipping boxes and sacks.
B(2.2, 1.7, 1.7, 14.6, 2.7, 3.8, palette.woodLight);
B(2.3, 0.12, 1.8, 14.6, 3.15, 3.8, palette.woodDark);
B(2.3, 0.12, 1.8, 14.6, 2.3, 3.8, palette.woodDark);
B(1.7, 0.8, 1.2, -10.5, 2.25, 13.0, 0xbca276);
// ---------------------------------------------------------------------
// Warehouses, city wall, cypresses, and background architecture
// ---------------------------------------------------------------------
function warehouse(cx, cz, width = 8.6, depth = 6.2) {
const wallH = 4.2;
const baseY = 1.8;
B(width + 0.5, 0.45, depth + 0.5, cx, 1.84, cz, palette.limestoneDark);
B(width, wallH, 0.42, cx, baseY + wallH / 2, cz - depth / 2, palette.plaster);
B(width, wallH, 0.42, cx, baseY + wallH / 2, cz + depth / 2, palette.plasterDark);
B(0.42, wallH, depth, cx - width / 2, baseY + wallH / 2, cz, palette.plaster);
B(0.42, wallH, depth, cx + width / 2, baseY + wallH / 2, cz, palette.plaster);
// Front wall with a central door.
const sideWidth = (width - 2.5) / 2;
B(
sideWidth, wallH, 0.42,
cx - 1.25 - sideWidth / 2,
baseY + wallH / 2,
cz - depth / 2,
palette.plaster
);
B(
sideWidth, wallH, 0.42,
cx + 1.25 + sideWidth / 2,
baseY + wallH / 2,
cz - depth / 2,
palette.plaster
);
B(2.5, 3.1, 0.16, cx, baseY + 1.55, cz - depth / 2 - 0.12, palette.dark);
B(2.85, 0.23, 0.55, cx, baseY + 3.16, cz - depth / 2 - 0.1, palette.limestoneLight);
// Small square window.
B(0.85, 0.85, 0.12, cx - 2.7, baseY + 2.55, cz - depth / 2 - 0.1, palette.dark);
B(0.85, 0.85, 0.12, cx + 2.7, baseY + 2.55, cz - depth / 2 - 0.1, palette.dark);
// Stepped tile roof, ridge running left-to-right.
const roofRows = 8;
for (let i = 0; i < roofRows; i++) {
const z = cz - depth / 2 - 0.35 + i * (depth + 0.7) / (roofRows - 1);
const rise = 1 - Math.abs(i - (roofRows - 1) / 2) / ((roofRows - 1) / 2);
const y = baseY + wallH + 0.25 + rise * 1.2;
B(
width + 1.0, 0.28, (depth + 0.7) / roofRows + 0.03,
cx, y, z,
i % 2 ? palette.roof : 0x8d402e
);
}
B(width + 1.1, 0.32, 0.42, cx, baseY + wallH + 1.55, cz, 0xb95c3d);
}
warehouse(-14, 16.1);
warehouse(0, 16.4);
warehouse(14, 16.1);
// Low city wall.
for (let x = -28; x <= 28; x += 2) {
B(1.94, 1.7, 0.85, x, 2.55, 27.2, palette.limestone);
B(2.0, 0.18, 1.0, x, 3.48, 27.2, palette.limestoneLight);
}
function cypress(x, z, scale = 1) {
B(0.35 * scale, 3.2 * scale, 0.35 * scale, x, 3.0, z, palette.woodDark);
B(
1.8 * scale, 2.0 * scale, 1.8 * scale,
x, 4.4 * scale, z, 0x3f5d3d
);
B(
1.45 * scale, 1.7 * scale, 1.45 * scale,
x, 5.75 * scale, z, 0x496b43
);
B(
0.95 * scale, 1.45 * scale, 0.95 * scale,
x, 7.0 * scale, z, 0x52764a
);
B(
0.5 * scale, 1.0 * scale, 0.5 * scale,
x, 8.0 * scale, z, 0x5d8050
);
}
cypress(-22, 23.5, 0.85);
cypress(22.5, 23.3, 0.95);
cypress(7.5, 24.2, 0.72);
// Distant blocky town.
for (let i = 0; i < 14; i++) {
const x = -30 + i * 4.6;
const h = 3.5 + (i % 4) * 0.8;
B(3.2, h, 3.6, x, 2 + h / 2, 33 + (i % 3) * 2.2, 0xb7aa8e);
B(3.6, 0.35, 4.0, x, 2 + h, 33 + (i % 3) * 2.2, 0x9e593f);
}
// Blocky clouds.
for (const cloud of [
[-24, 21, 44, 1.0],
[9, 25, 49, 1.25],
[29, 18, 40, 0.8]
]) {
const [x, y, z, s] = cloud;
B(4.2 * s, 1.4 * s, 1.8 * s, x, y, z, 0xe4e9df);
B(2.2 * s, 2.1 * s, 1.8 * s, x + 0.6 * s, y + 0.7 * s, z, 0xf0eee3);
B(2.8 * s, 1.5 * s, 1.8 * s, x - 1.7 * s, y - 0.1 * s, z, 0xd7e1d9);
}
commitStaticBoxes();
// ---------------------------------------------------------------------
// Animated workers
// ---------------------------------------------------------------------
function makeWorker(tunicColor, skinColor, hairColor, zOffset, carriesBasket = false) {
const root = new THREE.Group();
root.position.set(-10, PATH_Y + 0.06, PATH_Z + zOffset);
scene.add(root);
const torso = D(root, 0.64, 0.76, 0.38, 0, 1.03, 0, tunicColor);
D(root, 0.72, 0.34, 0.44, 0, 0.61, 0, tunicColor);
D(root, 0.66, 0.1, 0.41, 0, 0.76, 0, 0x4c3a2c);
D(root, 0.43, 0.43, 0.4, 0.03, 1.67, 0, skinColor);
D(root, 0.45, 0.14, 0.42, 0.01, 1.91, 0, hairColor);
D(root, 0.07, 0.08, 0.06, 0.25, 1.69, 0.11, palette.dark);
D(root, 0.07, 0.08, 0.06, 0.25, 1.69, -0.11, palette.dark);
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(0, 0.61, 0.13);
rightLeg.position.set(0, 0.61, -0.13);
root.add(leftLeg, rightLeg);
D(leftLeg, 0.19, 0.62, 0.2, 0, -0.29, 0, 0x70503b);
D(rightLeg, 0.19, 0.62, 0.2, 0, -0.29, 0, 0x70503b);
D(leftLeg, 0.25, 0.12, 0.3, 0.07, -0.56, 0, 0x443429);
D(rightLeg, 0.25, 0.12, 0.3, 0.07, -0.56, 0, 0x443429);
const leftArm = new THREE.Group();
const rightArm = new THREE.Group();
leftArm.position.set(0, 1.3, 0.32);
rightArm.position.set(0, 1.3, -0.32);
root.add(leftArm, rightArm);
D(leftArm, 0.17, 0.62, 0.17, 0, -0.28, 0, tunicColor);
D(rightArm, 0.17, 0.62, 0.17, 0, -0.28, 0, tunicColor);
D(leftArm, 0.17, 0.16, 0.17, 0, -0.6, 0, skinColor);
D(rightArm, 0.17, 0.16, 0.17, 0, -0.6, 0, skinColor);
if (carriesBasket) {
D(root, 0.74, 0.45, 0.65, 0.62, 0.67, 0, 0xa37b42);
D(root, 0.62, 0.06, 0.53, 0.62, 0.91, 0, 0x684b2d);
}
return {
root,
leftLeg,
rightLeg,
leftArm,
rightArm,
x: -10 + Math.random() * 5,
direction: Math.random() > 0.5 ? 1 : -1,
speed: 1.05 + Math.random() * 0.4,
phase: Math.random() * Math.PI * 2
};
}
const workers = [
makeWorker(0xb65e43, 0xc88e63, 0x3b2a21, 0.4, true),
makeWorker(0xd4c09a, 0x9d6746, 0x292522, -0.42, false),
makeWorker(0x536f78, 0xd4a276, 0x4a3526, 0.02, false)
];
// ---------------------------------------------------------------------
// Suspended cargo: fixed over the hold, moving vertically only
// ---------------------------------------------------------------------
const cargo = new THREE.Group();
cargo.position.set(1, 8.6, -6.5);
scene.add(cargo);
// Wooden cradle and corner frame.
D(cargo, 3.1, 0.18, 2.6, 0, -1.02, 0, palette.woodLight);
D(cargo, 3.15, 0.16, 0.18, 0, -0.75, -1.1, palette.wood);
D(cargo, 3.15, 0.16, 0.18, 0, -0.75, 1.1, palette.wood);
for (const x of [-1.42, 1.42]) {
for (const z of [-1.12, 1.12]) {
D(cargo, 0.16, 2.2, 0.16, x, 0.05, z, palette.woodDark);
}
}
// Four amphorae inside the suspended frame.
for (const x of [-0.72, 0.72]) {
for (const z of [-0.56, 0.56]) {
D(cargo, 0.28, 0.16, 0.28, x, -0.83, z, palette.terracotta);
D(cargo, 0.48, 0.62, 0.48, x, -0.43, z, palette.terracotta);
D(cargo, 0.34, 0.2, 0.34, x, -0.04, z, palette.terracottaLight);
D(cargo, 0.19, 0.32, 0.19, x, 0.2, z, palette.terracottaLight);
D(cargo, 0.27, 0.1, 0.27, x, 0.4, z, palette.terracotta);
D(cargo, 0.1, 0.32, 0.1, x, 0.23, z + 0.25, palette.terracotta);
D(cargo, 0.1, 0.32, 0.1, x, 0.23, z - 0.25, palette.terracotta);
}
}
// Lifting yoke.
D(cargo, 2.9, 0.18, 0.18, 0, 1.13, 0, palette.woodDark);
D(cargo, 0.18, 0.18, 2.35, 0, 1.13, 0, palette.woodDark);
D(cargo, 0.3, 0.3, 0.3, 0, 1.37, 0, palette.woodLight);
const ropeGeometry = new THREE.BufferGeometry();
ropeGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(
[1, 9.9, -6.5, 1, cargo.position.y + 1.48, -6.5],
3
)
);
const rope = new THREE.Line(
ropeGeometry,
new THREE.LineBasicMaterial({ color: 0x493727 })
);
scene.add(rope);
// ---------------------------------------------------------------------
// Animated sea glints
// ---------------------------------------------------------------------
const waveCount = 42;
const wavePositions = new Float32Array(waveCount * 6);
const waveData = [];
for (let i = 0; i < waveCount; i++) {
const x = -42 + Math.random() * 84;
const z = -43 + Math.random() * 42;
const length = 1.2 + Math.random() * 3.8;
waveData.push({ x, z, length, phase: Math.random() * Math.PI * 2 });
wavePositions.set(
[x, 0.025, z, x + length, 0.025, z],
i * 6
);
}
const waveGeometry = new THREE.BufferGeometry();
waveGeometry.setAttribute("position", new THREE.BufferAttribute(wavePositions, 3));
const waves = new THREE.LineSegments(
waveGeometry,
new THREE.LineBasicMaterial({
color: 0xc0e0dc,
transparent: true,
opacity: 0.38
})
);
scene.add(waves);
// ---------------------------------------------------------------------
// Custom camera controls — no external controls addon
// ---------------------------------------------------------------------
const cameraState = {
theta: 0.69,
phi: 0.91,
radius: 52,
target: new THREE.Vector3(-1, 3.2, -0.5)
};
function updateCamera() {
const { theta, phi, radius, target } = cameraState;
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
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;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.22,
1.35
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {}
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.045,
23,
78
);
updateCamera();
},
{ passive: false }
);
updateCamera();
// ---------------------------------------------------------------------
// UI and labels
// ---------------------------------------------------------------------
const pauseButton = document.getElementById("pause-button");
const hoistStatus = document.getElementById("hoist-status");
const routeStatus = document.getElementById("route-status");
let paused = false;
function togglePause() {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
routeStatus.textContent = paused
? "Protected route paused"
: "Protected route open";
}
pauseButton.addEventListener("click", togglePause);
document.getElementById("route-view").addEventListener("click", () => {
cameraState.theta = 0.28;
cameraState.phi = 0.73;
cameraState.radius = 31;
cameraState.target.set(0, 2.8, 4.8);
updateCamera();
});
document.getElementById("top-view").addEventListener("click", () => {
cameraState.theta = 0;
cameraState.phi = 0.22;
cameraState.radius = 52;
cameraState.target.set(-1, 0, 1);
updateCamera();
});
document.getElementById("reset-view").addEventListener("click", () => {
cameraState.theta = 0.69;
cameraState.phi = 0.91;
cameraState.radius = 52;
cameraState.target.set(-1, 3.2, -0.5);
updateCamera();
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
togglePause();
}
if (event.key.toLowerCase() === "r") {
cameraState.theta = 0.69;
cameraState.phi = 0.91;
cameraState.radius = 52;
cameraState.target.set(-1, 3.2, -0.5);
updateCamera();
}
});
const labels = [
{
element: document.getElementById("label-path"),
position: new THREE.Vector3(-7.5, 3.5, PATH_Z)
},
{
element: document.getElementById("label-hold"),
position: new THREE.Vector3(1, 3.2, -6.5)
},
{
element: document.getElementById("label-store"),
position: new THREE.Vector3(10.2, 4.2, 4.2)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
for (const label of labels) {
projected.copy(label.position).project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.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;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
}
// ---------------------------------------------------------------------
// Animation loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
let simulationTime = 0;
let previousHoistState = "";
function smoothstep(value) {
const t = THREE.MathUtils.clamp(value, 0, 1);
return t * t * (3 - 2 * t);
}
function updateWorkers(dt) {
for (const worker of workers) {
worker.x += worker.direction * worker.speed * dt;
if (worker.x >= PATH_END - 0.5) {
worker.x = PATH_END - 0.5;
worker.direction = -1;
} else if (worker.x <= PATH_START + 0.5) {
worker.x = PATH_START + 0.5;
worker.direction = 1;
}
worker.root.position.x = worker.x;
worker.root.rotation.y = worker.direction > 0 ? 0 : Math.PI;
const gait = simulationTime * worker.speed * 5.2 + worker.phase;
const swing = Math.sin(gait) * 0.48;
worker.leftLeg.rotation.z = swing;
worker.rightLeg.rotation.z = -swing;
worker.leftArm.rotation.z = -swing * 0.78;
worker.rightArm.rotation.z = swing * 0.78;
worker.root.position.y =
PATH_Y + 0.06 + Math.abs(Math.sin(gait)) * 0.035;
}
}
function updateHoist() {
const cycle = simulationTime % 12;
let y;
let state;
if (cycle < 3.5) {
y = THREE.MathUtils.lerp(8.6, 3.4, smoothstep(cycle / 3.5));
state = "Lowering over Hold I";
} else if (cycle < 5.2) {
y = 3.4;
state = "Load held in Hold I";
} else if (cycle < 9) {
y = THREE.MathUtils.lerp(3.4, 8.6, smoothstep((cycle - 5.2) / 3.8));
state = "Raising from Hold I";
} else {
y = 8.6;
state = "Hoist secured above Hold I";
}
// The load never changes X or Z: it remains over the open hold.
cargo.position.y = y;
cargo.rotation.z = Math.sin(simulationTime * 0.8) * 0.014;
const positions = ropeGeometry.attributes.position;
positions.setXYZ(0, 1, 9.9, -6.5);
positions.setXYZ(1, 1, y + 1.48, -6.5);
positions.needsUpdate = true;
if (state !== previousHoistState) {
hoistStatus.textContent = state;
previousHoistState = state;
}
}
function updateRouteMarkers() {
routeMarkers.forEach((marker, index) => {
const x = PATH_START +
((simulationTime * 2.1 + index * 3) % (PATH_END - PATH_START));
marker.position.x = x;
marker.position.z = PATH_Z;
});
}
function updateWaves() {
const position = waveGeometry.attributes.position;
waveData.forEach((wave, index) => {
const y = 0.025 + Math.sin(simulationTime * 1.2 + wave.phase) * 0.025;
position.setXYZ(index * 2, wave.x, y, wave.z);
position.setXYZ(
index * 2 + 1,
wave.x + wave.length,
y + Math.sin(simulationTime + wave.phase) * 0.012,
wave.z
);
});
position.needsUpdate = true;
}
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused) simulationTime += dt;
updateWorkers(dt);
updateHoist();
updateRouteMarkers();
updateWaves();
updateLabels();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
const loading = document.getElementById("loading");
loading.style.opacity = "0";
setTimeout(() => loading.remove(), 550);
animate();
</script>
</body>
</html>
```