Prompt specification
Build or customize the Three.js 3D scene "Germination stage dependence" 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: Germination stage dependence
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/germination-stage-dependence-x0786
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows seed reserves and germination. Show a seed opening, root emerging, and first leaves unfolding through distinct models; symbolic reserves decrease before the developing leaves gain a photosynthesis indicator. Low-poly.
Working Three.js Starter (germination-stage-dependence-x0786):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Reserve to Sunlight — Low-Poly Germination</title>
<style>
:root {
color-scheme: dark;
--bg: #08130f;
--panel: rgba(9, 24, 18, 0.76);
--panel-border: rgba(185, 224, 194, 0.16);
--text: #eef5e9;
--muted: #91a89a;
--reserve: #e7a84c;
--leaf: #73d67b;
--progress: 0%;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--text);
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
cursor: grab;
touch-action: none;
}
#scene.dragging {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.topbar {
position: absolute;
top: 28px;
left: 32px;
right: 32px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 28px;
}
.eyebrow {
margin: 0 0 12px;
color: var(--leaf);
font-size: 0.69rem;
font-weight: 750;
letter-spacing: 0.21em;
text-transform: uppercase;
}
h1 {
max-width: 700px;
margin: 0;
font-size: clamp(2.6rem, 6.2vw, 6.4rem);
font-weight: 620;
line-height: 0.9;
letter-spacing: -0.065em;
text-wrap: balance;
}
h1 .arrow {
color: var(--reserve);
font-weight: 350;
}
.subtitle {
max-width: 460px;
margin: 17px 0 0;
color: var(--muted);
font-size: 0.92rem;
line-height: 1.55;
}
.readout {
width: 272px;
flex: 0 0 auto;
padding: 18px;
border: 1px solid var(--panel-border);
border-radius: 4px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(14px);
pointer-events: auto;
}
.readout-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18px;
padding-bottom: 13px;
border-bottom: 1px solid var(--panel-border);
}
.readout-title {
font-size: 0.7rem;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.live-dot {
display: inline-flex;
align-items: center;
gap: 7px;
color: var(--muted);
font-size: 0.64rem;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.live-dot::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--leaf);
box-shadow: 0 0 12px var(--leaf);
content: "";
}
.meter + .meter {
margin-top: 18px;
}
.meter-label {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 8px;
color: var(--muted);
font-size: 0.7rem;
font-weight: 650;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.meter-value {
color: var(--text);
font-variant-numeric: tabular-nums;
letter-spacing: 0;
}
.reserve-cells {
display: grid;
grid-template-columns: repeat(10, 1fr);
gap: 3px;
height: 9px;
}
.reserve-cells span {
border-radius: 1px;
background: var(--reserve);
box-shadow: 0 0 8px rgba(231, 168, 76, 0.2);
transition: opacity 120ms linear, transform 120ms linear;
}
.meter-track {
height: 9px;
overflow: hidden;
border-radius: 1px;
background: rgba(255, 255, 255, 0.08);
}
.meter-fill {
width: 0;
height: 100%;
background: linear-gradient(90deg, #4aab67, #a0e887);
box-shadow: 0 0 14px rgba(115, 214, 123, 0.45);
}
.sun-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
color: var(--leaf);
font-size: 0.65rem;
letter-spacing: 0.1em;
opacity: 0.5;
text-transform: uppercase;
transition: opacity 250ms ease, color 250ms ease;
}
.sun-row.active {
color: #b1f4a8;
opacity: 1;
}
.sun-icon {
display: grid;
width: 24px;
height: 24px;
place-items: center;
border: 1px solid currentColor;
border-radius: 50%;
font-size: 0.8rem;
}
.reset-camera {
width: 100%;
margin-top: 17px;
padding: 9px 10px;
border: 1px solid var(--panel-border);
border-radius: 3px;
background: rgba(255, 255, 255, 0.035);
color: var(--muted);
font: inherit;
font-size: 0.67rem;
font-weight: 700;
letter-spacing: 0.11em;
text-transform: uppercase;
cursor: pointer;
transition: 150ms ease;
}
.reset-camera:hover {
border-color: rgba(185, 224, 194, 0.36);
color: var(--text);
background: rgba(255, 255, 255, 0.07);
}
.stage-label {
position: absolute;
z-index: 2;
padding: 7px 10px;
border: 1px solid rgba(198, 222, 205, 0.2);
border-radius: 2px;
background: rgba(7, 17, 13, 0.68);
color: #c6d7ca;
font-size: 0.61rem;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
white-space: nowrap;
transform: translate(-50%, -50%);
backdrop-filter: blur(8px);
transition: opacity 180ms ease;
}
.stage-label::before {
display: inline-block;
width: 5px;
height: 5px;
margin-right: 7px;
border-radius: 50%;
background: var(--reserve);
content: "";
}
.stage-label.root::before {
background: #e8dfbd;
}
.stage-label.leaf::before {
background: var(--leaf);
}
.bottom-deck {
position: absolute;
right: 28px;
bottom: 24px;
left: 28px;
display: grid;
grid-template-columns: minmax(250px, 0.8fr) minmax(400px, 2fr);
gap: 24px;
padding: 18px 20px;
border: 1px solid var(--panel-border);
border-radius: 4px;
background: var(--panel);
box-shadow: 0 20px 70px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(15px);
pointer-events: auto;
}
.phase-number {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 7px;
color: var(--leaf);
font-size: 0.65rem;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.phase-number span:first-child {
display: grid;
width: 24px;
height: 24px;
place-items: center;
border: 1px solid currentColor;
border-radius: 50%;
}
.phase-title {
margin: 0;
font-size: 1.02rem;
font-weight: 680;
letter-spacing: -0.01em;
}
.phase-description {
min-height: 35px;
margin: 7px 0 0;
color: var(--muted);
font-size: 0.74rem;
line-height: 1.45;
}
.timeline {
align-self: center;
}
.timeline-meta {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 9px;
color: var(--muted);
font-size: 0.65rem;
font-variant-numeric: tabular-nums;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.phase-steps {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 4px;
margin-bottom: 8px;
}
.phase-step {
height: 2px;
background: rgba(255, 255, 255, 0.11);
transition: background 180ms ease, box-shadow 180ms ease;
}
.phase-step.active {
background: var(--leaf);
box-shadow: 0 0 9px rgba(115, 214, 123, 0.5);
}
.scrubber {
width: 100%;
height: 4px;
margin: 0;
appearance: none;
border-radius: 0;
background:
linear-gradient(
90deg,
var(--leaf) 0%,
var(--leaf) var(--progress),
rgba(255, 255, 255, 0.12) var(--progress),
rgba(255, 255, 255, 0.12) 100%
);
cursor: pointer;
}
.scrubber::-webkit-slider-thumb {
width: 12px;
height: 12px;
appearance: none;
border: 2px solid #0a1911;
border-radius: 50%;
background: #b1f4a8;
box-shadow: 0 0 0 1px rgba(177, 244, 168, 0.4);
}
.scrubber::-moz-range-thumb {
width: 10px;
height: 10px;
border: 2px solid #0a1911;
border-radius: 50%;
background: #b1f4a8;
box-shadow: 0 0 0 1px rgba(177, 244, 168, 0.4);
}
.transport {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 13px;
}
.transport-buttons {
display: flex;
gap: 7px;
}
.transport button {
min-width: 70px;
padding: 7px 11px;
border: 1px solid var(--panel-border);
border-radius: 2px;
background: rgba(255, 255, 255, 0.035);
color: var(--text);
font: inherit;
font-size: 0.64rem;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
cursor: pointer;
transition: 150ms ease;
}
.transport button:hover {
border-color: rgba(185, 224, 194, 0.36);
background: rgba(255, 255, 255, 0.075);
}
.transport button.primary {
border-color: rgba(115, 214, 123, 0.45);
color: #c3f7bc;
}
.camera-hint {
color: var(--muted);
font-size: 0.62rem;
letter-spacing: 0.07em;
text-transform: uppercase;
}
@media (max-width: 820px) {
.topbar {
top: 17px;
right: 16px;
left: 16px;
}
h1 {
font-size: clamp(2.4rem, 11vw, 4rem);
}
.subtitle {
display: none;
}
.readout {
position: absolute;
top: 108px;
right: 0;
width: 205px;
padding: 13px;
}
.readout-header,
.reset-camera {
display: none;
}
.meter + .meter {
margin-top: 12px;
}
.bottom-deck {
right: 12px;
bottom: 12px;
left: 12px;
grid-template-columns: 1fr;
gap: 12px;
padding: 14px;
}
.phase-description {
display: none;
}
.phase-title {
font-size: 0.9rem;
}
.camera-hint {
display: none;
}
.stage-label {
display: none;
}
}
@media (max-height: 650px) and (min-width: 821px) {
.subtitle {
display: none;
}
.bottom-deck {
bottom: 12px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Animated low-poly seed germination scene"></canvas>
<div class="hud">
<header class="topbar">
<div>
<p class="eyebrow">Botanical systems / germination study 01</p>
<h1>Reserve <span class="arrow">→</span><br />Sunlight.</h1>
<p class="subtitle">
A low-poly study of stored energy becoming roots, unfolded leaves,
and the first fragile exchange of light for carbon.
</p>
</div>
<aside class="readout" aria-label="Plant energy indicators">
<div class="readout-header">
<span class="readout-title">Energy state</span>
<span class="live-dot">Live</span>
</div>
<div class="meter">
<div class="meter-label">
<span>Reserve</span>
<span class="meter-value" id="reserveValue">100%</span>
</div>
<div class="reserve-cells" id="reserveCells" aria-hidden="true"></div>
</div>
<div class="meter">
<div class="meter-label">
<span>Photosynthesis</span>
<span class="meter-value" id="photoValue">0%</span>
</div>
<div class="meter-track">
<div class="meter-fill" id="photoFill"></div>
</div>
<div class="sun-row" id="sunRow">
<span class="sun-icon">☀</span>
<span>Leaf energy input</span>
</div>
</div>
<button class="reset-camera" id="resetCamera" type="button">
Reset camera
</button>
</aside>
</header>
<div class="stage-label seed" id="seedLabel">01 / Seed coat</div>
<div class="stage-label root" id="rootLabel">02 / Radicle</div>
<div class="stage-label leaf" id="leafLabel">03 / First leaves</div>
<section class="bottom-deck" aria-label="Animation controls">
<div>
<div class="phase-number">
<span id="phaseNumber">01</span>
<span id="phaseStatus">Dormancy</span>
</div>
<h2 class="phase-title" id="phaseTitle" aria-live="polite">
Stored for a future shoot
</h2>
<p class="phase-description" id="phaseDescription">
The intact seed holds its embryo and nutrient reserves in reserve.
</p>
</div>
<div class="timeline">
<div class="timeline-meta">
<span>Germination sequence</span>
<span id="timeReadout">00:00 / 00:18</span>
</div>
<div class="phase-steps" aria-hidden="true">
<span class="phase-step active"></span>
<span class="phase-step"></span>
<span class="phase-step"></span>
<span class="phase-step"></span>
<span class="phase-step"></span>
</div>
<input
class="scrubber"
id="scrubber"
type="range"
min="0"
max="1000"
value="0"
aria-label="Scrub germination timeline"
/>
<div class="transport">
<div class="transport-buttons">
<button class="primary" id="playButton" type="button">Pause</button>
<button id="restartButton" type="button">Restart</button>
</div>
<div class="camera-hint">Drag to orbit · Scroll to zoom</div>
</div>
</div>
</section>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x08130f);
scene.fog = new THREE.FogExp2(0x08130f, 0.052);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraTarget = new THREE.Vector3(-0.45, -0.02, 0);
let cameraYaw = 0.58;
let cameraPitch = 0.27;
let cameraDistance = window.innerWidth < 820 ? 10.2 : 8.4;
function updateCamera() {
const horizontal = Math.cos(cameraPitch) * cameraDistance;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontal,
cameraTarget.y + Math.sin(cameraPitch) * cameraDistance,
cameraTarget.z + Math.cos(cameraYaw) * horizontal
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Lighting
scene.add(new THREE.HemisphereLight(0xc9ebd4, 0x271b12, 1.7));
const keyLight = new THREE.DirectionalLight(0xfff1ca, 3.2);
keyLight.position.set(4.5, 7, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 20;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x72d9a2, 1.5);
rimLight.position.set(-4, 2.5, -5);
scene.add(rimLight);
const reserveLight = new THREE.PointLight(0xf3ae4e, 1.3, 3.2);
reserveLight.position.set(-1.1, 0.15, 0.4);
scene.add(reserveLight);
// Faceted soil cutaway
const soilBlock = new THREE.Mesh(
new THREE.BoxGeometry(6.2, 1.85, 2.65),
new THREE.MeshStandardMaterial({
color: 0x6e4b32,
roughness: 1,
metalness: 0,
transparent: true,
opacity: 0.075,
depthWrite: false
})
);
soilBlock.position.set(-0.55, -1.48, -0.02);
scene.add(soilBlock);
const soilEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(soilBlock.geometry),
new THREE.LineBasicMaterial({
color: 0xa78a67,
transparent: true,
opacity: 0.17
})
);
soilEdges.position.copy(soilBlock.position);
scene.add(soilEdges);
const soilTop = new THREE.Mesh(
new THREE.PlaneGeometry(6.2, 2.65),
new THREE.MeshStandardMaterial({
color: 0x5c3e29,
roughness: 1,
transparent: true,
opacity: 0.46,
depthWrite: false,
side: THREE.DoubleSide
})
);
soilTop.rotation.x = -Math.PI / 2;
soilTop.position.set(-0.55, -0.54, -0.02);
soilTop.receiveShadow = true;
scene.add(soilTop);
const soilChipGeometry = new THREE.IcosahedronGeometry(0.13, 0);
const soilChipMaterial = new THREE.MeshStandardMaterial({
color: 0x70492f,
roughness: 1,
flatShading: true
});
const chipPositions = [
[-2.7, -0.48, -0.55], [-2.3, -0.46, 0.45],
[-1.9, -0.48, -0.7], [-1.7, -0.47, 0.62],
[-0.4, -0.47, -0.52], [-0.1, -0.49, 0.6],
[0.35, -0.47, -0.65], [0.75, -0.49, 0.42],
[1.2, -0.46, -0.4], [1.65, -0.48, 0.55],
[2.1, -0.47, -0.52], [2.45, -0.49, 0.22]
];
chipPositions.forEach((position, index) => {
const chip = new THREE.Mesh(soilChipGeometry, soilChipMaterial);
chip.position.set(...position);
chip.scale.set(
0.6 + (index % 4) * 0.18,
0.35 + (index % 3) * 0.1,
0.65 + (index % 5) * 0.12
);
chip.rotation.set(index * 0.7, index * 0.43, index * 0.21);
chip.castShadow = true;
scene.add(chip);
});
// Low-poly seed shell, split into two separate hull models.
const seedBase = new THREE.Vector3(-1.12, 0.04, 0);
const shellMaterial = new THREE.MeshStandardMaterial({
color: 0x9a6334,
roughness: 0.78,
metalness: 0.02,
flatShading: true,
side: THREE.DoubleSide
});
const shellInnerMaterial = new THREE.MeshStandardMaterial({
color: 0x4a2b18,
roughness: 1,
flatShading: true,
side: THREE.BackSide
});
const leftShell = new THREE.Group();
const rightShell = new THREE.Group();
const leftGeometry = new THREE.SphereGeometry(
0.74, 10, 7, -Math.PI / 2, Math.PI
);
const rightGeometry = new THREE.SphereGeometry(
0.74, 10, 7, Math.PI / 2, Math.PI
);
function makeShell(geometry, group, innerOnly = false) {
const material = innerOnly ? shellInnerMaterial : shellMaterial;
const mesh = new THREE.Mesh(geometry, material);
mesh.scale.set(0.84, 1.12, 0.7);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
return mesh;
}
makeShell(leftGeometry, leftShell);
makeShell(rightGeometry, rightShell);
const leftInner = makeShell(leftGeometry, leftShell, true);
const rightInner = makeShell(rightGeometry, rightShell, true);
leftInner.scale.set(0.78, 1.055, 0.635);
rightInner.scale.set(0.78, 1.055, 0.635);
leftShell.position.copy(seedBase);
rightShell.position.copy(seedBase);
scene.add(leftShell, rightShell);
// Small polygon markings on the shell.
const shellMarkGeometry = new THREE.IcosahedronGeometry(0.035, 0);
const shellMarkMaterial = new THREE.MeshStandardMaterial({
color: 0x704021,
roughness: 1,
flatShading: true
});
const leftMarks = [
[-0.38, 0.25, 0.22], [-0.42, -0.22, 0.12],
[-0.25, 0.64, 0.05], [-0.18, -0.62, 0.02]
];
const rightMarks = [
[0.39, 0.3, 0.2], [0.44, -0.16, 0.12],
[0.25, 0.62, 0.04], [0.19, -0.62, 0.03]
];
leftMarks.forEach((position) => {
const mark = new THREE.Mesh(shellMarkGeometry, shellMarkMaterial);
mark.position.set(...position);
mark.scale.set(1.4, 0.7, 0.45);
leftShell.add(mark);
});
rightMarks.forEach((position) => {
const mark = new THREE.Mesh(shellMarkGeometry, shellMarkMaterial);
mark.position.set(...position);
mark.scale.set(1.4, 0.7, 0.45);
rightShell.add(mark);
});
// Symbolic reserve packets inside the seed.
const reserveGeometry = new THREE.IcosahedronGeometry(0.105, 0);
const reserveMaterial = new THREE.MeshStandardMaterial({
color: 0xe5a345,
emissive: 0x7d3c08,
emissiveIntensity: 0.42,
roughness: 0.62,
flatShading: true
});
const reservePieces = [];
const reserveOffsets = [
[-0.2, 0.25, 0.12], [0.17, 0.28, -0.08],
[-0.27, 0.02, -0.04], [0.28, 0.02, 0.1],
[0, 0.47, 0], [-0.1, -0.27, 0.08],
[0.12, -0.28, -0.05], [0, 0.08, 0.25],
[-0.05, 0.18, -0.24]
];
reserveOffsets.forEach((offset, index) => {
const piece = new THREE.Mesh(reserveGeometry, reserveMaterial);
piece.position.set(
seedBase.x + offset[0],
seedBase.y + offset[1],
seedBase.z + offset[2]
);
piece.rotation.set(index * 0.63, index * 0.37, index * 0.21);
piece.castShadow = true;
scene.add(piece);
reservePieces.push({
mesh: piece,
origin: piece.position.clone(),
phase: index * 0.18
});
});
// Tapered low-poly tube utility.
function createTaperedTube(
curve,
tubularSegments = 36,
radialSegments = 6,
startRadius = 0.09,
endRadius = 0.015
) {
const frames = curve.computeFrenetFrames(tubularSegments, false);
const positions = [];
const indices = [];
const uvs = [];
for (let i = 0; i <= tubularSegments; i++) {
const t = i / tubularSegments;
const point = curve.getPointAt(t);
const radius = THREE.MathUtils.lerp(startRadius, endRadius, t);
for (let j = 0; j <= radialSegments; j++) {
const angle = (j / radialSegments) * Math.PI * 2;
const normal = frames.normals[i];
const binormal = frames.binormals[i];
const vertex = new THREE.Vector3()
.copy(point)
.addScaledVector(normal, -Math.cos(angle) * radius)
.addScaledVector(binormal, Math.sin(angle) * radius);
positions.push(vertex.x, vertex.y, vertex.z);
uvs.push(j / radialSegments, t);
}
}
for (let i = 1; i <= tubularSegments; i++) {
for (let j = 1; j <= radialSegments; j++) {
const a = (radialSegments + 1) * (i - 1) + (j - 1);
const b = (radialSegments + 1) * i + (j - 1);
const c = (radialSegments + 1) * i + j;
const d = (radialSegments + 1) * (i - 1) + j;
indices.push(a, b, d);
indices.push(b, c, d);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setIndex(indices);
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2));
geometry.computeVertexNormals();
return geometry;
}
function setTubeProgress(mesh, progress) {
const indexCount = mesh.geometry.index.count;
const visibleIndices =
Math.floor((indexCount * THREE.MathUtils.clamp(progress, 0, 1)) / 6) * 6;
mesh.geometry.setDrawRange(0, visibleIndices);
}
// Primary root / radicle.
const rootCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.12, -0.34, 0),
new THREE.Vector3(-1.08, -0.78, 0.035),
new THREE.Vector3(-0.91, -1.18, -0.035),
new THREE.Vector3(-0.97, -1.58, 0.07),
new THREE.Vector3(-0.76, -1.98, -0.04),
new THREE.Vector3(-0.55, -2.39, 0.035)
]);
const rootMaterial = new THREE.MeshStandardMaterial({
color: 0xe7ddbb,
roughness: 0.92,
flatShading: true,
side: THREE.DoubleSide
});
const rootMesh = new THREE.Mesh(
createTaperedTube(rootCurve, 44, 6, 0.095, 0.016),
rootMaterial
);
rootMesh.castShadow = true;
scene.add(rootMesh);
// Fine lateral roots.
const rootBranches = [];
const branchDefinitions = [
{
curve: new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.03, -1.02, 0.02),
new THREE.Vector3(-1.35, -1.12, 0.08),
new THREE.Vector3(-1.65, -1.3, 0.03),
new THREE.Vector3(-1.78, -1.48, -0.02)
]),
start: 0.4
},
{
curve: new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.95, -1.51, 0.045),
new THREE.Vector3(-0.62, -1.64, 0.12),
new THREE.Vector3(-0.34, -1.72, 0.07),
new THREE.Vector3(-0.18, -1.91, 0.02)
]),
start: 0.53
},
{
curve: new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.83, -1.9, -0.01),
new THREE.Vector3(-1.05, -2.06, -0.11),
new THREE.Vector3(-1.28, -2.18, -0.16)
]),
start: 0.67
},
{
curve: new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.63, -2.31, 0.03),
new THREE.Vector3(-0.35, -2.39, 0.08),
new THREE.Vector3(-0.14, -2.57, 0.05)
]),
start: 0.84
}
];
branchDefinitions.forEach((definition) => {
const branch = new THREE.Mesh(
createTaperedTube(definition.curve, 18, 5, 0.043, 0.008),
rootMaterial
);
branch.castShadow = true;
scene.add(branch);
rootBranches.push({ mesh: branch, start: definition.start });
});
// Shoot / stem.
const stemCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.12, 0.34, 0),
new THREE.Vector3(-1.11, 0.74, 0),
new THREE.Vector3(-1.04, 1.14, 0.01),
new THREE.Vector3(-0.91, 1.56, 0.015),
new THREE.Vector3(-0.75, 1.93, 0)
]);
const stemMaterial = new THREE.MeshStandardMaterial({
color: 0x6f8e3d,
roughness: 0.86,
flatShading: true,
side: THREE.DoubleSide
});
const stemMesh = new THREE.Mesh(
createTaperedTube(stemCurve, 38, 7, 0.105, 0.037),
stemMaterial
);
stemMesh.castShadow = true;
scene.add(stemMesh);
// Faceted leaf mesh: three longitudinal vertices per station.
function createLeafGeometry() {
const stations = [
{ y: 0.00, width: 0.035, ridge: 0.005 },
{ y: 0.25, width: 0.27, ridge: 0.115 },
{ y: 0.59, width: 0.43, ridge: 0.175 },
{ y: 0.92, width: 0.29, ridge: 0.115 },
{ y: 1.22, width: 0.00, ridge: 0.005 }
];
const positions = [];
const indices = [];
stations.forEach((station) => {
positions.push(
-station.width, station.y, 0,
0, station.y, station.ridge,
station.width, station.y, 0
);
});
for (let i = 0; i < stations.length - 1; i++) {
const a = i * 3;
const b = a + 3;
indices.push(
a, a + 1, b + 1,
a, b + 1, b,
a + 1, a + 2, b + 2,
a + 1, b + 2, b + 1
);
}
const indexed = new THREE.BufferGeometry();
indexed.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
indexed.setIndex(indices);
const geometry = indexed.toNonIndexed();
indexed.dispose();
geometry.computeVertexNormals();
return geometry;
}
const leafGeometry = createLeafGeometry();
const leafMaterial = new THREE.MeshStandardMaterial({
color: 0x627b39,
emissive: 0x183e1d,
emissiveIntensity: 0,
roughness: 0.78,
flatShading: true,
side: THREE.DoubleSide
});
const veinMaterial = new THREE.LineBasicMaterial({
color: 0xa9cb72,
transparent: true,
opacity: 0.58
});
function createLeafModel(scale = 1) {
const group = new THREE.Group();
const blade = new THREE.Mesh(leafGeometry, leafMaterial);
blade.castShadow = true;
blade.receiveShadow = true;
group.add(blade);
const midribCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(0, 0.01, 0.018),
new THREE.Vector3(0, 0.25, 0.13),
new THREE.Vector3(0, 0.59, 0.19),
new THREE.Vector3(0, 0.92, 0.13),
new THREE.Vector3(0, 1.19, 0.018)
]);
const midrib = new THREE.Mesh(
createTaperedTube(midribCurve, 18, 5, 0.017, 0.005),
new THREE.MeshStandardMaterial({
color: 0xb5cf73,
roughness: 0.85,
flatShading: true
})
);
group.add(midrib);
const veinVertices = [];
const veinStations = [
{ y: 0.25, width: 0.27, ridge: 0.13 },
{ y: 0.59, width: 0.43, ridge: 0.19 },
{ y: 0.92, width: 0.29, ridge: 0.13 }
];
veinStations.forEach((station) => {
veinVertices.push(
0, station.y, station.ridge + 0.008,
-station.width * 0.72, station.y + 0.06, 0.012,
0, station.y, station.ridge + 0.008,
station.width * 0.72, station.y + 0.06, 0.012
);
});
const veinGeometry = new THREE.BufferGeometry();
veinGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(veinVertices, 3)
);
const veins = new THREE.LineSegments(veinGeometry, veinMaterial);
group.add(veins);
group.scale.setScalar(scale);
return group;
}
const rightLeaf = createLeafModel(1.02);
rightLeaf.position.set(-0.91, 1.5, 0);
scene.add(rightLeaf);
const leftLeaf = createLeafModel(0.82);
leftLeaf.position.set(-0.76, 1.9, 0.015);
scene.add(leftLeaf);
// Small apical bud.
const bud = new THREE.Mesh(
new THREE.ConeGeometry(0.09, 0.28, 6),
new THREE.MeshStandardMaterial({
color: 0x83a94d,
roughness: 0.86,
flatShading: true
})
);
bud.position.set(-0.74, 2.02, 0);
bud.castShadow = true;
scene.add(bud);
// Photosynthesis indicator surrounding the developing leaves.
const photoHalo = new THREE.Mesh(
new THREE.RingGeometry(0.64, 0.675, 40),
new THREE.MeshBasicMaterial({
color: 0x9cf58d,
transparent: true,
opacity: 0,
side: THREE.DoubleSide,
depthWrite: false,
depthTest: false,
blending: THREE.AdditiveBlending
})
);
photoHalo.position.set(-0.65, 1.65, 0.15);
photoHalo.renderOrder = 10;
scene.add(photoHalo);
const moteCount = 28;
const motePositions = new Float32Array(moteCount * 3);
const moteSeeds = [];
for (let i = 0; i < moteCount; i++) {
const angle = i * 2.399963;
const radius = 0.28 + (i % 5) * 0.075;
moteSeeds.push({
angle,
radius,
phase: i * 0.71,
height: ((i % 7) - 3) * 0.075
});
}
const moteGeometry = new THREE.BufferGeometry();
moteGeometry.setAttribute(
"position",
new THREE.BufferAttribute(motePositions, 3)
);
const moteMaterial = new THREE.PointsMaterial({
color: 0xb8ff9a,
size: 0.047,
transparent: true,
opacity: 0,
depthWrite: false,
blending: THREE.AdditiveBlending,
sizeAttenuation: true
});
const motes = new THREE.Points(moteGeometry, moteMaterial);
motes.renderOrder = 9;
scene.add(motes);
// Timeline UI
const reserveCells = document.querySelector("#reserveCells");
for (let i = 0; i < 10; i++) {
const cell = document.createElement("span");
reserveCells.appendChild(cell);
}
const reserveValue = document.querySelector("#reserveValue");
const photoValue = document.querySelector("#photoValue");
const photoFill = document.querySelector("#photoFill");
const sunRow = document.querySelector("#sunRow");
const scrubber = document.querySelector("#scrubber");
const playButton = document.querySelector("#playButton");
const restartButton = document.querySelector("#restartButton");
const resetCameraButton = document.querySelector("#resetCamera");
const timeReadout = document.querySelector("#timeReadout");
const phaseNumber = document.querySelector("#phaseNumber");
const phaseStatus = document.querySelector("#phaseStatus");
const phaseTitle = document.querySelector("#phaseTitle");
const phaseDescription = document.querySelector("#phaseDescription");
const phaseSteps = [...document.querySelectorAll(".phase-step")];
const seedLabel = document.querySelector("#seedLabel");
const rootLabel = document.querySelector("#rootLabel");
const leafLabel = document.querySelector("#leafLabel");
const duration = 18;
let progress = 0;
let playing = !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
let previousTime = performance.now();
let visualTime = 0;
let lastPhase = -1;
const phases = [
{
end: 0.13,
number: "01",
status: "Dormancy",
title: "Stored for a future shoot",
description:
"The intact seed holds its embryo and nutrient reserves in reserve."
},
{
end: 0.31,
number: "02",
status: "Imbibition",
title: "The seed coat begins to split",
description:
"Water uptake revives the embryo, and pressure opens the protective hull."
},
{
end: 0.48,
number: "03",
status: "Radicle",
title: "The first root probes downward",
description:
"The radicle emerges, anchoring the plant and searching the soil for water."
},
{
end: 0.68,
number: "04",
status: "Reserve transfer",
title: "Stored energy becomes new growth",
description:
"Amber reserve packets diminish as their stored energy lifts the shoot."
},
{
end: 0.84,
number: "05",
status: "Cotyledons",
title: "Folded leaves reach toward light",
description:
"The first leaves expand from their folded state, exposing broad new surfaces."
},
{
end: 1.01,
number: "06",
status: "Photosynthesis",
title: "Sunlight replaces the seed's reserves",
description:
"The leaves activate photosynthesis, converting light into the plant's next reserves."
}
];
function smooth(min, max, value) {
return THREE.MathUtils.smoothstep(value, min, max);
}
function updatePlayButton() {
playButton.textContent = playing ? "Pause" : progress >= 1 ? "Replay" : "Play";
playButton.setAttribute(
"aria-label",
playing ? "Pause animation" : "Play animation"
);
}
function getPhaseIndex() {
for (let i = 0; i < phases.length; i++) {
if (progress < phases[i].end) return i;
}
return phases.length - 1;
}
function updatePhaseUI() {
const index = getPhaseIndex();
if (index === lastPhase) return;
lastPhase = index;
const phase = phases[index];
phaseNumber.textContent = phase.number;
phaseStatus.textContent = phase.status;
phaseTitle.textContent = phase.title;
phaseDescription.textContent = phase.description;
phaseSteps.forEach((step, stepIndex) => {
step.classList.toggle("active", stepIndex <= Math.min(index, 4));
});
}
function applyProgress(p) {
const opening = smooth(0.12, 0.31, p);
const depletion = smooth(0.12, 0.59, p);
const reserve = 1 - depletion;
const rootProgress = smooth(0.24, 0.68, p);
const stemProgress = smooth(0.34, 0.68, p);
const leafEmergence = smooth(0.61, 0.73, p);
const leafUnfold = smooth(0.66, 0.88, p);
const photosynthesis = smooth(0.72, 0.93, p);
// Seed hull separation.
leftShell.position.set(
seedBase.x - opening * 0.15,
seedBase.y + opening * 0.025,
seedBase.z
);
rightShell.position.set(
seedBase.x + opening * 0.15,
seedBase.y + opening * 0.025,
seedBase.z
);
leftShell.rotation.z = opening * 0.22;
rightShell.rotation.z = -opening * 0.22;
leftShell.rotation.y = -opening * 0.08;
rightShell.rotation.y = opening * 0.08;
// Consume symbolic reserve packets.
reservePieces.forEach(({ mesh, origin, phase }) => {
const shrink = 1 - smooth(phase, phase + 0.18, depletion);
mesh.scale.setScalar(Math.max(0.001, shrink));
const outward = mesh.position.clone().sub(origin);
mesh.position.copy(origin).addScaledVector(outward, (1 - shrink) * 0.55);
});
reserveLight.intensity = 0.35 + reserve * 1.1;
// Root and stem growth.
setTubeProgress(rootMesh, rootProgress);
rootBranches.forEach(({ mesh, start }) => {
const branchProgress = smooth(start, Math.min(1, start + 0.28), p);
setTubeProgress(mesh, branchProgress);
});
setTubeProgress(stemMesh, stemProgress);
// Leaves emerge, then rotate from folded to open.
const rightAngle = THREE.MathUtils.lerp(-0.17, -1.04, leafUnfold);
const leftAngle = THREE.MathUtils.lerp(0.17, 1.08, leafUnfold);
const sway = Math.sin(visualTime * 0.75) * 0.015 * photosynthesis;
rightLeaf.rotation.set(0.06, -0.06, rightAngle + sway);
leftLeaf.rotation.set(-0.03, 0.1, leftAngle - sway);
const visibleLeafScale = 0.025 + leafEmergence * 0.975;
rightLeaf.scale.setScalar(visibleLeafScale * 1.02);
leftLeaf.scale.setScalar(visibleLeafScale * 0.82);
bud.scale.setScalar(0.025 + stemProgress * 0.975);
bud.rotation.z = Math.sin(visualTime * 0.8) * 0.025 * photosynthesis;
// Leaves become visibly photosynthetically active only after reserves
// have fallen to zero.
leafMaterial.color.lerpColors(
new THREE.Color(0x627b39),
new THREE.Color(0x4fb85d),
photosynthesis
);
leafMaterial.emissive.setHex(0x286f36);
leafMaterial.emissiveIntensity = photosynthesis * 0.32;
veinMaterial.opacity = 0.42 + photosynthesis * 0.42;
stemMaterial.color.lerpColors(
new THREE.Color(0x718641),
new THREE.Color(0x4b9b51),
photosynthesis
);
photoHalo.material.opacity = photosynthesis * 0.32;
photoHalo.scale.setScalar(0.88 + photosynthesis * 0.18);
moteMaterial.opacity = photosynthesis * 0.84;
// UI meters.
const reservePercent = Math.round(reserve * 100);
const photoPercent = Math.round(photosynthesis * 100);
reserveValue.textContent = `${reservePercent}%`;
photoValue.textContent = `${photoPercent}%`;
photoFill.style.width = `${photoPercent}%`;
sunRow.classList.toggle("active", photosynthesis > 0.02);
[...reserveCells.children].forEach((cell, index) => {
const threshold = index / reserveCells.children.length;
cell.style.opacity = reserve > threshold ? "1" : "0.12";
cell.style.transform = reserve > threshold ? "scaleY(1)" : "scaleY(0.35)";
});
scrubber.value = Math.round(p * 1000);
document.documentElement.style.setProperty(
"--progress",
`${Math.round(p * 100)}%`
);
const elapsed = Math.round(p * duration);
timeReadout.textContent = `00:${String(elapsed).padStart(2, "0")} / 00:18`;
updatePhaseUI();
}
function updateMotes() {
const positionAttribute = moteGeometry.getAttribute("position");
moteSeeds.forEach((seed, index) => {
const angle = seed.angle + visualTime * 0.23;
const radius = seed.radius * (1 + Math.sin(visualTime * 0.7 + seed.phase) * 0.08);
positionAttribute.setXYZ(
index,
-0.65 + Math.cos(angle) * radius,
1.65 + Math.sin(angle) * radius * 0.62 + seed.height,
0.08 + Math.sin(seed.phase) * 0.18
);
});
positionAttribute.needsUpdate = true;
}
const projected = new THREE.Vector3();
function positionLabel(element, worldPosition, opacity) {
projected.copy(worldPosition).project(camera);
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`;
element.style.opacity = String(opacity);
}
function updateLabels() {
positionLabel(
seedLabel,
new THREE.Vector3(-1.12, 0.18, 0.55),
0.9 * (1 - smooth(0.42, 0.62, progress))
);
positionLabel(
rootLabel,
new THREE.Vector3(-0.92, -1.57, 0.22),
0.9 * smooth(0.3, 0.42, progress) * (1 - smooth(0.82, 1, progress))
);
positionLabel(
leafLabel,
new THREE.Vector3(-0.25, 1.73, 0.3),
0.9 * smooth(0.7, 0.83, progress)
);
}
function resetCamera() {
cameraYaw = 0.58;
cameraPitch = 0.27;
cameraDistance = window.innerWidth < 820 ? 10.2 : 8.4;
updateCamera();
}
// Direct camera controls, implemented without examples or addons.
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - lastPointerX;
const deltaY = event.clientY - lastPointerY;
cameraYaw -= deltaX * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + deltaY * 0.005,
-0.12,
0.95
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
updateCamera();
});
function stopDragging(event) {
dragging = false;
canvas.classList.remove("dragging");
if (event && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraDistance = THREE.MathUtils.clamp(
cameraDistance + event.deltaY * 0.006,
5.2,
14
);
updateCamera();
},
{ passive: false }
);
resetCameraButton.addEventListener("click", resetCamera);
playButton.addEventListener("click", () => {
if (progress >= 1) {
progress = 0;
playing = true;
} else {
playing = !playing;
}
updatePlayButton();
});
restartButton.addEventListener("click", () => {
progress = 0;
playing = true;
updatePlayButton();
});
scrubber.addEventListener("input", (event) => {
progress = Number(event.target.value) / 1000;
playing = false;
applyProgress(progress);
updatePlayButton();
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space" && event.target === document.body) {
event.preventDefault();
playButton.click();
}
if (event.key.toLowerCase() === "r") {
restartButton.click();
}
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
visualTime += delta;
if (playing) {
progress = Math.min(1, progress + delta / duration);
if (progress >= 1) {
playing = false;
updatePlayButton();
}
}
applyProgress(progress);
updateMotes();
photoHalo.quaternion.copy(camera.quaternion);
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
applyProgress(progress);
updatePlayButton();
requestAnimationFrame(animate);
</script>
</body>
</html>
```