Prompt specification
Build or customize the Three.js 3D scene "Slow and rapid growth morphology panels" 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: Slow and rapid growth morphology panels
Category: Science & Physics · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/slow-and-rapid-growth-morphology-panels-x1946
Scene Description Prompt:
Slow and rapid growth morphology panels. Show two explicitly illustrative growth sequences with different surface roughness; state that actual crystal morphology depends on material and conditions rather than growth speed alone. Please build this with Three.js from cdnjs in one self-contained HTML file, using a 3D cutaway.
Working Three.js Starter (slow-and-rapid-growth-morphology-panels-x1946):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Growth Morphology — Slow vs. Rapid</title>
<style>
:root {
color-scheme: dark;
--bg: #070b11;
--panel: #101721;
--panel-2: #0b1119;
--line: rgba(190, 220, 240, 0.13);
--text: #edf7ff;
--muted: #91a4b6;
--cyan: #67e8dd;
--cyan-soft: rgba(103, 232, 221, 0.12);
--orange: #ffad61;
--orange-soft: rgba(255, 173, 97, 0.12);
}
* {
box-sizing: border-box;
}
html {
min-width: 320px;
background: var(--bg);
}
body {
margin: 0;
min-height: 100vh;
color: var(--text);
background:
radial-gradient(circle at 12% 0%, rgba(39, 135, 153, 0.13), transparent 31rem),
radial-gradient(circle at 91% 13%, rgba(176, 91, 40, 0.12), transparent 34rem),
linear-gradient(180deg, #080d14 0%, #070b11 48%, #090d13 100%);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
width: min(1480px, 100%);
margin: 0 auto;
padding: 30px clamp(16px, 3vw, 42px) 34px;
}
.masthead {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 30px;
align-items: end;
margin-bottom: 23px;
}
.eyebrow {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 9px;
margin-bottom: 13px;
color: var(--muted);
font-size: 0.72rem;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 26px;
height: 1px;
background: currentColor;
content: "";
}
h1 {
max-width: 880px;
margin: 0;
font-size: clamp(2.1rem, 5vw, 4.65rem);
font-weight: 620;
letter-spacing: -0.055em;
line-height: 0.98;
}
.title-accent {
color: #b9d7e5;
}
.intro {
max-width: 420px;
margin: 0 0 3px;
color: var(--muted);
font-size: 0.97rem;
line-height: 1.65;
}
.schematic-tag {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 255, 255, 0.025);
color: #bfd0dd;
font-size: 0.69rem;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
white-space: nowrap;
}
.schematic-tag span {
width: 7px;
height: 7px;
border-radius: 50%;
background: #d9e9f3;
box-shadow: 0 0 12px rgba(217, 233, 243, 0.55);
}
.toolbar {
position: sticky;
z-index: 20;
top: 10px;
display: grid;
grid-template-columns: auto minmax(160px, 1fr) auto auto;
gap: 17px;
align-items: center;
margin-bottom: 19px;
padding: 13px 14px;
border: 1px solid var(--line);
border-radius: 15px;
background: rgba(13, 19, 28, 0.82);
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(18px);
}
.control-button {
min-height: 39px;
padding: 0 16px;
border: 1px solid rgba(190, 220, 240, 0.17);
border-radius: 10px;
background: rgba(255, 255, 255, 0.045);
cursor: pointer;
font-size: 0.8rem;
font-weight: 720;
transition: background 160ms ease, border-color 160ms ease;
}
.control-button:hover {
border-color: rgba(190, 220, 240, 0.34);
background: rgba(255, 255, 255, 0.08);
}
.control-button.primary {
min-width: 93px;
border-color: rgba(103, 232, 221, 0.35);
background: var(--cyan-soft);
color: #c9fff9;
}
.timeline-wrap {
display: grid;
grid-template-columns: auto minmax(100px, 1fr) auto;
gap: 12px;
align-items: center;
}
.timeline-label {
color: var(--muted);
font-size: 0.69rem;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
white-space: nowrap;
}
input[type="range"] {
width: 100%;
height: 5px;
margin: 0;
border: 0;
border-radius: 999px;
outline: none;
background:
linear-gradient(
to right,
var(--cyan) 0%,
var(--cyan) var(--fill, 0%),
#263340 var(--fill, 0%),
#263340 100%
);
cursor: pointer;
appearance: none;
-webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
width: 17px;
height: 17px;
border: 3px solid #14252b;
border-radius: 50%;
background: #b9fff8;
box-shadow: 0 0 0 1px rgba(103, 232, 221, 0.45), 0 0 16px rgba(103, 232, 221, 0.32);
appearance: none;
-webkit-appearance: none;
}
input[type="range"]::-moz-range-thumb {
width: 13px;
height: 13px;
border: 3px solid #14252b;
border-radius: 50%;
background: #b9fff8;
box-shadow: 0 0 0 1px rgba(103, 232, 221, 0.45), 0 0 16px rgba(103, 232, 221, 0.32);
}
.stage-counter {
display: flex;
align-items: baseline;
gap: 7px;
min-width: 67px;
color: var(--muted);
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.08em;
}
.stage-counter strong {
color: var(--text);
font-size: 1rem;
font-variant-numeric: tabular-nums;
}
.panels {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
}
.panel {
position: relative;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 20px;
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%),
var(--panel);
box-shadow: 0 24px 65px rgba(0, 0, 0, 0.2);
}
.panel::before {
position: absolute;
z-index: 2;
top: 0;
right: 0;
left: 0;
height: 2px;
background: linear-gradient(90deg, transparent, var(--accent), transparent);
content: "";
opacity: 0.82;
}
.panel.slow {
--accent: var(--cyan);
--accent-rgb: 103, 232, 221;
--soft: var(--cyan-soft);
}
.panel.rapid {
--accent: var(--orange);
--accent-rgb: 255, 173, 97;
--soft: var(--orange-soft);
}
.panel-header {
display: flex;
justify-content: space-between;
gap: 18px;
align-items: flex-start;
padding: 22px 23px 13px;
}
.panel-kicker {
margin-bottom: 7px;
color: var(--accent);
font-size: 0.67rem;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.panel h2 {
margin: 0;
font-size: clamp(1.35rem, 2.4vw, 2rem);
font-weight: 630;
letter-spacing: -0.035em;
}
.panel-subtitle {
margin: 7px 0 0;
color: var(--muted);
font-size: 0.83rem;
line-height: 1.45;
}
.roughness {
flex: 0 0 auto;
min-width: 118px;
padding: 9px 11px;
border: 1px solid rgba(var(--accent-rgb), 0.22);
border-radius: 11px;
background: var(--soft);
}
.roughness-label {
margin-bottom: 7px;
color: var(--muted);
font-size: 0.59rem;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.roughness-bars {
display: flex;
gap: 4px;
height: 7px;
}
.roughness-bars i {
flex: 1;
border-radius: 2px;
background: rgba(var(--accent-rgb), 0.15);
}
.roughness-bars i.on {
background: var(--accent);
box-shadow: 0 0 9px rgba(var(--accent-rgb), 0.32);
}
.roughness-value {
margin-top: 6px;
color: var(--accent);
font-size: 0.68rem;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.viewport {
position: relative;
height: clamp(390px, 39vw, 520px);
overflow: hidden;
background:
radial-gradient(
circle at 50% 43%,
rgba(var(--accent-rgb), 0.10),
transparent 43%
),
linear-gradient(180deg, rgba(4, 8, 13, 0.08), rgba(4, 8, 13, 0.48));
}
.viewport::after {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 26%;
pointer-events: none;
background: linear-gradient(transparent, rgba(5, 9, 14, 0.72));
content: "";
}
.viewport canvas {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
.viewport canvas:active {
cursor: grabbing;
}
.viewport canvas:focus-visible {
outline: 2px solid var(--accent);
outline-offset: -3px;
}
.viewport-top {
position: absolute;
z-index: 3;
top: 13px;
left: 15px;
display: flex;
flex-wrap: wrap;
gap: 7px;
pointer-events: none;
}
.view-pill {
padding: 6px 9px;
border: 1px solid rgba(var(--accent-rgb), 0.22);
border-radius: 999px;
background: rgba(8, 13, 20, 0.72);
color: var(--accent);
font-size: 0.61rem;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.view-pill.muted {
border-color: rgba(190, 220, 240, 0.13);
color: #9eb1c2;
}
.cutaway-key {
position: absolute;
z-index: 3;
top: 52px;
left: 18px;
display: flex;
align-items: center;
gap: 8px;
color: #a9bbc8;
font-size: 0.65rem;
font-weight: 650;
letter-spacing: 0.05em;
pointer-events: none;
}
.cutaway-key::before {
width: 18px;
height: 1px;
background: var(--accent);
box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.6);
content: "";
}
.stage-caption {
position: absolute;
z-index: 3;
right: 18px;
bottom: 16px;
left: 18px;
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 18px;
align-items: end;
pointer-events: none;
}
.caption-number {
margin-bottom: 4px;
color: var(--accent);
font-size: 0.63rem;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.caption-title {
color: #f1f8fc;
font-size: 1rem;
font-weight: 690;
letter-spacing: -0.015em;
}
.caption-copy {
max-width: 380px;
margin-top: 4px;
color: #9aafbe;
font-size: 0.73rem;
line-height: 1.45;
}
.drag-hint {
display: flex;
align-items: center;
gap: 7px;
color: #728797;
font-size: 0.63rem;
white-space: nowrap;
}
.drag-hint svg {
width: 16px;
height: 16px;
stroke: currentColor;
}
.stages {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 1px;
border-top: 1px solid var(--line);
background: var(--line);
}
.stage-button {
min-width: 0;
padding: 14px 10px 15px;
border: 0;
background: var(--panel-2);
cursor: pointer;
text-align: left;
transition: background 150ms ease, color 150ms ease;
}
.stage-button:hover {
background: #111a24;
}
.stage-button.active {
background: var(--soft);
}
.stage-index {
display: block;
margin-bottom: 5px;
color: #647787;
font-size: 0.58rem;
font-weight: 800;
letter-spacing: 0.12em;
}
.stage-button.active .stage-index {
color: var(--accent);
}
.stage-name {
display: block;
overflow: hidden;
color: #9eb0bf;
font-size: 0.68rem;
font-weight: 690;
text-overflow: ellipsis;
white-space: nowrap;
}
.stage-button.active .stage-name {
color: #ecf7fb;
}
.caveat {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
gap: 16px;
align-items: start;
margin-top: 18px;
padding: 18px 21px;
border: 1px solid rgba(255, 205, 130, 0.2);
border-radius: 15px;
background:
linear-gradient(90deg, rgba(255, 173, 97, 0.075), transparent 55%),
rgba(15, 18, 24, 0.8);
}
.caveat-icon {
display: grid;
width: 33px;
height: 33px;
place-items: center;
border: 1px solid rgba(255, 173, 97, 0.28);
border-radius: 50%;
color: var(--orange);
font-family: Georgia, serif;
font-size: 1.1rem;
font-style: italic;
}
.caveat strong {
color: #f3e6d7;
font-size: 0.84rem;
letter-spacing: 0.01em;
}
.caveat p {
margin: 4px 0 0;
color: #a9aeb4;
font-size: 0.79rem;
line-height: 1.55;
}
.footnote {
display: flex;
justify-content: space-between;
gap: 16px;
margin-top: 13px;
color: #607484;
font-size: 0.65rem;
letter-spacing: 0.04em;
}
@media (max-width: 920px) {
.masthead {
grid-template-columns: 1fr;
gap: 15px;
}
.intro {
max-width: 680px;
}
.schematic-tag {
justify-self: start;
}
.panels {
grid-template-columns: 1fr;
}
.viewport {
height: min(520px, 62vw);
min-height: 390px;
}
}
@media (max-width: 650px) {
.app {
padding-top: 21px;
}
.toolbar {
position: relative;
top: auto;
grid-template-columns: auto 1fr auto;
gap: 10px;
}
.timeline-wrap {
display: block;
}
.timeline-label {
display: none;
}
.stage-counter {
justify-self: end;
}
#replayButton {
display: none;
}
.panel-header {
padding: 19px 17px 11px;
}
.roughness {
min-width: 100px;
padding: 8px;
}
.viewport {
height: 420px;
}
.drag-hint {
display: none;
}
.stage-caption {
grid-template-columns: 1fr;
}
.stage-button {
padding: 12px 7px;
}
.stage-name {
font-size: 0.61rem;
}
.footnote {
flex-direction: column;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.001ms !important;
}
}
</style>
</head>
<body>
<main class="app">
<header class="masthead">
<div>
<div class="eyebrow">Interactive morphology study · 01</div>
<h1>
Slow vs. rapid growth:
<span class="title-accent">surface texture changes</span>
</h1>
</div>
<div>
<p class="intro">
Two deliberately idealized growth sequences shown as interactive 3D
cutaways. The shared timeline reveals how ordered layers and a rough,
interrupted surface could look.
</p>
<div class="schematic-tag"><span></span> Schematic · not to scale</div>
</div>
</header>
<section class="toolbar" aria-label="Growth sequence controls">
<button class="control-button primary" id="playButton" type="button">
❚❚ Pause
</button>
<div class="timeline-wrap">
<label class="timeline-label" for="timeline">Growth sequence</label>
<input
id="timeline"
type="range"
min="0"
max="1000"
value="0"
aria-label="Growth sequence progress"
/>
</div>
<div class="stage-counter" aria-live="polite">
Stage <strong id="stageNumber">01</strong><span>/ 04</span>
</div>
<button class="control-button" id="replayButton" type="button">
↺ Replay
</button>
</section>
<section class="panels" aria-label="Illustrative growth morphology panels">
<article class="panel slow">
<header class="panel-header">
<div>
<div class="panel-kicker">Panel 01 · Illustrative sequence</div>
<h2>Slow growth</h2>
<p class="panel-subtitle">Ordered, smooth-looking terraced layers</p>
</div>
<div class="roughness" aria-label="Low illustrative surface roughness">
<div class="roughness-label">Surface roughness</div>
<div class="roughness-bars" aria-hidden="true">
<i class="on"></i><i class="on"></i><i></i><i></i><i></i>
</div>
<div class="roughness-value">Low · stylized</div>
</div>
</header>
<div class="viewport" id="slowViewport">
<div class="viewport-top">
<span class="view-pill">3D radial cutaway</span>
<span class="view-pill muted">Normalized sequence</span>
</div>
<div class="cutaway-key">Exposed growth bands</div>
<div class="stage-caption">
<div>
<div class="caption-number" id="slowCaptionNumber">Stage 01 · Nucleation</div>
<div class="caption-title">The first small seed</div>
<div class="caption-copy" id="slowCaptionCopy">
A compact seed establishes the first idealized layer.
</div>
</div>
<div class="drag-hint">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M8 7.5V5a2 2 0 1 1 4 0v2M12 7V4a2 2 0 1 1 4 0v3M16 7V5a2 2 0 1 1 4 0v8c0 4.4-2.4 8-7 8h-1.2a7 7 0 0 1-5.2-2.3L3.5 15a2 2 0 0 1 2.9-2.7L8 14V7.5Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
Drag to orbit · scroll to zoom
</div>
</div>
</div>
<div class="stages" aria-label="Slow growth stages">
<button class="stage-button active" type="button" data-kind="slow" data-stage="0">
<span class="stage-index">01</span><span class="stage-name">Nucleation</span>
</button>
<button class="stage-button" type="button" data-kind="slow" data-stage="1">
<span class="stage-index">02</span><span class="stage-name">Layer advance</span>
</button>
<button class="stage-button" type="button" data-kind="slow" data-stage="2">
<span class="stage-index">03</span><span class="stage-name">Band closure</span>
</button>
<button class="stage-button" type="button" data-kind="slow" data-stage="3">
<span class="stage-index">04</span><span class="stage-name">Developed habit</span>
</button>
</div>
</article>
<article class="panel rapid">
<header class="panel-header">
<div>
<div class="panel-kicker">Panel 02 · Illustrative sequence</div>
<h2>Rapid growth</h2>
<p class="panel-subtitle">Interrupted, rough-looking surface texture</p>
</div>
<div class="roughness" aria-label="High illustrative surface roughness">
<div class="roughness-label">Surface roughness</div>
<div class="roughness-bars" aria-hidden="true">
<i class="on"></i><i class="on"></i><i class="on"></i><i class="on"></i><i class="on"></i>
</div>
<div class="roughness-value">High · stylized</div>
</div>
</header>
<div class="viewport" id="rapidViewport">
<div class="viewport-top">
<span class="view-pill">3D radial cutaway</span>
<span class="view-pill muted">Normalized sequence</span>
</div>
<div class="cutaway-key">Interrupted growth bands</div>
<div class="stage-caption">
<div>
<div class="caption-number" id="rapidCaptionNumber">Stage 01 · Nucleation</div>
<div class="caption-title">The first small seed</div>
<div class="caption-copy" id="rapidCaptionCopy">
A compact seed establishes the first idealized layer.
</div>
</div>
<div class="drag-hint">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M8 7.5V5a2 2 0 1 1 4 0v2M12 7V4a2 2 0 1 1 4 0v3M16 7V5a2 2 0 1 1 4 0v8c0 4.4-2.4 8-7 8h-1.2a7 7 0 0 1-5.2-2.3L3.5 15a2 2 0 0 1 2.9-2.7L8 14V7.5Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
Drag to orbit · scroll to zoom
</div>
</div>
</div>
<div class="stages" aria-label="Rapid growth stages">
<button class="stage-button active" type="button" data-kind="rapid" data-stage="0">
<span class="stage-index">01</span><span class="stage-name">Nucleation</span>
</button>
<button class="stage-button" type="button" data-kind="rapid" data-stage="1">
<span class="stage-index">02</span><span class="stage-name">Many nuclei</span>
</button>
<button class="stage-button" type="button" data-kind="rapid" data-stage="2">
<span class="stage-index">03</span><span class="stage-name">Defect capture</span>
</button>
<button class="stage-button" type="button" data-kind="rapid" data-stage="3">
<span class="stage-index">04</span><span class="stage-name">Developed habit</span>
</button>
</div>
</article>
</section>
<aside class="caveat">
<div class="caveat-icon">i</div>
<div>
<strong>Interpret with care: these are explicitly illustrative sequences, not predictive simulations.</strong>
<p>
Actual crystal morphology depends on material and conditions rather than
growth speed alone. Temperature, supersaturation, transport, impurities,
interfaces, and nucleation kinetics may all be more important than a
simple slow-versus-rapid label.
</p>
</div>
</aside>
<footer class="footnote">
<span>Geometry, colors, and timing are diagrammatic.</span>
<span>No absolute time or length scale is implied.</span>
</footer>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const PROFILE = [
[0.00, 0.52],
[0.10, 0.78],
[0.22, 0.94],
[0.35, 1.04],
[0.48, 1.10],
[0.61, 1.08],
[0.73, 1.00],
[0.83, 0.88],
[0.91, 0.72],
[0.97, 0.50],
[1.00, 0.26]
];
const BOTTOM = -1.27;
const FULL_HEIGHT = 2.54;
const GAP_CENTER = 0.82;
const GAP_WIDTH = 0.92;
const stageCopy = {
slow: [
{
title: "Nucleation",
copy: "A compact seed establishes the first idealized layer."
},
{
title: "Layer advance",
copy: "Evenly spaced terraces advance around the seed in this ordered schematic."
},
{
title: "Band closure",
copy: "The radial cut face reveals regular, parallel internal growth bands."
},
{
title: "Developed habit",
copy: "The illustrative final crystal has a smooth-looking, broadly faceted exterior."
}
],
rapid: [
{
title: "Nucleation",
copy: "A compact seed establishes the first idealized layer."
},
{
title: "Many nuclei",
copy: "Additional local nuclei appear across the growing surface in this schematic."
},
{
title: "Defect capture",
copy: "Growth bands become interrupted and the cut-face edge grows uneven."
},
{
title: "Developed habit",
copy: "The illustrative final crystal has a rough, irregular exterior and jagged terraces."
}
]
};
function hash(value) {
const x = Math.sin(value * 127.1 + 311.7) * 43758.5453123;
return x - Math.floor(x);
}
function profileAt(v) {
const clamped = THREE.MathUtils.clamp(v, 0, 1);
for (let i = 0; i < PROFILE.length - 1; i++) {
const a = PROFILE[i];
const b = PROFILE[i + 1];
if (clamped <= b[0]) {
const t = (clamped - a[0]) / (b[0] - a[0]);
return THREE.MathUtils.lerp(a[1], b[1], t);
}
}
return PROFILE[PROFILE.length - 1][1];
}
function pushTriangle(positions, colors, a, b, c, color) {
positions.push(
a[0], a[1], a[2],
b[0], b[1], b[2],
c[0], c[1], c[2]
);
for (let i = 0; i < 3; i++) {
colors.push(color.r, color.g, color.b);
}
}
function createCrystalView(viewport, kind) {
const isSlow = kind === "slow";
const accent = isSlow ? 0x67e8dd : 0xffad61;
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute("role", "img");
renderer.domElement.setAttribute(
"aria-label",
`${isSlow ? "Slow-growth" : "Rapid-growth"} illustrative crystal cutaway. Drag to orbit and scroll to zoom.`
);
viewport.prepend(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(39, 1, 0.1, 100);
const orbit = {
theta: GAP_CENTER,
targetTheta: GAP_CENTER,
phi: 1.18,
targetPhi: 1.18,
radius: 5.25,
targetRadius: 5.25
};
const hemisphere = new THREE.HemisphereLight(0xd9f5ff, 0x11131a, 2.2);
scene.add(hemisphere);
const key = new THREE.DirectionalLight(0xffffff, 3.0);
key.position.set(4.5, 6.2, 5.5);
scene.add(key);
const rim = new THREE.DirectionalLight(isSlow ? 0x73fff1 : 0xff9c43, 2.2);
rim.position.set(-4.0, 2.0, -4.8);
scene.add(rim);
const frontGlow = new THREE.PointLight(accent, 28, 9, 2);
frontGlow.position.set(2.5, 1.0, 4.2);
scene.add(frontGlow);
const pedestalMaterial = new THREE.MeshStandardMaterial({
color: 0x111a24,
roughness: 0.72,
metalness: 0.34
});
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(1.52, 1.66, 0.14, 64),
pedestalMaterial
);
pedestal.position.y = -1.43;
scene.add(pedestal);
const ringMaterial = new THREE.MeshBasicMaterial({
color: accent,
transparent: true,
opacity: 0.38
});
for (const radius of [1.03, 1.43]) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(radius, 0.008, 6, 96),
ringMaterial
);
ring.rotation.x = Math.PI / 2;
ring.position.y = -1.352;
scene.add(ring);
}
const outerMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: isSlow ? 0.23 : 0.91,
metalness: isSlow ? 0.18 : 0.05,
flatShading: true,
side: THREE.DoubleSide,
emissive: accent,
emissiveIntensity: isSlow ? 0.025 : 0.012
});
const cutMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: isSlow ? 0.48 : 0.76,
metalness: 0.08,
flatShading: false,
side: THREE.DoubleSide
});
const cutLineMaterial = new THREE.LineBasicMaterial({
color: isSlow ? 0xbafff7 : 0xffd1a1,
transparent: true,
opacity: isSlow ? 0.32 : 0.22
});
const terraceMaterial = new THREE.LineBasicMaterial({
color: isSlow ? 0xd7fffb : 0xffc88f,
transparent: true,
opacity: isSlow ? 0.23 : 0.07
});
const growthFrontMaterial = new THREE.LineBasicMaterial({
color: accent,
transparent: true,
opacity: 0.9
});
const shardMaterial = new THREE.MeshStandardMaterial({
color: isSlow ? 0xbffff8 : 0xffc077,
roughness: 0.82,
metalness: 0.03,
flatShading: true
});
const crystal = new THREE.Group();
scene.add(crystal);
let lastProgress = -1;
function clearCrystal() {
for (const child of [...crystal.children]) {
child.traverse((object) => {
if (object.geometry) {
object.geometry.dispose();
}
});
crystal.remove(child);
}
}
function outerFaceColor(ring, segment) {
const color = new THREE.Color();
if (isSlow) {
color.setHSL(
0.485 + (hash(ring * 7 + segment * 13) - 0.5) * 0.022,
0.43,
0.56 + (hash(ring * 17 + segment * 5) - 0.5) * 0.075
);
} else {
color.setHSL(
0.065 + (hash(ring * 9 + segment * 19) - 0.5) * 0.028,
0.64,
0.47 + (hash(ring * 21 + segment * 11) - 0.5) * 0.11
);
}
return color;
}
function cutBandColor(band) {
const color = new THREE.Color();
if (isSlow) {
color.setHSL(
0.48 + Math.sin(band * 1.25) * 0.018,
0.48,
0.28 + (band % 2) * 0.075
);
} else {
color.setHSL(
0.065 + Math.sin(band * 1.7) * 0.022,
0.53,
0.25 + (band % 3) * 0.05
);
}
return color;
}
function roughnessAt(ring, segment) {
const amplitude = isSlow ? 0.018 : 0.13;
return (
hash(ring * 31.7 + segment * 17.3 + (isSlow ? 7 : 93)) - 0.5
) * amplitude;
}
function buildCrystal(progress) {
clearCrystal();
const t = THREE.MathUtils.clamp(progress, 0, 1);
const heightFactor = 0.25 + 0.75 * Math.pow(t, 0.92);
const widthFactor = 0.31 + 0.69 * Math.pow(t, 0.68);
const segments = isSlow ? 18 : 29;
const gap = GAP_WIDTH;
const span = Math.PI * 2 - gap;
const startAngle = GAP_CENTER + gap / 2;
const ringPoints = [];
const ringY = [];
for (let ring = 0; ring < PROFILE.length; ring++) {
const v = PROFILE[ring][0];
const y = BOTTOM + v * FULL_HEIGHT * heightFactor;
const points = [];
ringY.push(y);
for (let segment = 0; segment <= segments; segment++) {
const u = segment / segments;
const angle = startAngle + u * span;
const radius =
PROFILE[ring][1] * widthFactor + roughnessAt(ring, segment);
points.push([
Math.cos(angle) * radius,
y,
Math.sin(angle) * radius
]);
}
ringPoints.push(points);
}
const outerPositions = [];
const outerColors = [];
for (let ring = 0; ring < PROFILE.length - 1; ring++) {
for (let segment = 0; segment < segments; segment++) {
const a = ringPoints[ring][segment];
const b = ringPoints[ring][segment + 1];
const c = ringPoints[ring + 1][segment + 1];
const d = ringPoints[ring + 1][segment];
const color = outerFaceColor(ring, segment);
pushTriangle(outerPositions, outerColors, a, b, c, color);
pushTriangle(outerPositions, outerColors, a, c, d, color);
}
}
const bottomCenter = [0, BOTTOM, 0];
const topCenter = [0, BOTTOM + FULL_HEIGHT * heightFactor, 0];
for (let segment = 0; segment < segments; segment++) {
pushTriangle(
outerPositions,
outerColors,
bottomCenter,
ringPoints[0][segment + 1],
ringPoints[0][segment],
outerFaceColor(-1, segment)
);
pushTriangle(
outerPositions,
outerColors,
topCenter,
ringPoints[PROFILE.length - 1][segment],
ringPoints[PROFILE.length - 1][segment + 1],
outerFaceColor(PROFILE.length, segment)
);
}
const outerGeometry = new THREE.BufferGeometry();
outerGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(outerPositions, 3)
);
outerGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(outerColors, 3)
);
outerGeometry.computeVertexNormals();
const outerMesh = new THREE.Mesh(outerGeometry, outerMaterial);
crystal.add(outerMesh);
const cutPositions = [];
const cutColors = [];
for (const edgeIndex of [0, segments]) {
for (let ring = 0; ring < PROFILE.length - 1; ring++) {
const axisA = [0, ringY[ring], 0];
const axisB = [0, ringY[ring + 1], 0];
const outerA = ringPoints[ring][edgeIndex];
const outerB = ringPoints[ring + 1][edgeIndex];
const color = cutBandColor(ring);
pushTriangle(cutPositions, cutColors, axisA, outerA, outerB, color);
pushTriangle(cutPositions, cutColors, axisA, outerB, axisB, color);
}
}
const cutGeometry = new THREE.BufferGeometry();
cutGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(cutPositions, 3)
);
cutGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(cutColors, 3)
);
cutGeometry.computeVertexNormals();
const cutMesh = new THREE.Mesh(cutGeometry, cutMaterial);
crystal.add(cutMesh);
const cutLinePositions = [];
for (const edgeIndex of [0, segments]) {
for (let ring = 0; ring < PROFILE.length; ring++) {
cutLinePositions.push(
0, ringY[ring], 0,
ringPoints[ring][edgeIndex][0],
ringY[ring],
ringPoints[ring][edgeIndex][2]
);
}
}
const cutLinesGeometry = new THREE.BufferGeometry();
cutLinesGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(cutLinePositions, 3)
);
crystal.add(new THREE.LineSegments(cutLinesGeometry, cutLineMaterial));
if (isSlow) {
const terracePositions = [];
for (let ring = 1; ring < PROFILE.length - 1; ring++) {
for (let segment = 0; segment < segments; segment++) {
terracePositions.push(
...ringPoints[ring][segment],
...ringPoints[ring][segment + 1]
);
}
}
const terraceGeometry = new THREE.BufferGeometry();
terraceGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(terracePositions, 3)
);
crystal.add(new THREE.LineSegments(terraceGeometry, terraceMaterial));
}
const frontGeometry = new THREE.BufferGeometry().setFromPoints(
ringPoints[PROFILE.length - 1].slice(0, -1)
);
const growthFront = new THREE.Line(frontGeometry, growthFrontMaterial);
growthFrontMaterial.opacity = t > 0.995 ? 0.38 : 0.92;
crystal.add(growthFront);
const axisGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, BOTTOM, 0),
new THREE.Vector3(0, BOTTOM + FULL_HEIGHT * heightFactor, 0)
]);
const axisMaterial = new THREE.LineBasicMaterial({
color: accent,
transparent: true,
opacity: 0.22
});
crystal.add(new THREE.Line(axisGeometry, axisMaterial));
if (!isSlow) {
const shardCount = 66;
const shardGeometry = new THREE.TetrahedronGeometry(0.054, 0);
const shards = new THREE.InstancedMesh(
shardGeometry,
shardMaterial,
shardCount
);
const dummy = new THREE.Object3D();
for (let i = 0; i < shardCount; i++) {
const v = 0.045 + hash(i * 3.91 + 4.2) * 0.91;
const angle = startAngle + hash(i * 8.17 + 1.4) * span;
const continuousRing = v * (PROFILE.length - 1);
const ring = Math.min(
PROFILE.length - 2,
Math.floor(continuousRing)
);
const fraction = continuousRing - ring;
const baseRadius = THREE.MathUtils.lerp(
PROFILE[ring][1],
PROFILE[ring + 1][1],
fraction
);
const radius =
baseRadius * widthFactor +
roughnessAt(continuousRing, angle * 2.1);
dummy.position.set(
Math.cos(angle) * (radius + 0.012),
BOTTOM + v * FULL_HEIGHT * heightFactor,
Math.sin(angle) * (radius + 0.012)
);
dummy.rotation.set(
hash(i * 6.2) * Math.PI,
hash(i * 9.1) * Math.PI,
hash(i * 12.7) * Math.PI
);
const active = v <= t + 0.035;
const size = active
? (0.45 + hash(i * 14.3) * 0.85) * (0.55 + widthFactor * 0.45)
: 0;
dummy.scale.setScalar(size);
dummy.updateMatrix();
shards.setMatrixAt(i, dummy.matrix);
}
shards.instanceMatrix.needsUpdate = true;
crystal.add(shards);
}
}
function updateCamera() {
orbit.theta = THREE.MathUtils.lerp(
orbit.theta,
orbit.targetTheta,
0.09
);
orbit.phi = THREE.MathUtils.lerp(
orbit.phi,
orbit.targetPhi,
0.09
);
orbit.radius = THREE.MathUtils.lerp(
orbit.radius,
orbit.targetRadius,
0.09
);
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.radius * sinPhi * Math.cos(orbit.theta),
orbit.radius * Math.cos(orbit.phi),
orbit.radius * sinPhi * Math.sin(orbit.theta)
);
camera.lookAt(0, -0.04, 0);
}
function resize() {
const width = Math.max(1, viewport.clientWidth);
const height = Math.max(1, viewport.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const observer = new ResizeObserver(resize);
observer.observe(viewport);
resize();
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
orbit.targetTheta -= dx * 0.006;
orbit.targetPhi = THREE.MathUtils.clamp(
orbit.targetPhi + dy * 0.005,
0.48,
2.45
);
});
function stopDragging() {
dragging = false;
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.targetRadius = THREE.MathUtils.clamp(
orbit.targetRadius + event.deltaY * 0.0035,
3.45,
8.0
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
orbit.targetTheta = GAP_CENTER;
orbit.targetPhi = 1.18;
orbit.targetRadius = 5.25;
});
renderer.domElement.addEventListener("keydown", (event) => {
const key = event.key;
if (key === "ArrowLeft") orbit.targetTheta -= 0.12;
else if (key === "ArrowRight") orbit.targetTheta += 0.12;
else if (key === "ArrowUp") {
orbit.targetPhi = Math.max(0.48, orbit.targetPhi - 0.08);
} else if (key === "ArrowDown") {
orbit.targetPhi = Math.min(2.45, orbit.targetPhi + 0.08);
} else if (key === "+" || key === "=") {
orbit.targetRadius = Math.max(3.45, orbit.targetRadius - 0.2);
} else if (key === "-") {
orbit.targetRadius = Math.min(8.0, orbit.targetRadius + 0.2);
} else {
return;
}
event.preventDefault();
});
return {
setProgress(progress) {
if (Math.abs(progress - lastProgress) < 0.00035) return;
lastProgress = progress;
buildCrystal(progress);
},
render() {
updateCamera();
renderer.render(scene, camera);
}
};
}
const slowView = createCrystalView(
document.getElementById("slowViewport"),
"slow"
);
const rapidView = createCrystalView(
document.getElementById("rapidViewport"),
"rapid"
);
const timeline = document.getElementById("timeline");
const playButton = document.getElementById("playButton");
const replayButton = document.getElementById("replayButton");
const stageNumber = document.getElementById("stageNumber");
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
let progress = 0;
let playing = !reducedMotion;
let lastTime = performance.now();
function getStage(value) {
if (value >= 0.9999) return 3;
return Math.min(3, Math.floor(value * 4));
}
function setPlaying(value) {
playing = value;
playButton.textContent = playing ? "❚❚ Pause" : "▶ Play";
playButton.setAttribute(
"aria-label",
playing ? "Pause growth sequence" : "Play growth sequence"
);
}
function updateUI() {
const stage = getStage(progress);
stageNumber.textContent = String(stage + 1).padStart(2, "0");
timeline.value = String(Math.round(progress * 1000));
timeline.style.setProperty("--fill", `${progress * 100}%`);
for (const kind of ["slow", "rapid"]) {
const copy = stageCopy[kind][stage];
document.getElementById(`${kind}CaptionNumber`).textContent =
`Stage ${String(stage + 1).padStart(2, "0")} · ${copy.title}`;
document.querySelector(
`#${kind}CaptionNumber`
).nextElementSibling.textContent = copy.title;
document.getElementById(`${kind}CaptionCopy`).textContent = copy.copy;
document.querySelectorAll(
`.stage-button[data-kind="${kind}"]`
).forEach((button) => {
button.classList.toggle(
"active",
Number(button.dataset.stage) === stage
);
});
}
slowView.setProgress(progress);
rapidView.setProgress(progress);
}
playButton.addEventListener("click", () => {
if (!playing && progress >= 0.9999) {
progress = 0;
}
setPlaying(!playing);
updateUI();
});
replayButton.addEventListener("click", () => {
progress = 0;
setPlaying(true);
updateUI();
});
timeline.addEventListener("input", () => {
progress = Number(timeline.value) / 1000;
setPlaying(false);
updateUI();
});
document.querySelectorAll(".stage-button").forEach((button) => {
button.addEventListener("click", () => {
const stage = Number(button.dataset.stage);
const targets = [0, 0.25, 0.53, 1];
progress = targets[stage];
setPlaying(false);
updateUI();
});
});
document.addEventListener("visibilitychange", () => {
lastTime = performance.now();
});
function animate(now) {
const delta = THREE.MathUtils.clamp((now - lastTime) / 1000, 0, 0.05);
lastTime = now;
if (playing) {
progress = Math.min(1, progress + delta / 12.5);
if (progress >= 1) {
setPlaying(false);
}
updateUI();
}
slowView.render();
rapidView.render();
requestAnimationFrame(animate);
}
setPlaying(playing);
updateUI();
requestAnimationFrame(animate);
</script>
</body>
</html>
```