Prompt specification
Build or customize the Three.js 3D scene "Archipelago colonization story scene" 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: Archipelago colonization story scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/archipelago-colonization-story-scene-x0903
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a fictional voxel archipelago being colonized in sequence. Start with a larger source island containing individuals marked by several visible variants, then show a small founder group reaching a second island and a later subset reaching a third. Keep each founder's ancestry marker visible during travel, and update the variant counts after each arrival. Use simple island vegetation and distinct landing spots to make the sequence readable. The later populations should reflect the sampled founders rather than magically recovering every source variant. Label the entire colonization story as invented and keep the inheritance rules deliberately simple.
Working Three.js Starter (archipelago-colonization-story-scene-x0903):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Inherited Archipelago — Invented Voxel Story</title>
<style>
:root {
--ink: #effbf7;
--muted: #a6c4c7;
--panel: rgba(8, 28, 37, 0.84);
--panel-border: rgba(166, 226, 220, 0.22);
--sun: #f5c451;
--tide: #43d9cf;
--moss: #92cf68;
--ember: #f0786c;
--north: #ffd166;
--reef: #5bc0eb;
--cinder: #ff7b9c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #071d2b;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.ui {
position: fixed;
z-index: 10;
pointer-events: none;
}
.panel {
background: var(--panel);
border: 1px solid var(--panel-border);
border-radius: 15px;
box-shadow: 0 15px 45px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#masthead {
top: 18px;
left: 18px;
width: min(420px, calc(100vw - 36px));
padding: 17px 19px 16px;
}
.eyebrow {
margin-bottom: 7px;
color: #81d9d2;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 34px);
line-height: 1.04;
letter-spacing: -0.035em;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.fiction-badge {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 13px;
padding: 7px 10px;
border: 1px solid rgba(255, 209, 102, 0.44);
border-radius: 999px;
background: rgba(255, 209, 102, 0.11);
color: #ffe29a;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.fiction-badge::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--sun);
content: "";
box-shadow: 0 0 12px rgba(245, 196, 81, 0.8);
}
#ledger {
top: 18px;
right: 18px;
width: 308px;
padding: 14px;
}
.ledger-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 9px;
color: #cce6e5;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.live-dot {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 5px;
border-radius: 50%;
background: #6ee7b7;
box-shadow: 0 0 10px rgba(110, 231, 183, 0.65);
}
.census {
padding: 10px 0;
border-top: 1px solid rgba(180, 220, 220, 0.12);
}
.census:first-of-type {
border-top: 0;
}
.census-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
margin-bottom: 7px;
}
.census-name {
font-size: 11px;
font-weight: 800;
letter-spacing: 0.06em;
}
.census-meta {
color: var(--muted);
font-size: 10px;
text-align: right;
}
.counts {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
}
.variant-count {
display: flex;
align-items: center;
justify-content: center;
gap: 5px;
min-height: 26px;
border: 1px solid rgba(180, 220, 220, 0.11);
border-radius: 7px;
background: rgba(255, 255, 255, 0.035);
color: #e9f7f5;
font-size: 11px;
font-variant-numeric: tabular-nums;
}
.variant-count i {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 2px;
box-shadow: 0 0 7px currentColor;
}
.variant-count.pending {
color: #789397;
}
#rules {
left: 18px;
bottom: 104px;
width: min(390px, calc(100vw - 36px));
padding: 14px 16px;
}
.rules-title {
margin-bottom: 7px;
color: #dff5f2;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.rules-copy {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.legend-row {
display: flex;
flex-wrap: wrap;
gap: 7px 13px;
margin: 9px 0 8px;
color: #dbeeea;
font-size: 10px;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 5px;
}
.legend-dot {
width: 9px;
height: 9px;
border-radius: 2px;
}
.ancestry-row {
display: flex;
flex-wrap: wrap;
gap: 8px 13px;
margin-top: 7px;
color: #bdd5d5;
font-size: 10px;
}
.shape {
display: inline-block;
margin-right: 4px;
color: white;
font-size: 12px;
line-height: 1;
text-shadow: 0 0 8px currentColor;
}
#transport {
bottom: 18px;
left: 50%;
width: min(760px, calc(100vw - 36px));
transform: translateX(-50%);
padding: 13px 15px 12px;
}
.transport-top {
display: flex;
align-items: center;
gap: 12px;
}
.play-button,
.small-button {
pointer-events: auto;
border: 1px solid rgba(167, 226, 219, 0.22);
border-radius: 9px;
background: rgba(255, 255, 255, 0.055);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 800;
cursor: pointer;
transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.play-button:hover,
.small-button:hover {
border-color: rgba(127, 229, 217, 0.55);
background: rgba(81, 199, 187, 0.13);
transform: translateY(-1px);
}
.play-button {
min-width: 102px;
padding: 10px 13px;
background: #183f46;
}
.small-button {
padding: 9px 10px;
}
#story-status {
flex: 1;
min-width: 0;
}
#story-status strong {
display: block;
margin-bottom: 2px;
color: #ecfffb;
font-size: 12px;
letter-spacing: 0.02em;
}
#story-status span {
display: block;
overflow: hidden;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
text-overflow: ellipsis;
white-space: nowrap;
}
.progress-track {
position: relative;
height: 5px;
margin-top: 12px;
overflow: hidden;
border-radius: 999px;
background: rgba(255, 255, 255, 0.09);
}
#progress-fill {
position: absolute;
inset: 0 auto 0 0;
width: 0;
border-radius: inherit;
background: linear-gradient(90deg, var(--sun), var(--tide), var(--moss));
box-shadow: 0 0 12px rgba(67, 217, 207, 0.45);
}
.stages {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 5px;
margin-top: 8px;
}
.stage {
min-width: 0;
color: #66868b;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.08em;
text-align: center;
text-transform: uppercase;
transition: color 180ms ease;
}
.stage.active {
color: #dffbf7;
}
.stage.completed {
color: #67bdb6;
}
#camera-hint {
right: 18px;
bottom: 18px;
padding: 9px 11px;
color: #a8c3c5;
font-size: 9px;
letter-spacing: 0.04em;
}
#world-labels {
position: fixed;
inset: 0;
z-index: 5;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
min-width: max-content;
padding: 6px 9px;
transform: translate(-50%, -100%);
border: 1px solid rgba(198, 238, 232, 0.23);
border-radius: 8px;
background: rgba(5, 25, 34, 0.77);
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
color: #e9f9f5;
font-size: 9px;
line-height: 1.25;
text-align: center;
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px);
}
.world-label b {
display: block;
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.world-label span {
color: #9ebfc0;
font-size: 8px;
}
.world-label.landing {
padding: 4px 7px;
border-radius: 999px;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.06em;
}
.world-label.route {
border-color: rgba(94, 210, 205, 0.25);
background: rgba(9, 46, 56, 0.65);
color: #a7efea;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
@media (max-width: 900px) {
#ledger {
top: auto;
right: 12px;
bottom: 102px;
width: 260px;
}
#rules {
display: none;
}
#camera-hint {
display: none;
}
#masthead {
top: 12px;
left: 12px;
width: min(370px, calc(100vw - 24px));
}
#transport {
bottom: 12px;
width: calc(100vw - 24px);
}
}
@media (max-width: 600px) {
#ledger {
display: none;
}
#masthead {
padding: 13px 14px;
}
#masthead .subtitle {
display: none;
}
.fiction-badge {
margin-top: 9px;
font-size: 8px;
}
#story-status span {
display: none;
}
.transport-top {
gap: 7px;
}
.small-button {
padding: 9px 8px;
}
.stage {
font-size: 0;
}
.stage::after {
display: block;
width: 5px;
height: 5px;
margin: auto;
border-radius: 50%;
background: currentColor;
content: "";
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="world-labels"></div>
<header id="masthead" class="ui panel">
<div class="eyebrow">A fictional migration in three acts</div>
<h1>The Inherited Archipelago</h1>
<p class="subtitle">
A large source island sends a small founder sample to a middle island.
Later, only a subset of that middle colony reaches the final shore.
</p>
<div class="fiction-badge">Invented fiction · not real ancestry</div>
</header>
<aside id="ledger" class="ui panel" aria-live="polite">
<div class="ledger-title">
<span><span class="live-dot"></span>Current variant censuses</span>
<span>Sun · Tide · Moss · Ember</span>
</div>
<div class="census">
<div class="census-head">
<span class="census-name">SOURCE ISLAND</span>
<span id="source-meta" class="census-meta">12 present</span>
</div>
<div id="source-counts" class="counts"></div>
</div>
<div class="census">
<div class="census-head">
<span class="census-name">FIRST COLONY</span>
<span id="first-meta" class="census-meta">awaiting arrival</span>
</div>
<div id="first-counts" class="counts"></div>
</div>
<div class="census">
<div class="census-head">
<span class="census-name">LATE COLONY</span>
<span id="late-meta" class="census-meta">awaiting arrival</span>
</div>
<div id="late-counts" class="counts"></div>
</div>
</aside>
<aside id="rules" class="ui panel">
<div class="rules-title">Deliberately simple inheritance rules</div>
<div class="legend-row" aria-label="Visible variants">
<span class="legend-item"><i class="legend-dot" style="background:var(--sun)"></i>Sun</span>
<span class="legend-item"><i class="legend-dot" style="background:var(--tide)"></i>Tide</span>
<span class="legend-item"><i class="legend-dot" style="background:var(--moss)"></i>Moss</span>
<span class="legend-item"><i class="legend-dot" style="background:var(--ember)"></i>Ember</span>
</div>
<p class="rules-copy">
Body color is the visible variant. Overhead shape is ancestry and remains
attached during travel. A colony receives exactly the sampled founders:
no mutation, no return migration, and no recovery of a missing variant.
</p>
<div class="ancestry-row">
<span class="legend-item"><b class="shape" style="color:var(--north)">■</b>North ancestry</span>
<span class="legend-item"><b class="shape" style="color:var(--reef)">●</b>Reef ancestry</span>
<span class="legend-item"><b class="shape" style="color:var(--cinder)">▲</b>Cinder ancestry</span>
</div>
</aside>
<section id="transport" class="ui panel">
<div class="transport-top">
<button id="play" class="play-button" type="button">Ⅱ Pause</button>
<button id="reset" class="small-button" type="button">↺ Reset</button>
<button id="overview" class="small-button" type="button">Overview</button>
<div id="story-status" aria-live="polite">
<strong id="story-title">01 / Source pool</strong>
<span id="story-copy">Twelve individuals occupy the large home island.</span>
</div>
</div>
<div class="progress-track"><div id="progress-fill"></div></div>
<div class="stages">
<div class="stage active">Source</div>
<div class="stage">Sample</div>
<div class="stage">Crossing</div>
<div class="stage">Colony</div>
<div class="stage">Subset</div>
<div class="stage">Arrival</div>
</div>
</section>
<div id="camera-hint" class="ui panel">
Drag: orbit · Shift/right-drag: pan · Wheel: zoom
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Story and UI state
// -------------------------------------------------------------------------
const VARIANTS = [
{ key: "Sun", color: 0xf5c451, css: "#f5c451" },
{ key: "Tide", color: 0x43d9cf, css: "#43d9cf" },
{ key: "Moss", color: 0x92cf68, css: "#92cf68" },
{ key: "Ember", color: 0xf0786c, css: "#f0786c" }
];
const ANCESTRIES = {
North: { color: 0xffd166, css: "#ffd166", shape: "square" },
Reef: { color: 0x5bc0eb, css: "#5bc0eb", shape: "circle" },
Cinder: { color: 0xff7b9c, css: "#ff7b9c", shape: "triangle" }
};
const SOURCE_COUNTS = [4, 3, 3, 2];
const FIRST_COUNTS = [2, 1, 1, 0];
const LATE_COUNTS = [0, 1, 1, 0];
const SOURCE_REMAINING = [2, 2, 2, 2];
const TIME = {
sourceEnd: 1.4,
selectionEnd: 3.0,
firstArrival: 8.2,
secondDeparture: 10.5,
lateArrival: 15.8,
total: 18.0
};
let storyTime = 0;
let playing = true;
let lastLedgerKey = "";
let lastStatusKey = "";
let cameraMode = "story";
const playButton = document.querySelector("#play");
const resetButton = document.querySelector("#reset");
const overviewButton = document.querySelector("#overview");
const progressFill = document.querySelector("#progress-fill");
const storyTitle = document.querySelector("#story-title");
const storyCopy = document.querySelector("#story-copy");
const stageElements = [...document.querySelectorAll(".stage")];
// -------------------------------------------------------------------------
// Three.js core scene
// -------------------------------------------------------------------------
const container = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
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.12;
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071d2b);
scene.fog = new THREE.Fog(0x071d2b, 34, 76);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
130
);
const hemisphere = new THREE.HemisphereLight(0xc9f4ff, 0x273b2a, 2.15);
scene.add(hemisphere);
const sunLight = new THREE.DirectionalLight(0xffe4b0, 3.15);
sunLight.position.set(-8, 18, 11);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -26;
sunLight.shadow.camera.right = 26;
sunLight.shadow.camera.top = 20;
sunLight.shadow.camera.bottom = -20;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 55;
sunLight.shadow.bias = -0.00045;
scene.add(sunLight);
const rimLight = new THREE.DirectionalLight(0x69d9e7, 1.2);
rimLight.position.set(12, 8, -14);
scene.add(rimLight);
const sea = new THREE.Mesh(
new THREE.PlaneGeometry(68, 42),
new THREE.MeshStandardMaterial({
color: 0x0b6170,
roughness: 0.6,
metalness: 0.12
})
);
sea.rotation.x = -Math.PI / 2;
sea.position.y = -0.52;
sea.receiveShadow = true;
scene.add(sea);
// A moving field of small voxel-like wave streaks.
const waveMaterial = new THREE.MeshBasicMaterial({
color: 0x8be0df,
transparent: true,
opacity: 0.17,
depthWrite: false
});
const waveGeometry = new THREE.BoxGeometry(1, 0.025, 0.055);
const waves = [];
for (let i = 0; i < 42; i++) {
const wave = new THREE.Mesh(waveGeometry, waveMaterial.clone());
const x = (hash(i * 7.3) - 0.5) * 62;
const z = (hash(i * 13.1 + 3) - 0.5) * 35;
wave.position.set(x, -0.485, z);
wave.rotation.y = (hash(i * 4.9) - 0.5) * 0.4;
wave.scale.x = 0.7 + hash(i * 2.4) * 2.2;
wave.userData.baseX = x;
wave.userData.phase = hash(i * 8.2) * Math.PI * 2;
scene.add(wave);
waves.push(wave);
}
// -------------------------------------------------------------------------
// Voxel islands and deterministic terrain helpers
// -------------------------------------------------------------------------
const islands = [
{
id: "source",
x: -8.5,
z: 0.4,
rx: 4.6,
rz: 3.3,
scale: 1.0
},
{
id: "first",
x: 1.0,
z: 0.0,
rx: 3.5,
rz: 2.8,
scale: 0.78
},
{
id: "late",
x: 10.6,
z: 0.4,
rx: 2.8,
rz: 2.3,
scale: 0.62
}
];
const sourceIsland = islands[0];
const firstIsland = islands[1];
const lateIsland = islands[2];
function hash(n) {
const x = Math.sin(n * 127.1 + 311.7) * 43758.5453123;
return x - Math.floor(x);
}
function terrainHeight(island, localX, localZ) {
const d = Math.sqrt(
(localX / island.rx) ** 2 +
(localZ / island.rz) ** 2
);
if (d < 0.38) return 1.55;
if (d < 0.68) return 1.20;
if (d < 0.88) return 0.78;
return 0.42;
}
function isIslandCell(island, gx, gz) {
const d = Math.sqrt(
(gx / island.rx) ** 2 +
(gz / island.rz) ** 2
);
const edge = 0.94 + hash(gx * 9.7 + gz * 6.1 + island.x) * 0.1;
return d < edge;
}
const islandGeometry = new THREE.BoxGeometry(0.985, 1, 0.985);
const grassTop = new THREE.MeshStandardMaterial({
color: 0x5f8f58,
roughness: 0.95
});
const sandTop = new THREE.MeshStandardMaterial({
color: 0xc9a66d,
roughness: 0.95
});
const earthSide = new THREE.MeshStandardMaterial({
color: 0x765843,
roughness: 1
});
const darkEarthSide = new THREE.MeshStandardMaterial({
color: 0x5c4739,
roughness: 1
});
function buildIsland(island) {
const grassMaterials = [
earthSide, earthSide, grassTop, darkEarthSide, earthSide, earthSide
];
const sandMaterials = [
earthSide, earthSide, sandTop, darkEarthSide, earthSide, earthSide
];
const minX = Math.ceil(-island.rx - 0.5);
const maxX = Math.floor(island.rx + 0.5);
const minZ = Math.ceil(-island.rz - 0.5);
const maxZ = Math.floor(island.rz + 0.5);
for (let gx = minX; gx <= maxX; gx++) {
for (let gz = minZ; gz <= maxZ; gz++) {
if (!isIslandCell(island, gx, gz)) continue;
const h = terrainHeight(island, gx, gz);
const mesh = new THREE.Mesh(
islandGeometry,
h > 0.9 ? grassMaterials : sandMaterials
);
mesh.position.set(
island.x + gx,
(h - 0.72) / 2,
island.z + gz
);
mesh.scale.y = h + 0.72;
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
}
}
}
islands.forEach(buildIsland);
// -------------------------------------------------------------------------
// Simple voxel vegetation
// -------------------------------------------------------------------------
const trunkMaterial = new THREE.MeshStandardMaterial({
color: 0x8a5e3e,
roughness: 1
});
const leafMaterial = new THREE.MeshStandardMaterial({
color: 0x3f8750,
roughness: 0.95
});
const leafLightMaterial = new THREE.MeshStandardMaterial({
color: 0x65a957,
roughness: 0.95
});
const grassBladeMaterial = new THREE.MeshStandardMaterial({
color: 0x7cad5e,
roughness: 1
});
function addPalm(island, localX, localZ, height = 1.9) {
const group = new THREE.Group();
const ground = terrainHeight(island, localX, localZ);
const trunkCount = Math.max(3, Math.round(height / 0.42));
for (let i = 0; i < trunkCount; i++) {
const trunk = new THREE.Mesh(
new THREE.BoxGeometry(0.17, 0.43, 0.17),
trunkMaterial
);
trunk.position.set(
i * 0.025,
0.21 + i * 0.4,
0
);
trunk.castShadow = true;
group.add(trunk);
}
const crown = new THREE.Group();
crown.position.set(trunkCount * 0.025, trunkCount * 0.4, 0);
for (let i = 0; i < 5; i++) {
const a = (i / 5) * Math.PI * 2;
const leaf = new THREE.Mesh(
new THREE.BoxGeometry(0.75, 0.1, 0.19),
i % 2 ? leafMaterial : leafLightMaterial
);
leaf.position.set(Math.cos(a) * 0.29, 0, Math.sin(a) * 0.29);
leaf.rotation.y = -a;
leaf.castShadow = true;
crown.add(leaf);
}
group.add(crown);
group.position.set(island.x + localX, ground, island.z + localZ);
scene.add(group);
}
function addPine(island, localX, localZ, height = 1.65) {
const group = new THREE.Group();
const ground = terrainHeight(island, localX, localZ);
const trunk = new THREE.Mesh(
new THREE.BoxGeometry(0.2, height, 0.2),
trunkMaterial
);
trunk.position.y = height / 2;
trunk.castShadow = true;
group.add(trunk);
const layers = [
{ y: height * 0.55, size: 0.85 },
{ y: height * 0.77, size: 0.66 },
{ y: height * 0.98, size: 0.43 }
];
for (const layer of layers) {
const crown = new THREE.Mesh(
new THREE.BoxGeometry(layer.size, 0.42, layer.size),
layer.size > 0.6 ? leafMaterial : leafLightMaterial
);
crown.position.y = layer.y;
crown.castShadow = true;
group.add(crown);
}
group.position.set(island.x + localX, ground, island.z + localZ);
scene.add(group);
}
function addGrass(island, localX, localZ) {
const group = new THREE.Group();
const ground = terrainHeight(island, localX, localZ);
for (let i = 0; i < 3; i++) {
const blade = new THREE.Mesh(
new THREE.BoxGeometry(0.07, 0.27 + i * 0.05, 0.08),
grassBladeMaterial
);
blade.position.set((i - 1) * 0.1, 0.14, (i % 2) * 0.08);
blade.rotation.z = (i - 1) * 0.18;
group.add(blade);
}
group.position.set(island.x + localX, ground, island.z + localZ);
scene.add(group);
}
addPalm(sourceIsland, -3.0, 2.0, 2.0);
addPalm(sourceIsland, 2.1, 2.0, 1.75);
addPalm(sourceIsland, 3.1, -1.0, 1.6);
addPine(sourceIsland, -3.1, -2.0, 1.65);
addPine(sourceIsland, 1.8, -2.0, 1.45);
addGrass(sourceIsland, -2.0, 2.0);
addGrass(sourceIsland, 0.0, 2.0);
addPalm(firstIsland, 0.0, 2.0, 1.55);
addPalm(firstIsland, 1.2, -1.8, 1.45);
addPine(firstIsland, 2.0, 1.0, 1.35);
addPine(firstIsland, -0.8, 2.0, 1.25);
addGrass(firstIsland, 0.2, -1.0);
addPalm(lateIsland, 1.2, 1.0, 1.25);
addPine(lateIsland, 0.8, 1.3, 1.05);
addGrass(lateIsland, 1.0, -0.8);
// -------------------------------------------------------------------------
// Distinct landing pads
// -------------------------------------------------------------------------
const landingPads = [];
const labelContainer = document.querySelector("#world-labels");
const worldLabels = [];
function addLanding(island, localX, localZ, color, label) {
const height = terrainHeight(island, localX, localZ);
const group = new THREE.Group();
const pad = new THREE.Mesh(
new THREE.CylinderGeometry(0.53, 0.56, 0.075, 16),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.16,
roughness: 0.7
})
);
pad.position.y = 0.04;
pad.receiveShadow = true;
group.add(pad);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.67, 0.055, 8, 24),
new THREE.MeshBasicMaterial({ color })
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.1;
group.add(ring);
const pebbleGeometry = new THREE.BoxGeometry(0.14, 0.12, 0.14);
for (let i = 0; i < 4; i++) {
const a = (i / 4) * Math.PI * 2 + Math.PI / 4;
const pebble = new THREE.Mesh(
pebbleGeometry,
new THREE.MeshStandardMaterial({ color: 0xe4d6ad, roughness: 1 })
);
pebble.position.set(Math.cos(a) * 0.83, 0.06, Math.sin(a) * 0.83);
group.add(pebble);
}
group.position.set(
island.x + localX,
height,
island.z + localZ
);
scene.add(group);
const labelItem = addWorldLabel(
label,
new THREE.Vector3(
island.x + localX,
height + 1.05,
island.z + localZ
),
"landing"
);
landingPads.push({ group, ring, labelItem, arrival: 0 });
return group;
}
addLanding(sourceIsland, 3.0, 0.0, 0xf5c451, "OUTBOUND PAD");
addLanding(firstIsland, -2.0, 0.0, 0x43d9cf, "FIRST ARRIVAL");
addLanding(firstIsland, 2.0, 0.0, 0x92cf68, "SECOND DEPARTURE");
addLanding(lateIsland, -1.0, 0.0, 0xbca8ff, "LATE ARRIVAL");
landingPads[0].arrival = -100;
landingPads[1].arrival = TIME.firstArrival;
landingPads[2].arrival = TIME.secondDeparture;
landingPads[3].arrival = TIME.lateArrival;
// Dotted sea routes help the sequence read without becoming a map overlay.
function addSeaRoute(x1, z1, x2, z2, color) {
const count = 7;
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.45
});
const geometry = new THREE.BoxGeometry(0.16, 0.13, 0.16);
for (let i = 0; i < count; i++) {
const t = (i + 1) / (count + 1);
const buoy = new THREE.Mesh(geometry, material);
buoy.position.set(
THREE.MathUtils.lerp(x1, x2, t),
-0.36,
THREE.MathUtils.lerp(z1, z2, t)
);
scene.add(buoy);
}
}
addSeaRoute(
sourceIsland.x + 3.0,
sourceIsland.z,
firstIsland.x - 2.0,
firstIsland.z,
0x54bdb9
);
addSeaRoute(
firstIsland.x + 2.0,
firstIsland.z,
lateIsland.x - 1.0,
lateIsland.z,
0x80a997
);
addWorldLabel(
"FIRST CROSSING",
new THREE.Vector3(-3.4, 0.75, 0.4),
"route"
);
addWorldLabel(
"SECOND CROSSING",
new THREE.Vector3(6.8, 0.75, 0.4),
"route"
);
// -------------------------------------------------------------------------
// Individuals, ancestry markers, and simple travel skiffs
// -------------------------------------------------------------------------
const markerTextureCache = new Map();
const ancestryMaterialCache = new Map();
function getAncestryMaterial(name) {
if (!ancestryMaterialCache.has(name)) {
ancestryMaterialCache.set(
name,
new THREE.MeshStandardMaterial({
color: ANCESTRIES[name].color,
emissive: ANCESTRIES[name].color,
emissiveIntensity: 0.22,
roughness: 0.5
})
);
}
return ancestryMaterialCache.get(name);
}
function getMarkerTexture(name) {
if (markerTextureCache.has(name)) {
return markerTextureCache.get(name);
}
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 128, 128);
const color = ANCESTRIES[name].css;
ctx.shadowColor = "rgba(0,0,0,0.5)";
ctx.shadowBlur = 8;
ctx.fillStyle = color;
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 7;
ctx.lineJoin = "round";
if (ANCESTRIES[name].shape === "square") {
ctx.fillRect(25, 25, 78, 78);
ctx.strokeRect(25, 25, 78, 78);
} else if (ANCESTRIES[name].shape === "circle") {
ctx.beginPath();
ctx.arc(64, 64, 39, 0, Math.PI * 2);
ctx.fill();
ctx.stroke();
} else {
ctx.beginPath();
ctx.moveTo(64, 20);
ctx.lineTo(106, 103);
ctx.lineTo(22, 103);
ctx.closePath();
ctx.fill();
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.needsUpdate = true;
markerTextureCache.set(name, texture);
return texture;
}
const skinMaterial = new THREE.MeshStandardMaterial({
color: 0xe6b487,
roughness: 0.9
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x15252a,
roughness: 0.8
});
const skiffMaterial = new THREE.MeshStandardMaterial({
color: 0xb68857,
roughness: 0.92
});
const skiffEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x785438,
roughness: 0.95
});
const variantMaterials = VARIANTS.map(variant =>
new THREE.MeshStandardMaterial({
color: variant.color,
emissive: variant.color,
emissiveIntensity: 0.075,
roughness: 0.62
})
);
const sourceLocalPositions = [
[-2, -1], [-1, -1], [0, -1], [1, -1],
[-2, 0], [-1, 0], [0, 0], [1, 0],
[-2, 1], [-1, 1], [0, 1], [1, 1]
];
const firstColonyLocalPositions = {
0: [-2, -1],
1: [-1, -1],
2: [-2, 1],
4: [-1, 1]
};
const lateColonyLocalPositions = {
1: [-1, -1],
2: [0, -1]
};
const peopleData = [
{ name: "S01", variant: 0, ancestry: "North" },
{ name: "S02", variant: 1, ancestry: "North" },
{ name: "S03", variant: 2, ancestry: "Reef" },
{ name: "S04", variant: 3, ancestry: "Reef" },
{ name: "S05", variant: 0, ancestry: "Cinder" },
{ name: "S06", variant: 1, ancestry: "North" },
{ name: "S07", variant: 2, ancestry: "Reef" },
{ name: "S08", variant: 3, ancestry: "Cinder" },
{ name: "S09", variant: 0, ancestry: "North" },
{ name: "S10", variant: 1, ancestry: "North" },
{ name: "S11", variant: 2, ancestry: "Cinder" },
{ name: "S12", variant: 0, ancestry: "Reef" }
];
const firstFounderIndices = [0, 1, 2, 4];
const laterFounderIndices = [1, 2];
function islandWorldPosition(island, localX, localZ) {
return new THREE.Vector3(
island.x + localX,
terrainHeight(island, localX, localZ),
island.z + localZ
);
}
function createPerson(data, index) {
const group = new THREE.Group();
const bodyMaterial = variantMaterials[data.variant];
const leftFoot = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 0.11, 0.18),
darkMaterial
);
leftFoot.position.set(-0.09, 0.055, 0.015);
group.add(leftFoot);
const rightFoot = leftFoot.clone();
rightFoot.position.x = 0.09;
group.add(rightFoot);
const leftLeg = new THREE.Mesh(
new THREE.BoxGeometry(0.105, 0.22, 0.12),
bodyMaterial
);
leftLeg.position.set(-0.09, 0.2, 0);
group.add(leftLeg);
const rightLeg = leftLeg.clone();
rightLeg.position.x = 0.09;
group.add(rightLeg);
const body = new THREE.Mesh(
new THREE.BoxGeometry(0.34, 0.38, 0.28),
bodyMaterial
);
body.position.y = 0.49;
body.castShadow = true;
group.add(body);
const head = new THREE.Mesh(
new THREE.BoxGeometry(0.27, 0.25, 0.25),
skinMaterial
);
head.position.y = 0.82;
head.castShadow = true;
group.add(head);
const leftArm = new THREE.Mesh(
new THREE.BoxGeometry(0.09, 0.3, 0.11),
bodyMaterial
);
leftArm.position.set(-0.235, 0.49, 0);
leftArm.rotation.z = -0.08;
group.add(leftArm);
const rightArm = leftArm.clone();
rightArm.position.x = 0.235;
rightArm.rotation.z = 0.08;
group.add(rightArm);
const eyeGeometry = new THREE.BoxGeometry(0.035, 0.035, 0.025);
const leftEye = new THREE.Mesh(eyeGeometry, darkMaterial);
leftEye.position.set(-0.065, 0.85, 0.132);
group.add(leftEye);
const rightEye = leftEye.clone();
rightEye.position.x = 0.065;
group.add(rightEye);
// The ancestry marker is a camera-facing sprite, so it remains readable
// above the person both on land and during the animated crossings.
const marker = new THREE.Sprite(
new THREE.SpriteMaterial({
map: getMarkerTexture(data.ancestry),
transparent: true,
depthTest: false,
depthWrite: false
})
);
marker.position.y = 1.43;
marker.scale.set(0.55, 0.55, 0.55);
marker.renderOrder = 100;
group.add(marker);
const markerStem = new THREE.Mesh(
new THREE.BoxGeometry(0.025, 0.25, 0.025),
getAncestryMaterial(data.ancestry)
);
markerStem.position.y = 1.16;
group.add(markerStem);
const selectionRing = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.035, 6, 20),
new THREE.MeshBasicMaterial({
color: 0xf4fffc,
transparent: true,
opacity: 0.9
})
);
selectionRing.rotation.x = Math.PI / 2;
selectionRing.position.y = 0.035;
selectionRing.visible = false;
group.add(selectionRing);
const skiff = new THREE.Group();
const hull = new THREE.Mesh(
new THREE.BoxGeometry(0.62, 0.09, 0.43),
skiffMaterial
);
hull.position.y = -0.025;
skiff.add(hull);
const bow = new THREE.Mesh(
new THREE.BoxGeometry(0.16, 0.08, 0.38),
skiffEdgeMaterial
);
bow.position.set(0.36, -0.025, 0);
bow.rotation.z = -0.18;
skiff.add(bow);
skiff.visible = false;
group.add(skiff);
const home = islandWorldPosition(
sourceIsland,
sourceLocalPositions[index][0],
sourceLocalPositions[index][1]
);
group.position.copy(home);
scene.add(group);
return {
data,
index,
group,
marker,
selectionRing,
skiff,
home
};
}
const people = peopleData.map(createPerson);
// -------------------------------------------------------------------------
// World-space DOM labels
// -------------------------------------------------------------------------
function addWorldLabel(html, position, className = "") {
const element = document.createElement("div");
element.className = `world-label ${className}`;
element.innerHTML = html;
labelContainer.appendChild(element);
const label = {
element,
position: position.clone()
};
worldLabels.push(label);
return label;
}
const sourceLabel = addWorldLabel(
"<b>Source Island</b><span>12-person home pool</span>",
new THREE.Vector3(sourceIsland.x, 3.6, sourceIsland.z - 0.5)
);
const firstLabel = addWorldLabel(
"<b>First Colony</b><span>awaiting founder sample</span>",
new THREE.Vector3(firstIsland.x, 3.25, firstIsland.z - 0.4)
);
const lateLabel = addWorldLabel(
"<b>Late Colony</b><span>awaiting subset</span>",
new THREE.Vector3(lateIsland.x, 3.0, lateIsland.z - 0.3)
);
function updateWorldLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of worldLabels) {
const projected = label.position.clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.2 &&
Math.abs(projected.y) < 1.2;
label.element.style.display = visible ? "block" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
// -------------------------------------------------------------------------
// Custom camera controls — no Three.js addons are used
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(-8.5, 0.7, 0.4);
const desiredTarget = cameraTarget.clone();
let cameraRadius = 18;
let desiredRadius = 18;
let cameraAzimuth = 0;
let cameraPolar = 0.83;
let dragging = false;
let dragButton = 0;
let previousPointer = { x: 0, y: 0 };
function responsiveRadius(base) {
const aspect = camera.aspect;
const multiplier = Math.max(1, Math.min(2.1, 1.18 / aspect));
return base * multiplier;
}
function storyCameraGoal(time) {
let target = new THREE.Vector3();
let radius = 18;
if (time < TIME.sourceEnd) {
target.set(sourceIsland.x, 0.65, sourceIsland.z);
radius = 18;
} else if (time < TIME.selectionEnd) {
target.set(sourceIsland.x, 0.65, sourceIsland.z);
radius = 17;
} else if (time < TIME.firstArrival) {
const u = THREE.MathUtils.smoothstep(
time,
TIME.selectionEnd,
TIME.firstArrival
);
target.set(
THREE.MathUtils.lerp(sourceIsland.x, firstIsland.x, u),
0.8,
0.2
);
radius = THREE.MathUtils.lerp(23, 18, u);
} else if (time < TIME.secondDeparture) {
target.set(firstIsland.x, 0.65, firstIsland.z);
radius = 14;
} else if (time < TIME.lateArrival) {
const u = THREE.MathUtils.smoothstep(
time,
TIME.secondDeparture,
TIME.lateArrival
);
target.set(
THREE.MathUtils.lerp(firstIsland.x, lateIsland.x, u),
0.7,
0.35
);
radius = THREE.MathUtils.lerp(20, 16, u);
} else {
target.set(lateIsland.x, 0.6, lateIsland.z);
radius = 13;
}
return { target, radius: responsiveRadius(radius) };
}
function updateCamera(delta) {
if (cameraMode === "story") {
const goal = storyCameraGoal(storyTime);
desiredTarget.copy(goal.target);
desiredRadius = goal.radius;
} else if (cameraMode === "overview") {
desiredTarget.set(0.6, 0.4, 0.3);
desiredRadius = responsiveRadius(34);
}
const smoothing = 1 - Math.exp(-delta * 2.7);
cameraTarget.lerp(desiredTarget, smoothing);
cameraRadius = THREE.MathUtils.lerp(cameraRadius, desiredRadius, smoothing);
const sinPolar = Math.sin(cameraPolar);
const cosPolar = Math.cos(cameraPolar);
camera.position.set(
cameraTarget.x + cameraRadius * sinPolar * Math.sin(cameraAzimuth),
cameraTarget.y + cameraRadius * cosPolar,
cameraTarget.z + cameraRadius * sinPolar * Math.cos(cameraAzimuth)
);
camera.lookAt(cameraTarget);
}
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
dragButton = event.button;
previousPointer = { x: event.clientX, y: event.clientY };
renderer.domElement.setPointerCapture(event.pointerId);
cameraMode = "manual";
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - previousPointer.x;
const dy = event.clientY - previousPointer.y;
previousPointer = { x: event.clientX, y: event.clientY };
if (event.shiftKey || dragButton === 2) {
const panScale = cameraRadius * 0.0016;
cameraTarget.x -= dx * panScale;
cameraTarget.z -= dy * panScale;
desiredTarget.copy(cameraTarget);
} else {
cameraAzimuth -= dx * 0.006;
cameraPolar = THREE.MathUtils.clamp(
cameraPolar + dy * 0.005,
0.35,
1.28
);
}
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraMode = "manual";
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * Math.exp(event.deltaY * 0.001),
7,
90
);
desiredRadius = cameraRadius;
},
{ passive: false }
);
// -------------------------------------------------------------------------
// Animated founder movement
// -------------------------------------------------------------------------
const tempVector = new THREE.Vector3();
function travelPosition(from, to, progress, arcHeight, clock) {
const u = THREE.MathUtils.clamp(progress, 0, 1);
const eased = u * u * (3 - 2 * u);
tempVector.lerpVectors(from, to, eased);
tempVector.y += Math.sin(Math.PI * u) * arcHeight;
tempVector.y += Math.sin(clock * 5 + u * 8) * 0.045 * Math.sin(Math.PI * u);
return tempVector;
}
function updatePeople(clock) {
for (const person of people) {
const isFirstFounder = firstFounderIndices.includes(person.index);
const isLaterFounder = laterFounderIndices.includes(person.index);
let inFirstTravel = false;
let inSecondTravel = false;
let firstPosition = null;
if (isFirstFounder) {
firstPosition = islandWorldPosition(
firstIsland,
firstColonyLocalPositions[person.index][0],
firstColonyLocalPositions[person.index][1]
);
}
let latePosition = null;
if (isLaterFounder) {
latePosition = islandWorldPosition(
lateIsland,
lateColonyLocalPositions[person.index][0],
lateColonyLocalPositions[person.index][1]
);
}
if (
isFirstFounder &&
storyTime >= TIME.selectionEnd &&
storyTime < TIME.firstArrival
) {
inFirstTravel = true;
const progress =
(storyTime - TIME.selectionEnd) /
(TIME.firstArrival - TIME.selectionEnd);
person.group.position.copy(
travelPosition(person.home, firstPosition, progress, 4.1, clock)
);
const direction = firstPosition.clone().sub(person.home);
person.group.rotation.y = Math.atan2(direction.x, direction.z);
} else if (
isLaterFounder &&
storyTime >= TIME.secondDeparture &&
storyTime < TIME.lateArrival
) {
inSecondTravel = true;
const progress =
(storyTime - TIME.secondDeparture) /
(TIME.lateArrival - TIME.secondDeparture);
person.group.position.copy(
travelPosition(firstPosition, latePosition, progress, 3.5, clock)
);
const direction = latePosition.clone().sub(firstPosition);
person.group.rotation.y = Math.atan2(direction.x, direction.z);
} else if (isLaterFounder && storyTime >= TIME.lateArrival) {
person.group.position.copy(latePosition);
person.group.rotation.y = 0;
} else if (isFirstFounder && storyTime >= TIME.firstArrival) {
person.group.position.copy(firstPosition);
person.group.rotation.y = 0;
} else {
person.group.position.copy(person.home);
person.group.rotation.y = 0;
}
person.skiff.visible = inFirstTravel || inSecondTravel;
person.selectionRing.visible =
isFirstFounder &&
storyTime >= TIME.sourceEnd &&
storyTime < TIME.selectionEnd;
if (person.selectionRing.visible) {
const pulse = 1 + Math.sin(clock * 5) * 0.09;
person.selectionRing.scale.setScalar(pulse);
}
// Marker remains visible and gently pulses, particularly while traveling.
const markerPulse = 1 + Math.sin(clock * 3.2 + person.index) * 0.045;
person.marker.scale.set(
0.55 * markerPulse,
0.55 * markerPulse,
0.55
);
}
}
// -------------------------------------------------------------------------
// Counts and story copy
// -------------------------------------------------------------------------
function renderCounts(element, counts) {
element.innerHTML = VARIANTS.map((variant, index) => {
const value = counts ? counts[index] : "—";
return `
<div class="variant-count ${counts ? "" : "pending"}"
title="${variant.key}: ${value}">
<i style="background:${variant.css};color:${variant.css}"></i>
<span>${value}</span>
</div>
`;
}).join("");
}
function updateLedger() {
const sourceHasDeparted = storyTime >= TIME.selectionEnd;
const firstHasArrived = storyTime >= TIME.firstArrival;
const secondHasDeparted = storyTime >= TIME.secondDeparture;
const lateHasArrived = storyTime >= TIME.lateArrival;
const sourceCounts = sourceHasDeparted
? SOURCE_REMAINING
: SOURCE_COUNTS;
const firstCounts = firstHasArrived
? (secondHasDeparted ? LATE_COUNTS : FIRST_COUNTS)
: null;
const lateCounts = lateHasArrived ? LATE_COUNTS : null;
const key = [
sourceHasDeparted,
firstHasArrived,
secondHasDeparted,
lateHasArrived
].join("|");
if (key === lastLedgerKey) return;
lastLedgerKey = key;
renderCounts(document.querySelector("#source-counts"), sourceCounts);
renderCounts(document.querySelector("#first-counts"), firstCounts);
renderCounts(document.querySelector("#late-counts"), lateCounts);
document.querySelector("#source-meta").textContent =
sourceHasDeparted ? "8 remain" : "12 present";
document.querySelector("#first-meta").textContent =
!firstHasArrived
? "awaiting arrival"
: (secondHasDeparted ? "2 remain" : "4 present");
document.querySelector("#late-meta").textContent =
lateHasArrived ? "2 present" : "awaiting arrival";
}
function getStoryStatus() {
if (storyTime < TIME.sourceEnd) {
return {
stage: 0,
title: "01 / Source pool",
copy: "Twelve individuals occupy the large home island, with four visible variants."
};
}
if (storyTime < TIME.selectionEnd) {
return {
stage: 1,
title: "02 / Founder sample",
copy: "Four are selected: 2 Sun, 1 Tide, 1 Moss, and no Ember. Their ancestry shapes stay attached."
};
}
if (storyTime < TIME.firstArrival) {
return {
stage: 2,
title: "03 / First crossing",
copy: "The four founders travel to the middle island. Watch the overhead ancestry markers."
};
}
if (storyTime < TIME.secondDeparture) {
return {
stage: 3,
title: "04 / First colony",
copy: "Arrival census: 2 Sun, 1 Tide, 1 Moss, 0 Ember. The unsampled Ember variant does not appear."
};
}
if (storyTime < TIME.lateArrival) {
return {
stage: 4,
title: "05 / A smaller subset",
copy: "Only the Tide and Moss founders leave the first colony for the final island."
};
}
return {
stage: 5,
title: "06 / Late colony",
copy: "Arrival census: 0 Sun, 1 Tide, 1 Moss, 0 Ember. Missing variants are not magically restored."
};
}
function updateStoryCopy() {
const status = getStoryStatus();
const key = `${status.stage}|${Math.floor(storyTime * 2)}`;
if (key !== lastStatusKey) {
lastStatusKey = key;
storyTitle.textContent = status.title;
storyCopy.textContent = status.copy;
stageElements.forEach((element, index) => {
element.classList.toggle("active", index === status.stage);
element.classList.toggle("completed", index < status.stage);
});
}
progressFill.style.width = `${(storyTime / TIME.total) * 100}%`;
}
function updateDynamicWorldLabels() {
if (storyTime < TIME.selectionEnd) {
sourceLabel.element.innerHTML =
"<b>Source Island</b><span>12-person home pool</span>";
} else {
sourceLabel.element.innerHTML =
"<b>Source Island</b><span>8 remain after departure</span>";
}
if (storyTime < TIME.firstArrival) {
firstLabel.element.innerHTML =
"<b>First Colony</b><span>awaiting 4 founders</span>";
} else if (storyTime < TIME.secondDeparture) {
firstLabel.element.innerHTML =
"<b>First Colony</b><span>4 present · 2 Sun · 1 Tide · 1 Moss</span>";
} else {
firstLabel.element.innerHTML =
"<b>First Colony</b><span>2 remain · 1 Tide · 1 Moss</span>";
}
if (storyTime < TIME.lateArrival) {
lateLabel.element.innerHTML =
"<b>Late Colony</b><span>awaiting 2 sampled founders</span>";
} else {
lateLabel.element.innerHTML =
"<b>Late Colony</b><span>2 present · 1 Tide · 1 Moss</span>";
}
}
// -------------------------------------------------------------------------
// Landing arrival pulses
// -------------------------------------------------------------------------
function updateLandingPads(clock) {
for (const pad of landingPads) {
const elapsed = storyTime - pad.arrival;
if (elapsed >= 0 && elapsed < 1.35) {
const pulse = 1 + Math.sin(elapsed * 10) * (1 - elapsed / 1.35) * 0.24;
pad.ring.scale.setScalar(pulse);
pad.ring.material.opacity = 1;
pad.ring.material.transparent = true;
} else {
pad.ring.scale.setScalar(1);
pad.ring.material.opacity = 0.9;
}
pad.group.position.y +=
Math.sin(clock * 2 + pad.arrival) * 0.00025;
}
}
// -------------------------------------------------------------------------
// Controls and animation loop
// -------------------------------------------------------------------------
playButton.addEventListener("click", () => {
if (storyTime >= TIME.total) {
storyTime = 0;
cameraMode = "story";
playing = true;
} else {
playing = !playing;
}
updatePlayButton();
});
resetButton.addEventListener("click", () => {
storyTime = 0;
playing = false;
cameraMode = "story";
cameraTarget.set(sourceIsland.x, 0.7, sourceIsland.z);
desiredTarget.copy(cameraTarget);
cameraRadius = responsiveRadius(18);
desiredRadius = cameraRadius;
updatePlayButton();
});
overviewButton.addEventListener("click", () => {
cameraMode = "overview";
});
function updatePlayButton() {
if (storyTime >= TIME.total) {
playButton.textContent = "▶ Replay";
} else {
playButton.textContent = playing ? "Ⅱ Pause" : "▶ Play";
}
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
let previousTime = performance.now();
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (playing) {
storyTime = Math.min(TIME.total, storyTime + delta);
if (storyTime >= TIME.total) {
playing = false;
updatePlayButton();
}
}
const clock = now / 1000;
for (let i = 0; i < waves.length; i++) {
const wave = waves[i];
wave.position.x =
wave.userData.baseX +
Math.sin(clock * 0.35 + wave.userData.phase) * 0.38;
wave.material.opacity =
0.12 + Math.sin(clock * 0.8 + wave.userData.phase) * 0.045;
}
updatePeople(clock);
updateLandingPads(clock);
updateLedger();
updateStoryCopy();
updateDynamicWorldLabels();
updateCamera(delta);
updateWorldLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updatePlayButton();
requestAnimationFrame(animate);
</script>
</body>
</html>
```