Prompt specification
Build or customize the Three.js 3D scene "Seed observation windowsill" 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: Seed observation windowsill
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/seed-observation-windowsill-x0083
Scene Description Prompt:
Please make a voxel Three.js scene in one standalone HTML file using cdnjs. Compose a windowsill with an avocado seed held above water, dated sketches, and rooted example; a time slider reveals labeled simplified growth stages rather than instant growth.
Working Three.js Starter (seed-observation-windowsill-x0083):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Avocado Windowsill — A Growth Study</title>
<style>
:root {
--ink: #27352c;
--muted: #667268;
--paper: #f4eddb;
--green: #58784f;
--green-dark: #36533c;
--line: rgba(39, 53, 44, 0.18);
--glass: rgba(250, 247, 235, 0.82);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d9dfd3;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#app,
#app canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
#app canvas {
display: block;
touch-action: none;
outline: none;
cursor: grab;
}
#app canvas.dragging {
cursor: grabbing;
}
.interface {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.masthead {
position: absolute;
top: 28px;
left: 32px;
max-width: 420px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.eyebrow {
margin: 0 0 8px;
color: var(--green-dark);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 54px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 360px;
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.stage-panel {
position: absolute;
top: 178px;
left: 32px;
width: min(330px, calc(100vw - 64px));
padding: 17px 18px 16px;
border: 1px solid rgba(255, 255, 255, 0.58);
border-radius: 5px;
background: rgba(247, 242, 226, 0.76);
box-shadow: 0 16px 45px rgba(48, 59, 47, 0.12);
backdrop-filter: blur(12px);
}
.stage-topline {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.stage-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #79965e;
box-shadow: 0 0 0 4px rgba(121, 150, 94, 0.14);
}
#stage-title {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 25px;
font-weight: 500;
letter-spacing: -0.02em;
}
#stage-copy {
min-height: 42px;
margin: 8px 0 13px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.progress-track {
height: 3px;
overflow: hidden;
border-radius: 99px;
background: rgba(54, 83, 60, 0.12);
}
#progress-fill {
width: 0;
height: 100%;
background: var(--green);
transition: width 80ms linear;
}
.utility {
position: absolute;
top: 28px;
right: 30px;
display: flex;
align-items: center;
gap: 10px;
pointer-events: auto;
}
.hint {
padding: 9px 11px;
border: 1px solid rgba(255, 255, 255, 0.48);
border-radius: 4px;
background: rgba(247, 242, 226, 0.62);
color: var(--muted);
font-size: 10px;
letter-spacing: 0.04em;
backdrop-filter: blur(8px);
}
.icon-button {
height: 36px;
padding: 0 12px;
border: 1px solid rgba(54, 83, 60, 0.2);
border-radius: 4px;
background: rgba(247, 242, 226, 0.82);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.icon-button:hover {
background: #f8f2e1;
}
.timeline {
position: absolute;
right: 30px;
bottom: 27px;
left: 30px;
max-width: 940px;
margin: 0 auto;
padding: 17px 22px 16px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 7px;
background: var(--glass);
box-shadow: 0 18px 60px rgba(42, 53, 42, 0.18);
backdrop-filter: blur(16px);
pointer-events: auto;
}
.timeline-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
margin-bottom: 14px;
}
.timeline-label {
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.timeline-note {
margin-left: 12px;
color: var(--muted);
font-size: 10px;
font-weight: 500;
letter-spacing: 0.02em;
text-transform: none;
}
#day-readout {
color: var(--green-dark);
font-family: Georgia, "Times New Roman", serif;
font-size: 18px;
white-space: nowrap;
}
#time-slider {
width: 100%;
height: 22px;
margin: 0;
appearance: none;
background: transparent;
cursor: ew-resize;
}
#time-slider::-webkit-slider-runnable-track {
height: 4px;
border-radius: 99px;
background:
linear-gradient(
to right,
var(--green) 0 var(--range-progress, 0%),
rgba(54, 83, 60, 0.16) var(--range-progress, 0%) 100%
);
}
#time-slider::-moz-range-track {
height: 4px;
border-radius: 99px;
background: rgba(54, 83, 60, 0.16);
}
#time-slider::-moz-range-progress {
height: 4px;
border-radius: 99px;
background: var(--green);
}
#time-slider::-webkit-slider-thumb {
width: 18px;
height: 18px;
margin-top: -7px;
appearance: none;
border: 3px solid #f8f2e1;
border-radius: 50%;
background: var(--green-dark);
box-shadow: 0 2px 8px rgba(39, 53, 44, 0.25);
}
#time-slider::-moz-range-thumb {
width: 13px;
height: 13px;
border: 3px solid #f8f2e1;
border-radius: 50%;
background: var(--green-dark);
box-shadow: 0 2px 8px rgba(39, 53, 44, 0.25);
}
.stage-markers {
display: grid;
grid-template-columns: repeat(5, 1fr);
margin-top: 2px;
}
.stage-marker {
padding: 5px 0;
border: 0;
background: transparent;
color: #788078;
cursor: pointer;
font-size: 10px;
text-align: left;
transition: color 160ms ease;
}
.stage-marker:last-child {
text-align: right;
}
.stage-marker:hover,
.stage-marker.active {
color: var(--green-dark);
font-weight: 800;
}
.stage-marker span {
display: block;
margin-top: 2px;
color: #92978f;
font-size: 9px;
font-weight: 500;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #e8e7dc;
color: var(--green-dark);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.masthead {
top: 20px;
left: 20px;
}
.subtitle {
display: none;
}
.stage-panel {
top: 116px;
left: 20px;
width: 260px;
padding: 13px 14px;
}
#stage-title {
font-size: 21px;
}
#stage-copy {
min-height: 0;
margin-bottom: 9px;
}
.utility {
top: 20px;
right: 18px;
}
.hint {
display: none;
}
.timeline {
right: 14px;
bottom: 14px;
left: 14px;
padding: 14px 14px 12px;
}
.timeline-note {
display: none;
}
.stage-marker {
font-size: 9px;
}
.stage-marker span {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="interface">
<header class="masthead">
<p class="eyebrow">Botanical observation no. 07</p>
<h1>Avocado<br />Windowsill</h1>
<p class="subtitle">
A seed waits above the water. Drag through the dated observations to
reveal each simplified stage of root and shoot growth.
</p>
</header>
<section class="stage-panel" aria-live="polite">
<div class="stage-topline">
<span id="stage-count">Observation 01 / 05</span>
<span class="stage-dot"></span>
</div>
<h2 id="stage-title">Soaked seed</h2>
<p id="stage-copy">
The intact seed is suspended above the water, waiting for the first
sign of a root.
</p>
<div class="progress-track">
<div id="progress-fill"></div>
</div>
</section>
<div class="utility">
<span class="hint">Drag to orbit · scroll to zoom</span>
<button id="reset-camera" class="icon-button" type="button">Reset view</button>
</div>
<section class="timeline" aria-label="Growth timeline">
<div class="timeline-head">
<div class="timeline-label">
Growth timeline
<span class="timeline-note">Simplified stages · illustrative dates</span>
</div>
<div id="day-readout">Day 0</div>
</div>
<input
id="time-slider"
type="range"
min="0"
max="4"
step="0.01"
value="0"
aria-label="Avocado growth stage"
/>
<div class="stage-markers">
<button class="stage-marker active" type="button" data-stage="0">
DAY 0<span>Soaked seed</span>
</button>
<button class="stage-marker" type="button" data-stage="1">
DAY 7<span>Root wakes</span>
</button>
<button class="stage-marker" type="button" data-stage="2">
DAY 21<span>Waterline</span>
</button>
<button class="stage-marker" type="button" data-stage="3">
DAY 45<span>First leaves</span>
</button>
<button class="stage-marker" type="button" data-stage="4">
DAY 75<span>Sapling</span>
</button>
</div>
</section>
</div>
<div id="loading">Preparing the windowsill…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const app = document.querySelector("#app");
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d9dfd3");
scene.fog = new THREE.Fog("#d9dfd3", 18, 31);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
app.appendChild(renderer.domElement);
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive 3D avocado windowsill. Drag to orbit and scroll to zoom."
);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraTarget = new THREE.Vector3(0, 2.35, 0);
const cameraState = {
yaw: 0.28,
pitch: 0.26,
radius: 14.2
};
function updateCamera() {
const { yaw, pitch, radius } = cameraState;
camera.position.set(
cameraTarget.x + Math.sin(yaw) * Math.cos(pitch) * radius,
cameraTarget.y + Math.sin(pitch) * radius,
cameraTarget.z + Math.cos(yaw) * Math.cos(pitch) * radius
);
camera.lookAt(cameraTarget);
}
updateCamera();
// -------------------------------------------------------------------------
// Lighting and materials
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight("#eef7ed", "#7c725c", 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff2c8", 4.2);
sun.position.set(-5, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -4;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0004;
scene.add(sun);
const windowLight = new THREE.PointLight("#b9dcff", 14, 12, 2);
windowLight.position.set(-2.8, 5.2, -0.8);
scene.add(windowLight);
const fillLight = new THREE.DirectionalLight("#d8e8cf", 1.3);
fillLight.position.set(6, 4, 8);
scene.add(fillLight);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...options
});
const M = {
wall: material("#e9e5d8"),
wallSide: material("#dedbcf"),
frame: material("#f2eee0"),
sky: material("#a9cfd8", {
emissive: "#9ec6d1",
emissiveIntensity: 0.25
}),
wood: material("#b99366"),
woodLight: material("#c5a479"),
woodDark: material("#95734f"),
paper: material("#eee3c8"),
redPin: material("#a95745"),
greenPin: material("#6f855b"),
bluePin: material("#527d91"),
seed: material("#704b32"),
seedLight: material("#896143"),
seedDark: material("#503726"),
crack: material("#30251c"),
root: material("#d8c69b"),
rootDark: material("#baa577"),
stem: material("#627c4d"),
stemLight: material("#78935a"),
leaf: material("#64884e"),
leafLight: material("#82a85e"),
leafDark: material("#42643d"),
water: material("#8cc7c7", {
transparent: true,
opacity: 0.48,
roughness: 0.18,
depthWrite: false
}),
glass: material("#d9eef0", {
transparent: true,
opacity: 0.17,
roughness: 0.08,
metalness: 0.08,
depthWrite: false,
side: THREE.DoubleSide
})
};
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function box(
width,
height,
depth,
mat,
x = 0,
y = 0,
z = 0,
parent = scene,
castsShadow = true
) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = castsShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const upVector = new THREE.Vector3(0, 1, 0);
function barBetween(a, b, width, mat, parent = scene) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const mesh = box(
width,
length,
width,
mat,
midpoint.x,
midpoint.y,
midpoint.z,
parent
);
mesh.quaternion.setFromUnitVectors(
upVector,
direction.clone().normalize()
);
return mesh;
}
function cylinder(
radiusTop,
radiusBottom,
height,
mat,
x,
y,
z,
segments = 12,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = mat !== M.glass && mat !== M.water;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function horizontalRing(radius, tube, y, x, z, parent = scene) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(radius, tube, 4, 12),
M.glass
);
ring.rotation.x = Math.PI / 2;
ring.position.set(x, y, z);
ring.renderOrder = 4;
parent.add(ring);
return ring;
}
// -------------------------------------------------------------------------
// Voxel room, window, sill, sky, and distant block city
// -------------------------------------------------------------------------
// Wall built around a large window opening.
box(1.7, 10, 0.35, M.wallSide, -6.15, 4.7, -1.9);
box(4.3, 10, 0.35, M.wall, 4.85, 4.7, -1.9);
box(8, 1.2, 0.35, M.wall, -1.3, 0.4, -1.9);
box(8, 2.6, 0.35, M.wall, -1.3, 8.7, -1.9);
// Sky behind the opening.
box(8, 6.4, 0.12, M.sky, -1.3, 4.2, -2.15, scene, false);
// Voxel sun.
const sunMat = material("#f4d36f", {
emissive: "#e9b64d",
emissiveIntensity: 0.35
});
box(0.48, 0.48, 0.08, sunMat, -3.65, 5.8, -2.02, scene, false);
box(0.78, 0.16, 0.08, sunMat, -3.65, 5.8, -2.02, scene, false);
box(0.16, 0.78, 0.08, sunMat, -3.65, 5.8, -2.02, scene, false);
// Small block clouds.
const cloudMat = material("#e8f0e6");
[
[-4.2, 6.55, -2.01, 0.7],
[-3.7, 6.55, -2.01, 0.42],
[-3.2, 6.55, -2.01, 0.58],
[0.45, 5.9, -2.01, 0.62],
[0.95, 5.9, -2.01, 0.38]
].forEach(([x, y, z, w]) => {
box(w, 0.18, 0.08, cloudMat, x, y, z, scene, false);
});
// Distant voxel buildings.
const buildingColors = [
material("#9cb6b4"),
material("#a6b6a9"),
material("#b7aaa0"),
material("#879fa2")
];
[
[-4.8, 1.45, 1.5],
[-3.65, 1.8, 1.1],
[-2.65, 1.3, 1.75],
[-1.35, 1.95, 1.25],
[-0.15, 1.5, 1.45],
[1.15, 1.7, 1.1],
[2.1, 1.35, 1.55]
].forEach(([x, y, w], index) => {
const height = index % 2 ? 1.7 : 2.2;
box(w, height, 0.1, buildingColors[index % 4], x, y, -2.02, scene, false);
box(w * 0.7, 0.12, 0.12, M.frame, x, y + height * 0.2, -1.95, scene, false);
});
// Window frame and mullions.
box(0.22, 6.65, 0.22, M.frame, -5.3, 4.2, -1.55);
box(0.22, 6.65, 0.22, M.frame, 2.7, 4.2, -1.55);
box(8.22, 0.22, 0.22, M.frame, -1.3, 1.0, -1.55);
box(8.22, 0.22, 0.22, M.frame, -1.3, 7.4, -1.55);
box(0.14, 6.4, 0.17, M.frame, -1.3, 4.2, -1.53);
box(8, 0.14, 0.17, M.frame, -1.3, 4.15, -1.53);
// Sill and trim.
box(14, 0.5, 3.2, M.wood, 0, 0.05, 0.1);
box(14, 0.12, 0.15, M.woodDark, 0, -0.08, 1.73);
box(14, 0.12, 0.15, M.woodLight, 0, 0.3, 1.72);
// Block-like grain along the sill.
for (let i = 0; i < 14; i++) {
const x = -6.3 + i;
box(
0.75 + (i % 3) * 0.12,
0.025,
0.025,
M.woodDark,
x,
0.31,
0.82 + (i % 2) * 0.15
);
}
// -------------------------------------------------------------------------
// Canvas textures for dated sketches and labels
// -------------------------------------------------------------------------
function pixelLine(ctx, x1, y1, x2, y2, color, width = 5) {
const steps = Math.max(
Math.abs(x2 - x1),
Math.abs(y2 - y1)
);
for (let i = 0; i <= steps; i++) {
const t = steps === 0 ? 0 : i / steps;
const x = Math.round(x1 + (x2 - x1) * t);
const y = Math.round(y1 + (y2 - y1) * t);
ctx.fillStyle = color;
ctx.fillRect(
x - Math.floor(width / 2),
y - Math.floor(width / 2),
width,
width
);
}
}
function sketchTexture(date, stage) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 320;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#f2e6c9";
ctx.fillRect(0, 0, 256, 320);
ctx.strokeStyle = "rgba(96, 83, 58, 0.14)";
ctx.lineWidth = 1;
for (let x = 16; x < 256; x += 24) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, 320);
ctx.stroke();
}
for (let y = 24; y < 320; y += 24) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(256, y);
ctx.stroke();
}
ctx.fillStyle = "#314033";
ctx.font = "700 23px monospace";
ctx.fillText(date, 18, 35);
ctx.fillStyle = "#87765a";
ctx.font = "15px monospace";
ctx.fillText("WINDOWSILL / ROOT STUDY", 18, 59);
// Water line.
ctx.fillStyle = "#b2ceca";
ctx.fillRect(18, 237, 220, 5);
// Blocky seed.
ctx.fillStyle = "#765039";
ctx.fillRect(107, 126, 42, 54);
ctx.fillRect(115, 116, 27, 12);
ctx.fillRect(116, 178, 25, 12);
ctx.fillStyle = "#946b48";
ctx.fillRect(116, 135, 12, 30);
if (stage >= 1) {
pixelLine(ctx, 128, 188, 125, 222, "#d5bf91", 6);
if (stage >= 2) {
pixelLine(ctx, 125, 222, 101, 248, "#d5bf91", 5);
pixelLine(ctx, 125, 222, 153, 250, "#d5bf91", 5);
}
}
if (stage >= 3) {
pixelLine(ctx, 128, 126, 130, 76, "#627c4d", 7);
ctx.fillStyle = "#719356";
ctx.fillRect(99, 77, 34, 15);
ctx.fillRect(91, 86, 19, 12);
ctx.fillRect(133, 98, 31, 14);
ctx.fillRect(154, 103, 17, 10);
}
ctx.fillStyle = "#87765a";
ctx.font = "13px monospace";
ctx.fillText("OBSERVED BY HAND", 18, 294);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
return texture;
}
function labelTexture(title, subtitle, background = "#eee3c8") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 160;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, 640, 160);
ctx.strokeStyle = "rgba(47, 65, 51, 0.28)";
ctx.lineWidth = 5;
ctx.strokeRect(8, 8, 624, 144);
ctx.fillStyle = "#304335";
ctx.font = "700 39px monospace";
ctx.fillText(title, 28, 69);
ctx.fillStyle = "#6e786c";
ctx.font = "22px monospace";
ctx.fillText(subtitle, 29, 113);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
return texture;
}
// -------------------------------------------------------------------------
// Dated sketch cards pinned to the wall
// -------------------------------------------------------------------------
const sketches = [
{ date: "08 FEB", stage: 0, x: 3.25, y: 5.05, rotation: -0.055 },
{ date: "02 MAR", stage: 2, x: 4.6, y: 4.82, rotation: 0.045 },
{ date: "19 APR", stage: 3, x: 5.95, y: 5.03, rotation: -0.035 }
];
sketches.forEach((item, index) => {
const group = new THREE.Group();
group.position.set(item.x, item.y, -1.66);
group.rotation.z = item.rotation;
scene.add(group);
box(
1.22,
1.52,
0.07,
M.paper,
0,
0,
0,
group
);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(1.18, 1.48),
new THREE.MeshBasicMaterial({
map: sketchTexture(item.date, item.stage),
toneMapped: false
})
);
face.position.z = 0.038;
group.add(face);
box(
0.13,
0.13,
0.11,
[M.redPin, M.greenPin, M.bluePin][index],
0,
0.7,
0.07,
group
);
});
// -------------------------------------------------------------------------
// Main suspended avocado seed and jar
// -------------------------------------------------------------------------
const mainX = -0.55;
const mainZ = 0.25;
// Faceted transparent jar.
const mainGlass = cylinder(
1.02,
1.02,
2.8,
M.glass,
mainX,
1.72,
mainZ,
12
);
mainGlass.renderOrder = 4;
cylinder(
0.96,
0.96,
0.055,
M.glass,
mainX,
0.355,
mainZ,
12
).renderOrder = 4;
horizontalRing(1.04, 0.055, 3.12, mainX, mainZ);
// Water, with a clear air gap below the seed.
const mainWater = cylinder(
0.91,
0.91,
0.9,
M.water,
mainX,
0.82,
mainZ,
12
);
mainWater.renderOrder = 2;
cylinder(
0.91,
0.91,
0.025,
material("#b9ded8", {
transparent: true,
opacity: 0.62,
depthWrite: false
}),
mainX,
1.275,
mainZ,
12
).renderOrder = 3;
// Voxel seed.
const seedGroup = new THREE.Group();
seedGroup.position.set(mainX, 2.42, mainZ);
scene.add(seedGroup);
box(0.53, 0.68, 0.5, M.seed, 0, 0, 0, seedGroup);
box(0.42, 0.23, 0.4, M.seedLight, 0, 0.39, -0.01, seedGroup);
box(0.38, 0.2, 0.37, M.seedDark, 0, -0.39, 0, seedGroup);
box(0.18, 0.53, 0.16, M.seedLight, -0.3, 0.02, 0.13, seedGroup);
box(0.17, 0.44, 0.15, M.seedDark, 0.3, -0.03, 0.09, seedGroup);
box(0.17, 0.28, 0.13, M.seedLight, 0.13, 0.25, 0.27, seedGroup);
// Seed split, revealed late in the first observation.
const crackGroup = new THREE.Group();
crackGroup.position.set(mainX, 2.49, mainZ + 0.265);
scene.add(crackGroup);
box(0.045, 0.24, 0.025, M.crack, 0, 0.03, 0, crackGroup);
box(0.14, 0.04, 0.025, M.crack, 0.05, 0.12, 0, crackGroup);
box(0.11, 0.035, 0.025, M.crack, -0.045, -0.06, 0, crackGroup);
box(0.10, 0.03, 0.025, M.crack, 0.05, -0.15, 0, crackGroup);
// Two cords suspend the seed from the rim.
barBetween(
[mainX - 0.72, 3.14, mainZ - 0.16],
[mainX - 0.1, 2.76, mainZ + 0.14],
0.035,
M.woodLight
);
barBetween(
[mainX + 0.72, 3.14, mainZ - 0.16],
[mainX + 0.16, 2.76, mainZ + 0.14],
0.035,
M.woodLight
);
barBetween(
[mainX - 0.25, 2.7, mainZ + 0.14],
[mainX + 0.25, 2.7, mainZ + 0.14],
0.04,
M.woodLight
);
// -------------------------------------------------------------------------
// Dynamic root and shoot construction
// -------------------------------------------------------------------------
const dynamicItems = [];
function registerDynamic(object, birth, mode = "bar") {
const item = {
object,
birth,
mode,
baseScale: object.scale.clone()
};
object.visible = false;
dynamicItems.push(item);
return item;
}
const rootGroup = new THREE.Group();
rootGroup.position.set(mainX, 1.99, mainZ);
scene.add(rootGroup);
const mainRootPoints = [
[0, 0, 0],
[0.01, -0.24, 0.01],
[-0.08, -0.48, 0.025],
[0.035, -0.72, 0.005],
[-0.045, -0.98, 0.04],
[0.08, -1.22, 0.02],
[-0.015, -1.47, 0],
[0.04, -1.68, -0.025]
];
const rootBirths = [
1.0,
1.18,
1.38,
1.58,
1.82,
2.18,
2.62,
3.08
];
for (let i = 0; i < mainRootPoints.length - 1; i++) {
const segment = barBetween(
mainRootPoints[i],
mainRootPoints[i + 1],
0.105 - i * 0.006,
i % 2 ? M.root : M.rootDark,
rootGroup
);
registerDynamic(segment, rootBirths[i]);
}
const rootBranches = [
{
points: [
[0.035, -0.72, 0.005],
[0.24, -0.84, 0.05],
[0.36, -1.03, 0.08]
],
birth: 2.3
},
{
points: [
[-0.045, -0.98, 0.04],
[-0.28, -1.12, 0.01],
[-0.42, -1.31, -0.02]
],
birth: 2.58
},
{
points: [
[0.08, -1.22, 0.02],
[0.31, -1.34, 0.1],
[0.46, -1.47, 0.12]
],
birth: 2.95
},
{
points: [
[-0.015, -1.47, 0],
[-0.21, -1.57, -0.08],
[-0.3, -1.69, -0.12]
],
birth: 3.35
}
];
rootBranches.forEach((branch, index) => {
for (let i = 0; i < branch.points.length - 1; i++) {
const segment = barBetween(
branch.points[i],
branch.points[i + 1],
0.066,
index % 2 ? M.root : M.rootDark,
rootGroup
);
registerDynamic(segment, branch.birth + i * 0.12);
}
});
const shootGroup = new THREE.Group();
shootGroup.position.set(mainX, 2.78, mainZ);
scene.add(shootGroup);
const stemPoints = [
[0, 0, 0],
[0.01, 0.28, 0],
[0.04, 0.58, 0.01],
[-0.02, 0.88, 0.015],
[0.055, 1.18, 0],
[0.03, 1.48, -0.01]
];
const stemBirths = [1.92, 2.05, 2.25, 2.46, 2.72, 2.98];
for (let i = 0; i < stemPoints.length - 1; i++) {
const segment = barBetween(
stemPoints[i],
stemPoints[i + 1],
0.105 - i * 0.008,
i % 2 ? M.stem : M.stemLight,
shootGroup
);
registerDynamic(segment, stemBirths[i]);
}
function createLeaf(position, rotation, birth, mirror = 1) {
const group = new THREE.Group();
group.position.set(...position);
group.rotation.z = rotation;
shootGroup.add(group);
const leafMat = birth > 3.5 ? M.leafLight : M.leaf;
box(0.42, 0.105, 0.22, leafMat, 0.17 * mirror, 0, 0, group);
box(0.2, 0.09, 0.17, leafMat, -0.09 * mirror, 0.005, 0, group);
box(0.2, 0.075, 0.13, M.leafDark, -0.2 * mirror, 0, 0, group);
box(0.13, 0.07, 0.1, M.leafLight, 0.31 * mirror, 0, 0, group);
registerDynamic(group, birth, "group");
return group;
}
createLeaf([0.03, 0.56, 0], -0.12, 2.78, 1);
createLeaf([-0.015, 0.86, 0.01], 0.28, 3.04, -1);
createLeaf([0.05, 1.16, 0], -0.2, 3.34, 1);
createLeaf([0.03, 1.46, -0.01], 0.18, 3.66, -1);
// -------------------------------------------------------------------------
// Rooted example jar on the right
// -------------------------------------------------------------------------
const exampleX = 3.55;
const exampleZ = 0.3;
const exampleGlass = cylinder(
0.75,
0.75,
1.95,
M.glass,
exampleX,
1.295,
exampleZ,
12
);
exampleGlass.renderOrder = 4;
cylinder(
0.7,
0.7,
0.05,
M.glass,
exampleX,
0.35,
exampleZ,
12
).renderOrder = 4;
horizontalRing(0.76, 0.045, 2.27, exampleX, exampleZ);
const exampleWater = cylinder(
0.66,
0.66,
0.94,
M.water,
exampleX,
0.82,
exampleZ,
12
);
exampleWater.renderOrder = 2;
// Example seed.
box(0.38, 0.48, 0.36, M.seed, exampleX, 1.74, exampleZ);
box(0.31, 0.18, 0.29, M.seedLight, exampleX, 2.01, exampleZ);
box(0.29, 0.16, 0.27, M.seedDark, exampleX, 1.49, exampleZ);
// Fixed, established root system.
const exampleRoots = [
[[0, 0, 0], [0.03, -0.32, 0], [-0.05, -0.64, 0.03]],
[[0.03, -0.32, 0], [0.27, -0.5, 0.03], [0.43, -0.76, 0.07]],
[[-0.05, -0.64, 0.03], [-0.3, -0.82, 0], [-0.46, -1.04, -0.03]],
[[0.03, -0.32, 0], [-0.22, -0.46, -0.03], [-0.35, -0.66, -0.08]]
];
exampleRoots.forEach((branch, index) => {
for (let i = 0; i < branch.length - 1; i++) {
barBetween(
[
exampleX + branch[i][0],
1.5 + branch[i][1],
exampleZ + branch[i][2]
],
[
exampleX + branch[i + 1][0],
1.5 + branch[i + 1][1],
exampleZ + branch[i + 1][2]
],
0.057,
index % 2 ? M.root : M.rootDark
);
}
});
// Example shoot.
barBetween(
[exampleX, 1.98, exampleZ],
[exampleX + 0.03, 2.48, exampleZ],
0.08,
M.stem
);
barBetween(
[exampleX + 0.01, 2.24, exampleZ],
[exampleX - 0.28, 2.43, exampleZ],
0.055,
M.stem
);
barBetween(
[exampleX + 0.03, 2.43, exampleZ],
[exampleX + 0.3, 2.62, exampleZ],
0.055,
M.stem
);
box(0.37, 0.1, 0.2, M.leaf, exampleX - 0.37, 2.46, exampleZ);
box(0.34, 0.095, 0.19, M.leafLight, exampleX + 0.38, 2.65, exampleZ);
box(0.27, 0.09, 0.17, M.leafDark, exampleX + 0.03, 2.84, exampleZ);
// Example label on a tiny sill sign.
const exampleLabel = new THREE.Mesh(
new THREE.PlaneGeometry(1.85, 0.46),
new THREE.MeshBasicMaterial({
map: labelTexture("ROOTED EXAMPLE", "DAY 54 / REFERENCE JAR"),
toneMapped: false
})
);
exampleLabel.position.set(exampleX, 0.57, 1.12);
scene.add(exampleLabel);
// Main jar label.
const mainLabel = new THREE.Mesh(
new THREE.PlaneGeometry(1.55, 0.39),
new THREE.MeshBasicMaterial({
map: labelTexture("SEED NO. 07", "SUSPENDED ABOVE WATER"),
toneMapped: false
})
);
mainLabel.position.set(mainX, 0.51, 1.12);
scene.add(mainLabel);
// -------------------------------------------------------------------------
// Timeline UI and smooth growth interpolation
// -------------------------------------------------------------------------
const stages = [
{
day: "Day 0",
title: "Soaked seed",
copy:
"The intact seed is suspended above the water, waiting for the first sign of a root."
},
{
day: "Day 7",
title: "Root wakes",
copy:
"A pale radicle emerges from the lower point of the seed and begins pointing downward."
},
{
day: "Day 21",
title: "Waterline reached",
copy:
"The root reaches the water, and a small green shoot opens from the split seed."
},
{
day: "Day 45",
title: "First leaves",
copy:
"The stem lifts above the seed while branching roots become more visible in the jar."
},
{
day: "Day 75",
title: "Young sapling",
copy:
"A simplified canopy is established. The rooted jar provides a visual reference."
}
];
const slider = document.querySelector("#time-slider");
const stageTitle = document.querySelector("#stage-title");
const stageCopy = document.querySelector("#stage-copy");
const stageCount = document.querySelector("#stage-count");
const dayReadout = document.querySelector("#day-readout");
const progressFill = document.querySelector("#progress-fill");
const markers = [...document.querySelectorAll(".stage-marker")];
let targetProgress = 0;
let currentProgress = 0;
let activeStage = 0;
function updateStageUI(index) {
if (index === activeStage && stageTitle.textContent) {
// Still refresh the slider's accessible text.
}
activeStage = index;
const stage = stages[index];
stageTitle.textContent = stage.title;
stageCopy.textContent = stage.copy;
stageCount.textContent = `Observation ${String(index + 1).padStart(
2,
"0"
)} / 05`;
dayReadout.textContent = stage.day;
markers.forEach((marker, markerIndex) => {
marker.classList.toggle("active", markerIndex === index);
});
slider.setAttribute(
"aria-valuetext",
`${stage.day}, ${stage.title}`
);
}
function updateSliderFill(value) {
const percentage = (value / 4) * 100;
slider.style.setProperty("--range-progress", `${percentage}%`);
}
function updateGrowth(progress) {
dynamicItems.forEach((item) => {
const amount = THREE.MathUtils.clamp(
progress - item.birth,
0,
1
);
const eased = 1 - Math.pow(1 - amount, 3);
if (eased <= 0.001) {
item.object.visible = false;
return;
}
item.object.visible = true;
if (item.mode === "group") {
item.object.scale.setScalar(Math.max(0.001, eased));
} else {
const scale = Math.max(0.001, eased);
item.object.scale.set(
item.baseScale.x * scale,
item.baseScale.y * scale,
item.baseScale.z * scale
);
}
});
crackGroup.visible = progress > 1.55;
const crackAmount = THREE.MathUtils.clamp(
(progress - 1.55) / 0.45,
0,
1
);
crackGroup.scale.setScalar(Math.max(0.001, crackAmount));
progressFill.style.width = `${(progress / 4) * 100}%`;
}
slider.addEventListener("input", () => {
targetProgress = Number(slider.value);
updateSliderFill(targetProgress);
updateStageUI(Math.round(targetProgress));
});
markers.forEach((marker) => {
marker.addEventListener("click", () => {
const stageIndex = Number(marker.dataset.stage);
targetProgress = stageIndex;
slider.value = String(stageIndex);
updateSliderFill(stageIndex);
updateStageUI(stageIndex);
});
});
updateStageUI(0);
updateSliderFill(0);
updateGrowth(0);
// -------------------------------------------------------------------------
// Direct camera controls — no external controls addon
// -------------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.yaw -= dx * 0.0055;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + dy * 0.0045,
0.08,
0.72
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (
event &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.01,
9,
19
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("keydown", (event) => {
const step = 0.08;
if (event.key === "ArrowLeft") {
cameraState.yaw += step;
} else if (event.key === "ArrowRight") {
cameraState.yaw -= step;
} else if (event.key === "ArrowUp") {
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + step,
0.08,
0.72
);
} else if (event.key === "ArrowDown") {
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch - step,
0.08,
0.72
);
} else {
return;
}
event.preventDefault();
updateCamera();
});
document.querySelector("#reset-camera").addEventListener("click", () => {
cameraState.yaw = 0.28;
cameraState.pitch = 0.26;
cameraState.radius = 14.2;
updateCamera();
});
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
let previousTime = performance.now();
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
// Smoothly ease toward the chosen observation.
currentProgress +=
(targetProgress - currentProgress) *
(1 - Math.exp(-delta * 8));
if (Math.abs(targetProgress - currentProgress) < 0.0001) {
currentProgress = targetProgress;
}
updateGrowth(currentProgress);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
requestAnimationFrame(() => {
const loading = document.querySelector("#loading");
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 450);
});
</script>
</body>
</html>
```