Prompt specification
Build or customize the Three.js 3D scene "School Garden Approval Workflow" 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: School Garden Approval Workflow
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/school-garden-approval-workflow-x3230
Scene Description Prompt:
Please use Three.js from cdnjs for a stylized scene based on this idea: school garden approval workflow. Animate a fictional garden proposal moving through teacher review, volunteer work, and inspection. Show reasons for revisions and distinguish permission from actual completion. Return one self-contained HTML file.
Working Three.js Starter (school-garden-approval-workflow-x3230):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Garden Gate — School Garden Approval Workflow</title>
<style>
:root {
--ink: #193b39;
--muted: #617470;
--paper: rgba(255, 252, 242, 0.92);
--paper-solid: #fffaf0;
--line: rgba(25, 59, 57, 0.14);
--blue: #327fc2;
--blue-soft: #e3f0fb;
--green: #278765;
--green-soft: #e2f3eb;
--purple: #7357a5;
--coral: #d95f49;
--coral-soft: #fff0eb;
--gold: #e8a83e;
--shadow: 0 18px 50px rgba(31, 61, 55, 0.14);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e6eee4;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body::after {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
opacity: 0.2;
background-image:
radial-gradient(circle at 20% 20%, rgba(255,255,255,.7) 0 1px, transparent 1.4px),
radial-gradient(circle at 80% 70%, rgba(25,59,57,.08) 0 1px, transparent 1.4px);
background-size: 22px 22px, 31px 31px;
mix-blend-mode: soft-light;
z-index: 3;
}
#scene {
position: fixed;
inset: 0;
z-index: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active { cursor: grabbing; }
.brand {
position: fixed;
z-index: 10;
top: 24px;
left: 26px;
pointer-events: none;
}
.brand-row {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 9px;
color: var(--purple);
font-size: 11px;
font-weight: 800;
letter-spacing: .15em;
text-transform: uppercase;
}
.brand-mark {
position: relative;
width: 25px;
height: 25px;
border-radius: 9px;
background: var(--ink);
box-shadow: 0 6px 16px rgba(25,59,57,.2);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
background: #f4c867;
border-radius: 50% 50% 45% 45%;
transform-origin: bottom center;
}
.brand-mark::before {
width: 8px;
height: 13px;
left: 5px;
top: 7px;
transform: rotate(-31deg);
}
.brand-mark::after {
width: 8px;
height: 13px;
right: 5px;
top: 7px;
transform: rotate(31deg);
}
.brand h1 {
margin: 0;
max-width: 460px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 44px);
line-height: .98;
letter-spacing: -.035em;
font-weight: 700;
}
.brand p {
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.top-tools {
position: fixed;
z-index: 20;
top: 24px;
right: 26px;
display: flex;
align-items: flex-start;
gap: 10px;
}
.legend {
display: grid;
gap: 7px;
padding: 12px 14px;
border: 1px solid rgba(255,255,255,.65);
border-radius: 16px;
background: rgba(255,252,242,.86);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
}
.legend-title {
margin-bottom: 2px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: .13em;
text-transform: uppercase;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
font-size: 11px;
white-space: nowrap;
}
.legend-dot {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: 0 0 0 4px rgba(0,0,0,.035);
}
.legend-dot.blue { background: var(--blue); }
.legend-dot.green { background: var(--green); }
.tool-button {
border: 1px solid rgba(255,255,255,.65);
background: rgba(255,252,242,.88);
color: var(--ink);
border-radius: 14px;
min-height: 44px;
padding: 0 14px;
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
transition: transform .18s ease, background .18s ease;
}
.tool-button:hover {
transform: translateY(-2px);
background: #fffdf7;
}
.status-panel {
position: fixed;
z-index: 10;
top: 132px;
right: 26px;
width: 294px;
padding: 17px;
border: 1px solid rgba(255,255,255,.7);
border-radius: 20px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(16px);
pointer-events: none;
}
.panel-kicker {
color: var(--muted);
font-size: 9px;
font-weight: 850;
letter-spacing: .14em;
text-transform: uppercase;
}
.proposal-id {
display: flex;
align-items: center;
justify-content: space-between;
margin: 5px 0 14px;
}
.proposal-id strong {
font-family: Georgia, serif;
font-size: 21px;
letter-spacing: -.02em;
}
.proposal-id span {
padding: 5px 8px;
border-radius: 999px;
background: var(--coral-soft);
color: var(--coral);
font-size: 9px;
font-weight: 850;
letter-spacing: .09em;
text-transform: uppercase;
}
.metric + .metric { margin-top: 12px; }
.metric-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
font-size: 11px;
}
.metric-name {
display: flex;
align-items: center;
gap: 7px;
font-weight: 800;
}
.metric-icon {
width: 8px;
height: 8px;
border-radius: 50%;
}
.metric-icon.blue { background: var(--blue); }
.metric-icon.green { background: var(--green); }
.metric-value {
color: var(--muted);
font-size: 10px;
font-weight: 750;
}
.bar {
height: 6px;
margin-top: 7px;
overflow: hidden;
border-radius: 999px;
background: rgba(25,59,57,.09);
}
.bar > span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
transition: width .22s linear;
}
.bar.blue > span { background: var(--blue); }
.bar.green > span { background: var(--green); }
.divider {
height: 1px;
margin: 15px 0 13px;
background: var(--line);
}
.check-list {
display: grid;
gap: 10px;
margin: 0;
padding: 0;
list-style: none;
}
.check-list li {
display: grid;
grid-template-columns: 18px 1fr auto;
align-items: center;
gap: 7px;
color: var(--muted);
font-size: 10.5px;
}
.check-box {
display: grid;
place-items: center;
width: 17px;
height: 17px;
border: 1px solid rgba(25,59,57,.18);
border-radius: 6px;
color: transparent;
font-size: 11px;
font-weight: 900;
}
.check-list li.done .check-box {
border-color: rgba(39,135,101,.24);
background: var(--green-soft);
color: var(--green);
}
.check-list li.revision .check-box {
border-color: rgba(217,95,73,.2);
background: var(--coral-soft);
color: var(--coral);
}
.check-list li b {
color: var(--ink);
font-size: 9px;
font-weight: 800;
}
.phase-panel {
position: fixed;
z-index: 10;
left: 26px;
bottom: 143px;
width: 330px;
padding: 18px 19px;
border: 1px solid rgba(255,255,255,.72);
border-radius: 20px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(16px);
pointer-events: none;
}
.phase-panel h2 {
margin: 5px 0 7px;
font-family: Georgia, serif;
font-size: 25px;
line-height: 1.05;
letter-spacing: -.025em;
}
.phase-panel p {
margin: 0;
color: var(--muted);
font-size: 11.5px;
line-height: 1.55;
}
.revision-box {
display: none;
margin-top: 12px;
padding: 11px 12px;
border-left: 3px solid var(--coral);
border-radius: 0 10px 10px 0;
background: var(--coral-soft);
color: #8b3f31;
font-size: 10.5px;
line-height: 1.45;
}
.revision-box.visible { display: block; }
.revision-box strong {
display: block;
margin-bottom: 2px;
color: var(--coral);
font-size: 9px;
letter-spacing: .08em;
text-transform: uppercase;
}
.annotation {
position: fixed;
z-index: 30;
left: 50%;
top: 24%;
width: min(360px, calc(100vw - 32px));
padding: 14px 16px;
border-radius: 15px;
color: white;
box-shadow: 0 18px 45px rgba(25,59,57,.2);
transform: translateX(-50%);
pointer-events: none;
opacity: 0;
transition: opacity .25s ease, transform .25s ease;
}
.annotation.visible {
opacity: 1;
transform: translateX(-50%) translateY(-4px);
}
.annotation.revision { background: var(--coral); }
.annotation.permission { background: var(--blue); }
.annotation.complete { background: var(--green); }
.annotation strong {
display: block;
margin-bottom: 3px;
font-size: 12px;
letter-spacing: .04em;
text-transform: uppercase;
}
.annotation span {
font-size: 11px;
opacity: .92;
}
.world-label {
position: fixed;
z-index: 8;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px 7px 7px;
border: 1px solid rgba(255,255,255,.75);
border-radius: 999px;
background: rgba(255,252,242,.87);
box-shadow: 0 8px 24px rgba(25,59,57,.12);
backdrop-filter: blur(10px);
transform: translate(-50%, -100%);
color: var(--ink);
font-size: 10px;
font-weight: 800;
white-space: nowrap;
cursor: pointer;
transition: background .2s ease, color .2s ease, transform .2s ease;
}
.world-label:hover {
transform: translate(-50%, -100%) translateY(-3px);
}
.world-label.active {
background: var(--ink);
color: white;
}
.world-label .number {
display: grid;
place-items: center;
width: 21px;
height: 21px;
border-radius: 50%;
background: var(--purple);
color: white;
font-size: 9px;
}
.world-label.build .number { background: var(--green); }
.world-label.inspect .number { background: var(--blue); }
.transport {
position: fixed;
z-index: 25;
left: 50%;
bottom: 22px;
width: min(720px, calc(100vw - 36px));
padding: 12px 14px 10px;
border: 1px solid rgba(255,255,255,.72);
border-radius: 19px;
background: rgba(255,252,242,.94);
box-shadow: var(--shadow);
backdrop-filter: blur(16px);
transform: translateX(-50%);
}
.transport-top {
display: grid;
grid-template-columns: 38px 38px 1fr auto;
align-items: center;
gap: 8px;
}
.round-button {
display: grid;
place-items: center;
width: 38px;
height: 38px;
border: 0;
border-radius: 12px;
background: var(--ink);
color: white;
font: inherit;
font-size: 16px;
cursor: pointer;
transition: transform .18s ease, background .18s ease;
}
.round-button:hover {
transform: translateY(-2px);
background: #2b5752;
}
.round-button.secondary {
background: #e8eee7;
color: var(--ink);
font-size: 18px;
}
.timeline {
position: relative;
height: 30px;
cursor: pointer;
}
.timeline-track {
position: absolute;
top: 13px;
left: 0;
right: 0;
height: 5px;
overflow: hidden;
border-radius: 999px;
background: #dfe6dd;
}
.timeline-fill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--purple), var(--green));
}
.timeline-head {
position: absolute;
top: 8px;
left: 0;
width: 15px;
height: 15px;
border: 3px solid var(--paper-solid);
border-radius: 50%;
background: var(--ink);
box-shadow: 0 2px 8px rgba(25,59,57,.2);
transform: translateX(-50%);
pointer-events: none;
}
.timeline-marker {
position: absolute;
top: 0;
height: 30px;
padding: 0;
border: 0;
background: none;
color: var(--muted);
font: inherit;
font-size: 8px;
font-weight: 800;
letter-spacing: .04em;
text-transform: uppercase;
transform: translateX(-50%);
cursor: pointer;
}
.timeline-marker::before {
content: "";
position: absolute;
top: 10px;
left: 50%;
width: 8px;
height: 8px;
border: 2px solid var(--paper-solid);
border-radius: 50%;
background: #aabbb0;
transform: translateX(-50%);
}
.timeline-marker span {
position: absolute;
top: 22px;
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
}
.time {
min-width: 67px;
color: var(--muted);
font-variant-numeric: tabular-nums;
font-size: 10px;
font-weight: 750;
text-align: right;
}
.drag-hint {
position: fixed;
z-index: 9;
right: 28px;
bottom: 26px;
color: rgba(25,59,57,.58);
font-size: 9px;
font-weight: 700;
letter-spacing: .04em;
pointer-events: none;
}
@media (max-width: 980px) {
.brand p { display: none; }
.legend { display: none; }
.status-panel { width: 255px; top: 106px; }
.phase-panel { width: 290px; }
.drag-hint { display: none; }
}
@media (max-width: 680px) {
.brand { top: 15px; left: 15px; }
.brand h1 { font-size: 27px; max-width: 260px; }
.brand-row { margin-bottom: 6px; }
.top-tools { top: 14px; right: 14px; }
.tool-button { min-height: 38px; padding: 0 10px; font-size: 10px; }
.status-panel {
top: 86px;
right: 14px;
width: 205px;
padding: 13px;
}
.proposal-id { margin-bottom: 10px; }
.proposal-id strong { font-size: 17px; }
.check-list li { font-size: 9px; }
.phase-panel {
left: 14px;
bottom: 132px;
width: calc(100vw - 28px);
max-width: 380px;
padding: 14px 15px;
}
.phase-panel h2 { font-size: 21px; }
.phase-panel p { font-size: 10.5px; }
.transport { bottom: 12px; width: calc(100vw - 24px); padding: 10px; }
.transport-top { grid-template-columns: 34px 34px 1fr 58px; gap: 6px; }
.round-button { width: 34px; height: 34px; }
.timeline-marker span { display: none; }
.world-label { font-size: 8px; padding: 5px 7px 5px 5px; }
.world-label .number { width: 18px; height: 18px; }
.annotation { top: 35%; }
}
@media (max-height: 700px) and (min-width: 681px) {
.status-panel { top: 108px; }
.phase-panel { bottom: 126px; }
.brand p { display: none; }
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive 3D school garden approval workflow"></main>
<header class="brand">
<div class="brand-row"><span class="brand-mark" aria-hidden="true"></span>The Garden Gate</div>
<h1>From proposal<br />to practice.</h1>
<p>A fictional school garden moves through review, work and inspection.</p>
</header>
<div class="top-tools">
<div class="legend" aria-label="Workflow color legend">
<div class="legend-title">Two different approvals</div>
<div class="legend-item"><span class="legend-dot blue"></span><b>Permission</b> · authorized to proceed</div>
<div class="legend-item"><span class="legend-dot green"></span><b>Completion</b> · physical work verified</div>
</div>
<button class="tool-button" id="overviewButton" type="button">Overview</button>
</div>
<section class="status-panel" aria-label="Live workflow status">
<div class="panel-kicker">Live workflow</div>
<div class="proposal-id">
<strong>Garden #24</strong>
<span id="proposalState">Submitted</span>
</div>
<div class="metric">
<div class="metric-head">
<span class="metric-name"><i class="metric-icon blue"></i>Permission</span>
<span class="metric-value" id="permissionValue">Not granted</span>
</div>
<div class="bar blue"><span id="permissionBar"></span></div>
</div>
<div class="metric">
<div class="metric-head">
<span class="metric-name"><i class="metric-icon green"></i>Actual completion</span>
<span class="metric-value" id="completionValue">0% complete</span>
</div>
<div class="bar green"><span id="completionBar"></span></div>
</div>
<div class="divider"></div>
<ul class="check-list">
<li id="teacherCheck"><span class="check-box">✓</span><span>Teacher review</span><b id="teacherCheckText">Waiting</b></li>
<li id="inspectionCheck"><span class="check-box">✓</span><span>Final inspection</span><b id="inspectionCheckText">Pending</b></li>
<li id="wateringCheck"><span class="check-box">✓</span><span>Watering & care handoff</span><b id="wateringCheckText">Pending</b></li>
</ul>
</section>
<section class="phase-panel" aria-live="polite">
<div class="panel-kicker" id="phaseStep">01 · Proposal</div>
<h2 id="phaseTitle">A good idea enters the gate.</h2>
<p id="phaseDescription">
Garden #24 proposes six raised beds beside the school, with a care roster and weekly classroom lessons.
</p>
<div class="revision-box" id="revisionBox">
<strong>Revision requested</strong>
Bed B needs a shade plan so seedlings will not scorch during afternoon classes.
</div>
</section>
<div class="annotation" id="annotation" role="status">
<strong id="annotationTitle"></strong>
<span id="annotationText"></span>
</div>
<button class="world-label review" data-stage="review" type="button">
<span class="number">01</span>Teacher review
</button>
<button class="world-label build" data-stage="build" type="button">
<span class="number">02</span>Volunteer work
</button>
<button class="world-label inspect" data-stage="inspect" type="button">
<span class="number">03</span>Inspection
</button>
<section class="transport" aria-label="Animation controls">
<div class="transport-top">
<button class="round-button" id="playButton" type="button" aria-label="Pause animation">Ⅱ</button>
<button class="round-button secondary" id="restartButton" type="button" aria-label="Restart animation">↻</button>
<div class="timeline" id="timeline" aria-label="Workflow timeline">
<div class="timeline-track"><div class="timeline-fill" id="timelineFill"></div></div>
<div class="timeline-head" id="timelineHead"></div>
<button class="timeline-marker" data-time="5" style="left:14.7%" type="button"><span>Review</span></button>
<button class="timeline-marker" data-time="21" style="left:61.8%" type="button"><span>Build</span></button>
<button class="timeline-marker" data-time="27" style="left:79.4%" type="button"><span>Inspect</span></button>
</div>
<div class="time" id="timeReadout">00:00 / 00:34</div>
</div>
</section>
<div class="drag-hint">Drag to orbit · Scroll to zoom</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
const DURATION = 34;
const sceneHost = document.getElementById('scene');
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
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.16;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe6eee4);
scene.fog = new THREE.Fog(0xe6eee4, 32, 55);
const camera = new THREE.OrthographicCamera(-12, 12, 8, -8, 0.1, 100);
const orbit = {
yaw: 0.56,
pitch: 0.78,
radius: 28,
target: new THREE.Vector3(0, 0.55, 0),
zoom: 1
};
function updateCamera() {
const cp = Math.cos(orbit.pitch);
camera.position.set(
orbit.target.x + Math.sin(orbit.yaw) * cp * orbit.radius,
orbit.target.y + Math.sin(orbit.pitch) * orbit.radius,
orbit.target.z + Math.cos(orbit.yaw) * cp * orbit.radius
);
camera.lookAt(orbit.target);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = aspect < 1 ? 19 : 15;
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.zoom = orbit.zoom;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener('resize', resize);
const hemisphere = new THREE.HemisphereLight(0xfff9e9, 0x597366, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3d3, 3.2);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 38;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fillLight = new THREE.DirectionalLight(0xa9d8e7, 1.0);
fillLight.position.set(10, 7, -8);
scene.add(fillLight);
const palette = {
ink: 0x193b39,
dark: 0x244a46,
cream: 0xfff8e8,
grass: 0x91b98b,
grassDark: 0x5f8a69,
soil: 0x795542,
wood: 0xb98250,
woodDark: 0x805437,
purple: 0x7357a5,
purpleSoft: 0xd8d0eb,
blue: 0x327fc2,
blueSoft: 0xc8dfef,
green: 0x278765,
greenSoft: 0xb9d9c3,
coral: 0xd95f49,
gold: 0xe8a83e,
white: 0xffffff
};
function material(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
...extra
});
}
function addMesh(geometry, mat, x = 0, y = 0, z = 0, parent = scene) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(w, h, d, color, x = 0, y = 0, z = 0, parent = scene, extra = {}) {
return addMesh(
new THREE.BoxGeometry(w, h, d),
typeof color === 'number' ? material(color, extra) : color,
x, y, z, parent
);
}
function cylinder(rTop, rBottom, h, color, x = 0, y = 0, z = 0, parent = scene, extra = {}) {
return addMesh(
new THREE.CylinderGeometry(rTop, rBottom, h, 16),
typeof color === 'number' ? material(color, extra) : color,
x, y, z, parent
);
}
function sphere(r, color, x = 0, y = 0, z = 0, parent = scene, extra = {}) {
return addMesh(
new THREE.SphereGeometry(r, 18, 12),
typeof color === 'number' ? material(color, extra) : color,
x, y, z, parent
);
}
function makeBoard(x, z, w, h, title, lines, accent = '#7357a5') {
const canvas = document.createElement('canvas');
canvas.width = 1024;
canvas.height = 512;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const group = new THREE.Group();
group.position.set(x, 2.65, z);
scene.add(group);
box(w + 0.18, h + 0.18, 0.18, palette.dark, 0, 0, 0, group);
const face = addMesh(
new THREE.PlaneGeometry(w, h),
new THREE.MeshBasicMaterial({ map: texture }),
0, 0, 0.101, group
);
face.castShadow = false;
[-w * 0.36, w * 0.36].forEach(px => {
box(0.13, 2.25, 0.13, palette.woodDark, px, -1.58, 0, group);
});
const board = { group, canvas, ctx: canvas.getContext('2d'), texture };
drawBoard(board, title, lines, accent);
return board;
}
function drawBoard(board, title, lines, accent = '#7357a5', footer = '') {
const ctx = board.ctx;
const c = board.canvas;
ctx.clearRect(0, 0, c.width, c.height);
ctx.fillStyle = '#fff8e8';
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, c.width, 24);
ctx.fillRect(0, 455, c.width, 57);
ctx.fillStyle = '#193b39';
ctx.font = '800 62px Arial, sans-serif';
ctx.textAlign = 'center';
ctx.fillText(title, c.width / 2, 105);
ctx.fillStyle = accent;
ctx.fillRect(360, 128, 304, 9);
ctx.textAlign = 'left';
ctx.font = '600 38px Arial, sans-serif';
lines.forEach((line, i) => {
const y = 205 + i * 74;
const isRevision = line.toUpperCase().includes('NEEDED');
ctx.fillStyle = isRevision ? '#d95f49' : '#193b39';
ctx.fillText(isRevision ? '!' : '✓', 115, y);
ctx.fillText(line, 165, y);
});
ctx.textAlign = 'center';
ctx.fillStyle = '#fff8e8';
ctx.font = '800 30px Arial, sans-serif';
ctx.fillText(footer || 'SCHOOL GARDEN · PROPOSAL #24', c.width / 2, 493);
board.texture.needsUpdate = true;
}
function makeSprite(text, background, foreground = '#ffffff') {
const canvas = document.createElement('canvas');
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, 256, 256);
ctx.beginPath();
ctx.arc(128, 128, 104, 0, Math.PI * 2);
ctx.fillStyle = background;
ctx.fill();
ctx.lineWidth = 12;
ctx.strokeStyle = 'rgba(255,255,255,.78)';
ctx.stroke();
ctx.fillStyle = foreground;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = '900 90px Arial, sans-serif';
ctx.fillText(text, 128, 128);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false
}));
sprite.scale.set(0.64, 0.64, 1);
sprite.renderOrder = 8;
return sprite;
}
function makeTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(0.15, 0.21, 1.4, palette.woodDark, 0, 0.7, 0, group);
sphere(0.72, palette.grassDark, 0, 1.65, 0, group);
sphere(0.5, 0x7daa79, -0.38, 1.65, 0.08, group);
sphere(0.48, 0x9fc48d, 0.42, 1.76, -0.03, group);
return group;
}
function makePerson(color, x, z, scale = 1, role = 'volunteer') {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
const skin = role === 'teacher' ? 0xc98f6b : 0xb87955;
const shirt = material(color);
const pants = material(0x38545a);
[-0.16, 0.16].forEach(px => {
cylinder(0.11, 0.12, 0.65, pants, px, 0.38, 0, group);
box(0.23, 0.12, 0.36, palette.ink, px, 0.08, 0.07, group);
});
addMesh(new THREE.CapsuleGeometry(0.27, 0.48, 5, 12), shirt, 0, 1.02, 0, group);
const head = sphere(0.25, skin, 0, 1.59, 0, group);
head.scale.set(0.92, 1.05, 0.92);
const hair = sphere(0.255, role === 'teacher' ? 0x58463e : 0x3d3a35, 0, 1.68, -0.035, group);
hair.scale.set(1, 0.58, 0.95);
[-0.085, 0.085].forEach(px => {
sphere(0.024, palette.ink, px, 1.62, 0.225, group);
});
const makeArm = side => {
const arm = new THREE.Group();
arm.position.set(side * 0.31, 1.21, 0);
group.add(arm);
cylinder(0.075, 0.09, 0.55, shirt, 0, -0.23, 0, arm);
sphere(0.09, skin, 0, -0.53, 0, arm);
return arm;
};
const leftArm = makeArm(-1);
const rightArm = makeArm(1);
if (role === 'teacher') {
box(0.47, 0.025, 0.15, 0x293f48, 0, 1.62, 0.23, group);
box(0.035, 0.035, 0.025, 0x293f48, -0.12, 1.62, 0.315, group);
box(0.035, 0.035, 0.025, 0x293f48, 0.12, 1.62, 0.315, group);
} else if (role === 'inspector') {
cylinder(0.32, 0.32, 0.055, palette.blue, 0, 1.79, 0, group);
cylinder(0.19, 0.19, 0.06, palette.blueSoft, 0, 1.83, 0, group);
} else {
cylinder(0.3, 0.3, 0.05, palette.gold, 0, 1.79, 0, group);
cylinder(0.17, 0.17, 0.07, palette.gold, 0, 1.83, 0, group);
}
return { group, leftArm, rightArm, baseY: 0 };
}
function makeDesk(x, z, width = 2.6, topColor = palette.wood) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
box(width, 0.18, 1.08, topColor, 0, 1.16, 0, group);
box(width - 0.25, 0.09, 0.9, palette.woodDark, 0, 0.98, 0, group);
[-width * 0.38, width * 0.38].forEach(px => {
box(0.15, 1.05, 0.15, palette.woodDark, px, 0.55, -0.32, group);
box(0.15, 1.05, 0.15, palette.woodDark, px, 0.55, 0.32, group);
});
return group;
}
function makePlant(parent, x, z, seed = 0) {
const plant = new THREE.Group();
plant.position.set(x, 0, z);
parent.add(plant);
const colors = [0x4f9c62, 0x6fac68, 0x3f8554, 0x8bbb72];
for (let i = 0; i < 4; i++) {
const angle = (i / 4) * Math.PI * 2 + seed * 0.37;
const px = Math.cos(angle) * 0.16;
const pz = Math.sin(angle) * 0.14;
cylinder(0.025, 0.035, 0.4 + (i % 2) * 0.08, palette.green, px, 0.23, pz, plant);
const leaf = sphere(0.16, colors[(i + seed) % colors.length], px, 0.39, pz, plant);
leaf.scale.set(1.45, 0.45, 0.85);
leaf.rotation.z = angle;
}
return plant;
}
function makeRibbon(points, width, color) {
const curve = new THREE.CatmullRomCurve3(
points.map(p => new THREE.Vector3(p[0], 0.13, p[1]))
);
const segments = 90;
const positions = [];
const indices = [];
const side = new THREE.Vector3();
for (let i = 0; i <= segments; i++) {
const t = i / segments;
const p = curve.getPoint(t);
const tangent = curve.getTangent(t);
side.set(-tangent.z, 0, tangent.x).normalize().multiplyScalar(width / 2);
positions.push(p.x + side.x, p.y, p.z + side.z);
positions.push(p.x - side.x, p.y, p.z - side.z);
if (i < segments) {
const a = i * 2;
indices.push(a, a + 2, a + 1, a + 1, a + 2, a + 3);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
const path = addMesh(geometry, material(color, { side: THREE.DoubleSide }));
path.castShadow = false;
return curve;
}
// Diorama base
const backgroundFloor = addMesh(
new THREE.PlaneGeometry(100, 100),
material(0xe6eee4),
0, -1.02, 0
);
backgroundFloor.rotation.x = -Math.PI / 2;
backgroundFloor.castShadow = false;
box(24, 0.82, 11.4, 0x6c8a70, 0, -0.55, 0);
box(23.55, 0.18, 10.95, palette.grass, 0, -0.08, 0);
// Stage pads
cylinder(2.45, 2.45, 0.1, palette.purpleSoft, -6, 0.04, -0.15);
cylinder(3.05, 3.05, 0.1, palette.greenSoft, 0.05, 0.04, 0.05);
cylinder(2.35, 2.35, 0.1, palette.blueSoft, 7, 0.04, -0.15);
const pathPoints = [
[-10.4, 2.7], [-9.0, 2.25], [-7.2, 1.8], [-5.8, 0.85],
[-3.3, 1.45], [-1.4, 1.7], [1.4, 1.55], [3.6, 1.05],
[5.7, 0.65], [8.8, 0.55]
];
const pathCurve = makeRibbon(pathPoints, 0.82, 0xd7c8a3);
for (let i = 0; i < 23; i++) {
const p = pathCurve.getPoint(i / 22);
const stone = cylinder(0.08, 0.08, 0.025, 0xc5b58f, p.x, 0.16, p.z);
stone.castShadow = false;
}
// Back fence
for (let x = -10.5; x <= 10.5; x += 2.1) {
box(0.13, 1.35, 0.13, palette.cream, x, 0.72, -4.78);
sphere(0.09, palette.cream, x, 1.43, -4.78);
}
box(21.2, 0.11, 0.11, palette.cream, 0, 0.62, -4.78);
box(21.2, 0.11, 0.11, palette.cream, 0, 1.08, -4.78);
makeTree(-10.4, -3.65, 0.95);
makeTree(10.2, -3.65, 1.05);
makeTree(10.3, 3.8, 0.8);
makeTree(-10.5, 3.8, 0.73);
// Review area
const reviewBoard = makeBoard(
-6.0, -3.65, 4.75, 2.05, 'TEACHER REVIEW',
['Learning goals align', 'Care roster assigned', 'Shade plan needed'],
'#7357a5'
);
makeDesk(-6, 0.62, 2.65);
const teacher = makePerson(0x7357a5, -6.15, -1.12, 1.0, 'teacher');
const reviewClipboard = box(0.66, 0.035, 0.82, palette.cream, -6.55, 1.28, 0.66);
reviewClipboard.rotation.y = -0.12;
box(0.28, 0.06, 0.08, palette.purple, -6.55, 1.32, 0.96);
// Planning cart for revision
makeDesk(-9.15, 2.35, 1.8, 0xb89a6b);
const planSheet = box(0.72, 0.025, 0.6, palette.cream, -9.05, 1.28, 2.25);
planSheet.rotation.y = 0.16;
box(0.05, 0.03, 0.5, palette.purple, -9.12, 1.31, 2.25).rotation.y = 0.16;
box(0.38, 0.03, 0.04, palette.purple, -8.98, 1.31, 2.12).rotation.y = 0.16;
// Permission gate
const gate = new THREE.Group();
gate.position.set(-3.18, 0, 1.45);
scene.add(gate);
box(0.17, 2.35, 0.17, palette.blue, 0, 1.18, -1.05, gate);
box(0.17, 2.35, 0.17, palette.blue, 0, 1.18, 1.05, gate);
box(0.2, 0.2, 2.3, palette.blue, 0, 2.32, 0, gate);
box(0.24, 0.13, 2.38, palette.cream, 0, 2.48, 0, gate);
const permissionSign = makeBoard(
-3.15, -0.8, 2.35, 1.05, 'PERMISSION',
['Authorized to begin', 'Blue = approval to proceed'],
'#327fc2'
);
permissionSign.group.position.y = 2.18;
const permissionLamp = sphere(
0.13,
material(0x8a9992, { emissive: 0x000000 }),
-3.15, 2.95, -0.72
);
// Volunteer garden
const gardenBoard = makeBoard(
0.0, -3.65, 4.65, 2.05, 'VOLUNTEER WORK',
['Permission granted', 'Physical work in progress', 'Six raised beds'],
'#278765'
);
const bedPositions = [
[-1.45, -1.05], [-0.25, -1.05], [0.95, -1.05],
[-1.45, 0.12], [-0.25, 0.12], [0.95, 0.12]
];
const plants = [];
bedPositions.forEach(([x, z], index) => {
box(1.18, 0.31, 0.86, palette.wood, x, 0.27, z);
box(1.08, 0.055, 0.76, palette.soil, x, 0.46, z);
[-0.48, 0.48].forEach(dx => {
box(0.1, 0.38, 0.9, palette.woodDark, x + dx, 0.25, z);
});
const plant = makePlant(scene, x, z, index);
plant.position.y = 0.48;
plant.scale.setScalar(0.001);
plants.push(plant);
});
// Shade structure on the bed that caused the revision
const shadeStructure = new THREE.Group();
shadeStructure.position.set(-0.25, 0, 0.12);
scene.add(shadeStructure);
box(0.08, 1.25, 0.08, palette.woodDark, -0.61, 0.65, -0.4, shadeStructure);
box(0.08, 1.25, 0.08, palette.woodDark, 0.61, 0.65, -0.4, shadeStructure);
box(0.08, 1.25, 0.08, palette.woodDark, -0.61, 0.65, 0.4, shadeStructure);
box(0.08, 1.25, 0.08, palette.woodDark, 0.61, 0.65, 0.4, shadeStructure);
box(1.35, 0.045, 1.0, palette.blueSoft, 0, 1.25, 0, shadeStructure);
const volunteers = [
makePerson(0xd76f52, -2.15, -1.7, 0.92, 'volunteer'),
makePerson(0x327fc2, 2.1, -1.55, 0.9, 'volunteer'),
makePerson(0xe3a43a, -2.0, 0.25, 0.86, 'volunteer'),
makePerson(0x5f9d75, 2.05, 0.28, 0.88, 'volunteer')
];
// Small watering can and tools
const wateringCan = new THREE.Group();
wateringCan.position.set(1.95, 0.02, 0.75);
scene.add(wateringCan);
cylinder(0.22, 0.25, 0.38, palette.blue, 0, 0.28, 0, wateringCan);
cylinder(0.08, 0.12, 0.42, palette.blue, 0.31, 0.36, 0, wateringCan).rotation.z = -0.9;
const handle = new THREE.Mesh(
new THREE.TorusGeometry(0.24, 0.035, 8, 20, Math.PI),
material(palette.blue)
);
handle.position.set(-0.02, 0.53, 0);
handle.rotation.z = Math.PI;
wateringCan.add(handle);
// Inspection area
const inspectionBoard = makeBoard(
7.0, -3.65, 4.45, 2.05, 'INSPECTION',
['Safe paths and tools', 'Soil and drainage checked', 'Plants established'],
'#327fc2'
);
makeDesk(7.0, 0.35, 2.5, 0x8fa99c);
const inspector = makePerson(0x327fc2, 7.05, -1.22, 1.0, 'inspector');
const checklist = box(0.7, 0.035, 0.88, palette.cream, 7.55, 1.28, 0.42);
checklist.rotation.y = 0.13;
box(0.3, 0.05, 0.08, palette.blue, 7.55, 1.32, 0.78);
// Completion flag
const flag = new THREE.Group();
flag.position.set(8.45, 0, 1.92);
scene.add(flag);
cylinder(0.045, 0.055, 2.6, palette.woodDark, 0, 1.3, 0, flag);
const flagCloth = box(1.12, 0.62, 0.06, palette.green, 0.55, 2.27, 0, flag);
flag.visible = false;
const completionToken = makeSprite('✓', '#278765');
completionToken.position.set(7.8, 1.68, 0.48);
completionToken.visible = false;
// Active stage rings
function makeRing(x, z, radius, color) {
const ring = addMesh(
new THREE.TorusGeometry(radius, 0.055, 8, 64),
material(color, { transparent: true, opacity: 0.15, emissive: color, emissiveIntensity: 0.08 }),
x, 0.17, z
);
ring.rotation.x = -Math.PI / 2;
ring.castShadow = false;
return ring;
}
const reviewRing = makeRing(-6, -0.15, 2.56, palette.purple);
const buildRing = makeRing(0.05, 0.05, 3.17, palette.green);
const inspectRing = makeRing(7, -0.15, 2.47, palette.blue);
// Moving proposal packet
const packet = new THREE.Group();
scene.add(packet);
box(0.92, 1.18, 0.13, palette.cream, 0, 0, 0, packet);
box(0.98, 0.12, 0.15, palette.purple, 0, 0.61, 0, packet);
const packetCanvas = document.createElement('canvas');
packetCanvas.width = 512;
packetCanvas.height = 640;
const packetTexture = new THREE.CanvasTexture(packetCanvas);
packetTexture.colorSpace = THREE.SRGBColorSpace;
packetTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const packetFace = addMesh(
new THREE.PlaneGeometry(0.84, 1.08),
new THREE.MeshBasicMaterial({ map: packetTexture }),
0, -0.02, 0.072, packet
);
packetFace.castShadow = false;
box(0.25, 0.08, 0.15, palette.gold, 0, 0.67, 0, packet);
function drawPacket(title, lines, accent, status) {
const ctx = packetCanvas.getContext('2d');
ctx.clearRect(0, 0, 512, 640);
ctx.fillStyle = '#fffdf4';
ctx.fillRect(0, 0, 512, 640);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 512, 36);
ctx.fillStyle = '#193b39';
ctx.textAlign = 'center';
ctx.font = '900 41px Arial, sans-serif';
ctx.fillText(title, 256, 112);
ctx.fillStyle = accent;
ctx.fillRect(102, 139, 308, 8);
ctx.textAlign = 'left';
ctx.font = '700 25px Arial, sans-serif';
lines.forEach((line, i) => {
ctx.fillStyle = line.startsWith('!') ? '#d95f49' : '#193b39';
ctx.fillText(line, 52, 205 + i * 57);
});
ctx.fillStyle = accent;
ctx.fillRect(34, 493, 444, 88);
ctx.fillStyle = '#ffffff';
ctx.textAlign = 'center';
ctx.font = '900 25px Arial, sans-serif';
ctx.fillText(status, 256, 548);
packetTexture.needsUpdate = true;
}
const packetShadow = addMesh(
new THREE.CircleGeometry(0.48, 32),
material(0x193b39, { transparent: true, opacity: 0.16, depthWrite: false }),
0, 0.18, 0
);
packetShadow.rotation.x = -Math.PI / 2;
packetShadow.castShadow = false;
const packetRing = addMesh(
new THREE.TorusGeometry(0.58, 0.035, 8, 40),
material(palette.gold, {
transparent: true,
opacity: 0.72,
emissive: palette.gold,
emissiveIntensity: 0.25
}),
0, 0.2, 0
);
packetRing.rotation.x = -Math.PI / 2;
packetRing.castShadow = false;
const permissionToken = makeSprite('✓', '#9aa69f');
permissionToken.position.set(-5.18, 1.5, 0.68);
scene.add(permissionToken);
const packetKeys = [
{ t: 0, p: new THREE.Vector3(-9.15, 1.43, 2.32) },
{ t: 4, p: new THREE.Vector3(-6.0, 1.43, 0.78) },
{ t: 8, p: new THREE.Vector3(-5.85, 1.52, 0.58) },
{ t: 10, p: new THREE.Vector3(-9.05, 1.46, 2.25) },
{ t: 13, p: new THREE.Vector3(-9.05, 1.46, 2.25) },
{ t: 15, p: new THREE.Vector3(-6.0, 1.48, 0.67) },
{ t: 18, p: new THREE.Vector3(-3.18, 1.48, 1.45) },
{ t: 21, p: new THREE.Vector3(-0.15, 1.5, 1.62) },
{ t: 26, p: new THREE.Vector3(6.92, 1.5, 0.48) },
{ t: 30, p: new THREE.Vector3(7.18, 1.62, 0.35) },
{ t: 34, p: new THREE.Vector3(7.18, 1.62, 0.35) }
];
function smooth(t) {
t = THREE.MathUtils.clamp(t, 0, 1);
return t * t * (3 - 2 * t);
}
function samplePacket(time) {
if (time <= packetKeys[0].t) return packetKeys[0].p.clone();
for (let i = 0; i < packetKeys.length - 1; i++) {
const a = packetKeys[i];
const b = packetKeys[i + 1];
if (time >= a.t && time <= b.t) {
const u = smooth((time - a.t) / (b.t - a.t));
return a.p.clone().lerp(b.p, u);
}
}
return packetKeys[packetKeys.length - 1].p.clone();
}
// DOM references
const ui = {
proposalState: document.getElementById('proposalState'),
permissionValue: document.getElementById('permissionValue'),
permissionBar: document.getElementById('permissionBar'),
completionValue: document.getElementById('completionValue'),
completionBar: document.getElementById('completionBar'),
teacherCheck: document.getElementById('teacherCheck'),
teacherCheckText: document.getElementById('teacherCheckText'),
inspectionCheck: document.getElementById('inspectionCheck'),
inspectionCheckText: document.getElementById('inspectionCheckText'),
wateringCheck: document.getElementById('wateringCheck'),
wateringCheckText: document.getElementById('wateringCheckText'),
phaseStep: document.getElementById('phaseStep'),
phaseTitle: document.getElementById('phaseTitle'),
phaseDescription: document.getElementById('phaseDescription'),
revisionBox: document.getElementById('revisionBox'),
annotation: document.getElementById('annotation'),
annotationTitle: document.getElementById('annotationTitle'),
annotationText: document.getElementById('annotationText'),
playButton: document.getElementById('playButton'),
restartButton: document.getElementById('restartButton'),
overviewButton: document.getElementById('overviewButton'),
timeline: document.getElementById('timeline'),
timelineFill: document.getElementById('timelineFill'),
timelineHead: document.getElementById('timelineHead'),
timeReadout: document.getElementById('timeReadout')
};
const phaseData = [
{
start: 0, end: 4, step: '01 · Proposal', title: 'A good idea enters the gate.',
description: 'Garden #24 proposes six raised beds beside the school, with a care roster and weekly classroom lessons.'
},
{
start: 4, end: 10, step: '02 · Teacher review', title: 'Ms. Alvarez checks the plan.',
description: 'Learning goals and the care roster pass. One practical detail still needs attention.'
},
{
start: 10, end: 15, step: '03 · Revision', title: 'One useful change.',
description: 'The proposal returns to planning so the team can solve a specific problem before any work begins.'
},
{
start: 15, end: 18, step: '04 · Permission', title: 'Approved to proceed.',
description: 'Blue records permission: the school has authorized the work. It does not mean the garden is finished.'
},
{
start: 18, end: 26, step: '05 · Volunteer work', title: 'Approval becomes action.',
description: 'Volunteers build and plant the beds. Green completion rises only as real work is completed.'
},
{
start: 26, end: 30, step: '06 · Inspection', title: 'Now the garden is checked.',
description: 'The inspector verifies paths, soil, drainage and established plants before the handoff.'
},
{
start: 30, end: 34, step: '07 · Complete', title: 'Permission and completion align.',
description: 'The work is physically complete and verified. The proposal has become a living school garden.'
}
];
function phaseIndexAt(t) {
for (let i = phaseData.length - 1; i >= 0; i--) {
if (t >= phaseData[i].start) return i;
}
return 0;
}
let elapsed = 0;
let playing = !window.matchMedia('(prefers-reduced-motion: reduce)').matches;
let previousPhase = -1;
let previousPacketKey = '';
let previousBoardState = '';
function formatTime(t) {
const seconds = Math.floor(t);
return `00:${String(seconds).padStart(2, '0')}`;
}
function setCheck(element, textElement, state, text) {
element.classList.toggle('done', state === 'done');
element.classList.toggle('revision', state === 'revision');
textElement.textContent = text;
}
function updateWorkflow(t) {
const phase = phaseIndexAt(t);
const data = phaseData[phase];
const completion = THREE.MathUtils.clamp((t - 18) / 8, 0, 1);
const completionPercent = Math.round(completion * 100);
const permissionGranted = t >= 15;
if (phase !== previousPhase) {
ui.phaseStep.textContent = data.step;
ui.phaseTitle.textContent = data.title;
ui.phaseDescription.textContent = data.description;
ui.revisionBox.classList.toggle('visible', phase === 2);
previousPhase = phase;
}
ui.proposalState.textContent =
phase === 0 ? 'Submitted' :
phase <= 2 ? 'Revision' :
phase === 3 ? 'Approved' :
phase === 4 ? 'In progress' :
phase === 5 ? 'Inspecting' : 'Verified';
ui.permissionValue.textContent = permissionGranted ? 'Granted · proceed' : 'Not granted';
ui.permissionBar.style.width = permissionGranted ? '100%' : '0%';
ui.completionValue.textContent =
t >= 30 ? '100% · verified' : `${completionPercent}% complete`;
ui.completionBar.style.width = `${completionPercent}%`;
setCheck(
ui.teacherCheck,
ui.teacherCheckText,
t >= 15 ? 'done' : t >= 10 ? 'revision' : 'pending',
t >= 15 ? 'Approved' : t >= 10 ? 'Revise' : t >= 4 ? 'Reviewing' : 'Waiting'
);
setCheck(
ui.inspectionCheck,
ui.inspectionCheckText,
t >= 30 ? 'done' : t >= 26 ? 'pending' : 'pending',
t >= 30 ? 'Verified' : t >= 26 ? 'Checking' : 'Pending'
);
setCheck(
ui.wateringCheck,
ui.wateringCheckText,
t >= 30 ? 'done' : t >= 24 ? 'pending' : 'pending',
t >= 30 ? 'Handed off' : t >= 24 ? 'Watering' : 'Pending'
);
// Packet content changes at meaningful workflow moments.
let packetKey = 'proposal';
if (phase === 1) packetKey = 'review';
if (phase === 2) packetKey = 'revision';
if (phase === 3) packetKey = 'approved';
if (phase === 4) packetKey = 'building';
if (phase === 5) packetKey = 'inspection';
if (phase === 6) packetKey = 'complete';
if (packetKey !== previousPacketKey) {
if (packetKey === 'proposal') {
drawPacket('GARDEN #24', ['6 raised beds', 'Weekly lessons', 'Care roster'], '#7357a5', 'SUBMITTED');
} else if (packetKey === 'review') {
drawPacket('TEACHER REVIEW', ['✓ Learning goals', '✓ Care roster', '! Shade plan needed'], '#7357a5', 'IN REVIEW');
} else if (packetKey === 'revision') {
drawPacket('REVISION #1', ['ADD A SHADE PLAN', 'Bed B needs 30% cover', 'Keep care roster'], '#d95f49', 'RETURN TO PLAN');
} else if (packetKey === 'approved') {
drawPacket('REVISION CLEARED', ['✓ Shade plan added', '✓ Learning goals', '✓ Care roster'], '#327fc2', 'PERMISSION GRANTED');
} else if (packetKey === 'building') {
drawPacket('WORK ORDER #24', ['Build 6 beds', 'Plant + water', 'Record completion'], '#278765', 'WORK IN PROGRESS');
} else if (packetKey === 'inspection') {
drawPacket('INSPECTION COPY', ['Check paths + tools', 'Check soil + drainage', 'Verify all 6 beds'], '#327fc2', 'READY TO VERIFY');
} else {
drawPacket('GARDEN COMPLETE', ['✓ Permission granted', '✓ Physical work done', '✓ Inspection passed'], '#278765', 'VERIFIED COMPLETE');
}
previousPacketKey = packetKey;
}
const boardState = t >= 15 ? 'approved' : t >= 10 ? 'revision' : 'review';
if (boardState !== previousBoardState) {
if (boardState === 'approved') {
drawBoard(reviewBoard, 'TEACHER REVIEW', ['Learning goals align', 'Care roster assigned', 'Shade plan included'], '#278765', 'REVIEW APPROVED · PERMISSION GRANTED');
} else if (boardState === 'revision') {
drawBoard(reviewBoard, 'TEACHER REVIEW', ['Learning goals align', 'Care roster assigned', 'Shade plan needed'], '#d95f49', 'REVISION REQUESTED · BED B');
} else {
drawBoard(reviewBoard, 'TEACHER REVIEW', ['Learning goals align', 'Care roster assigned', 'Checking shade details'], '#7357a5');
}
previousBoardState = boardState;
}
// Permission token travels from the teacher desk to the gate.
const tokenStart = new THREE.Vector3(-5.18, 1.5, 0.68);
const tokenEnd = new THREE.Vector3(-3.15, 2.72, -0.72);
if (t < 15) {
permissionToken.position.copy(tokenStart);
permissionToken.material.map.dispose();
permissionToken.material.map = makeSprite('✓', '#9aa69f').material.map;
permissionToken.material.needsUpdate = true;
} else {
permissionToken.position.copy(tokenStart);
if (!permissionToken.userData.approvedTexture) {
permissionToken.userData.approvedTexture = makeSprite('✓', '#327fc2').material.map;
}
permissionToken.material.map = permissionToken.userData.approvedTexture;
permissionToken.material.needsUpdate = true;
const u = smooth((t - 15) / 3);
permissionToken.position.lerpVectors(tokenStart, tokenEnd, u);
}
permissionLamp.material.color.set(permissionGranted ? 0x327fc2 : 0x8a9992);
permissionLamp.material.emissive.set(permissionGranted ? 0x174d77 : 0x000000);
permissionLamp.material.emissiveIntensity = permissionGranted ? 0.65 : 0;
// Physical work appears one bed at a time.
plants.forEach((plant, i) => {
const start = 18 + i * (8 / 6);
const u = smooth((t - start) / 1.1);
plant.scale.setScalar(Math.max(0.001, u));
plant.rotation.y = (i % 2 ? 0.12 : -0.08);
});
const shadeVisible = t >= 19.2;
shadeStructure.visible = shadeVisible;
shadeStructure.scale.y = shadeVisible ? 1 : 0.001;
flag.visible = t >= 30;
if (flag.visible) {
const pop = smooth((t - 30) / 1.2);
flag.scale.set(pop, pop, pop);
flagCloth.rotation.y = Math.sin(t * 2.4) * 0.05;
}
completionToken.visible = t >= 30;
if (completionToken.visible) {
const pop = smooth((t - 30) / 0.8);
completionToken.scale.set(0.64 * pop, 0.64 * pop, 1);
}
// People animate only while doing their stage.
const teacherActive = t >= 4 && t < 15;
const teacherSwing = teacherActive ? Math.sin(t * 4.4) * 0.34 : 0;
teacher.rightArm.rotation.z = teacherSwing;
teacher.leftArm.rotation.z = -teacherSwing * 0.35;
teacher.group.position.y = teacherActive ? Math.abs(Math.sin(t * 4.4)) * 0.025 : 0;
const workActive = t >= 18 && t < 26;
volunteers.forEach((person, i) => {
const phase = t * (4.2 + i * 0.16) + i * 1.7;
const swing = workActive ? Math.sin(phase) * 0.5 : 0;
person.leftArm.rotation.z = -swing;
person.rightArm.rotation.z = swing;
person.group.position.y = workActive ? Math.abs(Math.sin(phase)) * 0.035 : 0;
});
wateringCan.rotation.y = workActive ? Math.sin(t * 2.2) * 0.12 : 0;
const inspectActive = t >= 26 && t < 30;
const inspectSwing = inspectActive ? Math.sin(t * 4.6) * 0.38 : 0;
inspector.rightArm.rotation.z = -inspectSwing;
inspector.leftArm.rotation.z = inspectSwing * 0.25;
inspector.group.position.y = inspectActive ? Math.abs(Math.sin(t * 4.6)) * 0.02 : 0;
// Packet motion.
const packetPosition = samplePacket(t);
packet.position.copy(packetPosition);
packet.position.y += Math.sin(t * 4.2) * 0.045;
packet.quaternion.copy(camera.quaternion);
packet.rotation.z = Math.sin(t * 1.8) * 0.025;
packetShadow.position.set(packetPosition.x, 0.18, packetPosition.z);
packetRing.position.set(packetPosition.x, 0.2, packetPosition.z);
packetRing.material.opacity = 0.48 + Math.sin(t * 4) * 0.17;
packetRing.scale.setScalar(1 + Math.sin(t * 4) * 0.07);
// Stage rings.
const activeStage = phase <= 3 ? 0 : phase === 4 ? 1 : 2;
[
[reviewRing, 0],
[buildRing, 1],
[inspectRing, 2]
].forEach(([ring, index]) => {
ring.material.opacity = index === activeStage ? 0.88 : 0.16;
ring.scale.setScalar(index === activeStage ? 1 + Math.sin(t * 2.4) * 0.025 : 1);
});
// Annotation callouts.
ui.annotation.classList.remove('revision', 'permission', 'complete');
if (t >= 9.6 && t < 15) {
ui.annotation.className = 'annotation revision visible';
ui.annotationTitle.textContent = 'Revision requested';
ui.annotationText.textContent = 'Bed B lacks a shade plan. The proposal returns to planning.';
} else if (t >= 15 && t < 18) {
ui.annotation.className = 'annotation permission visible';
ui.annotationTitle.textContent = 'Permission granted';
ui.annotationText.textContent = 'Authorized to begin. Physical completion is still at zero.';
} else if (t >= 30) {
ui.annotation.className = 'annotation complete visible';
ui.annotationTitle.textContent = 'Completion verified';
ui.annotationText.textContent = 'Six beds planted, watered and inspected. Green means done.';
} else {
ui.annotation.className = 'annotation';
}
const percent = (t / DURATION) * 100;
ui.timelineFill.style.width = `${percent}%`;
ui.timelineHead.style.left = `${percent}%`;
ui.timeReadout.textContent = `${formatTime(t)} / ${formatTime(DURATION)}`;
ui.playButton.textContent = playing ? 'Ⅱ' : '▶';
ui.playButton.setAttribute('aria-label', playing ? 'Pause animation' : 'Play animation');
}
// World-space labels are projected to screen coordinates.
const worldLabels = [
{ element: document.querySelector('.world-label.review'), position: new THREE.Vector3(-6, 4.02, -3.65) },
{ element: document.querySelector('.world-label.build'), position: new THREE.Vector3(0, 4.02, -3.65) },
{ element: document.querySelector('.world-label.inspect'), position: new THREE.Vector3(7, 4.02, -3.65) }
];
const projected = new THREE.Vector3();
function updateWorldLabels() {
worldLabels.forEach(item => {
projected.copy(item.position).project(camera);
const visible = projected.z > -1 && projected.z < 1;
item.element.style.display = visible ? 'flex' : 'none';
item.element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
item.element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
});
}
function updateLabelActive(t) {
const phase = phaseIndexAt(t);
const stage = phase <= 3 ? 'review' : phase === 4 ? 'build' : 'inspect';
worldLabels.forEach(item => {
item.element.classList.toggle('active', item.element.dataset.stage === stage);
});
}
// Direct orbit controls, implemented without addons.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener('pointerdown', event => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener('pointermove', event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.yaw -= dx * 0.005;
orbit.pitch = THREE.MathUtils.clamp(orbit.pitch + dy * 0.004, 0.5, 1.16);
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && 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();
orbit.zoom = THREE.MathUtils.clamp(orbit.zoom * Math.exp(-event.deltaY * 0.001), 0.68, 1.65);
}, { passive: false });
renderer.domElement.addEventListener('dblclick', resetOverview);
function resetOverview() {
orbit.target.set(0, 0.55, 0);
orbit.zoom = window.innerWidth / window.innerHeight < 1 ? 0.82 : 1;
}
function focusStage(stage) {
const settings = {
review: { target: new THREE.Vector3(-5.8, 0.65, -0.4), zoom: 1.35, time: 5 },
build: { target: new THREE.Vector3(0.1, 0.65, 0.1), zoom: 1.42, time: 21 },
inspect: { target: new THREE.Vector3(7, 0.65, -0.3), zoom: 1.4, time: 27 }
}[stage];
orbit.target.copy(settings.target);
orbit.zoom = settings.zoom;
elapsed = settings.time;
playing = false;
}
document.querySelectorAll('.world-label').forEach(button => {
button.addEventListener('click', () => focusStage(button.dataset.stage));
});
document.querySelectorAll('.timeline-marker').forEach(button => {
button.addEventListener('click', event => {
event.stopPropagation();
elapsed = Number(button.dataset.time);
playing = false;
const stage = Number(button.dataset.time) < 18 ? 'review' : Number(button.dataset.time) < 26 ? 'build' : 'inspect';
const settings = {
review: new THREE.Vector3(-5.8, 0.65, -0.4),
build: new THREE.Vector3(0.1, 0.65, 0.1),
inspect: new THREE.Vector3(7, 0.65, -0.3)
};
orbit.target.copy(settings[stage]);
});
});
ui.timeline.addEventListener('click', event => {
if (event.target.closest('.timeline-marker')) return;
const rect = ui.timeline.getBoundingClientRect();
elapsed = THREE.MathUtils.clamp((event.clientX - rect.left) / rect.width, 0, 1) * DURATION;
playing = false;
});
ui.playButton.addEventListener('click', () => {
if (elapsed >= DURATION) elapsed = 0;
playing = !playing;
});
ui.restartButton.addEventListener('click', () => {
elapsed = 0;
playing = true;
resetOverview();
});
ui.overviewButton.addEventListener('click', resetOverview);
resize();
updateCamera();
updateWorkflow(elapsed);
updateWorldLabels();
updateLabelActive(elapsed);
let lastTime = performance.now();
function animate(now) {
requestAnimationFrame(animate);
const delta = Math.min(0.05, (now - lastTime) / 1000);
lastTime = now;
if (playing) {
elapsed = Math.min(DURATION, elapsed + delta);
if (elapsed >= DURATION) playing = false;
}
updateCamera();
updateWorkflow(elapsed);
updateLabelActive(elapsed);
updateWorldLabels();
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```