Prompt specification
Build or customize the Three.js 3D scene "Spice-growing island and maritime exchange routes" 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: Spice-growing island and maritime exchange routes
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/spice-growing-island-and-maritime-exchange-routes-x2623
Scene Description Prompt:
Make a low-poly Three.js scene in a self-contained HTML file using cdnjs: Spice-growing island and maritime exchange routes. Build a compact island scene linked to a sourced regional trade map. Show cultivation, local exchange, and shipping while including relevant colonial coercion in contextual notes.
Working Three.js Starter (spice-growing-island-and-maritime-exchange-routes-x2623):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#17363b">
<title>Spice Island — Cultivation, Exchange and Coercion</title>
<style>
:root {
color-scheme: dark;
--ink: #eef4e9;
--muted: #b8cbc6;
--panel: rgba(17, 43, 47, 0.88);
--panel-strong: rgba(12, 34, 38, 0.95);
--line: rgba(213, 235, 219, 0.18);
--gold: #e6b85c;
--leaf: #8fbf79;
--teal: #63d3c3;
--red: #e37b65;
--shadow: 0 18px 55px rgba(2, 18, 22, 0.3);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #79aeb2;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, a { font: inherit; }
button:focus-visible,
a:focus-visible,
summary:focus-visible {
outline: 2px solid var(--gold);
outline-offset: 3px;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene.dragging { cursor: grabbing; }
.glass {
background: var(--panel);
border: 1px solid var(--line);
box-shadow: var(--shadow);
backdrop-filter: blur(16px) saturate(120%);
-webkit-backdrop-filter: blur(16px) saturate(120%);
}
#intro {
position: fixed;
top: 22px;
left: 24px;
width: min(430px, calc(100vw - 48px));
pointer-events: none;
text-shadow: 0 2px 18px rgba(0, 0, 0, .38);
}
.eyebrow {
margin: 0 0 7px;
color: var(--gold);
font-size: 11px;
font-weight: 800;
letter-spacing: .17em;
text-transform: uppercase;
}
h1 {
margin: 0;
max-width: 390px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(31px, 4vw, 54px);
font-weight: 500;
line-height: .98;
letter-spacing: -.035em;
}
#intro p {
max-width: 385px;
margin: 11px 0 0;
color: #f2f7ef;
font-size: 13px;
line-height: 1.5;
text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}
#story {
position: fixed;
left: 24px;
top: 196px;
width: min(395px, calc(100vw - 48px));
max-height: calc(100vh - 222px);
overflow: auto;
padding: 15px;
border-radius: 17px;
scrollbar-width: thin;
}
.topic-tabs {
display: flex;
gap: 6px;
overflow-x: auto;
padding-bottom: 12px;
border-bottom: 1px solid var(--line);
}
.topic-tabs button {
flex: 0 0 auto;
padding: 7px 9px;
border: 1px solid transparent;
border-radius: 999px;
background: rgba(255, 255, 255, .055);
color: var(--muted);
font-size: 11px;
font-weight: 700;
cursor: pointer;
}
.topic-tabs button:hover,
.topic-tabs button.active {
color: #102b2d;
background: var(--gold);
}
#topic-kicker {
margin: 15px 0 5px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
}
#topic-title {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 25px;
font-weight: 500;
line-height: 1.1;
}
#topic-body {
margin: 9px 0 13px;
color: #d8e6df;
font-size: 12.5px;
line-height: 1.55;
}
#facts {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.fact {
min-height: 57px;
padding: 9px;
border: 1px solid rgba(255, 255, 255, .09);
border-radius: 10px;
background: rgba(255, 255, 255, .04);
}
.fact strong {
display: block;
margin-bottom: 3px;
color: var(--gold);
font-size: 10px;
letter-spacing: .06em;
text-transform: uppercase;
}
.fact span {
color: #dce8e1;
font-size: 11px;
line-height: 1.35;
}
.timeline {
margin-top: 14px;
padding-top: 12px;
border-top: 1px solid var(--line);
}
.timeline-label {
margin-bottom: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
}
#era-buttons {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 5px;
}
#era-buttons button {
min-height: 45px;
padding: 6px;
border: 1px solid rgba(255, 255, 255, .12);
border-radius: 9px;
background: rgba(255, 255, 255, .045);
color: var(--muted);
font-size: 10px;
line-height: 1.25;
cursor: pointer;
}
#era-buttons button.active {
border-color: rgba(230, 184, 92, .65);
background: rgba(230, 184, 92, .13);
color: var(--ink);
}
#era-note {
margin: 9px 0 0;
color: #c9d9d3;
font-size: 11px;
line-height: 1.45;
}
#era-note.warning {
padding: 9px;
border-left: 2px solid var(--red);
border-radius: 0 7px 7px 0;
background: rgba(227, 123, 101, .1);
color: #f0d8d0;
}
#map-card {
position: fixed;
top: 22px;
right: 24px;
width: 365px;
overflow: hidden;
border-radius: 17px;
}
.map-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 14px 9px;
}
.map-head strong {
font-family: Georgia, "Times New Roman", serif;
font-size: 16px;
font-weight: 500;
}
.map-head a {
color: var(--gold);
font-size: 10px;
font-weight: 800;
text-decoration: none;
white-space: nowrap;
}
.map-head a:hover { text-decoration: underline; }
#regional-map {
display: block;
width: 100%;
height: auto;
background:
radial-gradient(circle at 48% 50%, rgba(99, 211, 195, .08), transparent 45%),
#12383d;
}
#regional-map .land {
fill: #617765;
stroke: #91a58a;
stroke-width: 1.2;
}
#regional-map .coast {
fill: none;
stroke: rgba(210, 230, 202, .34);
stroke-width: 1;
}
#regional-map .route {
fill: none;
stroke: #e6b85c;
stroke-width: 1.5;
stroke-dasharray: 4 4;
opacity: .75;
}
#regional-map text {
fill: #c9dbd0;
font-family: system-ui, sans-serif;
font-size: 9px;
paint-order: stroke;
stroke: #12383d;
stroke-width: 2.5px;
stroke-linejoin: round;
}
#regional-map .map-label {
fill: #f0e4c8;
font-size: 9px;
font-weight: 700;
}
#regional-map .hotspot {
cursor: pointer;
transition: r .2s ease;
}
#regional-map .hotspot:hover { r: 6; }
.map-caption {
padding: 10px 14px 12px;
color: var(--muted);
font-size: 10.5px;
line-height: 1.45;
}
details {
border-top: 1px solid var(--line);
}
summary {
padding: 9px 14px;
color: var(--gold);
font-size: 10px;
font-weight: 800;
cursor: pointer;
}
.sources {
padding: 0 14px 12px;
color: var(--muted);
font-size: 10px;
line-height: 1.5;
}
.sources a {
color: #e8d8ad;
text-decoration: none;
}
.sources a:hover { text-decoration: underline; }
#controls {
position: fixed;
right: 24px;
bottom: 24px;
display: flex;
align-items: center;
gap: 7px;
padding: 8px;
border-radius: 13px;
}
#controls button {
padding: 8px 10px;
border: 1px solid rgba(255, 255, 255, .1);
border-radius: 9px;
background: rgba(255, 255, 255, .05);
color: var(--muted);
font-size: 10px;
font-weight: 750;
cursor: pointer;
}
#controls button.active {
border-color: rgba(99, 211, 195, .45);
background: rgba(99, 211, 195, .12);
color: var(--ink);
}
#controls button:hover { color: var(--ink); }
#controls .reset {
margin-left: 3px;
color: var(--gold);
}
#markers {
position: fixed;
inset: 0;
pointer-events: none;
}
.marker {
position: absolute;
display: flex;
align-items: center;
gap: 6px;
padding: 5px 8px 5px 5px;
transform: translate(-50%, -50%);
border: 1px solid rgba(255, 255, 255, .32);
border-radius: 999px;
background: rgba(11, 35, 39, .78);
color: #f4f7ee;
font-size: 10px;
font-weight: 750;
white-space: nowrap;
box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
pointer-events: auto;
cursor: pointer;
}
.marker::before {
content: "";
width: 8px;
height: 8px;
border: 2px solid #f5d489;
border-radius: 50%;
background: #e6b85c;
box-shadow: 0 0 0 3px rgba(230, 184, 92, .17);
}
.marker.active {
border-color: var(--gold);
background: rgba(51, 69, 52, .92);
}
.legend {
position: fixed;
left: 50%;
bottom: 24px;
transform: translateX(-50%);
display: flex;
gap: 13px;
padding: 8px 12px;
border-radius: 999px;
color: #dce9e2;
font-size: 10px;
pointer-events: none;
}
.legend span {
display: flex;
align-items: center;
gap: 5px;
}
.legend i {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
}
.legend .farm { background: var(--leaf); }
.legend .trade { background: var(--gold); }
.legend .sea { background: var(--teal); }
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #17363b;
color: var(--gold);
font-size: 12px;
letter-spacing: .12em;
text-transform: uppercase;
}
#loading.hidden { display: none; }
@media (max-width: 900px) {
#intro { top: 14px; left: 14px; width: calc(100vw - 28px); }
#intro p { display: none; }
h1 { font-size: 32px; max-width: 300px; }
#story {
left: 14px;
top: 105px;
width: calc(100vw - 28px);
max-height: 35vh;
padding: 12px;
}
#map-card { display: none; }
#controls { right: 14px; bottom: 14px; flex-wrap: wrap; max-width: 210px; }
#controls button { padding: 7px 8px; }
.legend { display: none; }
.marker { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
* { scroll-behavior: auto !important; }
#regional-map .hotspot { transition: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly spice-growing island scene"></canvas>
<div id="loading">Building the island…</div>
<header id="intro">
<p class="eyebrow">Maritime Southeast Asia · composite model</p>
<h1>Spice Island</h1>
<p>
Follow cloves and nutmeg from cultivated groves through village exchange
and onto the sea—then examine the violence behind colonial monopolies.
</p>
</header>
<section id="story" class="glass" aria-live="polite">
<nav class="topic-tabs" aria-label="Scene topics">
<button class="active" data-topic="overview">Overview</button>
<button data-topic="cultivation">Cultivation</button>
<button data-topic="exchange">Local exchange</button>
<button data-topic="shipping">Shipping</button>
<button data-topic="coercion">Coercion</button>
</nav>
<p id="topic-kicker"></p>
<h2 id="topic-title"></h2>
<p id="topic-body"></p>
<div id="facts"></div>
<div class="timeline">
<div class="timeline-label">Historical context</div>
<div id="era-buttons">
<button class="active" data-era="before">Before 1600</button>
<button data-era="during">1605–1621</button>
<button data-era="after">After 1621</button>
</div>
<p id="era-note"></p>
</div>
</section>
<aside id="map-card" class="glass" aria-label="Regional trade map and sources">
<div class="map-head">
<strong>Regional trade map</strong>
<a
id="source-map-link"
href="https://www.worldhistory.org/Spice_Islands/"
target="_blank"
rel="noopener noreferrer"
>Open source map ↗</a>
</div>
<svg id="regional-map" viewBox="0 0 520 300" role="img" aria-label="Schematic map of spice routes across Maritime Southeast Asia">
<defs>
<marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5"
markerWidth="5" markerHeight="5" orient="auto-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#e6b85c"></path>
</marker>
</defs>
<!-- Schematic modern coastlines, intentionally simplified. -->
<path class="land" d="M12 18 L101 8 152 30 174 62 156 91 120 94 102 122 70 109 36 83 15 67Z"></path>
<path class="land" d="M150 83 L177 104 188 139 202 170 194 191 180 172 173 142 153 119Z"></path>
<path class="land" d="M178 191 L226 203 267 220 275 237 241 234 208 220 180 213Z"></path>
<path class="land" d="M274 93 L319 78 361 89 377 116 365 151 338 160 313 139 288 132Z"></path>
<path class="land" d="M376 75 L398 67 412 84 405 103 388 108 378 94Z"></path>
<path class="land" d="M420 91 L438 80 449 95 443 112 429 116 418 105Z"></path>
<path class="land" d="M449 133 L463 126 474 136 470 151 457 155 448 145Z"></path>
<path class="land" d="M469 153 L480 149 489 158 482 169 471 167Z"></path>
<!-- Illustrative sea routes. -->
<path class="route" d="M199 181 C235 142 270 111 323 91" marker-end="url(#arrow)"></path>
<path class="route" d="M322 91 C365 78 397 73 419 91" marker-end="url(#arrow)"></path>
<path class="route" d="M419 91 C449 114 453 139 470 151" marker-end="url(#arrow)"></path>
<path class="route" d="M201 181 C255 209 303 224 357 216" marker-end="url(#arrow)"></path>
<text x="52" y="55">MAINLAND</text>
<text x="147" y="152" transform="rotate(-73 147 152)">MALAY PENINSULA</text>
<text x="198" y="217">SUMATRA</text>
<text x="296" y="124">BORNEO</text>
<text x="379" y="59">SULAWESI</text>
<text x="423" y="78">TERNATE</text>
<text x="428" y="119">AMBON</text>
<text x="454" y="129">BANDA</text>
<text x="267" y="247">JAVA</text>
<text x="181" y="174">MALACCA</text>
<text x="349" y="199" class="map-label">Makassar</text>
<circle class="hotspot" data-topic="shipping" cx="201" cy="181" r="5" fill="#63d3c3"></circle>
<circle class="hotspot" data-topic="shipping" cx="357" cy="216" r="5" fill="#63d3c3"></circle>
<circle class="hotspot" data-topic="cultivation" cx="419" cy="91" r="5" fill="#8fbf79"></circle>
<circle class="hotspot" data-topic="cultivation" cx="428" cy="109" r="5" fill="#8fbf79"></circle>
<circle class="hotspot" data-topic="cultivation" cx="454" cy="135" r="5" fill="#8fbf79"></circle>
<circle class="hotspot" data-topic="exchange" cx="321" cy="91" r="5" fill="#e6b85c"></circle>
</svg>
<p class="map-caption">
Redrawn schematic—not a facsimile. The linked source map and essay provide
regional geography and historical orientation; the arrows here are interpretive.
</p>
<details>
<summary>Sources and historical cautions</summary>
<div class="sources">
<p>
<a href="https://www.worldhistory.org/Spice_Islands/" target="_blank" rel="noopener noreferrer">
World History Encyclopedia — Spice Islands: map and overview
</a><br>
<a href="https://www.britannica.com/place/Banda-Islands" target="_blank" rel="noopener noreferrer">
Encyclopaedia Britannica — Banda Islands, conquest and spice trade
</a><br>
<a href="https://www.nationaalarchief.nl/en/what-was-the-dutch-east-india-company-voc" target="_blank" rel="noopener noreferrer">
Dutch National Archives — What was the VOC?
</a>
</p>
<p>
The island is a composite teaching model. Spice crops came from
different islands and landscapes; they should not be read as one
surveyed historical plantation.
</p>
</div>
</details>
</aside>
<div id="controls" class="glass" aria-label="Scene layer controls">
<button class="layer active" data-layer="cultivation" aria-pressed="true">Cultivation</button>
<button class="layer active" data-layer="exchange" aria-pressed="true">Local trade</button>
<button class="layer active" data-layer="shipping" aria-pressed="true">Shipping</button>
<button class="reset" id="reset-camera">Reset view</button>
</div>
<div id="markers"></div>
<div class="legend glass" aria-hidden="true">
<span><i class="farm"></i> Cultivation</span>
<span><i class="trade"></i> Village exchange</span>
<span><i class="sea"></i> Maritime route</span>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x83b2b6);
scene.fog = new THREE.Fog(0x83b2b6, 23, 53);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 0.8, 0);
let yaw = 0.72;
let pitch = 0.55;
let distance = 18.5;
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function updateCamera() {
const horizontal = Math.cos(pitch) * distance;
camera.position.set(
target.x + Math.sin(yaw) * horizontal,
target.y + Math.sin(pitch) * distance,
target.z + Math.cos(yaw) * horizontal
);
camera.lookAt(target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xd6eef1, 0x4b5b35, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe2ad, 3.4);
sun.position.set(-9, 17, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -16;
sun.shadow.camera.right = 16;
sun.shadow.camera.top = 16;
sun.shadow.camera.bottom = -16;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x87bfc6, 0.65);
fill.position.set(10, 6, -12);
scene.add(fill);
const cultivationGroup = new THREE.Group();
const exchangeGroup = new THREE.Group();
const shippingGroup = new THREE.Group();
scene.add(cultivationGroup, exchangeGroup, shippingGroup);
const palette = {
ocean: 0x3f9da2,
oceanLight: 0x5bb4b4,
cliff: 0x94744e,
sand: 0xd4bd80,
grass: 0x65854d,
grassLight: 0x789452,
wood: 0x6f4930,
darkWood: 0x493328,
leaf: 0x2f6c45,
leafLight: 0x4e8b4d,
nutmeg: 0x3d7847,
clove: 0x285c40,
red: 0xb94e3d,
cream: 0xe9d9ad,
teal: 0x65cabd,
gold: 0xe2ad52,
roof: 0x9d5538,
skin: 0xb77952
};
function mat(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.88,
metalness: options.metalness ?? 0,
flatShading: options.flatShading ?? true,
side: options.side ?? THREE.FrontSide,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
});
}
const materials = {
wood: mat(palette.wood),
darkWood: mat(palette.darkWood),
leaf: mat(palette.leaf),
leafLight: mat(palette.leafLight),
nutmeg: mat(palette.nutmeg),
clove: mat(palette.clove),
red: mat(palette.red),
cream: mat(palette.cream),
teal: mat(palette.teal),
gold: mat(palette.gold),
roof: mat(palette.roof),
skin: mat(palette.skin),
cliff: mat(palette.cliff),
sand: mat(palette.sand)
};
function mesh(geometry, material, parent, x = 0, y = 0, z = 0) {
const object = new THREE.Mesh(geometry, material);
object.position.set(x, y, z);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(parent, w, h, d, material, x = 0, y = 0, z = 0) {
return mesh(new THREE.BoxGeometry(w, h, d), material, parent, x, y, z);
}
function cylinder(parent, r1, r2, h, sides, material, x = 0, y = 0, z = 0) {
return mesh(
new THREE.CylinderGeometry(r1, r2, h, sides),
material,
parent,
x,
y,
z
);
}
// ------------------------------------------------------------
// Low-poly ocean
// ------------------------------------------------------------
const oceanGeometry = new THREE.PlaneGeometry(70, 70, 36, 36);
oceanGeometry.rotateX(-Math.PI / 2);
const oceanMaterial = new THREE.MeshPhongMaterial({
color: palette.ocean,
flatShading: true,
shininess: 32,
specular: 0x7bd5cf
});
const ocean = mesh(oceanGeometry, oceanMaterial, scene, 0, 0, 0);
ocean.castShadow = false;
ocean.receiveShadow = false;
const oceanPositions = oceanGeometry.attributes.position;
// A pale, irregular surf ring around the island.
const surfPoints = [];
for (let i = 0; i <= 72; i++) {
const angle = i / 72 * Math.PI * 2;
const radius = 5.15 + 0.22 * Math.sin(angle * 5) + 0.12 * Math.cos(angle * 9);
surfPoints.push(new THREE.Vector3(
Math.cos(angle) * radius,
0.045,
Math.sin(angle) * radius
));
}
const surfGeometry = new THREE.BufferGeometry().setFromPoints(surfPoints);
const surf = new THREE.Line(
surfGeometry,
new THREE.LineBasicMaterial({
color: 0xd8eee1,
transparent: true,
opacity: 0.55
})
);
scene.add(surf);
// ------------------------------------------------------------
// Irregular island with faceted vegetation and beach rings
// ------------------------------------------------------------
const sectors = 24;
const rings = [
{ radius: 1.25, height: 1.48, color: 0x4f7847 },
{ radius: 2.75, height: 1.30, color: 0x65854d },
{ radius: 4.05, height: 0.70, color: 0x8e985a },
{ radius: 4.72, height: 0.10, color: 0xd4bd80 }
];
function radialFactor(angle) {
return 1
+ 0.075 * Math.sin(angle * 3 + 0.7)
+ 0.035 * Math.cos(angle * 7 - 0.4);
}
const positions = [];
const colors = [];
const indices = [];
const color = new THREE.Color();
for (let r = 0; r < rings.length; r++) {
const ring = rings[r];
color.setHex(ring.color);
for (let s = 0; s < sectors; s++) {
const angle = s / sectors * Math.PI * 2;
const radius = ring.radius * radialFactor(angle);
positions.push(
Math.cos(angle) * radius,
ring.height,
Math.sin(angle) * radius
);
colors.push(color.r, color.g, color.b);
}
}
const centerIndex = positions.length / 3;
positions.push(0, 1.52, 0);
color.setHex(0x527d47);
colors.push(color.r, color.g, color.b);
for (let s = 0; s < sectors; s++) {
const next = (s + 1) % sectors;
indices.push(centerIndex, next, s);
}
for (let r = 0; r < rings.length - 1; r++) {
for (let s = 0; s < sectors; s++) {
const next = (s + 1) % sectors;
const a = r * sectors + s;
const b = r * sectors + next;
const c = (r + 1) * sectors + s;
const d = (r + 1) * sectors + next;
indices.push(a, b, c, b, d, c);
}
}
const islandGeometry = new THREE.BufferGeometry();
islandGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
islandGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
islandGeometry.setIndex(indices);
islandGeometry.computeVertexNormals();
const island = mesh(
islandGeometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.96,
flatShading: true
}),
scene
);
// Faceted cliff band below the beach.
const cliffPositions = [];
const cliffIndices = [];
for (let s = 0; s < sectors; s++) {
const angle = s / sectors * Math.PI * 2;
const radius = rings[3].radius * radialFactor(angle);
cliffPositions.push(
Math.cos(angle) * radius,
0.11,
Math.sin(angle) * radius
);
cliffPositions.push(
Math.cos(angle) * (radius * 0.94),
-0.38 - 0.10 * Math.sin(angle * 4),
Math.sin(angle) * (radius * 0.94)
);
}
for (let s = 0; s < sectors; s++) {
const next = (s + 1) % sectors;
const a = s * 2;
const b = s * 2 + 1;
const c = next * 2;
const d = next * 2 + 1;
cliffIndices.push(a, b, c, b, d, c);
}
const cliffGeometry = new THREE.BufferGeometry();
cliffGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(cliffPositions, 3)
);
cliffGeometry.setIndex(cliffIndices);
cliffGeometry.computeVertexNormals();
mesh(cliffGeometry, materials.cliff, scene);
function groundHeight(x, z) {
const distance = Math.hypot(x, z);
if (distance < 1.2) return 1.51;
if (distance < 2.75) {
return THREE.MathUtils.lerp(1.50, 1.30, (distance - 1.2) / 1.55);
}
if (distance < 4.05) {
return THREE.MathUtils.lerp(1.30, 0.70, (distance - 2.75) / 1.30);
}
return THREE.MathUtils.lerp(0.70, 0.12, (distance - 4.05) / 0.67);
}
// Small scattered rocks.
for (let i = 0; i < 19; i++) {
const angle = i * 2.39;
const radius = 3.35 + (i % 4) * 0.24;
const x = Math.cos(angle) * radius;
const z = Math.sin(angle) * radius;
const rock = mesh(
new THREE.DodecahedronGeometry(0.12 + (i % 3) * 0.035, 0),
materials.cliff,
scene,
x,
groundHeight(x, z) + 0.08,
z
);
rock.scale.set(1.3, 0.75, 1);
rock.rotation.set(i * 0.2, i * 0.7, i * 0.1);
}
// ------------------------------------------------------------
// Cultivation: clove and nutmeg groves
// ------------------------------------------------------------
function makeTree(type, scale = 1) {
const group = new THREE.Group();
const isClove = type === "clove";
const trunkHeight = isClove ? 0.64 : 0.57;
const trunk = cylinder(
group,
0.075 * scale,
0.105 * scale,
trunkHeight * scale,
6,
materials.darkWood,
0,
trunkHeight * scale * 0.5,
0
);
trunk.rotation.z = (Math.random() - 0.5) * 0.08;
if (isClove) {
const crown = mesh(
new THREE.IcosahedronGeometry(0.46 * scale, 0),
materials.clove,
group,
0,
0.82 * scale,
0
);
crown.scale.set(0.82, 1.25, 0.82);
const flowers = [
[0.27, 0.76, 0.18],
[-0.25, 0.86, 0.05],
[0.04, 0.69, -0.27],
[0.05, 1.03, 0.12]
];
flowers.forEach(([x, y, z]) => {
const flower = mesh(
new THREE.IcosahedronGeometry(0.065 * scale, 0),
materials.red,
group,
x * scale,
y * scale,
z * scale
);
flower.scale.set(0.8, 1.2, 0.8);
});
} else {
const crownMaterial = materials.nutmeg;
const offsets = [
[0, 0.85, 0, 0.55],
[-0.24, 0.73, 0.08, 0.38],
[0.25, 0.76, 0.02, 0.39]
];
offsets.forEach(([x, y, z, radius], index) => {
const crown = mesh(
new THREE.DodecahedronGeometry(radius * scale, 0),
index === 0 ? crownMaterial : materials.leafLight,
group,
x * scale,
y * scale,
z * scale
);
crown.scale.set(1.15, 0.86, 1.05);
crown.rotation.y = index * 0.9;
});
}
return group;
}
function plantTree(parent, type, x, z, scale = 1) {
const tree = makeTree(type, scale);
tree.position.set(x, groundHeight(x, z), z);
tree.rotation.y = (x * 7.1 + z * 3.7) % Math.PI;
parent.add(tree);
return tree;
}
const farm = new THREE.Group();
farm.position.set(-2.05, groundHeight(-2.05, -0.65), -0.65);
farm.rotation.y = -0.15;
cultivationGroup.add(farm);
// Terrace and planting beds.
box(farm, 2.55, 0.16, 1.65, mat(0x74563b), 0, 0.06, 0);
for (let row = 0; row < 4; row++) {
const bed = box(
farm,
2.25,
0.13,
0.22,
mat(0x584333),
0,
0.18,
-0.58 + row * 0.38
);
bed.rotation.y = 0.035 * row;
}
for (let i = 0; i < 7; i++) {
plantTree(farm, "clove", -0.93 + i * 0.31, -0.62, 0.72);
}
for (let i = 0; i < 6; i++) {
plantTree(farm, "nutmeg", -0.9 + i * 0.36, 0.54, 0.72);
}
// Farm hut.
const farmHut = new THREE.Group();
farmHut.position.set(-1.18, 0.17, -1.12);
farmHut.rotation.y = 0.15;
farm.add(farmHut);
box(farmHut, 0.85, 0.65, 0.72, materials.wood, 0, 0.34, 0);
const farmRoof = mesh(
new THREE.ConeGeometry(0.76, 0.55, 4),
materials.roof,
farmHut,
0,
0.91,
0
);
farmRoof.rotation.y = Math.PI / 4;
// Drying trays and a small barrel.
for (let i = 0; i < 3; i++) {
cylinder(
farm,
0.19,
0.19,
0.07,
8,
materials.cream,
0.95,
0.25,
-0.4 + i * 0.38
);
}
cylinder(farm, 0.22, 0.18, 0.42, 8, materials.gold, 1.02, 0.30, 0.83);
// ------------------------------------------------------------
// Local village and exchange market
// ------------------------------------------------------------
function makeHouse(parent, x, z, scale = 1, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
parent.add(group);
for (const sx of [-0.38, 0.38]) {
for (const sz of [-0.32, 0.32]) {
box(group, 0.11, 0.65, 0.11, materials.darkWood, sx, 0.34, sz);
}
}
box(group, 0.9, 0.12, 0.78, materials.darkWood, 0, 0.70, 0);
box(group, 0.74, 0.46, 0.64, materials.wood, 0, 0.95, 0);
const roof = mesh(
new THREE.ConeGeometry(0.85, 0.58, 4),
materials.roof,
group,
0,
1.46,
0
);
roof.rotation.y = Math.PI / 4;
roof.scale.z = 0.95;
box(group, 0.24, 0.32, 0.025, materials.darkWood, 0, 0.93, 0.335);
return group;
}
const village = new THREE.Group();
village.position.set(0.85, groundHeight(0.85, -1.15), -1.15);
exchangeGroup.add(village);
makeHouse(village, -0.75, 0.15, 0.68, 0.16);
makeHouse(village, 0.42, 0.05, 0.74, -0.28);
makeHouse(village, 0.12, -0.75, 0.58, 0.55);
// Market canopy.
const canopy = new THREE.Group();
canopy.position.set(-0.05, 0, 0.72);
village.add(canopy);
for (const x of [-0.56, 0.56]) {
for (const z of [-0.27, 0.27]) {
box(canopy, 0.08, 1.05, 0.08, materials.darkWood, x, 0.53, z);
}
}
box(canopy, 1.32, 0.10, 0.76, materials.cream, 0, 1.08, 0);
box(canopy, 1.15, 0.12, 0.48, materials.wood, 0, 0.43, 0);
// Sacks, bowls and spice baskets.
for (let i = 0; i < 7; i++) {
const sack = mesh(
new THREE.IcosahedronGeometry(0.16, 0),
i % 3 === 0 ? materials.gold : materials.cream,
canopy,
-0.42 + i * 0.14,
0.60 + (i % 2) * 0.035,
-0.08 + (i % 3) * 0.08
);
sack.scale.set(0.85, 1.25, 0.85);
}
// Small human figures for scale.
function makePerson(parent, x, z, color, scale = 1) {
const person = new THREE.Group();
person.position.set(x, 0, z);
person.scale.setScalar(scale);
cylinder(person, 0.09, 0.13, 0.38, 6, mat(color), 0, 0.2, 0);
mesh(new THREE.IcosahedronGeometry(0.105, 0), materials.skin, person, 0, 0.48, 0);
box(person, 0.12, 0.05, 0.12, materials.darkWood, -0.055, 0.04, 0);
box(person, 0.12, 0.05, 0.12, materials.darkWood, 0.055, 0.04, 0);
parent.add(person);
}
makePerson(village, -0.62, 0.36, 0xa7583f, 0.82);
makePerson(village, 0.35, 0.78, 0x486e7c, 0.78);
makePerson(village, 0.72, -0.38, 0xd1a35a, 0.74);
// ------------------------------------------------------------
// Paths and exchange pulses
// ------------------------------------------------------------
const exchangeCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.65, 1.40, -0.28),
new THREE.Vector3(-0.85, 1.46, -0.46),
new THREE.Vector3(-0.10, 1.48, -0.60),
new THREE.Vector3(0.62, 1.48, -0.62),
new THREE.Vector3(1.32, 1.30, -0.24),
new THREE.Vector3(2.32, 0.98, 0.48),
new THREE.Vector3(3.28, 0.72, 1.68)
]);
const exchangePath = mesh(
new THREE.TubeGeometry(exchangeCurve, 70, 0.065, 5, false),
materials.gold,
exchangeGroup
);
exchangePath.castShadow = false;
const exchangePulses = [];
for (let i = 0; i < 7; i++) {
const pulse = mesh(
new THREE.IcosahedronGeometry(0.075, 0),
materials.teal,
exchangeGroup
);
exchangePulses.push(pulse);
}
// ------------------------------------------------------------
// Port, warehouse, cargo and dock
// ------------------------------------------------------------
const port = new THREE.Group();
exchangeGroup.add(port);
const warehouse = new THREE.Group();
warehouse.position.set(3.18, groundHeight(3.18, 1.48), 1.48);
warehouse.rotation.y = -0.42;
port.add(warehouse);
box(warehouse, 1.55, 1.05, 1.25, materials.wood, 0, 0.54, 0);
const warehouseRoof = mesh(
new THREE.ConeGeometry(1.32, 0.68, 4),
materials.roof,
warehouse,
0,
1.40,
0
);
warehouseRoof.rotation.y = Math.PI / 4;
box(warehouse, 0.34, 0.60, 0.04, materials.darkWood, 0.25, 0.31, 0.64);
// Dock along a diagonal toward the sea.
const dock = new THREE.Group();
const dockStart = new THREE.Vector3(3.72, 0.55, 2.05);
const dockEnd = new THREE.Vector3(6.35, 0.28, 3.12);
const dockDirection = dockEnd.clone().sub(dockStart);
const dockAngle = Math.atan2(dockDirection.z, dockDirection.x);
const dockLength = dockDirection.length();
dock.position.copy(dockStart).add(dockEnd).multiplyScalar(0.5);
dock.rotation.y = -dockAngle;
shippingGroup.add(dock);
const plankCount = 14;
for (let i = 0; i < plankCount; i++) {
const x = -dockLength / 2 + (i + 0.5) * dockLength / plankCount;
box(dock, dockLength / plankCount * 0.86, 0.12, 1.03, materials.wood, x, 0, 0);
}
for (let i = 0; i < 5; i++) {
const x = -dockLength / 2 + 0.35 + i * (dockLength - 0.7) / 4;
for (const z of [-0.42, 0.42]) {
cylinder(dock, 0.09, 0.12, 1.2, 6, materials.darkWood, x, -0.38, z);
}
}
// Cargo on the dock.
for (let i = 0; i < 6; i++) {
const crate = box(
shippingGroup,
0.42,
0.36,
0.42,
i % 2 ? materials.gold : materials.wood,
4.35 + (i % 3) * 0.47,
0.43 + (i > 3 ? 0.38 : 0),
2.30 + Math.floor(i / 3) * 0.32
);
crate.rotation.y = i * 0.21;
}
// ------------------------------------------------------------
// Ships and shipping route
// ------------------------------------------------------------
function makeShip(scale = 1) {
const ship = new THREE.Group();
ship.scale.setScalar(scale);
const hull = mesh(
new THREE.CylinderGeometry(0.72, 0.45, 2.55, 6),
materials.darkWood,
ship,
0,
0.25,
0
);
hull.rotation.z = Math.PI / 2;
hull.scale.z = 0.58;
box(ship, 1.75, 0.13, 0.75, materials.wood, 0, 0.43, 0);
box(ship, 0.68, 0.50, 0.58, materials.gold, -0.47, 0.70, 0);
const mast = cylinder(ship, 0.035, 0.055, 1.95, 6, materials.darkWood, 0.12, 1.45, 0);
mast.rotation.z = 0.03;
const boom = cylinder(ship, 0.028, 0.035, 1.05, 6, materials.darkWood, 0.12, 1.67, 0);
boom.rotation.x = Math.PI / 2;
const sailGeometry = new THREE.BufferGeometry();
sailGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
0.16, 2.20, 0,
0.16, 0.83, 0,
0.16, 1.55, 0.88
], 3)
);
sailGeometry.computeVertexNormals();
const sailMaterial = mat(palette.cream, {
side: THREE.DoubleSide,
roughness: 1
});
const sail = mesh(sailGeometry, sailMaterial, ship);
sail.userData.isSail = true;
return ship;
}
const shippingCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(5.90, 0.13, 2.95),
new THREE.Vector3(8.20, 0.13, 4.35),
new THREE.Vector3(11.20, 0.13, 3.10),
new THREE.Vector3(14.10, 0.13, 0.10),
new THREE.Vector3(16.20, 0.13, -4.20)
]);
const routeGeometry = new THREE.BufferGeometry().setFromPoints(
shippingCurve.getPoints(120)
);
const route = new THREE.Line(
routeGeometry,
new THREE.LineDashedMaterial({
color: 0x8fe1d2,
dashSize: 0.46,
gapSize: 0.30,
transparent: true,
opacity: 0.65
})
);
route.computeLineDistances();
shippingGroup.add(route);
const ship = makeShip(0.78);
shippingGroup.add(ship);
// Local outrigger canoe.
function makeCanoe() {
const canoe = new THREE.Group();
const hull = mesh(
new THREE.CylinderGeometry(0.27, 0.16, 1.65, 7),
materials.wood,
canoe,
0,
0.16,
0
);
hull.rotation.z = Math.PI / 2;
hull.scale.z = 0.5;
box(canoe, 1.85, 0.055, 0.055, materials.darkWood, 0, 0.25, 0.48);
box(canoe, 1.85, 0.055, 0.055, materials.darkWood, 0, 0.25, -0.48);
cylinder(canoe, 0.035, 0.035, 1.15, 6, materials.darkWood, 0.1, 0.55, 0);
return canoe;
}
const canoe = makeCanoe();
canoe.position.set(6.62, 0.08, 3.42);
canoe.rotation.y = -0.72;
shippingGroup.add(canoe);
// ------------------------------------------------------------
// Marker overlays
// ------------------------------------------------------------
const markerData = [
{ topic: "cultivation", label: "Spice groves", position: new THREE.Vector3(-2.05, 2.55, -0.65) },
{ topic: "exchange", label: "Village market", position: new THREE.Vector3(0.85, 2.78, -1.15) },
{ topic: "shipping", label: "Harbor", position: new THREE.Vector3(3.35, 2.05, 1.65) },
{ topic: "shipping", label: "Shipping route", position: new THREE.Vector3(8.25, 2.10, 4.35) },
{ topic: "coercion", label: "Read the context", position: new THREE.Vector3(1.0, 3.15, 2.5) }
];
const markerElements = [];
markerData.forEach((data) => {
const button = document.createElement("button");
button.className = "marker";
button.dataset.topic = data.topic;
button.textContent = data.label;
button.addEventListener("click", () => setTopic(data.topic));
document.querySelector("#markers").appendChild(button);
markerElements.push({ element: button, position: data.position });
});
// ------------------------------------------------------------
// Editorial content
// ------------------------------------------------------------
const topics = {
overview: {
kicker: "Composite island · Maluku, c. 1600–1630",
title: "A garden connected to the sea",
body:
"Cloves and nutmeg moved through established local and regional networks long before colonial rule. This compressed island links cultivation, village exchange and maritime transport; it is not a literal reconstruction of one plantation.",
facts: [
["Cloves", "Aromatic flower buds; especially associated with Ambon and Ternate."],
["Nutmeg", "The seed and mace of Myristica fragrans; especially linked with Banda."],
["Seasonal wind", "Monsoons shaped sailing schedules, risk and bargaining power."],
["Many actors", "Malay, Chinese, Arab, Gujarati, Portuguese, Dutch and island communities traded here."]
]
},
cultivation: {
kicker: "Layer 1 · Cultivation",
title: "Knowledge, labor and planted landscapes",
body:
"Clove and nutmeg were local crops requiring ecological knowledge, skilled propagation and sustained labor. The scene separates the two crops for clarity, although gardens, forests and trading estates overlapped in complex ways.",
facts: [
["Propagation", "Seed viability, nursery care and transplanting were crucial."],
["Terroir", "Soil, rainfall, elevation and access shaped where crops thrived."],
["Labor", "Family labor, specialists, tenants and coerced workers all appear."],
["Landscape change", "Plantations could displace forests and existing cultivation."]
]
},
exchange: {
kicker: "Layer 2 · Local exchange",
title: "The village was a trading center",
body:
"Farm produce moved through village markets alongside fish, sago, food, textiles, ceramics and household goods. Exchange was organized by local kin, guilds, rulers and port institutions—not simply by European merchants.",
facts: [
["Market", "A point for weighing, sorting, bargaining and redistribution."],
["Standards", "Measures, quality expectations and credit structured transactions."],
["Connections", "Village markets linked inland producers to coastal shipping."],
["Agency", "Communities negotiated prices, access and obligations."]
]
},
shipping: {
kicker: "Layer 3 · Shipping",
title: "Seasonal winds linked island and region",
body:
"Sailing knowledge connected Maluku to Java, Sulawesi, the Malay Peninsula and wider Asian routes. The route line represents a maritime network, not one fixed itinerary: ships carried spices, but also people, textiles, metals, food and news.",
facts: [
["Monsoons", "Seasonal winds made timing, ports and cargo planning strategic."],
["Local craft", "Canoes and regional vessels linked nearby shores."],
["Ocean ships", "Larger vessels connected ports across Maritime Southeast Asia."],
["Competition", "Ports and rulers negotiated access among multiple trading powers."]
]
},
coercion: {
kicker: "Context · Colonial monopoly and violence",
title: "The trade system was also coercive",
body:
"After Dutch expansion, the VOC imposed a monopoly over cloves and nutmeg. Cultivation contracts, compulsory deliveries, taxes and military force reshaped island economies. The Banda conquest of 1621 included a massacre, enslavement and forced relocation.",
facts: [
["Contract", "Cultivators could be required to plant and deliver specified crops."],
["Monopoly", "The VOC restricted trade to channels and prices it controlled."],
["Banda 1621", "Resistance to Dutch rule was met with extreme violence."],
["Aftermath", "Forced cultivation and depopulation continued across islands."]
]
}
};
const eras = {
before: {
text:
"Before 1600, island communities already cultivated, traded and governed the spice trade. Malay, Chinese, Arab, Gujarati and other merchants participated in broad regional networks; European arrival did not create exchange from nothing.",
warning: false
},
during: {
text:
"Between Dutch expansion and the conquest of Banda, rivalry intensified. The VOC used contracts, blockades and military force to gain control of production and shipping. Local rulers and communities resisted in different ways.",
warning: false
},
after: {
text:
"After the 1621 Banda conquest, the VOC tightened its monopoly. The Banda Islands were depopulated; survivors were relocated and nutmeg cultivation was reorganized under coercion. Ambon also experienced forced clove cultivation.",
warning: true
}
};
function setTopic(topic) {
const data = topics[topic];
if (!data) return;
document.querySelector("#topic-kicker").textContent = data.kicker;
document.querySelector("#topic-title").textContent = data.title;
document.querySelector("#topic-body").textContent = data.body;
const facts = document.querySelector("#facts");
facts.replaceChildren();
data.facts.forEach(([heading, text]) => {
const fact = document.createElement("div");
fact.className = "fact";
const strong = document.createElement("strong");
strong.textContent = heading;
const span = document.createElement("span");
span.textContent = text;
fact.append(strong, span);
facts.append(fact);
});
document.querySelectorAll("[data-topic]").forEach((element) => {
element.classList.toggle("active", element.dataset.topic === topic);
});
}
function setEra(era) {
const data = eras[era];
if (!data) return;
document.querySelectorAll("[data-era]").forEach((element) => {
element.classList.toggle("active", element.dataset.era === era);
});
const note = document.querySelector("#era-note");
note.textContent = data.text;
note.classList.toggle("warning", data.warning);
}
document.querySelectorAll(".topic-tabs [data-topic]").forEach((button) => {
button.addEventListener("click", () => setTopic(button.dataset.topic));
});
document.querySelectorAll("#regional-map [data-topic]").forEach((element) => {
element.addEventListener("click", () => setTopic(element.dataset.topic));
element.setAttribute("tabindex", "0");
element.setAttribute("role", "button");
element.addEventListener("keydown", (event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
setTopic(element.dataset.topic);
}
});
});
document.querySelectorAll("[data-era]").forEach((button) => {
button.addEventListener("click", () => setEra(button.dataset.era));
});
// Layer visibility.
const layerGroups = {
cultivation: cultivationGroup,
exchange: exchangeGroup,
shipping: shippingGroup
};
document.querySelectorAll("[data-layer]").forEach((button) => {
button.addEventListener("click", () => {
const key = button.dataset.layer;
const group = layerGroups[key];
group.visible = !group.visible;
button.classList.toggle("active", group.visible);
button.setAttribute("aria-pressed", String(group.visible));
});
});
// ------------------------------------------------------------
// Custom camera controls — no addons
// ------------------------------------------------------------
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.classList.add("dragging");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
yaw -= dx * 0.006;
pitch = THREE.MathUtils.clamp(pitch + dy * 0.004, 0.24, 1.18);
updateCamera();
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
distance = THREE.MathUtils.clamp(
distance + event.deltaY * 0.012,
9.5,
27
);
updateCamera();
}, { passive: false });
document.querySelector("#reset-camera").addEventListener("click", () => {
yaw = 0.72;
pitch = 0.55;
distance = 18.5;
target.set(0, 0.8, 0);
updateCamera();
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
function resize() {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
const projected = new THREE.Vector3();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const time = reducedMotion ? 0 : elapsed;
// Gentle low-poly water movement.
for (let i = 0; i < oceanPositions.count; i++) {
const x = oceanPositions.getX(i);
const z = oceanPositions.getZ(i);
oceanPositions.setY(
i,
Math.sin(x * 0.48 + time * 0.72) * 0.032 +
Math.cos(z * 0.39 - time * 0.57) * 0.025
);
}
oceanPositions.needsUpdate = true;
surf.position.y = Math.sin(time * 0.9) * 0.014;
// Moving ship along the route.
const shipT = (time * 0.018) % 1;
const shipPoint = shippingCurve.getPointAt(shipT);
const shipTangent = shippingCurve.getTangentAt(shipT);
ship.position.copy(shipPoint);
ship.position.y += Math.sin(time * 1.8) * 0.025;
ship.rotation.y = Math.atan2(shipTangent.x, shipTangent.z) + Math.PI / 2;
ship.rotation.z = Math.sin(time * 1.25) * 0.012;
// Exchange pulses.
exchangePulses.forEach((pulse, index) => {
const t = (time * 0.095 + index / exchangePulses.length) % 1;
pulse.position.copy(exchangeCurve.getPointAt(t));
pulse.position.y += 0.055;
});
canoe.position.y = 0.08 + Math.sin(time * 1.7) * 0.018;
canoe.rotation.z = Math.sin(time * 1.3) * 0.018;
// Project HTML markers over the 3D scene.
markerElements.forEach(({ element, position }) => {
projected.copy(position).project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "flex" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
});
renderer.render(scene, camera);
}
setTopic("overview");
setEra("before");
animate();
loading.classList.add("hidden");
</script>
</body>
</html>
```