Prompt specification
Build or customize the Three.js 3D scene "Geology process selection table" 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: Geology process selection table
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/geology-process-selection-table-x1180
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows the rock cycle. Provide buttons for weathering, burial, melting, and cooling on a schematic landscape; highlight affected rock zones and their conceptual transitions while preserving clear source and destination labels. Low-poly.
Working Three.js Starter (geology-process-selection-table-x1180):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Rock Cycle — Interactive Low-Poly Landscape</title>
<style>
:root {
--ink: #202a2a;
--muted: #65706c;
--paper: rgba(250, 249, 244, 0.91);
--line: rgba(37, 52, 50, 0.13);
--source: #d88a2f;
--destination: #168f82;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background: #e9e8df;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button { font: inherit; }
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene:active { cursor: grabbing; }
.topbar {
position: fixed;
z-index: 10;
top: 22px;
left: 24px;
right: 24px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
position: relative;
width: 42px;
height: 42px;
border: 1px solid rgba(31, 43, 41, 0.22);
border-radius: 50%;
background: rgba(250, 249, 244, 0.76);
box-shadow: 0 8px 25px rgba(42, 52, 49, 0.08);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
left: 9px;
right: 9px;
height: 7px;
transform: skewY(-13deg);
}
.brand-mark::before {
top: 10px;
background: #56615f;
clip-path: polygon(0 100%, 22% 0, 43% 100%, 66% 15%, 100% 100%);
}
.brand-mark::after {
top: 24px;
background: #c98037;
clip-path: polygon(0 100%, 28% 18%, 50% 100%, 72% 30%, 100% 100%);
}
.brand h1 {
margin: 0;
font-size: 18px;
line-height: 1.05;
letter-spacing: -0.035em;
font-weight: 760;
}
.brand p {
margin: 5px 0 0;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.header-tools {
display: flex;
align-items: center;
gap: 12px;
pointer-events: auto;
}
.legend {
display: flex;
align-items: center;
gap: 14px;
padding: 10px 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(250, 249, 244, 0.76);
backdrop-filter: blur(12px);
color: #59635f;
font-size: 11px;
font-weight: 700;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.legend i {
width: 8px;
height: 8px;
border-radius: 50%;
display: inline-block;
}
.legend .source-dot { background: var(--source); }
.legend .destination-dot { background: var(--destination); }
#reset-view {
height: 38px;
padding: 0 14px;
border: 1px solid var(--line);
border-radius: 11px;
color: #48534f;
background: rgba(250, 249, 244, 0.78);
backdrop-filter: blur(12px);
cursor: pointer;
font-size: 12px;
font-weight: 750;
transition: transform 160ms ease, background 160ms ease;
}
#reset-view:hover {
transform: translateY(-1px);
background: #fffdf7;
}
.panel {
position: fixed;
z-index: 10;
top: 94px;
left: 24px;
width: 336px;
max-height: calc(100vh - 118px);
overflow-y: auto;
padding: 19px;
border: 1px solid rgba(37, 52, 50, 0.13);
border-radius: 20px;
background: var(--paper);
box-shadow: 0 18px 60px rgba(42, 52, 49, 0.13);
backdrop-filter: blur(18px);
scrollbar-width: thin;
scrollbar-color: #c9c8bf transparent;
}
.eyebrow {
margin: 0 0 7px;
color: #74807a;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.panel > h2 {
margin: 0 0 15px;
font-size: 23px;
line-height: 1.1;
letter-spacing: -0.045em;
font-weight: 770;
}
.process-list {
display: grid;
gap: 8px;
}
.process {
position: relative;
display: grid;
grid-template-columns: 34px 1fr 22px;
align-items: center;
gap: 10px;
width: 100%;
padding: 11px 10px;
border: 1px solid rgba(39, 52, 49, 0.1);
border-left: 4px solid var(--process);
border-radius: 13px;
color: var(--ink);
background: rgba(255, 255, 255, 0.58);
text-align: left;
cursor: pointer;
transition: transform 150ms ease, border-color 150ms ease,
box-shadow 150ms ease, background 150ms ease;
}
.process:hover {
transform: translateX(2px);
background: rgba(255, 255, 255, 0.9);
}
.process.active {
border-color: var(--process);
background: #fffdf8;
box-shadow: 0 7px 24px color-mix(in srgb, var(--process) 22%, transparent);
}
.process .number {
display: grid;
place-items: center;
width: 32px;
height: 32px;
border-radius: 9px;
color: white;
background: var(--process);
font-size: 11px;
font-weight: 820;
}
.process strong {
display: block;
font-size: 13px;
line-height: 1.15;
letter-spacing: -0.01em;
}
.process small {
display: block;
margin-top: 3px;
color: #77817d;
font-size: 10px;
line-height: 1.2;
}
.process .arrow {
color: #a0a5a1;
font-size: 17px;
text-align: center;
transition: transform 150ms ease, color 150ms ease;
}
.process.active .arrow {
color: var(--process);
transform: translate(2px, -2px);
}
.detail {
margin-top: 15px;
padding-top: 15px;
border-top: 1px solid var(--line);
min-height: 178px;
}
.detail-kicker {
color: var(--active-color, var(--source));
font-size: 9px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.detail h3 {
margin: 6px 0 10px;
font-size: 17px;
letter-spacing: -0.025em;
}
.equation {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 7px;
margin-bottom: 9px;
font-size: 11px;
font-weight: 750;
}
.equation .from {
color: var(--source);
}
.equation .to {
color: var(--destination);
}
.equation b {
color: #9ca29e;
font-weight: 500;
}
.detail p {
margin: 0;
color: #5d6863;
font-size: 12px;
line-height: 1.55;
}
.concept-note {
display: flex;
gap: 7px;
margin-top: 11px;
color: #7a837f;
font-size: 9px;
line-height: 1.4;
}
.concept-note::before {
content: "✦";
color: var(--active-color, var(--source));
font-size: 11px;
}
#labels {
position: fixed;
z-index: 5;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.zone-label {
position: absolute;
min-width: 132px;
padding: 9px 11px 10px;
border: 1px solid rgba(37, 52, 50, 0.17);
border-radius: 11px;
background: rgba(255, 254, 249, 0.91);
box-shadow: 0 8px 24px rgba(36, 45, 43, 0.11);
opacity: 0;
transform: translate(-50%, -100%);
transition: opacity 180ms ease, border-color 180ms ease,
box-shadow 180ms ease, background 180ms ease;
will-change: left, top;
}
.zone-label.visible { opacity: 1; }
.zone-label::after {
content: "";
position: absolute;
left: 50%;
bottom: -10px;
width: 1px;
height: 10px;
background: rgba(37, 52, 50, 0.3);
}
.zone-label.source {
border-color: var(--source);
background: #fffaf0;
box-shadow: 0 9px 27px rgba(190, 115, 32, 0.2);
}
.zone-label.destination {
border-color: var(--destination);
background: #f4fffc;
box-shadow: 0 9px 27px rgba(18, 129, 116, 0.18);
}
.zone-relation {
display: none;
width: fit-content;
margin-bottom: 5px;
padding: 3px 6px;
border-radius: 5px;
font-size: 8px;
font-weight: 900;
letter-spacing: 0.13em;
}
.zone-label.source .zone-relation {
display: block;
color: #8b4c0c;
background: #f6d7ad;
}
.zone-label.destination .zone-relation {
display: block;
color: #0b665d;
background: #c8eee7;
}
.zone-title {
display: block;
font-size: 12px;
font-weight: 820;
letter-spacing: -0.015em;
white-space: nowrap;
}
.zone-subtitle {
display: block;
margin-top: 2px;
color: #77817c;
font-size: 9px;
white-space: nowrap;
}
#transition-tag {
position: fixed;
z-index: 6;
padding: 7px 10px;
border-radius: 999px;
color: white;
background: #d88a2f;
box-shadow: 0 7px 20px rgba(31, 40, 38, 0.15);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
pointer-events: none;
transform: translate(-50%, -50%);
opacity: 0;
transition: opacity 180ms ease;
white-space: nowrap;
}
.view-hint {
position: fixed;
z-index: 4;
right: 25px;
bottom: 22px;
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid rgba(37, 52, 50, 0.1);
border-radius: 10px;
color: #727b77;
background: rgba(250, 249, 244, 0.72);
backdrop-filter: blur(10px);
font-size: 10px;
font-weight: 650;
pointer-events: none;
}
.view-hint span {
color: #34413d;
font-size: 14px;
}
@media (max-width: 760px) {
.topbar {
top: 14px;
left: 14px;
right: 14px;
}
.brand h1 { font-size: 15px; }
.brand p { font-size: 8px; }
.brand-mark { width: 36px; height: 36px; }
.brand-mark::before { top: 8px; }
.brand-mark::after { top: 21px; }
.legend { display: none; }
#reset-view {
height: 35px;
padding: 0 11px;
font-size: 10px;
}
.panel {
top: auto;
left: 12px;
right: 12px;
bottom: 12px;
width: auto;
max-height: 46vh;
padding: 14px;
border-radius: 17px;
}
.panel > h2 {
margin-bottom: 11px;
font-size: 19px;
}
.process-list {
grid-template-columns: 1fr 1fr;
gap: 6px;
}
.process {
grid-template-columns: 29px 1fr;
gap: 7px;
padding: 8px 7px;
border-left-width: 3px;
}
.process .number {
width: 27px;
height: 27px;
border-radius: 8px;
font-size: 9px;
}
.process strong { font-size: 11px; }
.process small { font-size: 8px; }
.process .arrow { display: none; }
.detail {
min-height: 0;
margin-top: 11px;
padding-top: 11px;
}
.detail h3 { font-size: 14px; }
.detail p { font-size: 10px; }
.concept-note { display: none; }
.zone-label {
min-width: 104px;
padding: 7px 8px;
}
.zone-title { font-size: 10px; }
.zone-subtitle { font-size: 8px; }
.zone-relation { margin-bottom: 3px; font-size: 7px; }
.view-hint { display: none; }
}
@media (max-height: 650px) and (min-width: 761px) {
.panel {
top: 82px;
max-height: calc(100vh - 100px);
padding: 14px;
}
.panel > h2 { font-size: 19px; }
.process { padding: 8px; }
.detail { min-height: 0; padding-top: 10px; }
.concept-note { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly cutaway landscape showing the rock cycle"></canvas>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<h1>The Rock Cycle</h1>
<p>Interactive cutaway · not to scale</p>
</div>
</div>
<div class="header-tools">
<div class="legend" aria-label="Transition legend">
<span><i class="source-dot"></i>Source zone</span>
<span><i class="destination-dot"></i>Destination zone</span>
</div>
<button id="reset-view" type="button">Reset view</button>
</div>
</header>
<aside class="panel" aria-label="Rock cycle process controls">
<p class="eyebrow">Process controls</p>
<h2>Transform the landscape</h2>
<div class="process-list">
<button class="process" type="button" data-process="weathering"
style="--process:#d88a2f" aria-pressed="false">
<span class="number">01</span>
<span><strong>Weathering</strong><small>Exposed rock → sediment</small></span>
<span class="arrow">↗</span>
</button>
<button class="process" type="button" data-process="burial"
style="--process:#8068b2" aria-pressed="false">
<span class="number">02</span>
<span><strong>Burial</strong><small>Sediment → metamorphic rock</small></span>
<span class="arrow">↗</span>
</button>
<button class="process" type="button" data-process="melting"
style="--process:#df5b48" aria-pressed="false">
<span class="number">03</span>
<span><strong>Melting</strong><small>Rock → magma</small></span>
<span class="arrow">↗</span>
</button>
<button class="process" type="button" data-process="cooling"
style="--process:#258f86" aria-pressed="false">
<span class="number">04</span>
<span><strong>Cooling</strong><small>Magma → igneous rock</small></span>
<span class="arrow">↗</span>
</button>
</div>
<section id="detail" class="detail" aria-live="polite"></section>
</aside>
<div id="labels" aria-hidden="true">
<div class="zone-label" data-zone="igneous">
<span class="zone-relation"></span>
<span class="zone-title">Igneous outcrop</span>
<span class="zone-subtitle">Crystalline rock</span>
</div>
<div class="zone-label" data-zone="sediments">
<span class="zone-relation"></span>
<span class="zone-title">Sediment basin</span>
<span class="zone-subtitle">Loose grains & fragments</span>
</div>
<div class="zone-label" data-zone="metamorphic">
<span class="zone-relation"></span>
<span class="zone-title">Metamorphic bed</span>
<span class="zone-subtitle">Heat + pressure</span>
</div>
<div class="zone-label" data-zone="magma">
<span class="zone-relation"></span>
<span class="zone-title">Magma chamber</span>
<span class="zone-subtitle">Molten rock</span>
</div>
</div>
<div id="transition-tag"></div>
<div class="view-hint"><span>↔</span> Drag to orbit · Scroll to zoom</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, camera, and direct camera controls
// ------------------------------------------------------------
const canvas = document.querySelector("#scene");
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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e8df);
scene.fog = new THREE.Fog(0xe9e8df, 23, 42);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, -0.35, 0);
const orbit = {
theta: 0.62,
phi: 1.04,
radius: 18.5
};
function updateCamera() {
const horizontal = orbit.radius * Math.sin(orbit.phi);
camera.position.set(
target.x + horizontal * Math.sin(orbit.theta),
target.y + orbit.radius * Math.cos(orbit.phi),
target.z + horizontal * Math.cos(orbit.theta)
);
camera.lookAt(target);
camera.updateMatrixWorld();
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xfffdf3, 0x788379, 2.05);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d5, 3.15);
sun.position.set(-7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc9e0e2, 1.1);
fill.position.set(9, 6, -8);
scene.add(fill);
// ------------------------------------------------------------
// Deterministic helpers
// ------------------------------------------------------------
let seed = 41729;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function range(min, max) {
return min + (max - min) * random();
}
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.88,
metalness: options.metalness ?? 0,
flatShading: options.flatShading ?? true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
side: options.side ?? THREE.FrontSide
});
}
function mesh(geometry, material, position, parent = scene) {
const object = new THREE.Mesh(geometry, material);
if (position) object.position.set(...position);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(width, height, depth, position, color, parent = scene) {
return mesh(
new THREE.BoxGeometry(width, height, depth),
standardMaterial(color),
position,
parent
);
}
function makeRock(radius, color, scale = [1, 1, 1], parent = scene) {
const rock = mesh(
new THREE.IcosahedronGeometry(radius, 0),
standardMaterial(color),
null,
parent
);
rock.scale.set(...scale);
rock.rotation.set(range(-0.3, 0.3), range(0, Math.PI), range(-0.2, 0.2));
return rock;
}
// ------------------------------------------------------------
// Diorama, cutaway strata, terrain, and water
// ------------------------------------------------------------
box(14.8, 0.36, 8.6, [0, -3.48, 0], 0xb7b5a8);
box(14.0, 1.05, 0.28, [0, -0.55, -3.91], 0x9a7955);
box(14.0, 1.05, 0.28, [0, -1.60, -3.91], 0xb07f55);
box(14.0, 1.05, 0.28, [0, -2.65, -3.91], 0xc49361);
box(0.30, 3.25, 8.0, [-6.91, -1.63, 0], 0x9e7954);
box(0.30, 3.25, 8.0, [6.91, -1.63, 0], 0xb28359);
const terrainGeometry = new THREE.PlaneGeometry(14, 8, 10, 6);
terrainGeometry.rotateX(-Math.PI / 2);
const terrainPositions = terrainGeometry.attributes.position;
const terrainColors = [];
for (let i = 0; i < terrainPositions.count; i++) {
const x = terrainPositions.getX(i);
const z = terrainPositions.getZ(i);
const edgeX = Math.min(1, Math.max(0, (7 - Math.abs(x)) / 1.4));
const edgeZ = Math.min(1, Math.max(0, (4 - Math.abs(z)) / 1.0));
const edge = Math.min(edgeX, edgeZ);
let y = 0.02 + random() * 0.11 * edge;
if (x > 2.6 && z < -0.3) y -= 0.035;
terrainPositions.setY(i, y);
let color;
if (x > 2.3 && z < -0.25) {
color = new THREE.Color(0xb9ad82);
} else if (z > 0.2 && x > 2.2) {
color = new THREE.Color(0xc6b783);
} else if (x < -2.6) {
color = new THREE.Color(0x89967a);
} else {
color = new THREE.Color(0x9ca487);
}
color.offsetHSL(range(-0.015, 0.015), range(-0.03, 0.03), range(-0.035, 0.035));
terrainColors.push(color.r, color.g, color.b);
}
terrainGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(terrainColors, 3)
);
terrainGeometry.computeVertexNormals();
const terrainMaterial = standardMaterial(0xffffff);
terrainMaterial.vertexColors = true;
terrainMaterial.flatShading = true;
const terrain = mesh(terrainGeometry, terrainMaterial, null);
terrain.castShadow = false;
// Low-poly water bay.
const waterVertices = new Float32Array([
2.65, 0.10, -3.72,
6.70, 0.10, -3.72,
6.70, 0.10, -0.22,
3.25, 0.10, -0.22,
2.65, 0.10, -1.45,
2.65, 0.10, -3.72,
6.70, 0.10, -0.22,
3.25, 0.10, -0.22,
2.65, 0.10, -3.72,
3.25, 0.10, -0.22,
2.65, 0.10, -1.45
]);
const waterGeometry = new THREE.BufferGeometry();
waterGeometry.setAttribute(
"position",
new THREE.BufferAttribute(waterVertices, 3)
);
waterGeometry.computeVertexNormals();
const waterMaterial = standardMaterial(0x69aeb8, {
roughness: 0.36,
transparent: true,
opacity: 0.86
});
const water = mesh(waterGeometry, waterMaterial, null);
water.castShadow = false;
const waveMaterial = new THREE.MeshBasicMaterial({
color: 0xe5f4ef,
transparent: true,
opacity: 0.35,
depthWrite: false
});
for (let i = 0; i < 8; i++) {
const wave = mesh(
new THREE.BoxGeometry(range(0.35, 0.9), 0.012, 0.035),
waveMaterial,
[range(3.0, 6.25), 0.13, range(-3.35, -0.65)]
);
wave.rotation.y = range(-0.25, 0.25);
wave.castShadow = false;
wave.receiveShadow = false;
}
// Background hills and simple vegetation.
const hillMaterial = standardMaterial(0x7e8d70);
mesh(new THREE.ConeGeometry(2.4, 2.7, 7), hillMaterial, [-1.4, 1.25, -2.65]);
mesh(new THREE.ConeGeometry(1.8, 2.0, 7), standardMaterial(0x89977a), [-5.4, 0.95, -2.65]);
function makeTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
group.scale.setScalar(scale);
scene.add(group);
const trunk = mesh(
new THREE.CylinderGeometry(0.07, 0.10, 0.52, 5),
standardMaterial(0x6e5540),
[0, 0.25, 0],
group
);
const crown = mesh(
new THREE.ConeGeometry(0.34, 0.76, 6),
standardMaterial(0x4d7657),
[0, 0.75, 0],
group
);
trunk.rotation.y = range(0, Math.PI);
crown.rotation.y = range(0, Math.PI);
}
makeTree(-2.65, -1.8, 0.85);
makeTree(-1.9, -2.65, 0.65);
makeTree(1.05, -2.75, 0.72);
makeTree(2.0, -1.55, 0.58);
// ------------------------------------------------------------
// Rock-cycle zones
// ------------------------------------------------------------
const zones = {
igneous: {
id: "igneous",
group: new THREE.Group(),
labelAnchor: new THREE.Vector3(-4.1, 2.25, 0.15),
labelOffset: [-12, -8],
materials: [],
meshList: [],
halo: null
},
sediments: {
id: "sediments",
group: new THREE.Group(),
labelAnchor: new THREE.Vector3(4.15, 0.82, 1.15),
labelOffset: [8, -4],
materials: [],
meshList: [],
halo: null
},
metamorphic: {
id: "metamorphic",
group: new THREE.Group(),
labelAnchor: new THREE.Vector3(1.05, -0.58, 3.78),
labelOffset: [52, 5],
materials: [],
meshList: [],
halo: null
},
magma: {
id: "magma",
group: new THREE.Group(),
labelAnchor: new THREE.Vector3(-1.65, -1.50, 3.78),
labelOffset: [-52, 10],
materials: [],
meshList: [],
halo: null
}
};
Object.values(zones).forEach(zone => scene.add(zone.group));
// Igneous outcrop.
zones.igneous.group.position.set(-4.05, 0, -0.15);
const igneousMaterial = standardMaterial(0x647176);
const igneousDarkMaterial = standardMaterial(0x4c595e);
const mainIgneous = makeRock(
1.05,
0x69757a,
[1.45, 1.05, 1.0],
zones.igneous.group
);
mainIgneous.position.set(0, 0.92, 0.1);
makeRock(0.72, 0x59666b, [1.0, 1.2, 0.85], zones.igneous.group)
.position.set(-1.05, 0.64, 0.35);
makeRock(0.63, 0x758084, [1.15, 0.9, 0.8], zones.igneous.group)
.position.set(1.05, 0.58, -0.15);
makeRock(0.48, 0x505d61, [1.1, 0.75, 0.9], zones.igneous.group)
.position.set(0.35, 0.42, 0.85);
// Angular crystal columns reinforce the igneous character.
for (let i = 0; i < 4; i++) {
const column = mesh(
new THREE.CylinderGeometry(0.13, 0.18, 0.85, 6),
i % 2 ? igneousMaterial : igneousDarkMaterial,
[
-0.48 + i * 0.31,
1.85 + (i % 2) * 0.2,
-0.16 + (i % 2) * 0.18
],
zones.igneous.group
);
column.rotation.z = range(-0.15, 0.15);
}
// Sediment basin.
zones.sediments.group.position.set(4.15, 0, 1.18);
const sedimentColors = [0x9f8055, 0xb59768, 0xc5aa79];
for (let i = 0; i < 3; i++) {
const layer = mesh(
new THREE.CylinderGeometry(1.48 - i * 0.12, 1.62 - i * 0.12, 0.16, 9),
standardMaterial(sedimentColors[i]),
[0, 0.02 + i * 0.14, 0],
zones.sediments.group
);
layer.rotation.y = i * 0.26;
layer.scale.z = 0.72;
}
const pebbleColors = [0x8e765b, 0xb89a6c, 0x7e6a58, 0xd0b88b];
for (let i = 0; i < 14; i++) {
const angle = random() * Math.PI * 2;
const radius = Math.sqrt(random()) * 1.18;
const pebble = makeRock(
range(0.10, 0.23),
pebbleColors[i % pebbleColors.length],
[range(0.8, 1.5), range(0.45, 0.85), range(0.8, 1.35)],
zones.sediments.group
);
pebble.position.set(
Math.cos(angle) * radius,
0.48 + random() * 0.12,
Math.sin(angle) * radius * 0.7
);
}
// Metamorphic bed.
zones.metamorphic.group.position.set(1.05, 0, 3.35);
const metamorphicMaterial = standardMaterial(0x75627f);
const metamorphicLight = standardMaterial(0x8c7293);
const metamorphicDark = standardMaterial(0x51475f);
const slateA = makeRock(
1.0,
0x766184,
[1.25, 0.45, 0.78],
zones.metamorphic.group
);
slateA.position.set(-0.2, -0.94, 0);
const slateB = makeRock(
0.82,
0x8b7192,
[1.2, 0.36, 0.72],
zones.metamorphic.group
);
slateB.position.set(0.85, -1.33, 0.14);
slateB.rotation.z = -0.17;
const slateC = makeRock(
0.72,
0x574a68,
[1.15, 0.5, 0.7],
zones.metamorphic.group
);
slateC.position.set(-0.95, -1.48, 0.22);
for (let i = 0; i < 4; i++) {
const fragment = makeRock(
range(0.26, 0.48),
i % 2 ? metamorphicMaterial : metamorphicDark,
[1.25, 0.35, 0.72],
zones.metamorphic.group
);
fragment.position.set(
range(-1.15, 1.25),
range(-1.75, -0.63),
range(0.2, 0.62)
);
fragment.rotation.z = range(-0.35, 0.35);
}
// Magma chamber.
zones.magma.group.position.set(-1.65, 0, 3.38);
const hostMaterial = standardMaterial(0x443b38);
const hotMaterial = standardMaterial(0xff6b2e, {
roughness: 0.42,
emissive: 0xff3b0f,
emissiveIntensity: 1.35
});
const hotLightMaterial = standardMaterial(0xffb13b, {
roughness: 0.4,
emissive: 0xff7a16,
emissiveIntensity: 1.6
});
const hostA = makeRock(1.15, 0x443b38, [1.25, 0.9, 0.72], zones.magma.group);
hostA.position.set(0, -2.08, 0);
const hostB = makeRock(0.82, 0x55443b, [1.25, 0.85, 0.75], zones.magma.group);
hostB.position.set(0.92, -2.33, 0.17);
const hostC = makeRock(0.86, 0x3e3735, [1.15, 0.82, 0.72], zones.magma.group);
hostC.position.set(-0.88, -2.37, 0.18);
const glowA = makeRock(0.62, 0xff6b2e, [1.15, 0.8, 0.7], zones.magma.group);
glowA.position.set(-0.08, -2.00, 0.48);
glowA.userData.glow = true;
const glowB = makeRock(0.43, 0xffb13b, [1.1, 0.82, 0.65], zones.magma.group);
glowB.position.set(0.60, -2.32, 0.50);
glowB.userData.glow = true;
const magmaLight = new THREE.PointLight(0xff6428, 13, 8, 2);
magmaLight.position.set(-1.55, -1.92, 3.9);
scene.add(magmaLight);
// Register clickable zone meshes and preserve material base values.
const zoneMeshes = [];
Object.values(zones).forEach(zone => {
const materialSet = new Set();
zone.group.traverse(object => {
if (!object.isMesh) return;
object.userData.zone = zone.id;
zone.meshList.push(object);
zoneMeshes.push(object);
const materials = Array.isArray(object.material)
? object.material
: [object.material];
materials.forEach(material => {
materialSet.add(material);
material.userData.baseEmissive = material.emissive
? material.emissive.clone()
: new THREE.Color(0x000000);
material.userData.baseEmissiveIntensity = material.emissiveIntensity ?? 0;
});
});
zone.materials = [...materialSet];
});
// Highlight halos.
function makeHalo(position, radius, surface = false) {
const material = new THREE.MeshBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0,
depthTest: false,
depthWrite: false
});
const halo = mesh(
new THREE.TorusGeometry(radius, 0.055, 7, 42),
material,
position
);
if (surface) halo.rotation.x = Math.PI / 2;
halo.visible = false;
halo.renderOrder = 20;
halo.castShadow = false;
halo.receiveShadow = false;
return halo;
}
zones.igneous.halo = makeHalo([-4.05, 0.26, -0.1], 1.72, true);
zones.sediments.halo = makeHalo([4.15, 0.55, 1.18], 1.62, true);
zones.metamorphic.halo = makeHalo([1.05, -1.18, 4.02], 1.25, false);
zones.magma.halo = makeHalo([-1.65, -2.12, 4.02], 1.18, false);
// ------------------------------------------------------------
// Transition arrows
// ------------------------------------------------------------
const transitionData = {
weathering: {
title: "Weathering",
source: "igneous",
destination: "sediments",
sourceText: "Igneous rock",
destinationText: "Sediments",
color: 0xd88a2f,
description:
"At the surface, wind, water, ice, and chemical reactions break solid rock into smaller grains and fragments.",
concept:
"This conceptual route shows exposed igneous rock becoming sediment. In nature, many rock types can weather."
},
burial: {
title: "Burial & metamorphism",
source: "sediments",
destination: "metamorphic",
sourceText: "Sediments",
destinationText: "Metamorphic rock",
color: 0x8068b2,
description:
"Buried sediment experiences increasing pressure, heat, and chemically active fluids, changing its mineral structure.",
concept:
"The rock changes in the solid state. It is compacted and recrystallized without fully melting."
},
melting: {
title: "Melting",
source: "metamorphic",
destination: "magma",
sourceText: "Metamorphic rock",
destinationText: "Magma",
color: 0xdf5b48,
description:
"At sufficiently high temperature, the crystalline structure breaks down and the rock becomes a molten mixture.",
concept:
"This pathway simplifies one route into magma. Any rock type can melt when its temperature rises enough."
},
cooling: {
title: "Cooling & crystallization",
source: "magma",
destination: "igneous",
sourceText: "Magma",
destinationText: "Igneous rock",
color: 0x258f86,
description:
"As molten rock cools, minerals begin to crystallize. Slow cooling creates coarse crystals; fast cooling creates fine crystals.",
concept:
"Crystallization produces igneous rock, completing this conceptual loop through the landscape."
}
};
const arrows = {};
function createArrow(id, points) {
const data = transitionData[id];
const curve = new THREE.CatmullRomCurve3(
points.map(point => new THREE.Vector3(...point)),
false,
"catmullrom",
0.3
);
const lineMaterial = new THREE.LineDashedMaterial({
color: data.color,
dashSize: 0.22,
gapSize: 0.15,
transparent: true,
opacity: 0.18,
depthWrite: false
});
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(curve.getPoints(90)),
lineMaterial
);
line.computeLineDistances();
line.renderOrder = 4;
scene.add(line);
const arrowMaterial = new THREE.MeshBasicMaterial({
color: data.color,
transparent: true,
opacity: 0.34,
depthWrite: false
});
const arrowHead = mesh(
new THREE.ConeGeometry(0.16, 0.48, 7),
arrowMaterial,
null
);
arrowHead.position.copy(curve.getPoint(0.96));
arrowHead.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
curve.getTangent(0.96).normalize()
);
arrowHead.renderOrder = 5;
arrowHead.castShadow = false;
arrowHead.receiveShadow = false;
const particles = [];
for (let i = 0; i < 4; i++) {
const particle = mesh(
new THREE.SphereGeometry(0.085, 8, 6),
new THREE.MeshBasicMaterial({
color: data.color,
transparent: true,
opacity: 0.92,
depthWrite: false
}),
null
);
particle.renderOrder = 6;
particle.visible = false;
particle.castShadow = false;
particle.receiveShadow = false;
particles.push(particle);
}
arrows[id] = {
curve,
line,
lineMaterial,
arrowHead,
arrowMaterial,
particles
};
}
createArrow("weathering", [
[-3.55, 2.08, -0.10],
[-1.85, 2.82, 0.25],
[1.75, 2.45, 1.05],
[3.72, 0.90, 1.18]
]);
createArrow("burial", [
[4.05, 0.58, 1.38],
[3.48, -0.10, 2.50],
[2.15, -0.78, 3.40],
[1.40, -1.03, 3.78]
]);
createArrow("melting", [
[0.65, -1.20, 3.80],
[0.05, -1.52, 4.02],
[-0.92, -1.85, 3.90],
[-1.40, -2.05, 3.77]
]);
createArrow("cooling", [
[-1.85, -1.95, 3.82],
[-3.10, -1.52, 3.76],
[-4.95, -0.20, 2.72],
[-4.86, 0.80, 1.08],
[-4.10, 1.48, 0.32]
]);
// ------------------------------------------------------------
// UI and selection state
// ------------------------------------------------------------
const detail = document.querySelector("#detail");
const transitionTag = document.querySelector("#transition-tag");
const processButtons = [...document.querySelectorAll(".process")];
const labelElements = [...document.querySelectorAll(".zone-label")];
let activeTransition = "weathering";
function setTransition(id) {
if (!transitionData[id]) return;
activeTransition = id;
const data = transitionData[id];
processButtons.forEach(button => {
const selected = button.dataset.process === id;
button.classList.toggle("active", selected);
button.setAttribute("aria-pressed", String(selected));
});
detail.style.setProperty("--active-color", `#${data.color.toString(16).padStart(6, "0")}`);
detail.innerHTML = `
<div class="detail-kicker">Selected pathway · ${data.title}</div>
<h3>${data.title}</h3>
<div class="equation">
<span class="from">${data.sourceText}</span>
<b>→</b>
<span class="to">${data.destinationText}</span>
</div>
<p>${data.description}</p>
<div class="concept-note">${data.concept}</div>
`;
labelElements.forEach(label => {
const zoneId = label.dataset.zone;
const role =
zoneId === data.source
? "source"
: zoneId === data.destination
? "destination"
: null;
label.classList.toggle("source", role === "source");
label.classList.toggle("destination", role === "destination");
const relation = label.querySelector(".zone-relation");
relation.textContent = role ? role : "";
});
Object.entries(arrows).forEach(([arrowId, arrow]) => {
const selected = arrowId === id;
arrow.lineMaterial.opacity = selected ? 0.95 : 0.14;
arrow.arrowMaterial.opacity = selected ? 1 : 0.28;
arrow.particles.forEach(particle => {
particle.visible = selected;
});
});
transitionTag.textContent = data.title;
transitionTag.style.background = `#${data.color.toString(16).padStart(6, "0")}`;
}
processButtons.forEach(button => {
button.addEventListener("click", () => setTransition(button.dataset.process));
});
// ------------------------------------------------------------
// Custom pointer orbit, wheel zoom, and zone clicking
// ------------------------------------------------------------
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let dragging = false;
let moved = 0;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", event => {
dragging = true;
moved = 0;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
moved += Math.abs(dx) + Math.abs(dy);
orbit.theta = THREE.MathUtils.clamp(
orbit.theta - dx * 0.006,
-0.30,
1.22
);
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - dy * 0.005,
0.61,
1.31
);
previousX = event.clientX;
previousY = event.clientY;
updateCamera();
});
canvas.addEventListener("pointerup", event => {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (moved < 6) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(zoneMeshes, false);
if (hits.length) {
const clickedZone = hits[0].object.userData.zone;
const zoneToProcess = {
igneous: "weathering",
sediments: "burial",
metamorphic: "melting",
magma: "cooling"
};
setTransition(zoneToProcess[clickedZone]);
}
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
});
canvas.addEventListener("wheel", event => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
12.5,
25
);
updateCamera();
}, { passive: false });
function resetView() {
orbit.theta = 0.62;
orbit.phi = 1.04;
orbit.radius = 18.5;
updateCamera();
}
document.querySelector("#reset-view").addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("keydown", event => {
const index = Number(event.key) - 1;
if (index >= 0 && index < processButtons.length) {
setTransition(processButtons[index].dataset.process);
}
});
// ------------------------------------------------------------
// Project DOM labels from their 3D anchors
// ------------------------------------------------------------
const projected = new THREE.Vector3();
function positionLabel(element, anchor, offset) {
projected.copy(anchor).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.3 &&
projected.x < 1.3 &&
projected.y > -1.3 &&
projected.y < 1.3;
element.classList.toggle("visible", visible);
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth + offset[0];
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight + offset[1];
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function updateLabels() {
const compact = window.innerWidth <= 760;
Object.values(zones).forEach(zone => {
const element = labelElements.find(label => label.dataset.zone === zone.id);
const offset = compact
? [zone.labelOffset[0] * 0.45, zone.labelOffset[1] * 0.55]
: zone.labelOffset;
positionLabel(element, zone.labelAnchor, offset);
});
const activeArrow = arrows[activeTransition];
const tagAnchor = activeArrow.curve.getPoint(0.57);
projected.copy(tagAnchor).project(camera);
const tagVisible = projected.z > -1 && projected.z < 1;
transitionTag.style.opacity = tagVisible ? "1" : "0";
transitionTag.style.left =
`${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
transitionTag.style.top =
`${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
const sourceEmissive = new THREE.Color(0x8a4a09);
const destinationEmissive = new THREE.Color(0x075f55);
function animate() {
const elapsed = clock.getElapsedTime();
const data = transitionData[activeTransition];
// Pulsing, role-based material highlights.
Object.values(zones).forEach(zone => {
const role =
zone.id === data.source
? "source"
: zone.id === data.destination
? "destination"
: null;
const pulse = 0.22 + (Math.sin(elapsed * 4.1) + 1) * 0.10;
zone.materials.forEach(material => {
if (!material.emissive) return;
material.emissive.copy(material.userData.baseEmissive);
material.emissiveIntensity =
material.userData.baseEmissiveIntensity;
if (role === "source") {
material.emissive.copy(sourceEmissive);
material.emissiveIntensity = pulse;
} else if (role === "destination") {
material.emissive.copy(destinationEmissive);
material.emissiveIntensity = pulse;
}
});
const halo = zone.halo;
halo.visible = Boolean(role);
if (role) {
halo.material.color.set(role === "source" ? 0xe29a42 : 0x28a99b);
halo.material.opacity = 0.48 + Math.sin(elapsed * 4.1) * 0.16;
const haloPulse = 1 + Math.sin(elapsed * 3.2) * 0.055;
halo.scale.setScalar(haloPulse);
}
});
// Animated particles travelling along the selected transition.
const selectedArrow = arrows[activeTransition];
selectedArrow.particles.forEach((particle, index) => {
const progress = (elapsed * 0.24 + index / selectedArrow.particles.length) % 1;
particle.position.copy(selectedArrow.curve.getPoint(progress));
particle.scale.setScalar(0.85 + Math.sin(elapsed * 6 + index) * 0.16);
});
// Gentle heat pulse in the magma chamber.
zones.magma.group.traverse(object => {
if (object.userData.glow) {
const pulse = 1 + Math.sin(elapsed * 2.8 + object.position.x) * 0.055;
object.scale.multiplyScalar(pulse / (object.scale.x / object.scale.x));
object.material.emissiveIntensity =
object.material.userData.baseEmissiveIntensity *
(0.9 + Math.sin(elapsed * 3.1) * 0.15);
}
});
magmaLight.intensity = 12 + Math.sin(elapsed * 3.2) * 2.2;
water.position.y = Math.sin(elapsed * 0.65) * 0.012;
updateLabels();
renderer.render(scene, camera);
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
setTransition("weathering");
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```