Prompt specification
Build or customize the Three.js 3D scene "Rock cycle landscape museum" 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: Rock cycle landscape museum
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/rock-cycle-landscape-museum-x1179
Scene Description Prompt:
Use Three.js from cdnjs for an HTML voxel rock-cycle cutaway linking volcano, sediment, buried layers, and uplift without implying equal process timescales.
Working Three.js Starter (rock-cycle-landscape-museum-x1179):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="dark" />
<title>Voxel Rock Cycle — A Cutaway, Not a Clock</title>
<style>
:root {
--ink: #eef5f7;
--muted: #9caeb7;
--panel: rgba(9, 19, 29, 0.91);
--line: rgba(190, 220, 230, 0.14);
--accent: #ffb05c;
--accent-soft: rgba(255, 176, 92, 0.12);
--water: #63d4d8;
--shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #07111d;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#app,
#scene,
#labels {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
#labels {
z-index: 4;
pointer-events: none;
}
.masthead {
position: fixed;
z-index: 6;
top: 24px;
left: 28px;
max-width: min(480px, calc(100vw - 440px));
pointer-events: none;
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: #ffd19d;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 2px;
content: "";
background: var(--accent);
box-shadow: 0 0 16px rgba(255, 176, 92, 0.7);
}
.masthead h1 {
margin: 0;
font-size: clamp(24px, 3vw, 43px);
font-weight: 720;
line-height: 1.04;
letter-spacing: -0.045em;
}
.masthead p {
max-width: 470px;
margin: 12px 0 0;
color: #b4c3ca;
font-size: 13px;
line-height: 1.55;
}
.panel {
position: fixed;
z-index: 8;
top: 20px;
right: 20px;
bottom: 20px;
width: 370px;
overflow: auto;
padding: 22px;
border: 1px solid var(--line);
border-radius: 22px;
background:
linear-gradient(145deg, rgba(26, 43, 55, 0.35), transparent 40%),
var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(18px) saturate(130%);
scrollbar-width: thin;
scrollbar-color: #405563 transparent;
}
.panel h2 {
margin: 0;
font-size: 18px;
letter-spacing: -0.02em;
}
.panel-intro {
margin: 8px 0 17px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.not-a-clock {
display: grid;
grid-template-columns: 34px 1fr;
gap: 10px;
margin-bottom: 16px;
padding: 12px;
border: 1px solid rgba(255, 176, 92, 0.22);
border-radius: 14px;
background: var(--accent-soft);
}
.clock-icon {
display: grid;
width: 30px;
height: 30px;
place-items: center;
border: 1px solid rgba(255, 207, 149, 0.45);
border-radius: 50%;
color: #ffd19d;
font-size: 16px;
font-weight: 700;
}
.not-a-clock strong {
display: block;
color: #ffe0b6;
font-size: 11px;
letter-spacing: 0.04em;
}
.not-a-clock p {
margin: 4px 0 0;
color: #b8c3c8;
font-size: 10.5px;
line-height: 1.45;
}
.stages {
display: grid;
gap: 8px;
}
.stage {
position: relative;
display: grid;
grid-template-columns: 31px 1fr;
gap: 10px;
width: 100%;
padding: 12px;
overflow: hidden;
border: 1px solid transparent;
border-radius: 13px;
color: var(--ink);
background: rgba(255, 255, 255, 0.035);
text-align: left;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.stage:hover {
border-color: rgba(255, 255, 255, 0.15);
background: rgba(255, 255, 255, 0.07);
transform: translateX(-2px);
}
.stage.active {
border-color: rgba(255, 176, 92, 0.45);
background: linear-gradient(90deg, rgba(255, 176, 92, 0.16), rgba(255, 176, 92, 0.04));
}
.stage-number {
display: grid;
width: 27px;
height: 27px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.17);
border-radius: 8px;
color: #c7d2d6;
background: rgba(0, 0, 0, 0.18);
font-size: 11px;
font-weight: 800;
}
.stage.active .stage-number {
border-color: rgba(255, 188, 111, 0.55);
color: #18110b;
background: var(--accent);
}
.stage-title {
display: block;
margin: 1px 0 4px;
font-size: 12.5px;
font-weight: 750;
}
.stage-description {
display: block;
color: #9eafb7;
font-size: 10.5px;
line-height: 1.42;
}
.pace {
display: block;
margin-top: 7px;
color: #d8b780;
font-size: 9.5px;
font-weight: 650;
letter-spacing: 0.02em;
}
.panel-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 14px;
}
.action {
padding: 10px 12px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 11px;
color: #dce6e9;
background: rgba(255, 255, 255, 0.055);
font-size: 11px;
font-weight: 700;
cursor: pointer;
transition: background 150ms ease, border-color 150ms ease;
}
.action:hover {
border-color: rgba(255, 255, 255, 0.25);
background: rgba(255, 255, 255, 0.1);
}
.action.primary {
border-color: rgba(255, 176, 92, 0.45);
color: #1a1008;
background: var(--accent);
}
.tour-note {
margin: 8px 0 0;
color: #738790;
font-size: 9.5px;
line-height: 1.45;
text-align: center;
}
.panel-footer {
margin-top: 18px;
padding-top: 15px;
border-top: 1px solid var(--line);
color: #81949d;
font-size: 10px;
line-height: 1.55;
}
.world-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
min-width: 112px;
padding: 7px 10px 7px 7px;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 11px;
color: var(--ink);
background: rgba(7, 16, 25, 0.82);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
opacity: 0.76;
pointer-events: auto;
cursor: pointer;
transform: translate(-50%, -100%);
transition: opacity 160ms ease, border-color 160ms ease, background 160ms ease;
backdrop-filter: blur(9px);
}
.world-label:hover,
.world-label.active {
border-color: rgba(255, 188, 111, 0.62);
background: rgba(24, 25, 25, 0.93);
opacity: 1;
}
.label-pin {
display: grid;
flex: 0 0 auto;
width: 23px;
height: 23px;
place-items: center;
border-radius: 7px;
color: #1a1008;
background: var(--accent);
font-size: 10px;
font-weight: 850;
}
.world-label b {
display: block;
font-size: 10.5px;
}
.world-label small {
display: block;
margin-top: 2px;
color: #95a7ae;
font-size: 8.5px;
white-space: nowrap;
}
.legend {
position: fixed;
z-index: 6;
bottom: 24px;
left: 28px;
max-width: min(590px, calc(100vw - 440px));
padding: 13px 15px;
border: 1px solid var(--line);
border-radius: 15px;
background: rgba(8, 17, 26, 0.74);
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(12px);
}
.legend-title {
margin-bottom: 9px;
color: #b9c8cd;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-items {
display: flex;
flex-wrap: wrap;
gap: 8px 15px;
color: #91a2aa;
font-size: 9.5px;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 6px;
white-space: nowrap;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 2px;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.legend-note {
margin-top: 9px;
padding-top: 8px;
border-top: 1px solid var(--line);
color: #6f858f;
font-size: 9px;
line-height: 1.45;
}
.hint {
position: fixed;
z-index: 5;
right: 410px;
bottom: 27px;
color: rgba(208, 222, 228, 0.56);
font-size: 9.5px;
pointer-events: none;
}
#loading {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
color: #dce6e9;
background: #07111d;
font-size: 12px;
letter-spacing: 0.08em;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 860px) {
.masthead {
top: 17px;
left: 18px;
max-width: calc(100vw - 36px);
}
.masthead h1 {
font-size: 27px;
}
.masthead p {
display: none;
}
.panel {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 45vh;
padding: 16px;
border-radius: 18px;
}
.panel-intro,
.panel-footer {
display: none;
}
.not-a-clock {
margin-bottom: 10px;
padding: 9px;
}
.stages {
grid-template-columns: 1fr 1fr;
}
.stage {
padding: 9px;
}
.stage-description {
display: none;
}
.legend {
right: 10px;
bottom: calc(45vh + 18px);
left: 10px;
max-width: none;
padding: 9px 11px;
}
.legend-items,
.legend-note {
display: none;
}
.hint {
display: none;
}
.world-label {
min-width: auto;
padding: 5px;
}
.world-label > span:last-child {
display: none;
}
}
@media (max-width: 520px) {
.stages {
grid-template-columns: 1fr;
}
.panel {
max-height: 43vh;
}
.pace {
margin-top: 4px;
}
}
@media (prefers-reduced-motion: reduce) {
* {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<div id="app">
<div id="scene"></div>
<div id="labels"></div>
<header class="masthead">
<div class="eyebrow">Voxel earth systems</div>
<h1>From fire to bedrock—and back to the sky.</h1>
<p>
A cutaway through four linked processes. Spatial arrangement is schematic,
and each process can operate on a very different timescale.
</p>
</header>
<aside class="panel" aria-label="Rock-cycle stages">
<h2>Explore the cutaway</h2>
<p class="panel-intro">
Select a stage to move the camera and inspect its part of the system.
The rock cycle is a network of feedbacks, not a circular conveyor belt.
</p>
<div class="not-a-clock">
<div class="clock-icon" aria-hidden="true">≠</div>
<div>
<strong>Time is not scene spacing</strong>
<p>
The ranges below are broad and overlapping. Local climate, tectonics,
sediment supply, and fault activity can accelerate or stall a stage.
</p>
</div>
</div>
<div id="stages" class="stages"></div>
<div class="panel-actions">
<button id="tourButton" class="action primary" type="button" aria-pressed="false">
▶ Guided tour
</button>
<button id="overviewButton" class="action" type="button">
↺ Overview
</button>
</div>
<p class="tour-note">
Guided-tour pauses are for reading, not proportional elapsed time.
</p>
<div class="panel-footer">
<strong>Reading the scene:</strong>
arrows show transfers or exposure, not a synchronized clock.
Weathering, deposition, burial, faulting, and uplift may overlap in the
same landscape—or occur millions of years apart.
</div>
</aside>
<section class="legend" aria-label="Visualization key">
<div class="legend-title">Cutaway key</div>
<div class="legend-items">
<span class="legend-item">
<i class="swatch" style="background:#ff572d"></i>magma / lava
</span>
<span class="legend-item">
<i class="swatch" style="background:#3e444a"></i>igneous rock
</span>
<span class="legend-item">
<i class="swatch" style="background:#c5a36d"></i>sediment
</span>
<span class="legend-item">
<i class="swatch" style="background:#a96e48"></i>sedimentary rock
</span>
<span class="legend-item">
<i class="swatch" style="background:#65566c"></i>older basement
</span>
<span class="legend-item">
<i class="swatch" style="background:#5b7850"></i>land surface
</span>
</div>
<div class="legend-note">
Schematic cutaway · no scale · arrows show material transfer or tectonic exposure.
</div>
</section>
<div class="hint">Drag to orbit · wheel to zoom · keys 1–4 select stages</div>
<div id="loading">BUILDING THE CUTAWAY…</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stageData = [
{
title: "Volcano + cooling",
short: "Volcano",
description: "Lava erupts, then cools into crystalline igneous rock.",
pace: "Eruption: hours–days · cooling: months–years",
labelPace: "hours → years",
anchor: new THREE.Vector3(-12, 8.5, -3.2),
focus: new THREE.Vector3(-11.8, 2.1, -2.1)
},
{
title: "Sediment production",
short: "Sediment",
description: "Weathering breaks rock down; water and wind transport grains.",
pace: "Years → millions of years",
labelPace: "years → millions",
anchor: new THREE.Vector3(-4.1, 3.4, -1.9),
focus: new THREE.Vector3(-4.3, 0.7, -1.8)
},
{
title: "Burial + lithification",
short: "Buried layers",
description: "Deposited sediment is compacted and cemented into rock.",
pace: "Thousands → millions of years",
labelPace: "thousands → millions",
anchor: new THREE.Vector3(4.8, 4.6, 0),
focus: new THREE.Vector3(4.6, 0.2, 0)
},
{
title: "Uplift + exposure",
short: "Uplift",
description: "Tectonic forces raise buried rock; erosion reveals it.",
pace: "Highly variable: rapid faulting → millions of years",
labelPace: "rapid or very slow",
anchor: new THREE.Vector3(12.8, 6.2, -1),
focus: new THREE.Vector3(12.4, 1.6, -1)
}
];
const stageButtons = [];
const worldLabels = [];
const stageList = document.querySelector("#stages");
const labelLayer = document.querySelector("#labels");
stageData.forEach((stage, index) => {
const button = document.createElement("button");
button.className = "stage";
button.type = "button";
button.setAttribute("aria-pressed", "false");
button.innerHTML = `
<span class="stage-number">${index + 1}</span>
<span>
<span class="stage-title">${stage.title}</span>
<span class="stage-description">${stage.description}</span>
<span class="pace">${stage.pace}</span>
</span>
`;
button.addEventListener("click", () => {
stopTour();
selectStage(index, true);
});
stageList.appendChild(button);
stageButtons.push(button);
const label = document.createElement("button");
label.className = "world-label";
label.type = "button";
label.innerHTML = `
<span class="label-pin">${index + 1}</span>
<span>
<b>${stage.short}</b>
<small>${stage.labelPace}</small>
</span>
`;
label.addEventListener("click", (event) => {
event.stopPropagation();
stopTour();
selectStage(index, true);
});
labelLayer.appendChild(label);
worldLabels.push(label);
});
const container = document.querySelector("#scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111d);
scene.fog = new THREE.Fog(0x07111d, 48, 105);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
180
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel cutaway of the rock cycle"
);
container.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xc7ecff, 0x33271e, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe8c8, 3.4);
sun.position.set(-8, 25, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 24;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00025;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x66bde0, 1.4);
rim.position.set(18, 10, -22);
scene.add(rim);
const lavaLight = new THREE.PointLight(0xff4f1d, 34, 18, 2);
lavaLight.position.set(-12, 5.7, -3);
scene.add(lavaLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(180, 180),
new THREE.MeshStandardMaterial({
color: 0x08121d,
roughness: 1,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -6.48;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(100, 50, 0x254050, 0x172a36);
grid.position.y = -6.44;
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
const dummy = new THREE.Object3D();
const makeMaterial = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0.02,
...options
});
const stageGroups = stageData.map(() => {
const group = new THREE.Group();
scene.add(group);
return group;
});
function addBox(parent, x, y, z, sx, sy, sz, material, rz = 0) {
const mesh = new THREE.Mesh(cubeGeometry, material);
mesh.position.set(x, y, z);
mesh.scale.set(sx, sy, sz);
mesh.rotation.z = rz;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addInstancedBoxes(parent, items, material) {
const mesh = new THREE.InstancedMesh(cubeGeometry, material, items.length);
items.forEach((item, index) => {
dummy.position.set(item.x, item.y, item.z);
dummy.rotation.set(0, item.rz || 0, 0);
dummy.scale.set(item.sx, item.sy, item.sz);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addArrow(parent, origin, direction, length, color, headLength = 0.48) {
const arrow = new THREE.ArrowHelper(
new THREE.Vector3(...direction).normalize(),
new THREE.Vector3(...origin),
length,
color,
headLength,
headLength * 0.62
);
arrow.line.material.transparent = true;
arrow.line.material.opacity = 0.78;
arrow.cone.material.transparent = true;
arrow.cone.material.opacity = 0.88;
parent.add(arrow);
return arrow;
}
// Deterministic pseudo-random variation for the geological voxels.
let seed = 9317;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
// Main cutaway block. A front slice is omitted where the burial panel is shown.
const baseCells = [];
for (let iy = 0; iy < 4; iy++) {
for (let iz = 0; iz < 5; iz++) {
for (let ix = 0; ix < 23; ix++) {
const x = (ix - 11) * 1.6;
const z = -6.4 + iz * 1.6;
const y = -0.8 - iy * 1.6;
const burialWindow =
iz === 4 && (ix === 13 || ix === 14 || ix === 15);
if (!burialWindow) {
baseCells.push({ x, y, z, ix, iy, iz });
}
}
}
}
const baseMaterial = makeMaterial(0xffffff, { vertexColors: true });
const baseMesh = new THREE.InstancedMesh(
cubeGeometry,
baseMaterial,
baseCells.length
);
baseCells.forEach((cell, index) => {
dummy.position.set(cell.x, cell.y, cell.z);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1.55, 1.55, 1.55);
dummy.updateMatrix();
baseMesh.setMatrixAt(index, dummy.matrix);
let color;
if (cell.iy === 0) {
if (cell.x < -8) color = new THREE.Color(0x53634e);
else if (cell.x < 0) color = new THREE.Color(0xa78e62);
else if (cell.x < 8) color = new THREE.Color(0x82674b);
else color = new THREE.Color(0x596f4e);
} else if (cell.iy === 1) {
color = new THREE.Color(0xb07b51);
} else if (cell.iy === 2) {
color = new THREE.Color(0x67576a);
} else {
color = new THREE.Color(0x35485d);
}
color.multiplyScalar(0.88 + random() * 0.21);
baseMesh.setColorAt(index, color);
});
baseMesh.instanceMatrix.needsUpdate = true;
baseMesh.instanceColor.needsUpdate = true;
baseMesh.castShadow = true;
baseMesh.receiveShadow = true;
scene.add(baseMesh);
// ── Stage 1: volcano, conduit, lava, and ash ─────────────────────────────
const volcano = stageGroups[0];
const basalt = makeMaterial(0x41464b);
const scoria = makeMaterial(0x765447);
const darkScoria = makeMaterial(0x4c3b35);
const lava = makeMaterial(0xff5428, {
emissive: 0xff2b0c,
emissiveIntensity: 2.2,
roughness: 0.55
});
const hotLava = makeMaterial(0xffbf54, {
emissive: 0xff7b13,
emissiveIntensity: 2.6,
roughness: 0.45
});
const ash = makeMaterial(0x8c8b86, {
transparent: true,
opacity: 0.28,
depthWrite: false
});
const coneDark = [];
const coneBrown = [];
for (let level = 0; level < 7; level++) {
const radius = 4.65 - level * 0.53;
const y = 0.6 + level * 0.82;
const spacing = 0.72;
for (let gx = -6; gx <= 6; gx++) {
for (let gz = -6; gz <= 6; gz++) {
const dx = gx * spacing;
const dz = gz * spacing;
const distance = Math.hypot(dx, dz);
if (distance <= radius) {
const item = {
x: -12 + dx,
y,
z: -3.2 + dz,
sx: 0.69,
sy: 0.79,
sz: 0.69
};
if (level >= 5 || distance > radius * 0.76) {
coneBrown.push(item);
} else {
coneDark.push(item);
}
}
}
}
}
addInstancedBoxes(volcano, coneDark, basalt);
addInstancedBoxes(volcano, coneBrown, scoria);
const lavaBlocks = [];
for (let gx = -1; gx <= 1; gx++) {
for (let gz = -1; gz <= 1; gz++) {
if (Math.hypot(gx, gz) <= 1.25) {
lavaBlocks.push({
x: -12 + gx * 0.68,
y: 6.22,
z: -3.2 + gz * 0.68,
sx: 0.66,
sy: 0.42,
sz: 0.66
});
}
}
}
addInstancedBoxes(volcano, lavaBlocks, lava);
// A bright conduit on the exposed cut face makes the hidden plumbing legible.
const conduitBlocks = [];
for (let y = -4.8; y <= 5.4; y += 0.78) {
conduitBlocks.push({
x: -12,
y,
z: 0.05,
sx: 0.92,
sy: 0.74,
sz: 0.34
});
}
addInstancedBoxes(volcano, conduitBlocks, hotLava);
const smoke = [];
for (let i = 0; i < 7; i++) {
const mesh = addBox(
volcano,
-12 + (i % 2 ? 0.25 : -0.2),
7 + i * 0.55,
-3.2,
1.25 - i * 0.08,
1.05 - i * 0.06,
1.15 - i * 0.07,
ash
);
mesh.userData.baseY = mesh.position.y;
mesh.userData.phase = i / 7;
smoke.push(mesh);
}
// ── Stage 2: weathering, river, sediment basin ───────────────────────────
const sediment = stageGroups[1];
const weatheredRock = makeMaterial(0x77746b);
const sand = makeMaterial(0xc3a16a);
const paleSand = makeMaterial(0xd8bb83);
const water = makeMaterial(0x42bec8, {
emissive: 0x176b76,
emissiveIntensity: 0.55,
roughness: 0.38,
metalness: 0.08
});
const riverbank = makeMaterial(0x967d57);
const talus = [];
for (let i = 0; i < 18; i++) {
const t = i / 17;
talus.push({
x: -8.8 + t * 3.7 + (random() - 0.5) * 0.6,
y: 0.35 + random() * 0.5,
z: -2.9 + t * 1.2 + (random() - 0.5) * 1.1,
sx: 0.42 + random() * 0.35,
sy: 0.35 + random() * 0.35,
sz: 0.42 + random() * 0.35
});
}
addInstancedBoxes(sediment, talus, weatheredRock);
const riverPoints = [
new THREE.Vector3(-8.2, 0.22, -2.9),
new THREE.Vector3(-7.2, 0.22, -2.45),
new THREE.Vector3(-6.2, 0.22, -1.8),
new THREE.Vector3(-5.35, 0.22, -1.55),
new THREE.Vector3(-4.1, 0.22, -1.9),
new THREE.Vector3(-2.8, 0.22, -2.45)
];
const riverBlocks = [];
const bankBlocks = [];
riverPoints.forEach((point, index) => {
riverBlocks.push({
x: point.x,
y: point.y,
z: point.z,
sx: 1.05,
sy: 0.26,
sz: 0.72
});
bankBlocks.push({
x: point.x - 0.35,
y: 0.08,
z: point.z - 0.58,
sx: 0.85,
sy: 0.25,
sz: 0.48
});
bankBlocks.push({
x: point.x + 0.35,
y: 0.08,
z: point.z + 0.58,
sx: 0.85,
sy: 0.25,
sz: 0.48
});
});
addInstancedBoxes(sediment, riverBlocks, water);
addInstancedBoxes(sediment, bankBlocks, riverbank);
const basinSand = [];
const basinWater = [];
for (let gx = -4; gx <= 4; gx++) {
for (let gz = -3; gz <= 3; gz++) {
const ellipse = (gx * gx) / 17 + (gz * gz) / 10;
if (ellipse <= 1) {
const item = {
x: -3.25 + gx * 0.55,
y: 0.1,
z: -2.65 + gz * 0.55,
sx: 0.53,
sy: 0.26,
sz: 0.53
};
if (ellipse < 0.56) basinWater.push(item);
else basinSand.push(item);
}
}
}
addInstancedBoxes(sediment, basinSand, sand);
addInstancedBoxes(sediment, basinWater, water);
const grains = [];
for (let i = 0; i < 24; i++) {
grains.push({
x: -5.4 + random() * 3.4,
y: 0.36 + random() * 0.4,
z: -0.75 + random() * 0.8,
sx: 0.16 + random() * 0.16,
sy: 0.14 + random() * 0.12,
sz: 0.16 + random() * 0.16
});
}
addInstancedBoxes(sediment, grains, paleSand);
addArrow(
sediment,
[-8.2, 2.3, -2.2],
[1, -0.15, 0.1],
3.1,
0xe7ae69
);
// ── Stage 3: burial, compaction, and the layered rock window ────────────
const burial = stageGroups[2];
const recentSediment = makeMaterial(0xd2ae72);
const compacted = makeMaterial(0xa96e48);
const deepRock = makeMaterial(0x66566c);
const basement = makeMaterial(0x3a4c60);
const pressure = makeMaterial(0xe69c4d, {
emissive: 0x8c3d10,
emissiveIntensity: 0.45
});
const burialFront = [
{ x: 3.2, y: -0.8, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 4.8, y: -0.8, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 6.4, y: -0.8, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 3.2, y: -2.4, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 4.8, y: -2.4, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 6.4, y: -2.4, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 3.2, y: -4, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 4.8, y: -4, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 6.4, y: -4, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 3.2, y: -5.6, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 4.8, y: -5.6, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 },
{ x: 6.4, y: -5.6, z: 0.04, sx: 1.56, sy: 1.55, sz: 1.58 }
];
addInstancedBoxes(burial, burialFront.slice(0, 3), recentSediment);
addInstancedBoxes(burial, burialFront.slice(3, 6), compacted);
addInstancedBoxes(burial, burialFront.slice(6, 9), deepRock);
addInstancedBoxes(burial, burialFront.slice(9), basement);
// Fresh sediment accumulating above older rock.
const overburden = [];
for (let layer = 0; layer < 3; layer++) {
for (let gx = -1; gx <= 1; gx++) {
for (let gz = -1; gz <= 1; gz++) {
overburden.push({
x: 4.8 + gx * 0.78,
y: 0.18 + layer * 0.7,
z: -1.35 + gz * 0.78,
sx: 0.75,
sy: 0.67,
sz: 0.75
});
}
}
}
addInstancedBoxes(burial, overburden, layerColorMaterial());
function layerColorMaterial() {
return makeMaterial(0xc49a63);
}
addArrow(burial, [4.8, 4.1, -0.4], [0, -1, 0], 2.1, 0xe7a454);
addArrow(burial, [3.35, 3.7, -0.4], [0, -1, 0], 1.7, 0xe7a454, 0.38);
addArrow(burial, [6.25, 3.7, -0.4], [0, -1, 0], 1.7, 0xe7a454, 0.38);
// ── Stage 4: faulted uplift and exposure ─────────────────────────────────
const uplift = stageGroups[3];
const upliftedTop = makeMaterial(0x657b50);
const upliftedSand = makeMaterial(0xb58a5a);
const upliftedRock = makeMaterial(0x926044);
const upliftedDeep = makeMaterial(0x66566b);
const fault = makeMaterial(0x252a31);
const exposedEdge = makeMaterial(0xd0a66d);
const columns = [
{ x: 11.2, shift: 0.0 },
{ x: 12.8, shift: 0.65 },
{ x: 14.4, shift: 1.3 }
];
columns.forEach(({ x, shift }) => {
addBox(uplift, x, -1.65 + shift, 0.04, 1.55, 1.48, 1.58, upliftedDeep);
addBox(uplift, x, -0.17 + shift, 0.04, 1.55, 1.48, 1.58, upliftedRock);
addBox(uplift, x, 1.31 + shift, 0.04, 1.55, 1.48, 1.58, upliftedSand);
addBox(uplift, x, 2.79 + shift, 0.04, 1.55, 1.48, 1.58, upliftedTop);
});
const hillBlocks = [];
for (let level = 0; level < 4; level++) {
for (let gx = -3; gx <= 3; gx++) {
for (let gz = -2; gz <= 1; gz++) {
if (Math.abs(gx) + Math.abs(gz) * 0.7 <= 3.5 - level) {
hillBlocks.push({
x: 12.5 + gx * 0.72,
y: 0.35 + level * 0.76,
z: -2.5 + gz * 0.72,
sx: 0.69,
sy: 0.73,
sz: 0.69
});
}
}
}
}
addInstancedBoxes(uplift, hillBlocks, upliftedTop);
addBox(uplift, 10.05, 0.1, -1.05, 0.18, 6.4, 0.2, fault, -0.34);
addBox(uplift, 14.9, 2.25, 0.12, 0.18, 4.5, 0.2, exposedEdge, -0.25);
addArrow(uplift, [15.2, 2.7, -1.1], [0, 1, 0], 3.4, 0xe7b166, 0.6);
// Transfer arrows are kept in the scene rather than interpreted as a timeline.
addArrow(scene, [-1.5, 2.05, -1.3], [1, -0.05, 0], 3.7, 0xd8ae72);
addArrow(scene, [7.2, 1.15, 0.1], [0.85, 0.52, 0], 3.6, 0xd8ae72);
// Save each stage material's original state so focus dimming is reversible.
stageGroups.forEach((group) => {
const materials = new Set();
group.traverse((object) => {
if (object.isMesh && object.material) materials.add(object.material);
});
group.userData.materialStates = [...materials].map((material) => ({
material,
opacity: material.opacity,
transparent: material.transparent,
depthWrite: material.depthWrite,
emissiveIntensity: material.emissiveIntensity ?? 0
}));
});
let activeStage = 0;
let dimOtherStages = false;
function applyStageEmphasis() {
stageGroups.forEach((group, index) => {
const focused = index === activeStage;
group.userData.materialStates.forEach((state) => {
const material = state.material;
if (dimOtherStages && !focused) {
material.opacity = state.opacity * 0.25;
material.transparent = true;
material.depthWrite = false;
} else {
material.opacity = state.opacity;
material.transparent = state.transparent;
material.depthWrite = state.depthWrite;
}
if (material.emissive) {
material.emissiveIntensity =
state.emissiveIntensity * (focused ? 1.22 : 1);
}
});
});
}
// Custom orbit controls; no external control addons are used.
const cameraControls = {
target: new THREE.Vector3(1.8, 0.8, -1),
goalTarget: new THREE.Vector3(1.8, 0.8, -1),
radius: 37,
goalRadius: 37,
theta: 0.64,
goalTheta: 0.64,
phi: 0.94,
goalPhi: 0.94,
dragging: false,
pointerX: 0,
pointerY: 0
};
let viewMode = "overview";
function overviewRadius() {
return window.innerWidth < 700 ? 78 : 37;
}
function resetCamera() {
viewMode = "overview";
const mobile = window.innerWidth < 700;
cameraControls.goalTarget.set(mobile ? 0 : 1.8, 0.8, -1);
cameraControls.goalRadius = overviewRadius();
cameraControls.goalTheta = 0.64;
cameraControls.goalPhi = 0.94;
}
function focusStage(index) {
viewMode = "stage";
const stage = stageData[index];
cameraControls.goalTarget.copy(stage.focus);
cameraControls.goalRadius = window.innerWidth < 700 ? 25 : 17;
cameraControls.goalTheta = 0.6 + index * 0.025;
cameraControls.goalPhi = 0.96;
}
function selectStage(index, focus = true) {
activeStage = index;
dimOtherStages = true;
applyStageEmphasis();
stageButtons.forEach((button, buttonIndex) => {
const active = buttonIndex === index;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
worldLabels.forEach((label, labelIndex) => {
label.classList.toggle("active", labelIndex === index);
});
if (focus) focusStage(index);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
cameraControls.dragging = true;
cameraControls.pointerX = event.clientX;
cameraControls.pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!cameraControls.dragging) return;
const dx = event.clientX - cameraControls.pointerX;
const dy = event.clientY - cameraControls.pointerY;
cameraControls.pointerX = event.clientX;
cameraControls.pointerY = event.clientY;
cameraControls.goalTheta -= dx * 0.006;
cameraControls.goalPhi = THREE.MathUtils.clamp(
cameraControls.goalPhi - dy * 0.005,
0.3,
1.35
);
});
function endDrag(event) {
cameraControls.dragging = false;
renderer.domElement.style.cursor = "grab";
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("pointerleave", (event) => {
if (cameraControls.dragging) endDrag(event);
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraControls.goalRadius = THREE.MathUtils.clamp(
cameraControls.goalRadius * Math.exp(event.deltaY * 0.001),
9,
95
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLInputElement) return;
if (["1", "2", "3", "4"].includes(event.key)) {
stopTour();
selectStage(Number(event.key) - 1, true);
}
if (event.key === "0") {
stopTour();
resetCamera();
}
if (event.key === "ArrowLeft") cameraControls.goalTheta += 0.09;
if (event.key === "ArrowRight") cameraControls.goalTheta -= 0.09;
if (event.key === "ArrowUp") {
cameraControls.goalPhi = THREE.MathUtils.clamp(
cameraControls.goalPhi - 0.07,
0.3,
1.35
);
}
if (event.key === "ArrowDown") {
cameraControls.goalPhi = THREE.MathUtils.clamp(
cameraControls.goalPhi + 0.07,
0.3,
1.35
);
}
if (event.key === "+" || event.key === "=") {
cameraControls.goalRadius = Math.max(9, cameraControls.goalRadius - 2);
}
if (event.key === "-") {
cameraControls.goalRadius = Math.min(95, cameraControls.goalRadius + 2);
}
});
const overviewButton = document.querySelector("#overviewButton");
overviewButton.addEventListener("click", () => {
stopTour();
resetCamera();
});
const tourButton = document.querySelector("#tourButton");
let tourTimer = null;
let tourIndex = 0;
let tourPlaying = false;
// Unequal pauses intentionally discourage reading the animation as a clock.
const tourReadingPauses = [2600, 4800, 7200, 9500];
function stopTour() {
if (tourTimer !== null) window.clearTimeout(tourTimer);
tourTimer = null;
tourPlaying = false;
tourButton.textContent = "▶ Guided tour";
tourButton.setAttribute("aria-pressed", "false");
}
function advanceTour() {
if (!tourPlaying) return;
if (tourIndex >= stageData.length) {
stopTour();
return;
}
selectStage(tourIndex, true);
tourIndex += 1;
if (tourIndex >= stageData.length) {
tourTimer = window.setTimeout(stopTour, tourReadingPauses[3]);
} else {
tourTimer = window.setTimeout(
advanceTour,
tourReadingPauses[tourIndex - 1]
);
}
}
tourButton.addEventListener("click", () => {
if (tourPlaying) {
stopTour();
return;
}
tourPlaying = true;
tourIndex = 0;
tourButton.textContent = "Ⅱ Pause tour";
tourButton.setAttribute("aria-pressed", "true");
advanceTour();
});
function updateCamera(delta) {
const damping = 1 - Math.exp(-delta * 7);
cameraControls.theta +=
(cameraControls.goalTheta - cameraControls.theta) * damping;
cameraControls.phi +=
(cameraControls.goalPhi - cameraControls.phi) * damping;
cameraControls.radius +=
(cameraControls.goalRadius - cameraControls.radius) * damping;
cameraControls.target.lerp(cameraControls.goalTarget, damping);
const sinPhi = Math.sin(cameraControls.phi);
camera.position.set(
cameraControls.target.x +
cameraControls.radius * sinPhi * Math.sin(cameraControls.theta),
cameraControls.target.y +
cameraControls.radius * Math.cos(cameraControls.phi),
cameraControls.target.z +
cameraControls.radius * sinPhi * Math.cos(cameraControls.theta)
);
camera.lookAt(cameraControls.target);
}
const projected = new THREE.Vector3();
function updateWorldLabels() {
const width = renderer.domElement.clientWidth;
const height = renderer.domElement.clientHeight;
stageData.forEach((stage, index) => {
projected.copy(stage.anchor).project(camera);
const visible = projected.z > -1 && projected.z < 1;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
worldLabels[index].style.left = `${x}px`;
worldLabels[index].style.top = `${y}px`;
worldLabels[index].style.visibility = visible ? "visible" : "hidden";
});
}
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
updateCamera(delta);
if (!reducedMotion) {
lavaLight.intensity = 31 + Math.sin(elapsed * 3.2) * 7;
lava.emissiveIntensity = 2.05 + Math.sin(elapsed * 3.8) * 0.38;
hotLava.emissiveIntensity = 2.55 + Math.sin(elapsed * 4.6 + 0.8) * 0.42;
smoke.forEach((mesh, index) => {
const travel = (elapsed * 0.34 + mesh.userData.phase) % 1.7;
mesh.position.y = mesh.userData.baseY + travel;
mesh.position.x += Math.sin(elapsed * 0.7 + index) * 0.0008;
});
}
updateWorldLabels();
renderer.render(scene, camera);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
if (viewMode === "overview") {
cameraControls.goalRadius = overviewRadius();
}
}
window.addEventListener("resize", resize);
selectStage(0, false);
dimOtherStages = false;
applyStageEmphasis();
resetCamera();
updateCamera(1);
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
});
</script>
</body>
</html>
```