Prompt specification
Build or customize the Three.js 3D scene "Cooling block fracture analogy" 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: Cooling block fracture analogy
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/cooling-block-fracture-analogy-x1126
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing columnar basalt. Place an unfractured block beside a progressively segmented column cluster; use staged visual transitions labeled as a qualitative cooling-joint analogy rather than a physical fracture simulation. Stylized solid forms.
Working Three.js Starter (cooling-block-fracture-analogy-x1126):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Columnar Basalt — Qualitative Cooling-Joint Analogy</title>
<style>
:root {
color-scheme: dark;
--bg: #0b1118;
--panel: rgba(16, 23, 31, 0.88);
--panel-border: rgba(185, 211, 224, 0.16);
--text: #edf3f5;
--muted: #9eacb5;
--accent: #b9d8dc;
--warm: #d6ae82;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 58% 35%, #192631 0%, #0c131b 47%, #070b10 100%);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(3, 7, 11, 0.28), transparent 24%),
radial-gradient(circle at 50% 46%, transparent 48%, rgba(2, 5, 8, 0.38));
}
header {
position: fixed;
top: 28px;
left: 32px;
z-index: 10;
max-width: 460px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 10px;
color: var(--accent);
font-size: 0.69rem;
font-weight: 700;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(2rem, 4.1vw, 4.25rem);
font-weight: 520;
letter-spacing: -0.055em;
line-height: 0.95;
}
.subtitle {
max-width: 390px;
margin: 15px 0 0;
color: var(--muted);
font-size: 0.92rem;
line-height: 1.55;
}
.model-badge {
position: fixed;
top: 30px;
right: 32px;
z-index: 12;
display: flex;
align-items: center;
gap: 9px;
padding: 10px 13px;
border: 1px solid var(--panel-border);
border-radius: 999px;
background: rgba(12, 18, 25, 0.72);
color: #c6d4d9;
font-size: 0.66rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
backdrop-filter: blur(14px);
}
.model-badge::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--warm);
box-shadow: 0 0 14px rgba(214, 174, 130, 0.7);
content: "";
}
.view-tools {
position: fixed;
top: 88px;
right: 30px;
z-index: 12;
display: flex;
gap: 7px;
}
.icon-button {
width: 38px;
height: 38px;
padding: 0;
border: 1px solid var(--panel-border);
border-radius: 9px;
background: rgba(14, 21, 29, 0.76);
color: #dce7eb;
cursor: pointer;
backdrop-filter: blur(12px);
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
.icon-button:hover {
border-color: rgba(185, 216, 220, 0.4);
background: rgba(31, 45, 56, 0.9);
transform: translateY(-1px);
}
.icon-button:focus-visible,
.stage-button:focus-visible,
#playButton:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 3px;
}
.annotation {
position: fixed;
z-index: 8;
display: flex;
align-items: center;
gap: 9px;
pointer-events: none;
transform: translate(-50%, -100%);
transition: opacity 150ms ease;
}
.annotation::after {
position: absolute;
top: 100%;
left: 7px;
width: 1px;
height: 24px;
background: linear-gradient(rgba(185, 216, 220, 0.7), transparent);
content: "";
}
.annotation-dot {
width: 6px;
height: 6px;
border: 1px solid rgba(185, 216, 220, 0.8);
border-radius: 50%;
background: #17242d;
box-shadow: 0 0 0 4px rgba(185, 216, 220, 0.07);
}
.annotation-copy {
padding: 7px 9px;
border: 1px solid rgba(185, 216, 220, 0.14);
border-radius: 6px;
background: rgba(10, 16, 22, 0.7);
color: #dbe7e9;
font-size: 0.62rem;
font-weight: 700;
letter-spacing: 0.12em;
white-space: nowrap;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.annotation-copy small {
display: block;
margin-top: 3px;
color: #82939d;
font-size: 0.54rem;
font-weight: 600;
letter-spacing: 0.09em;
}
.timeline-panel {
position: fixed;
bottom: 24px;
left: 50%;
z-index: 15;
width: min(920px, calc(100% - 48px));
padding: 17px 18px 14px;
border: 1px solid var(--panel-border);
border-radius: 17px;
background: var(--panel);
box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
transform: translateX(-50%);
backdrop-filter: blur(20px);
}
.panel-main {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
}
.stage-heading {
min-width: 0;
}
#stageCount {
display: block;
margin-bottom: 6px;
color: var(--warm);
font-size: 0.61rem;
font-weight: 800;
letter-spacing: 0.17em;
}
#stageTitle {
margin: 0;
font-size: 1.05rem;
font-weight: 650;
letter-spacing: -0.01em;
}
#stageDescription {
margin: 5px 0 0;
color: var(--muted);
font-size: 0.79rem;
line-height: 1.45;
}
#playButton {
flex: 0 0 auto;
display: inline-flex;
align-items: center;
gap: 8px;
min-width: 98px;
height: 38px;
padding: 0 14px;
border: 1px solid rgba(185, 216, 220, 0.26);
border-radius: 9px;
background: rgba(185, 216, 220, 0.09);
color: var(--text);
font-size: 0.73rem;
font-weight: 700;
cursor: pointer;
transition:
background 160ms ease,
border-color 160ms ease;
}
#playButton:hover {
border-color: rgba(185, 216, 220, 0.5);
background: rgba(185, 216, 220, 0.16);
}
#playIcon {
color: var(--accent);
font-size: 0.76rem;
}
.steps {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
margin-top: 14px;
}
.stage-button {
position: relative;
display: flex;
align-items: center;
gap: 9px;
min-width: 0;
padding: 9px 10px;
border: 1px solid rgba(185, 216, 220, 0.1);
border-radius: 9px;
background: rgba(255, 255, 255, 0.018);
color: #82919a;
text-align: left;
cursor: pointer;
transition:
color 180ms ease,
border-color 180ms ease,
background 180ms ease;
}
.stage-button:hover {
color: #d3dee2;
border-color: rgba(185, 216, 220, 0.24);
}
.stage-button.active {
border-color: rgba(185, 216, 220, 0.42);
background: rgba(185, 216, 220, 0.1);
color: #eff7f8;
}
.stage-number {
display: grid;
width: 24px;
height: 24px;
flex: 0 0 24px;
place-items: center;
border: 1px solid currentColor;
border-radius: 50%;
font-size: 0.59rem;
font-weight: 800;
opacity: 0.7;
}
.stage-button.active .stage-number {
border-color: var(--warm);
color: var(--warm);
opacity: 1;
}
.stage-name {
overflow: hidden;
font-size: 0.69rem;
font-weight: 700;
line-height: 1.2;
text-overflow: ellipsis;
white-space: nowrap;
}
.disclaimer {
display: flex;
align-items: center;
gap: 8px;
margin-top: 12px;
padding-top: 11px;
border-top: 1px solid rgba(185, 216, 220, 0.09);
color: #778791;
font-size: 0.65rem;
line-height: 1.4;
}
.disclaimer::before {
width: 18px;
height: 1px;
flex: 0 0 18px;
background: var(--warm);
content: "";
}
.gesture-hint {
position: fixed;
right: 31px;
bottom: 30px;
z-index: 7;
color: rgba(196, 211, 218, 0.5);
font-size: 0.61rem;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 900px) {
.gesture-hint {
display: none;
}
.model-badge {
top: auto;
right: 18px;
bottom: 245px;
}
}
@media (max-width: 680px) {
header {
top: 20px;
left: 20px;
max-width: calc(100% - 40px);
}
h1 {
font-size: 2.35rem;
}
.subtitle {
max-width: 310px;
font-size: 0.78rem;
}
.model-badge {
right: 14px;
bottom: 278px;
padding: 8px 10px;
font-size: 0.54rem;
}
.view-tools {
top: 20px;
right: 14px;
flex-direction: column;
}
.timeline-panel {
bottom: 12px;
width: calc(100% - 24px);
padding: 14px;
border-radius: 14px;
}
.panel-main {
gap: 12px;
}
#stageDescription {
max-width: 245px;
font-size: 0.69rem;
}
#playButton {
min-width: 38px;
width: 38px;
padding: 0;
justify-content: center;
}
#playText {
display: none;
}
.steps {
grid-template-columns: repeat(2, 1fr);
}
.stage-button {
padding: 7px 8px;
}
.disclaimer {
font-size: 0.59rem;
}
.annotation-copy {
padding: 5px 7px;
font-size: 0.53rem;
}
.annotation-copy small {
display: none;
}
}
@media (max-height: 650px) and (min-width: 681px) {
.subtitle,
.annotation {
display: none;
}
.timeline-panel {
bottom: 12px;
padding-top: 12px;
padding-bottom: 10px;
}
.steps {
margin-top: 9px;
}
.disclaimer {
margin-top: 8px;
padding-top: 8px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive stylized columnar basalt scene"></div>
<div class="vignette"></div>
<header>
<div class="eyebrow">Geological Form Study / 01</div>
<h1>Columnar<br />Basalt</h1>
<p class="subtitle">
An unfractured block beside a progressively articulated cluster,
staged as a visual analogy for cooling-joint formation.
</p>
</header>
<div class="model-badge">Qualitative analogy</div>
<div class="view-tools" aria-label="Camera controls">
<button class="icon-button" id="zoomIn" aria-label="Zoom in">+</button>
<button class="icon-button" id="zoomOut" aria-label="Zoom out">−</button>
<button class="icon-button" id="resetView" aria-label="Reset camera view">↺</button>
</div>
<div class="annotation" id="blockAnnotation">
<span class="annotation-dot"></span>
<div class="annotation-copy">
Unfractured block
<small>Reference form</small>
</div>
</div>
<div class="annotation" id="clusterAnnotation">
<span class="annotation-dot"></span>
<div class="annotation-copy">
Progressive cluster
<small id="clusterSubLabel">Continuous mass</small>
</div>
</div>
<section class="timeline-panel" aria-label="Basalt progression controls">
<div class="panel-main">
<div class="stage-heading" aria-live="polite">
<span id="stageCount">Stage 01 / 04</span>
<h2 id="stageTitle">Continuous mass</h2>
<p id="stageDescription">
A single polygonal envelope establishes the intact starting form.
</p>
</div>
<button id="playButton" type="button" aria-label="Play staged progression">
<span id="playIcon">▶</span>
<span id="playText">Play</span>
</button>
</div>
<div class="steps" role="tablist" aria-label="Progression stages">
<button
class="stage-button active"
role="tab"
aria-selected="true"
data-stage="0"
>
<span class="stage-number">01</span>
<span class="stage-name">Continuous mass</span>
</button>
<button
class="stage-button"
role="tab"
aria-selected="false"
data-stage="1"
>
<span class="stage-number">02</span>
<span class="stage-name">Joint guides</span>
</button>
<button
class="stage-button"
role="tab"
aria-selected="false"
data-stage="2"
>
<span class="stage-number">03</span>
<span class="stage-name">Boundaries clarified</span>
</button>
<button
class="stage-button"
role="tab"
aria-selected="false"
data-stage="3"
>
<span class="stage-number">04</span>
<span class="stage-name">Discrete columns</span>
</button>
</div>
<div class="disclaimer">
Qualitative cooling-joint analogy only. The changing spacing, outlines,
and cap heights are authored visual transitions—not a physical fracture,
thermal, or mechanical simulation.
</div>
</section>
<div class="gesture-hint">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";
// -------------------------------------------------------------------------
// Scene and renderer
// -------------------------------------------------------------------------
const sceneHost = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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;
renderer.setClearColor(0x0b1118, 1);
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0b1118);
scene.fog = new THREE.Fog(0x0b1118, 13, 27);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
60
);
const cameraTarget = new THREE.Vector3(0, 1.35, 0);
const cameraState = {
azimuth: 0.49,
polar: 1.04,
radius: 11.8,
defaultRadius: 11.8
};
function updateCamera() {
const horizontal = Math.sin(cameraState.polar) * cameraState.radius;
camera.position.set(
cameraTarget.x +
Math.sin(cameraState.azimuth) * horizontal,
cameraTarget.y +
Math.cos(cameraState.polar) * cameraState.radius,
cameraTarget.z +
Math.cos(cameraState.azimuth) * horizontal
);
camera.lookAt(cameraTarget);
}
updateCamera();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xc7dce5, 0x171a1f, 1.75);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffe3c1, 3.2);
keyLight.position.set(-5, 8, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 22;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x7eafd0, 2.15);
rimLight.position.set(6, 4, -5);
scene.add(rimLight);
const lowFill = new THREE.PointLight(0xc28e63, 16, 14, 2);
lowFill.position.set(-1, 1.4, 4.2);
scene.add(lowFill);
// -------------------------------------------------------------------------
// Platform and floor
// -------------------------------------------------------------------------
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x080c11,
roughness: 1,
metalness: 0
});
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.43;
floor.receiveShadow = true;
scene.add(floor);
const plinthMaterial = new THREE.MeshStandardMaterial({
color: 0x111820,
roughness: 0.94,
metalness: 0.03,
flatShading: true
});
const plinth = new THREE.Mesh(
new THREE.CylinderGeometry(8.1, 8.48, 0.38, 64, 1, false),
plinthMaterial
);
plinth.position.y = -0.23;
plinth.receiveShadow = true;
plinth.castShadow = true;
scene.add(plinth);
const plinthEdgeMaterial = new THREE.LineBasicMaterial({
color: 0x40515b,
transparent: true,
opacity: 0.22
});
const plinthEdge = new THREE.LineSegments(
new THREE.EdgesGeometry(plinth.geometry, 18),
plinthEdgeMaterial
);
plinthEdge.position.copy(plinth.position);
scene.add(plinthEdge);
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function appendTriangle(target, a, b, c) {
target.push(
a.x, a.y, a.z,
b.x, b.y, b.z,
c.x, c.y, c.z
);
}
function makeColumnGeometry(radius, sides = 6) {
const sidePositions = [];
const capPositions = [];
const levels = [
{ y: 0.00, scale: 0.94 },
{ y: 0.12, scale: 1.00 },
{ y: 0.83, scale: 0.98 },
{ y: 1.00, scale: 0.90 }
];
const rings = levels.map((level, levelIndex) => {
const ring = [];
for (let i = 0; i < sides; i++) {
const angle = (i / sides) * Math.PI * 2;
const irregularity =
1 +
Math.sin(i * 2.31 + levelIndex * 0.73) * 0.018 +
Math.cos(i * 1.17 + levelIndex * 1.41) * 0.012;
const r = radius * level.scale * irregularity;
ring.push(
new THREE.Vector3(
Math.cos(angle) * r,
level.y,
Math.sin(angle) * r
)
);
}
return ring;
});
for (let level = 0; level < rings.length - 1; level++) {
const lower = rings[level];
const upper = rings[level + 1];
for (let i = 0; i < sides; i++) {
const next = (i + 1) % sides;
appendTriangle(
sidePositions,
lower[i],
upper[i],
lower[next]
);
appendTriangle(
sidePositions,
upper[i],
upper[next],
lower[next]
);
}
}
const bottomCenter = new THREE.Vector3(0, 0, 0);
const topCenter = new THREE.Vector3(0, 1, 0);
const bottom = rings[0];
const top = rings[rings.length - 1];
for (let i = 0; i < sides; i++) {
const next = (i + 1) % sides;
appendTriangle(capPositions, bottomCenter, bottom[i], bottom[next]);
appendTriangle(capPositions, topCenter, top[next], top[i]);
}
const positions = new Float32Array(
sidePositions.length + capPositions.length
);
positions.set(sidePositions, 0);
positions.set(capPositions, sidePositions.length);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
geometry.clearGroups();
geometry.addGroup(0, sidePositions.length / 3, 0);
geometry.addGroup(
sidePositions.length / 3,
capPositions.length / 3,
1
);
geometry.computeVertexNormals();
geometry.computeBoundingSphere();
return geometry;
}
function makeFacetedBlockGeometry(width, height, depth) {
const sidePositions = [];
const capPositions = [];
const hx = width / 2;
const hz = depth / 2;
const chamfer = Math.min(width, depth) * 0.16;
const crossSection = [
new THREE.Vector2(-hx + chamfer, -hz),
new THREE.Vector2(hx - chamfer, -hz),
new THREE.Vector2(hx, -hz + chamfer),
new THREE.Vector2(hx, hz - chamfer),
new THREE.Vector2(hx - chamfer, hz),
new THREE.Vector2(-hx + chamfer, hz),
new THREE.Vector2(-hx, hz - chamfer),
new THREE.Vector2(-hx, -hz + chamfer)
];
const levels = [
{ y: 0, scale: 0.94, offsetX: 0.00, offsetZ: 0.00 },
{ y: height * 0.16, scale: 1.00, offsetX: 0.04, offsetZ: -0.02 },
{ y: height * 0.83, scale: 0.97, offsetX: -0.04, offsetZ: 0.01 },
{ y: height, scale: 0.89, offsetX: 0.03, offsetZ: 0.02 }
];
const rings = levels.map((level) =>
crossSection.map(
(point) =>
new THREE.Vector3(
point.x * level.scale + level.offsetX,
level.y,
point.y * level.scale + level.offsetZ
)
)
);
for (let level = 0; level < rings.length - 1; level++) {
const lower = rings[level];
const upper = rings[level + 1];
for (let i = 0; i < lower.length; i++) {
const next = (i + 1) % lower.length;
appendTriangle(sidePositions, lower[i], upper[i], lower[next]);
appendTriangle(sidePositions, upper[i], upper[next], lower[next]);
}
}
const bottomCenter = new THREE.Vector3(0, 0, 0);
const topCenter = new THREE.Vector3(0, height, 0);
const bottom = rings[0];
const top = rings[rings.length - 1];
for (let i = 0; i < bottom.length; i++) {
const next = (i + 1) % bottom.length;
appendTriangle(capPositions, bottomCenter, bottom[i], bottom[next]);
appendTriangle(capPositions, topCenter, top[next], top[i]);
}
const positions = new Float32Array(
sidePositions.length + capPositions.length
);
positions.set(sidePositions, 0);
positions.set(capPositions, sidePositions.length);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
geometry.clearGroups();
geometry.addGroup(0, sidePositions.length / 3, 0);
geometry.addGroup(
sidePositions.length / 3,
capPositions.length / 3,
1
);
geometry.computeVertexNormals();
geometry.computeBoundingSphere();
return geometry;
}
// -------------------------------------------------------------------------
// Unfractured reference block
// -------------------------------------------------------------------------
const blockGeometry = makeFacetedBlockGeometry(2.55, 2.65, 2.18);
const blockSideMaterial = new THREE.MeshStandardMaterial({
color: 0x46515a,
roughness: 0.94,
metalness: 0.025,
flatShading: true
});
const blockTopMaterial = new THREE.MeshStandardMaterial({
color: 0x59636a,
roughness: 0.9,
metalness: 0.025,
flatShading: true
});
const block = new THREE.Mesh(blockGeometry, [
blockSideMaterial,
blockTopMaterial
]);
block.position.set(-3.05, 0.01, 0.18);
block.rotation.y = -0.11;
block.castShadow = true;
block.receiveShadow = true;
scene.add(block);
const blockEdgeMaterial = new THREE.LineBasicMaterial({
color: 0x91a4ad,
transparent: true,
opacity: 0.13
});
const blockEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(blockGeometry, 16),
blockEdgeMaterial
);
block.add(blockEdges);
// -------------------------------------------------------------------------
// Progressive column cluster
// -------------------------------------------------------------------------
const clusterCenter = new THREE.Vector2(1.25, 0.14);
const columnRadius = 0.58;
const packedRadius = 1.12;
const columnSideBase = new THREE.Color(0x323c45);
const columnTopBase = new THREE.Color(0x49555d);
const columnConfigurations = [
{
angle: null,
lightOffset: 0.015,
heights: [3.45, 3.45, 3.55, 3.95]
},
{
angle: 0,
lightOffset: -0.012,
heights: [3.45, 3.45, 3.25, 3.45]
},
{
angle: Math.PI / 3,
lightOffset: 0.022,
heights: [3.45, 3.45, 3.40, 3.75]
},
{
angle: (Math.PI * 2) / 3,
lightOffset: -0.022,
heights: [3.45, 3.45, 3.20, 3.35]
},
{
angle: Math.PI,
lightOffset: 0.006,
heights: [3.45, 3.45, 3.50, 3.82]
},
{
angle: (Math.PI * 4) / 3,
lightOffset: 0.018,
heights: [3.45, 3.45, 3.28, 3.55]
},
{
angle: (Math.PI * 5) / 3,
lightOffset: -0.006,
heights: [3.45, 3.45, 3.42, 3.68]
}
];
const columns = columnConfigurations.map((configuration) => {
const geometry = makeColumnGeometry(columnRadius, 6);
const sideMaterial = new THREE.MeshStandardMaterial({
color: columnSideBase,
roughness: 0.93,
metalness: 0.035,
flatShading: true
});
const topMaterial = new THREE.MeshStandardMaterial({
color: columnTopBase,
roughness: 0.88,
metalness: 0.035,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, [sideMaterial, topMaterial]);
mesh.castShadow = true;
mesh.receiveShadow = true;
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0xb9dde0,
transparent: true,
opacity: 0,
depthWrite: false
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 19),
edgeMaterial
);
const group = new THREE.Group();
group.add(mesh, edges);
scene.add(group);
return {
configuration,
group,
mesh,
edges,
sideMaterial,
topMaterial,
edgeMaterial
};
});
// Continuous polygonal envelope used only in the opening stage.
const massGeometry = new THREE.CylinderGeometry(
2.12,
2.23,
3.45,
7,
1,
false
);
const massMaterial = new THREE.MeshStandardMaterial({
color: 0x343e47,
roughness: 0.94,
metalness: 0.03,
flatShading: true,
transparent: true,
opacity: 1
});
const massEnvelope = new THREE.Mesh(massGeometry, massMaterial);
massEnvelope.position.set(clusterCenter.x, 1.725, clusterCenter.y);
massEnvelope.rotation.y = Math.PI / 7;
massEnvelope.castShadow = true;
massEnvelope.receiveShadow = true;
scene.add(massEnvelope);
// -------------------------------------------------------------------------
// Stage definitions and authored transitions
// -------------------------------------------------------------------------
const stages = [
{
name: "Continuous mass",
description:
"A single polygonal envelope establishes the intact starting form.",
clusterLabel: "Continuous mass",
spread: 0.98,
edgeOpacity: 0,
color: 0x39434c
},
{
name: "Joint guides",
description:
"Authored joint traces clarify the boundaries used in the cooling-joint analogy.",
clusterLabel: "Joint guides",
spread: 1.0,
edgeOpacity: 0.82,
color: 0x343e47
},
{
name: "Boundaries clarified",
description:
"Spacing and varied cap heights separate the stylized column boundaries.",
clusterLabel: "Boundaries clarified",
spread: 1.09,
edgeOpacity: 0.38,
color: 0x2e3841
},
{
name: "Discrete columns",
description:
"The analogy resolves into a discrete cluster of hexagonal basalt columns.",
clusterLabel: "Discrete columns",
spread: 1.18,
edgeOpacity: 0.1,
color: 0x29323a
}
];
let currentStage = 0;
let targetStage = 0;
let transition = null;
let playing = false;
let autoplayDelay = 0;
const stageCount = document.getElementById("stageCount");
const stageTitle = document.getElementById("stageTitle");
const stageDescription = document.getElementById("stageDescription");
const clusterSubLabel = document.getElementById("clusterSubLabel");
const stageButtons = [...document.querySelectorAll(".stage-button")];
const playButton = document.getElementById("playButton");
const playIcon = document.getElementById("playIcon");
const playText = document.getElementById("playText");
function easeInOutCubic(value) {
return value < 0.5
? 4 * value * value * value
: 1 - Math.pow(-2 * value + 2, 3) / 2;
}
function updateStageInterface(index) {
const stage = stages[index];
stageCount.textContent =
`Stage ${String(index + 1).padStart(2, "0")} / 04`;
stageTitle.textContent = stage.name;
stageDescription.textContent = stage.description;
clusterSubLabel.textContent = stage.clusterLabel;
stageButtons.forEach((button, buttonIndex) => {
const active = buttonIndex === index;
button.classList.toggle("active", active);
button.setAttribute("aria-selected", String(active));
});
}
function transitionTo(index, preservePlayback = false) {
targetStage = THREE.MathUtils.clamp(index, 0, stages.length - 1);
if (!preservePlayback) {
playing = false;
autoplayDelay = 0;
}
transition = {
from: currentStage,
to: targetStage,
elapsed: 0,
duration: 1.45
};
updateStageInterface(targetStage);
updatePlayButton();
}
function updatePlayButton() {
playIcon.textContent = playing ? "❚❚" : "▶";
playText.textContent = playing ? "Pause" : "Play";
playButton.setAttribute(
"aria-label",
playing ? "Pause staged progression" : "Play staged progression"
);
}
stageButtons.forEach((button) => {
button.addEventListener("click", () => {
transitionTo(Number(button.dataset.stage));
});
});
playButton.addEventListener("click", () => {
if (playing) {
playing = false;
autoplayDelay = 0;
updatePlayButton();
return;
}
if (targetStage >= stages.length - 1) {
transitionTo(0, true);
}
playing = true;
autoplayDelay = 0;
updatePlayButton();
});
function sampleNumber(values) {
const lower = Math.floor(currentStage);
const upper = Math.min(lower + 1, stages.length - 1);
const fraction = currentStage - lower;
return THREE.MathUtils.lerp(
values[lower],
values[upper],
fraction
);
}
function sampleStageValue(key) {
return sampleNumber(stages.map((stage) => stage[key]));
}
// -------------------------------------------------------------------------
// Direct camera controls: orbit, zoom, and reset
// -------------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.azimuth -= deltaX * 0.0052;
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar + deltaY * 0.0044,
0.58,
1.36
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event &&
renderer.domElement.hasPointerCapture &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
7.2,
19
);
updateCamera();
},
{ passive: false }
);
function zoomBy(amount) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + amount,
7.2,
19
);
updateCamera();
}
function resetView() {
cameraState.azimuth = 0.49;
cameraState.polar = 1.04;
cameraState.radius = cameraState.defaultRadius;
updateCamera();
}
document.getElementById("zoomIn").addEventListener("click", () => {
zoomBy(-1.1);
});
document.getElementById("zoomOut").addEventListener("click", () => {
zoomBy(1.1);
});
document.getElementById("resetView").addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
// -------------------------------------------------------------------------
// Projected scene annotations
// -------------------------------------------------------------------------
const blockAnnotation = document.getElementById("blockAnnotation");
const clusterAnnotation = document.getElementById("clusterAnnotation");
const blockAnchor = new THREE.Vector3(-3.05, 2.92, 0.18);
const clusterAnchor = new THREE.Vector3(1.25, 4.25, 0.14);
const projected = new THREE.Vector3();
function positionAnnotation(element, worldPosition) {
projected.copy(worldPosition).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
element.style.opacity = visible ? "1" : "0";
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
// -------------------------------------------------------------------------
// Resize handling
// -------------------------------------------------------------------------
function handleResize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.fov = camera.aspect < 0.8 ? 48 : 36;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
cameraState.defaultRadius = camera.aspect < 0.8 ? 17.5 : 11.8;
if (Math.abs(cameraState.radius - cameraState.defaultRadius) < 0.02) {
cameraState.radius = cameraState.defaultRadius;
}
updateCamera();
}
window.addEventListener("resize", handleResize);
handleResize();
// -------------------------------------------------------------------------
// Animation loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (transition) {
transition.elapsed += delta;
const progress = Math.min(
transition.elapsed / transition.duration,
1
);
currentStage = THREE.MathUtils.lerp(
transition.from,
transition.to,
easeInOutCubic(progress)
);
if (progress >= 1) {
currentStage = transition.to;
transition = null;
}
} else if (playing) {
autoplayDelay += delta;
if (autoplayDelay > 2.05) {
const next = targetStage + 1;
if (next >= stages.length) {
transitionTo(0, true);
} else {
transitionTo(next, true);
}
autoplayDelay = 0;
}
}
const spread = sampleStageValue("spread");
const edgeOpacity = sampleStageValue("edgeOpacity");
const currentColor = new THREE.Color(
Math.round(sampleStageValue("color"))
);
const massFade = THREE.MathUtils.clamp(
1 - currentStage / 0.88,
0,
1
);
massMaterial.opacity = massFade;
massMaterial.depthWrite = massFade > 0.96;
massEnvelope.visible = massFade > 0.008;
columns.forEach((column, index) => {
const configuration = column.configuration;
const height = sampleNumber(configuration.heights);
column.mesh.scale.y = height;
if (configuration.angle === null) {
column.group.position.set(
clusterCenter.x,
0.01,
clusterCenter.y
);
} else {
const radialDistance = packedRadius * spread;
column.group.position.set(
clusterCenter.x +
Math.cos(configuration.angle) * radialDistance,
0.01,
clusterCenter.y +
Math.sin(configuration.angle) * radialDistance
);
}
column.sideMaterial.color
.copy(currentColor)
.offsetHSL(0, 0, configuration.lightOffset);
column.topMaterial.color
.copy(columnTopBase)
.offsetHSL(0, 0, configuration.lightOffset * 0.45);
column.edgeMaterial.opacity = edgeOpacity;
});
positionAnnotation(blockAnnotation, blockAnchor);
positionAnnotation(clusterAnnotation, clusterAnchor);
renderer.render(scene, camera);
}
updateStageInterface(0);
updatePlayButton();
animate();
</script>
</body>
</html>
```