Prompt specification
Build or customize the Three.js 3D scene "Museum of Growth Models" 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: Museum of Growth Models
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/museum-of-growth-models-x3199
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring simple and compound growth over time. Create three pedestals comparing linear, exponential, and saturating accumulation with stated equations. Let visitors move a time slider and inspect scales before comparing heights. Voxel style.
Working Three.js Starter (museum-of-growth-models-x3199):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Growth Lab — Linear, Exponential & Saturating</title>
<style>
:root {
--paper: #f3efe5;
--paper-dark: #d8d1c3;
--ink: #111827;
--muted: #6d716f;
--stage: #0b1020;
--stage-line: #293248;
--linear: #62d9e5;
--exponential: #ffd166;
--saturating: #ff7a78;
--shadow: rgba(0, 0, 0, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
border-radius: 0;
}
#app {
position: relative;
width: 100%;
height: 100dvh;
min-height: 560px;
overflow: hidden;
background: var(--paper);
}
.topbar {
position: absolute;
inset: 0 0 auto 0;
z-index: 20;
height: 74px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 26px;
border-bottom: 1px solid rgba(17, 24, 39, 0.12);
background: var(--paper);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
position: relative;
width: 39px;
height: 39px;
flex: 0 0 auto;
}
.brand-mark span {
position: absolute;
display: block;
width: 19px;
height: 19px;
border: 2px solid var(--ink);
box-shadow: 3px 3px 0 rgba(17, 24, 39, 0.12);
}
.brand-mark span:nth-child(1) {
top: 0;
left: 0;
background: var(--linear);
}
.brand-mark span:nth-child(2) {
top: 0;
right: 0;
background: var(--exponential);
}
.brand-mark span:nth-child(3) {
bottom: 0;
left: 10px;
background: var(--saturating);
}
.eyebrow {
margin: 0 0 2px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: 18px;
line-height: 1.1;
letter-spacing: -0.02em;
}
.header-meta {
display: flex;
align-items: center;
gap: 9px;
}
.header-chip {
padding: 8px 10px;
border: 1px solid rgba(17, 24, 39, 0.18);
background: rgba(255, 255, 255, 0.28);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
#stage {
position: absolute;
inset: 74px 0 230px;
overflow: hidden;
isolation: isolate;
background:
radial-gradient(circle at 55% 37%, #1c2944 0%, #11192c 36%, #090e1b 76%),
var(--stage);
}
#stage::before {
content: "";
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
background-image:
linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
background-size: 32px 32px;
mask-image: linear-gradient(to bottom, transparent, black 22%, black 78%, transparent);
}
#stage canvas {
position: absolute;
inset: 0;
z-index: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
touch-action: none;
}
#stage canvas:focus-visible {
outline: 3px solid var(--linear);
outline-offset: -5px;
}
.stage-copy {
position: absolute;
z-index: 5;
top: 22px;
left: 25px;
width: 270px;
pointer-events: none;
color: #eef1f5;
}
.stage-copy .eyebrow {
color: #9ba8bc;
}
.stage-copy h2 {
margin: 7px 0 6px;
font-size: clamp(23px, 2.2vw, 34px);
line-height: 0.98;
letter-spacing: -0.055em;
}
.stage-copy p {
max-width: 245px;
margin: 0;
color: #aeb9cb;
font-size: 12px;
line-height: 1.55;
}
.stage-actions {
position: absolute;
z-index: 8;
top: 20px;
right: 22px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
}
.scene-button {
position: relative;
min-height: 38px;
padding: 0 13px;
border: 1px solid #536078;
color: #eef1f5;
background: rgba(12, 18, 34, 0.9);
box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.18);
cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
transition:
transform 120ms ease,
border-color 120ms ease,
background 120ms ease;
}
.scene-button:hover:not(:disabled) {
transform: translate(-1px, -1px);
border-color: #8b9ab5;
background: #18223a;
}
.scene-button:active:not(:disabled) {
transform: translate(2px, 2px);
box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.18);
}
.scene-button:focus-visible {
outline: 2px solid var(--linear);
outline-offset: 3px;
}
.scene-button[aria-pressed="true"] {
color: #0b1020;
border-color: var(--linear);
background: var(--linear);
}
.scene-button:disabled {
color: #657086;
border-color: #30394d;
cursor: not-allowed;
opacity: 0.7;
}
.scale-legend {
position: absolute;
z-index: 6;
top: 70px;
right: 22px;
display: none;
align-items: center;
gap: 9px;
padding: 9px 11px;
border: 1px solid #3d4962;
color: #cbd3df;
background: rgba(11, 16, 32, 0.88);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scale-legend.visible {
display: flex;
}
.scale-legend::before {
content: "";
width: 20px;
height: 9px;
border-top: 2px dashed #dce3ed;
}
.camera-hint {
position: absolute;
z-index: 5;
left: 22px;
bottom: 15px;
color: #8f9bb0;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
.voxel-note {
position: absolute;
z-index: 5;
right: 22px;
bottom: 15px;
color: #8f9bb0;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.07em;
text-transform: uppercase;
pointer-events: none;
}
#worldLabels {
position: absolute;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.series-tag {
--series: #ffffff;
position: absolute;
min-width: 118px;
padding: 8px 10px 7px;
border: 1px solid var(--series);
border-left-width: 5px;
color: #f5f7fa;
background: rgba(9, 14, 28, 0.9);
box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.18);
transform: translate(-50%, -100%);
transition:
border-color 150ms ease,
box-shadow 150ms ease;
}
.series-tag.winner {
border-color: #fff;
box-shadow:
5px 5px 0 rgba(0, 0, 0, 0.22),
0 0 0 2px var(--series);
}
.tag-kicker {
display: flex;
align-items: center;
gap: 6px;
color: #aeb9ca;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.tag-kicker::before {
content: "";
width: 6px;
height: 6px;
background: var(--series);
}
.tag-value {
margin-top: 3px;
font-size: 19px;
font-weight: 800;
line-height: 1;
letter-spacing: -0.035em;
}
.tag-value small {
margin-left: 3px;
color: #9ba8bc;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scale-tick {
position: absolute;
padding: 2px 5px;
border: 1px solid #4a566d;
color: #d7deea;
background: rgba(10, 15, 29, 0.88);
transform: translate(-100%, -50%);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.05em;
}
.dashboard {
position: absolute;
inset: auto 0 0;
z-index: 20;
height: 230px;
display: grid;
grid-template-rows: 74px 1fr;
gap: 13px;
padding: 16px 26px 18px;
border-top: 1px solid rgba(17, 24, 39, 0.15);
background:
linear-gradient(90deg, rgba(17, 24, 39, 0.035) 1px, transparent 1px) 0 0 / 24px 24px,
var(--paper);
}
.timeline-row {
display: grid;
grid-template-columns: 150px minmax(280px, 1fr) 210px;
align-items: center;
gap: 22px;
}
.play-button {
height: 48px;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
border: 2px solid var(--ink);
color: var(--paper);
background: var(--ink);
box-shadow: 4px 4px 0 rgba(17, 24, 39, 0.16);
cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.play-button:hover {
background: #273044;
}
.play-button:focus-visible {
outline: 3px solid var(--linear);
outline-offset: 3px;
}
#playIcon {
color: var(--linear);
font-size: 13px;
}
.timeline-center {
min-width: 0;
}
.timeline-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 14px;
margin-bottom: 6px;
}
.timeline-heading label {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#timeOutput {
font-size: 18px;
font-weight: 850;
letter-spacing: -0.04em;
}
#timeOutput small {
margin-left: 3px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
#timeSlider {
--progress: 60%;
width: 100%;
height: 8px;
margin: 0;
appearance: none;
border: 1px solid var(--ink);
border-radius: 0;
background: linear-gradient(
to right,
var(--ink) 0 var(--progress),
#c7c1b4 var(--progress) 100%
);
cursor: ew-resize;
}
#timeSlider::-webkit-slider-thumb {
width: 17px;
height: 22px;
appearance: none;
border: 2px solid var(--paper);
border-radius: 0;
background: var(--ink);
box-shadow: 0 0 0 1px var(--ink);
}
#timeSlider::-moz-range-thumb {
width: 15px;
height: 20px;
border: 2px solid var(--paper);
border-radius: 0;
background: var(--ink);
box-shadow: 0 0 0 1px var(--ink);
}
#timeSlider:focus-visible {
outline: 3px solid rgba(98, 217, 229, 0.75);
outline-offset: 4px;
}
.time-ticks {
display: flex;
justify-content: space-between;
margin-top: 7px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 700;
}
.scale-status {
display: grid;
grid-template-columns: 46px 1fr;
align-items: center;
gap: 10px;
min-height: 48px;
padding-left: 15px;
border-left: 1px solid rgba(17, 24, 39, 0.18);
}
.scale-status strong {
font-size: 20px;
line-height: 1;
letter-spacing: -0.04em;
}
.scale-status span {
display: block;
margin-bottom: 3px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
#scaleStatusText {
font-size: 10px;
font-weight: 800;
line-height: 1.25;
}
.equation-grid {
min-width: 0;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
}
.equation-card {
--series: #ffffff;
position: relative;
min-width: 0;
padding: 12px 14px 10px 16px;
overflow: hidden;
border: 1px solid rgba(17, 24, 39, 0.18);
background: rgba(255, 255, 255, 0.38);
transition:
transform 150ms ease,
border-color 150ms ease,
background 150ms ease;
}
.equation-card::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 6px;
background: var(--series);
}
.equation-card.winner {
border-color: var(--series);
background: rgba(255, 255, 255, 0.76);
transform: translateY(-2px);
}
.card-top {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
}
.card-title {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
font-weight: 900;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.card-title::before {
content: "";
width: 9px;
height: 9px;
background: var(--series);
box-shadow: 2px 2px 0 rgba(17, 24, 39, 0.16);
}
.card-value {
white-space: nowrap;
font-size: 17px;
font-weight: 850;
letter-spacing: -0.035em;
}
.card-value small {
margin-left: 2px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.equation {
margin-top: 6px;
overflow: hidden;
color: #29313f;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
font-weight: 700;
white-space: nowrap;
text-overflow: ellipsis;
}
.equation sup {
font-size: 0.72em;
}
.card-bottom {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 8px;
padding-top: 7px;
border-top: 1px solid rgba(17, 24, 39, 0.1);
}
.card-rule {
color: var(--muted);
font-size: 10px;
font-weight: 700;
}
.card-delta {
color: #4f5661;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 800;
text-align: right;
}
.comparing .equation-card {
background: rgba(255, 255, 255, 0.72);
}
@media (max-width: 900px) {
.header-meta .header-chip:last-child {
display: none;
}
.stage-copy {
width: 220px;
}
.stage-copy p {
display: none;
}
.timeline-row {
grid-template-columns: 126px 1fr 170px;
gap: 14px;
}
.equation-card {
padding-right: 10px;
padding-left: 13px;
}
.card-rule {
display: none;
}
}
@media (max-width: 700px) {
#app {
min-height: 650px;
}
.topbar {
height: 66px;
padding: 0 15px;
}
.brand h1 {
font-size: 15px;
}
.brand .eyebrow {
font-size: 8px;
}
.header-meta {
display: none;
}
#stage {
inset: 66px 0 310px;
}
.stage-copy {
top: 14px;
left: 15px;
width: 185px;
}
.stage-copy h2 {
margin-top: 5px;
font-size: 22px;
}
.stage-actions {
top: 13px;
right: 13px;
max-width: 170px;
}
.scene-button {
min-height: 34px;
padding: 0 9px;
font-size: 8px;
}
.scale-legend {
top: 92px;
right: 13px;
font-size: 8px;
}
.voxel-note {
display: none;
}
.dashboard {
height: 310px;
grid-template-rows: 151px 1fr;
padding: 13px 14px 15px;
}
.timeline-row {
grid-template-columns: 112px 1fr;
grid-template-rows: 52px 43px;
gap: 10px 15px;
}
.play-button {
grid-row: 1;
height: 47px;
}
.timeline-center {
grid-column: 2;
grid-row: 1;
}
.scale-status {
grid-column: 1 / -1;
grid-row: 2;
grid-template-columns: 40px 1fr;
min-height: 36px;
padding: 8px 0 0;
border-top: 1px solid rgba(17, 24, 39, 0.14);
border-left: 0;
}
.scale-status strong {
font-size: 17px;
}
.equation-grid {
display: flex;
overflow-x: auto;
padding-bottom: 5px;
scroll-snap-type: x mandatory;
}
.equation-card {
min-width: 250px;
flex: 0 0 250px;
scroll-snap-align: start;
}
.series-tag {
min-width: 98px;
padding: 6px 8px;
}
.tag-value {
font-size: 16px;
}
}
@media (max-height: 700px) and (min-width: 701px) {
.dashboard {
height: 205px;
grid-template-rows: 66px 1fr;
padding-top: 12px;
}
#stage {
bottom: 205px;
}
.equation-card {
padding-top: 9px;
padding-bottom: 8px;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<div id="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<span></span>
<span></span>
<span></span>
</div>
<div>
<p class="eyebrow">Interactive growth study / 03</p>
<h1>Three ways to accumulate</h1>
</div>
</div>
<div class="header-meta" aria-hidden="true">
<span class="header-chip">Voxel series</span>
<span class="header-chip">Shared scale / 0—200</span>
</div>
</header>
<main id="stage" aria-label="Interactive 3D comparison of linear, exponential, and saturating growth">
<div class="stage-copy">
<p class="eyebrow">Comparison field</p>
<h2>Same clock.<br>Different curves.</h2>
<p>Reveal the shared scale before comparing the live voxel stacks.</p>
</div>
<div class="stage-actions">
<button
id="inspectButton"
class="scene-button"
type="button"
aria-pressed="false"
>
1 · Inspect scale
</button>
<button
id="compareButton"
class="scene-button"
type="button"
aria-pressed="false"
disabled
title="Inspect the scale first"
>
2 · Compare heights
</button>
<button
id="resetButton"
class="scene-button"
type="button"
>
Reset view
</button>
</div>
<div id="scaleLegend" class="scale-legend">
Shared vertical scale · 0—200 units
</div>
<div id="worldLabels" aria-hidden="true"></div>
<div class="camera-hint">Drag to orbit · wheel / pinch to zoom · double-click to reset</div>
<div class="voxel-note">Each stacked layer represents 5 units</div>
</main>
<footer class="dashboard">
<div class="timeline-row">
<button id="playButton" class="play-button" type="button" aria-pressed="false">
<span id="playIcon" aria-hidden="true">▶</span>
<span id="playText">Play time</span>
</button>
<div class="timeline-center">
<div class="timeline-heading">
<label for="timeSlider">Time / t</label>
<output id="timeOutput" for="timeSlider">12.0 <small>units</small></output>
</div>
<input
id="timeSlider"
type="range"
min="0"
max="20"
step="0.1"
value="12"
aria-label="Time"
>
<div class="time-ticks" aria-hidden="true">
<span>0</span>
<span>5</span>
<span>10</span>
<span>15</span>
<span>20</span>
</div>
</div>
<div class="scale-status">
<strong>0—200</strong>
<div>
<span>Common vertical scale</span>
<div id="scaleStatusText">Step 1 · inspect scale</div>
</div>
</div>
</div>
<div class="equation-grid">
<article id="card-linear" class="equation-card" style="--series: var(--linear)">
<div class="card-top">
<div class="card-title">Linear</div>
<div class="card-value">
<span data-value>29.0</span><small>units</small>
</div>
</div>
<div class="equation">N(t) = 5 + 2t</div>
<div class="card-bottom">
<span class="card-rule">Constant additions</span>
<span class="card-delta">Step 1 · inspect scale</span>
</div>
</article>
<article id="card-exponential" class="equation-card" style="--series: var(--exponential)">
<div class="card-top">
<div class="card-title">Exponential</div>
<div class="card-value">
<span data-value>61.8</span><small>units</small>
</div>
</div>
<div class="equation">N(t) = 5(1.15)<sup>t</sup></div>
<div class="card-bottom">
<span class="card-rule">Constant percentage</span>
<span class="card-delta">Step 1 · inspect scale</span>
</div>
</article>
<article id="card-saturating" class="equation-card" style="--series: var(--saturating)">
<div class="card-top">
<div class="card-title">Saturating</div>
<div class="card-value">
<span data-value>164.7</span><small>units</small>
</div>
</div>
<div class="equation">N(t) = 5 + 175(1 − e<sup>−t/8</sup>)</div>
<div class="card-bottom">
<span class="card-rule">Approaches a ceiling</span>
<span class="card-delta">Step 1 · inspect scale</span>
</div>
</article>
</div>
</footer>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const labelsRoot = document.querySelector("#worldLabels");
const timeSlider = document.querySelector("#timeSlider");
const timeOutput = document.querySelector("#timeOutput");
const playButton = document.querySelector("#playButton");
const playIcon = document.querySelector("#playIcon");
const playText = document.querySelector("#playText");
const inspectButton = document.querySelector("#inspectButton");
const compareButton = document.querySelector("#compareButton");
const resetButton = document.querySelector("#resetButton");
const scaleLegend = document.querySelector("#scaleLegend");
const scaleStatusText = document.querySelector("#scaleStatusText");
const MAX_VALUE = 200;
const MAX_TIME = 20;
const BASE_Y = 0.94;
const MAX_HEIGHT = 8.2;
const LAYER_UNITS = 5;
const MAX_LAYERS = MAX_VALUE / LAYER_UNITS;
const GRID_SIZE = 5;
const VOXEL_SIZE = 0.165;
const VOXEL_SPACING = 0.205;
const series = [
{
id: "linear",
name: "Linear",
color: "#62d9e5",
x: -5.2,
equation: (t) => 5 + 2 * t,
rule: "Constant additions"
},
{
id: "exponential",
name: "Exponential",
color: "#ffd166",
x: 0,
equation: (t) => 5 * Math.pow(1.15, t),
rule: "Constant percentage"
},
{
id: "saturating",
name: "Saturating",
color: "#ff7a78",
x: 5.2,
equation: (t) => 5 + 175 * (1 - Math.exp(-t / 8)),
rule: "Approaches a ceiling"
}
];
let currentTime = 12;
let playing = false;
let inspected = false;
let guidesVisible = false;
let comparing = false;
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x0b1020, 19, 39);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Orbitable 3D growth comparison");
renderer.domElement.setAttribute("role", "img");
renderer.domElement.tabIndex = 0;
stage.prepend(renderer.domElement);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 3.6, 0);
const cameraState = {
theta: 0.31,
phi: 1.18,
radius: 19.5
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
const cosPhi = Math.cos(cameraState.phi);
camera.position.set(
cameraTarget.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y + cameraState.radius * cosPhi,
cameraTarget.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraState.theta = 0.31;
cameraState.phi = 1.18;
const aspect = stage.clientWidth / Math.max(stage.clientHeight, 1);
cameraState.radius = 19.5 + Math.max(0, 1.3 - aspect) * 14;
updateCamera();
}
const hemisphere = new THREE.HemisphereLight(0xc8dcff, 0x111524, 1.8);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4dd, 3.1);
keyLight.position.set(-8, 15, 11);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 15;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x70bfff, 1.6);
rimLight.position.set(10, 9, -9);
scene.add(rimLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(44, 44),
new THREE.MeshStandardMaterial({
color: 0x0a1020,
roughness: 0.94,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.025;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(40, 40, 0x33415d, 0x1c2740);
grid.position.y = 0.005;
grid.material.transparent = true;
grid.material.opacity = 0.42;
scene.add(grid);
function makePlaqueTexture(item, index) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const context = canvas.getContext("2d");
context.fillStyle = "#111827";
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = item.color;
context.fillRect(0, 0, 20, canvas.height);
context.fillStyle = "#f4f0e7";
context.font = "800 42px ui-monospace, monospace";
context.fillText(String(index + 1).padStart(2, "0"), 44, 55);
context.font = "800 29px sans-serif";
context.fillText(item.name.toUpperCase(), 112, 53);
context.fillStyle = "#7f899d";
context.font = "700 18px ui-monospace, monospace";
context.fillText("COMMON SCALE", 112, 91);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
return texture;
}
const voxelMeshes = [];
const pedestalTops = [];
const worldTags = [];
const dummy = new THREE.Object3D();
const tempColor = new THREE.Color();
series.forEach((item, index) => {
const pedestal = new THREE.Group();
pedestal.position.x = item.x;
scene.add(pedestal);
const lower = new THREE.Mesh(
new THREE.BoxGeometry(3.8, 0.32, 3.8),
new THREE.MeshStandardMaterial({
color: 0x111827,
roughness: 0.82
})
);
lower.position.y = 0.16;
lower.castShadow = true;
lower.receiveShadow = true;
pedestal.add(lower);
const body = new THREE.Mesh(
new THREE.BoxGeometry(3.3, 0.5, 3.3),
new THREE.MeshStandardMaterial({
color: 0x303a4f,
roughness: 0.72
})
);
body.position.y = 0.57;
body.castShadow = true;
body.receiveShadow = true;
pedestal.add(body);
const topMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(item.color).multiplyScalar(0.36),
roughness: 0.66,
metalness: 0.05,
emissive: new THREE.Color(item.color),
emissiveIntensity: 0.035
});
const top = new THREE.Mesh(
new THREE.BoxGeometry(2.9, 0.1, 2.9),
topMaterial
);
top.position.y = 0.87;
top.castShadow = true;
top.receiveShadow = true;
pedestal.add(top);
pedestalTops.push(topMaterial);
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(2.8, 0.7),
new THREE.MeshBasicMaterial({
map: makePlaqueTexture(item, index),
toneMapped: false
})
);
plaque.position.set(0, 0.55, 1.661);
pedestal.add(plaque);
const voxelGeometry = new THREE.BoxGeometry(
VOXEL_SIZE,
VOXEL_SIZE,
VOXEL_SIZE
);
const voxelMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.56,
metalness: 0.04,
vertexColors: true,
emissive: new THREE.Color(item.color),
emissiveIntensity: 0.045
});
const voxelMesh = new THREE.InstancedMesh(
voxelGeometry,
voxelMaterial,
MAX_LAYERS * GRID_SIZE * GRID_SIZE
);
voxelMesh.count = 0;
voxelMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
voxelMesh.castShadow = true;
voxelMesh.receiveShadow = true;
voxelMesh.frustumCulled = false;
pedestal.add(voxelMesh);
voxelMeshes.push(voxelMesh);
const tag = document.createElement("div");
tag.className = "series-tag";
tag.style.setProperty("--series", item.color);
tag.innerHTML = `
<div class="tag-kicker">${item.name}</div>
<div class="tag-value"><span>0.0</span><small>units</small></div>
`;
labelsRoot.appendChild(tag);
worldTags.push({
element: tag,
valueElement: tag.querySelector(".tag-value span"),
series: item
});
});
const guides = new THREE.Group();
guides.visible = false;
scene.add(guides);
const scaleTicks = [];
const scaleTickValues = [0, 50, 100, 150, 200];
scaleTickValues.forEach((value) => {
const y = BASE_Y + (value / MAX_VALUE) * MAX_HEIGHT;
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-8.35, y, 0),
new THREE.Vector3(8.35, y, 0)
]);
const material = new THREE.LineDashedMaterial({
color: 0xdce3ed,
dashSize: 0.2,
gapSize: 0.12,
transparent: true,
opacity: 0.62,
depthTest: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
line.renderOrder = 10;
guides.add(line);
const tickGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-8.5, y, 0),
new THREE.Vector3(-8.2, y, 0)
]);
const tickMaterial = new THREE.LineBasicMaterial({
color: 0xf2f4f8,
transparent: true,
opacity: 0.82,
depthTest: false
});
const tick = new THREE.Line(tickGeometry, tickMaterial);
tick.renderOrder = 11;
guides.add(tick);
const label = document.createElement("div");
label.className = "scale-tick";
label.textContent = value;
labelsRoot.appendChild(label);
scaleTicks.push({ value, y, element: label });
});
const rulerGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-8.35, BASE_Y, 0),
new THREE.Vector3(-8.35, BASE_Y + MAX_HEIGHT, 0)
]);
const rulerMaterial = new THREE.LineBasicMaterial({
color: 0xaeb9ca,
transparent: true,
opacity: 0.42,
depthTest: false
});
const ruler = new THREE.Line(rulerGeometry, rulerMaterial);
ruler.renderOrder = 10;
guides.add(ruler);
const motes = [];
const moteGeometry = new THREE.BoxGeometry(0.11, 0.11, 0.11);
const moteMaterial = new THREE.MeshStandardMaterial({
color: 0x394762,
roughness: 0.7,
metalness: 0.08,
transparent: true,
opacity: 0.56
});
for (let i = 0; i < 22; i++) {
const mote = new THREE.Mesh(moteGeometry, moteMaterial);
mote.position.set(
(Math.random() - 0.5) * 24,
1.5 + Math.random() * 10,
-4 - Math.random() * 9
);
mote.scale.setScalar(0.6 + Math.random() * 1.9);
mote.rotation.set(Math.random(), Math.random(), Math.random());
mote.userData.speed = 0.12 + Math.random() * 0.22;
mote.userData.phase = Math.random() * Math.PI * 2;
scene.add(mote);
motes.push(mote);
}
function updateVoxels() {
series.forEach((item, seriesIndex) => {
const value = item.equation(currentTime);
const layers = Math.min(
MAX_LAYERS,
Math.max(0, Math.ceil(value / LAYER_UNITS))
);
const mesh = voxelMeshes[seriesIndex];
let instanceIndex = 0;
for (let layer = 0; layer < layers; layer++) {
for (let x = 0; x < GRID_SIZE; x++) {
for (let z = 0; z < GRID_SIZE; z++) {
dummy.position.set(
(x - (GRID_SIZE - 1) / 2) * VOXEL_SPACING,
BASE_Y + layer * VOXEL_SPACING + VOXEL_SIZE / 2,
(z - (GRID_SIZE - 1) / 2) * VOXEL_SPACING
);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
mesh.setMatrixAt(instanceIndex, dummy.matrix);
tempColor.set(item.color);
const checker = (x + z + layer) % 2 === 0 ? 0.045 : -0.025;
const verticalShade = layer % 4 === 0 ? 0.025 : 0;
tempColor.offsetHSL(0, 0, checker + verticalShade);
mesh.setColorAt(instanceIndex, tempColor);
instanceIndex++;
}
}
}
mesh.count = instanceIndex;
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) {
mesh.instanceColor.needsUpdate = true;
}
});
}
function formatValue(value) {
return value.toFixed(1);
}
function updateReadouts() {
const values = series.map((item) => item.equation(currentTime));
const linearValue = values[0];
const highestValue = Math.max(...values);
const highestIndex = values.indexOf(highestValue);
timeOutput.innerHTML = `${currentTime.toFixed(1)} <small>units</small>`;
timeSlider.value = currentTime.toFixed(1);
timeSlider.style.setProperty(
"--progress",
`${(currentTime / MAX_TIME) * 100}%`
);
series.forEach((item, index) => {
const card = document.querySelector(`#card-${item.id}`);
const valueElement = card.querySelector("[data-value]");
const deltaElement = card.querySelector(".card-delta");
const isWinner = comparing && index === highestIndex;
valueElement.textContent = formatValue(values[index]);
card.classList.toggle("winner", isWinner);
if (!inspected) {
deltaElement.textContent = "Step 1 · inspect scale";
} else if (!comparing) {
deltaElement.textContent = "Scale ready · compare next";
} else if (index === 0) {
deltaElement.textContent = "Comparison baseline";
} else {
const difference = values[index] - linearValue;
deltaElement.textContent = `+${formatValue(difference)} vs linear`;
}
const tag = worldTags[index];
tag.valueElement.textContent = formatValue(values[index]);
tag.element.classList.toggle("winner", isWinner);
});
if (!inspected) {
scaleStatusText.textContent = "Step 1 · inspect scale";
} else if (comparing) {
scaleStatusText.textContent = "Comparing on one scale";
} else {
scaleStatusText.textContent = "Scale revealed · compare next";
}
}
function updateTime(value) {
currentTime = THREE.MathUtils.clamp(value, 0, MAX_TIME);
updateVoxels();
updateReadouts();
}
function setGuideVisibility() {
guides.visible = inspected && guidesVisible;
scaleLegend.classList.toggle("visible", guides.visible);
scaleTicks.forEach((tick) => {
tick.element.style.display = guides.visible ? "block" : "none";
});
inspectButton.setAttribute("aria-pressed", String(guidesVisible));
inspectButton.textContent = guidesVisible
? "Hide guides"
: inspected
? "Show guides"
: "1 · Inspect scale";
compareButton.setAttribute("aria-pressed", String(comparing));
compareButton.textContent = comparing
? "Exit comparison"
: "2 · Compare heights";
}
inspectButton.addEventListener("click", () => {
if (!inspected) {
inspected = true;
guidesVisible = true;
compareButton.disabled = false;
compareButton.title = "Compare all three stacks on the shared scale";
} else {
guidesVisible = !guidesVisible;
}
setGuideVisibility();
updateReadouts();
});
compareButton.addEventListener("click", () => {
if (!inspected) return;
comparing = !comparing;
if (comparing) {
guidesVisible = true;
}
document.body.classList.toggle("comparing", comparing);
setGuideVisibility();
updateReadouts();
});
resetButton.addEventListener("click", resetCamera);
timeSlider.addEventListener("input", (event) => {
playing = false;
playButton.setAttribute("aria-pressed", "false");
playIcon.textContent = "▶";
playText.textContent = "Play time";
updateTime(Number(event.target.value));
});
playButton.addEventListener("click", () => {
playing = !playing;
playButton.setAttribute("aria-pressed", String(playing));
playIcon.textContent = playing ? "Ⅱ" : "▶";
playText.textContent = playing ? "Pause time" : "Play time";
if (playing && currentTime >= MAX_TIME - 0.001) {
updateTime(0);
}
});
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(height, 1);
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
const pointers = new Map();
let previousPointer = null;
let previousPinchDistance = 0;
function pointerDistance() {
const points = [...pointers.values()];
if (points.length < 2) return 0;
return Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.focus({ preventScroll: true });
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
previousPinchDistance = pointerDistance();
} else {
previousPointer = { x: event.clientX, y: event.clientY };
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size >= 2) {
const distance = pointerDistance();
if (previousPinchDistance > 0 && distance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * (previousPinchDistance / distance),
12,
34
);
}
previousPinchDistance = distance;
} else if (previousPointer) {
const dx = event.clientX - previousPointer.x;
const dy = event.clientY - previousPointer.y;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.58,
1.43
);
previousPointer = { x: event.clientX, y: event.clientY };
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) {
previousPinchDistance = 0;
}
const first = [...pointers.values()][0];
previousPointer = first ? { x: first.x, y: first.y } : null;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
12,
34
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("keydown", (event) => {
const step = 0.09;
if (event.key === "ArrowLeft") {
cameraState.theta -= step;
} else if (event.key === "ArrowRight") {
cameraState.theta += step;
} else if (event.key === "ArrowUp") {
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - step,
0.58,
1.43
);
} else if (event.key === "ArrowDown") {
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + step,
0.58,
1.43
);
} else if (event.key === "0") {
resetCamera();
} else {
return;
}
event.preventDefault();
});
const projected = new THREE.Vector3();
function projectElement(element, worldPosition, visible = true) {
projected.copy(worldPosition).project(camera);
const inFront = projected.z >= -1 && projected.z <= 1;
const x = (projected.x * 0.5 + 0.5) * stage.clientWidth;
const y = (-projected.y * 0.5 + 0.5) * stage.clientHeight;
element.style.display = visible && inFront ? "block" : "none";
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function updateOverlays() {
series.forEach((item, index) => {
const value = item.equation(currentTime);
const capY = BASE_Y + (value / MAX_VALUE) * MAX_HEIGHT + 0.28;
projectElement(
worldTags[index].element,
new THREE.Vector3(item.x, capY, 0.08)
);
});
scaleTicks.forEach((tick) => {
projectElement(
tick.element,
new THREE.Vector3(-8.62, tick.y, 0),
guides.visible
);
});
}
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (playing) {
let nextTime = currentTime + delta * 1.25;
if (nextTime > MAX_TIME) {
nextTime = 0;
}
updateTime(nextTime);
}
if (!reducedMotion) {
motes.forEach((mote) => {
mote.position.y += Math.sin(
clock.elapsedTime * mote.userData.speed + mote.userData.phase
) * 0.0018;
mote.rotation.x += delta * 0.09;
mote.rotation.y += delta * 0.13;
});
}
const pulse = comparing
? 0.11 + Math.sin(clock.elapsedTime * 3) * 0.035
: 0.045;
voxelMeshes.forEach((mesh) => {
mesh.material.emissiveIntensity = pulse;
});
pedestalTops.forEach((material) => {
material.emissiveIntensity = comparing ? 0.11 : 0.035;
});
guides.children.forEach((child) => {
if (child.material && "opacity" in child.material) {
child.material.opacity = comparing
? Math.min(child.material.opacity, 0.28)
: child === ruler
? 0.42
: child.material.dashSize
? 0.62
: 0.82;
}
});
updateCamera();
renderer.render(scene, camera);
updateOverlays();
}
resize();
resetCamera();
updateTime(currentTime);
setGuideVisibility();
updateReadouts();
animate();
</script>
</body>
</html>
```