Prompt specification
Build or customize the Three.js 3D scene "Community compost drop-off area" 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: Community compost drop-off area
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/community-compost-drop-off-area-x1047
Scene Description Prompt:
I'd like to see this as a stylized Three.js scene: community compost drop-off area. Build bins at several labeled stages, sorting table, garden beds, and wheelbarrow; residents deliver appropriate symbolic material while finished compost follows a separate route to soil. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (community-compost-drop-off-area-x1047):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Common Ground — Community Compost Commons</title>
<style>
:root {
--ink: #173d35;
--muted: #55756d;
--paper: rgba(255, 252, 241, 0.94);
--teal: #268b76;
--gold: #d58b38;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dcece4;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 10;
pointer-events: none;
border: 1px solid rgba(23, 61, 53, 0.12);
background: var(--paper);
box-shadow: 0 12px 35px rgba(24, 65, 55, 0.13);
backdrop-filter: blur(12px);
}
#title-card {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 18px 20px 17px;
border-radius: 18px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 5px rgba(38, 139, 118, 0.12);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(29px, 4vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
#title-card p {
margin: 10px 0 0;
max-width: 330px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
#status-card {
top: 22px;
right: 22px;
display: flex;
align-items: center;
gap: 10px;
padding: 11px 15px;
border-radius: 999px;
color: var(--ink);
font-size: 12px;
font-weight: 750;
}
#status-dot {
width: 9px;
height: 9px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 0 rgba(38, 139, 118, 0.4);
animation: pulse 2s infinite;
}
@keyframes pulse {
70% {
box-shadow: 0 0 0 8px rgba(38, 139, 118, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(38, 139, 118, 0);
}
}
#legend {
left: 22px;
bottom: 22px;
display: flex;
flex-wrap: wrap;
gap: 9px 18px;
max-width: min(520px, calc(100vw - 44px));
padding: 12px 15px;
border-radius: 15px;
color: var(--muted);
font-size: 11px;
font-weight: 700;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
}
.swatch {
width: 24px;
height: 4px;
border-radius: 999px;
background: var(--teal);
}
.swatch.gold {
background: var(--gold);
}
#hint {
right: 22px;
bottom: 22px;
padding: 10px 13px;
border-radius: 12px;
color: var(--muted);
font-size: 11px;
font-weight: 650;
}
@media (max-width: 700px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
#title-card p {
display: none;
}
#status-card {
top: auto;
right: 12px;
bottom: 66px;
max-width: calc(100vw - 24px);
}
#legend {
left: 12px;
bottom: 12px;
}
#hint {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<section id="title-card" class="panel">
<div class="eyebrow">A neighborhood material loop</div>
<h1>Common Ground</h1>
<p>
Residents sort leaves, food scraps, and cardboard. Finished compost then
travels by wheelbarrow to feed the community garden.
</p>
</section>
<div id="status-card" class="panel">
<span id="status-dot"></span>
<span id="status-text">Residents sorting feedstock • compost curing</span>
</div>
<div id="legend" class="panel">
<div class="legend-item">
<span class="swatch"></span>
Resident sorting route
</div>
<div class="legend-item">
<span class="swatch gold"></span>
Finished compost to garden soil
</div>
</div>
<div id="hint" class="panel">Drag to orbit · Shift-drag to pan · 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";
// ------------------------------------------------------------
// Renderer, scene, camera, and lighting
// ------------------------------------------------------------
const container = document.getElementById("scene");
const statusText = document.getElementById("status-text");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdcece4);
scene.fog = new THREE.Fog(0xdcece4, 30, 58);
const camera = new THREE.PerspectiveCamera(
43,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
container.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xf3fff7, 0x63765d, 2.1);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1cf, 3.25);
sun.position.set(-10, 18, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 48;
sun.shadow.bias = -0.0007;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9dfff, 0.65);
fill.position.set(12, 8, -10);
scene.add(fill);
const orbit = {
target: new THREE.Vector3(-0.5, 0.75, 0),
radius: 25.5,
theta: 0.67,
phi: 0.96
};
const spherical = new THREE.Spherical();
function updateCamera() {
spherical.set(orbit.radius, orbit.phi, orbit.theta);
camera.position.setFromSpherical(spherical).add(orbit.target);
camera.lookAt(orbit.target);
}
updateCamera();
// ------------------------------------------------------------
// Geometry and material helpers
// ------------------------------------------------------------
function standard(color, roughness = 0.82, metalness = 0) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: true
});
}
function box(parent, size, color, pos = [0, 0, 0]) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
standard(color)
);
mesh.position.set(pos[0], pos[1], pos[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
topRadius,
bottomRadius,
height,
color,
pos = [0, 0, 0],
segments = 10
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
standard(color)
);
mesh.position.set(pos[0], pos[1], pos[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function ball(
parent,
radius,
color,
pos = [0, 0, 0],
scale = [1, 1, 1],
detail = 1
) {
const geometry =
detail === 0
? new THREE.DodecahedronGeometry(radius, 0)
: new THREE.SphereGeometry(radius, 10, 7);
const mesh = new THREE.Mesh(geometry, standard(color));
mesh.position.set(pos[0], pos[1], pos[2]);
mesh.scale.set(scale[0], scale[1], scale[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(parent, a, b, radius, color) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, direction.length(), 8),
standard(color)
);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
function group(parent = scene, pos = [0, 0, 0]) {
const result = new THREE.Group();
result.position.set(pos[0], pos[1], pos[2]);
parent.add(result);
return result;
}
let randomSeed = 4217;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
// ------------------------------------------------------------
// Canvas-based labels and signs
// ------------------------------------------------------------
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function badgeTexture(title, subtitle, accent, kicker = "") {
const canvas = document.createElement("canvas");
canvas.width = 700;
canvas.height = 190;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.shadowColor = "rgba(15,45,37,.18)";
ctx.shadowBlur = 18;
ctx.shadowOffsetY = 7;
roundedRect(ctx, 8, 8, 684, 174, 28);
ctx.fillStyle = "#fffdf4";
ctx.fill();
ctx.shadowColor = "transparent";
roundedRect(ctx, 8, 8, 684, 174, 28);
ctx.lineWidth = 6;
ctx.strokeStyle = accent;
ctx.stroke();
let textX = 35;
if (kicker) {
ctx.fillStyle = accent;
ctx.beginPath();
ctx.arc(68, 95, 38, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#fffdf4";
ctx.font = "800 31px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(kicker, 68, 95);
textX = 123;
}
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillStyle = "#173d35";
ctx.font = "800 35px Arial, sans-serif";
ctx.fillText(title, textX, subtitle ? 74 : 95, 535);
if (subtitle) {
ctx.fillStyle = "#5a766f";
ctx.font = "500 23px Arial, sans-serif";
ctx.fillText(subtitle, textX, 122, 530);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function badge(
title,
subtitle,
accent,
kicker = "",
width = 3.15,
pos = [0, 0, 0],
parent = scene
) {
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: badgeTexture(title, subtitle, accent, kicker),
transparent: true,
depthWrite: false,
toneMapped: false
})
);
sprite.scale.set(width, width * 190 / 700, 1);
sprite.position.set(pos[0], pos[1], pos[2]);
sprite.renderOrder = 5;
parent.add(sprite);
return sprite;
}
function panelTexture(text, background = "#173d35", foreground = "#fffaf0") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
roundedRect(ctx, 4, 4, 504, 120, 18);
ctx.fillStyle = background;
ctx.fill();
ctx.fillStyle = foreground;
ctx.font = "800 39px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 64, 470);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function panel(
parent,
text,
width,
height,
pos,
background = "#173d35",
foreground = "#fffaf0"
) {
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: panelTexture(text, background, foreground),
toneMapped: false
})
);
mesh.position.set(pos[0], pos[1], pos[2]);
parent.add(mesh);
return mesh;
}
// ------------------------------------------------------------
// Ground, courtyard, paths, fences, and planting
// ------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(42, 32),
standard(0x8ebc78)
);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
box(scene, [18.7, 0.12, 13.7], 0xd8c9aa, [-5.2, 0.02, -0.2]);
box(scene, [10.4, 0.13, 14.7], 0xbba37d, [7.2, 0.015, 0.2]);
// Paver accents around the sorting area.
for (let i = 0; i < 8; i++) {
box(
scene,
[1.65, 0.075, 0.7],
i % 2 ? 0xe4d6b9 : 0xcdbd9d,
[-10.2 + (i % 4) * 1.82, 0.12, 3.8 + Math.floor(i / 4) * 0.9]
);
}
// Fence at the back.
for (let x = -13; x <= 2.5; x += 1.5) {
box(scene, [0.16, 1.75, 0.16], 0x8b6847, [x, 0.82, -8.15]);
}
box(scene, [16.4, 0.13, 0.13], 0x9b7450, [-5.25, 0.75, -8.15]);
box(scene, [16.4, 0.13, 0.13], 0x9b7450, [-5.25, 1.35, -8.15]);
// Fence on the garden edge.
for (let z = -7; z <= 6; z += 1.5) {
box(scene, [0.16, 1.65, 0.16], 0x8b6847, [11.45, 0.78, z]);
}
box(scene, [0.13, 0.13, 13.8], 0x9b7450, [11.45, 0.7, -0.5]);
box(scene, [0.13, 0.13, 13.8], 0x9b7450, [11.45, 1.25, -0.5]);
function makeTree(x, z, scale = 1) {
const tree = group(scene, [x, 0, z]);
tree.scale.setScalar(scale);
cylinder(tree, 0.22, 0.34, 2.7, 0x79583b, [0, 1.35, 0], 8);
beam(tree, [0, 1.7, 0], [-0.7, 2.7, 0.1], 0.12, 0x79583b);
beam(tree, [0, 1.9, 0], [0.65, 2.85, -0.1], 0.12, 0x79583b);
ball(tree, 1.15, 0x4f8d58, [0, 3.15, 0], [1, 1.12, 0.95], 0);
ball(tree, 0.86, 0x6ca565, [-0.65, 2.75, 0.12], [1, 0.9, 1], 0);
ball(tree, 0.82, 0x78b56d, [0.72, 2.9, -0.08], [1, 0.94, 1], 0);
return tree;
}
makeTree(-12.2, -6.6, 1.05);
makeTree(-12.5, 3.8, 0.9);
makeTree(10.3, -6.4, 1.12);
makeTree(12.8, 7.7, 0.82);
function makeBush(x, z, size = 1) {
const bush = group(scene, [x, 0, z]);
bush.scale.setScalar(size);
ball(bush, 0.55, 0x5a9858, [0, 0.48, 0], [1, 0.75, 1], 0);
ball(bush, 0.43, 0x78ad67, [0.43, 0.42, 0.05], [1, 0.78, 1], 0);
ball(bush, 0.38, 0x4e8951, [-0.37, 0.38, 0.02], [1, 0.75, 1], 0);
}
[
[-10.8, -2.1], [-9.6, -6.4], [3.6, -6.5],
[10.3, 1.1], [3.1, 7.3], [-9.8, 7.0]
].forEach((p, i) => makeBush(p[0], p[1], 0.8 + (i % 3) * 0.12));
// Small grass tufts.
for (let i = 0; i < 34; i++) {
const x = -16 + random() * 32;
const z = -7.7 + random() * 15;
if (x > -14.5 && x < 3.8 && z > -7 && z < 6.4) continue;
if (x > 2.3 && x < 11.7 && z > -7.2 && z < 7.4) continue;
const tuft = group(scene, [x, 0.08, z]);
for (let j = 0; j < 3; j++) {
const blade = cylinder(
tuft,
0,
0.055,
0.35 + random() * 0.2,
j % 2 ? 0x6ea25f : 0x91b66c,
[(j - 1) * 0.09, 0.2, (random() - 0.5) * 0.08],
5
);
blade.rotation.z = (j - 1) * 0.25;
}
}
// ------------------------------------------------------------
// Route helpers
// ------------------------------------------------------------
function flatRoute(curve, color, width = 0.16, dashed = false) {
const count = 90;
for (let i = 0; i < count; i++) {
if (dashed && i % 3 === 0) continue;
const a = curve.getPointAt(i / count);
const b = curve.getPointAt((i + 1) / count);
const middle = a.clone().add(b).multiplyScalar(0.5);
const dx = b.x - a.x;
const dz = b.z - a.z;
const length = Math.hypot(dx, dz);
const yaw = -Math.atan2(dz, dx);
const segment = box(
scene,
[length * 1.04, 0.038, width],
color,
[middle.x, 0.13, middle.z]
);
segment.rotation.y = yaw;
}
}
function groundArrow(x, z, yaw, color, scale = 1) {
const shape = new THREE.Shape();
shape.moveTo(0.42, 0);
shape.lineTo(-0.13, 0.25);
shape.lineTo(-0.03, 0);
shape.lineTo(-0.13, -0.25);
shape.closePath();
const holder = group(scene, [x, 0.16, z]);
holder.rotation.y = yaw;
holder.scale.setScalar(scale);
const arrow = new THREE.Mesh(
new THREE.ShapeGeometry(shape),
standard(color)
);
arrow.rotation.x = -Math.PI / 2;
arrow.receiveShadow = true;
holder.add(arrow);
return holder;
}
const leafRouteCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-11.5, 0, 7.2),
new THREE.Vector3(-9.8, 0, 5.0),
new THREE.Vector3(-8.2, 0, 3.3),
new THREE.Vector3(-7.4, 0, 2.15)
]);
const foodRouteCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.7, 0, 8.4),
new THREE.Vector3(-2.8, 0, 6.1),
new THREE.Vector3(-4.0, 0, 3.7),
new THREE.Vector3(-4.2, 0, 2.15)
]);
const cardboardRouteCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-8.8, 0, 8.1),
new THREE.Vector3(-7.5, 0, 6.1),
new THREE.Vector3(-6.1, 0, 3.9),
new THREE.Vector3(-5.8, 0, 2.15)
]);
flatRoute(leafRouteCurve, 0x2b967f, 0.12, true);
flatRoute(foodRouteCurve, 0x2b967f, 0.12, true);
flatRoute(cardboardRouteCurve, 0x2b967f, 0.12, true);
// ------------------------------------------------------------
// Sorting table
// ------------------------------------------------------------
const table = group(scene, [-5.8, 0, 0.7]);
for (const x of [-2.25, 2.25]) {
for (const z of [-0.58, 0.58]) {
box(table, [0.18, 1.08, 0.18], 0x8b6545, [x, 0.58, z]);
}
}
box(table, [5.25, 0.18, 1.7], 0xb68b59, [0, 1.12, 0]);
box(table, [5.05, 0.08, 1.5], 0xd1aa76, [0, 1.25, 0]);
const bays = [
{ x: -1.75, color: 0x5eaa58, text: "LEAVES", ink: "#173d35" },
{ x: 0, color: 0xe5a23c, text: "SCRAPS", ink: "#4a3215" },
{ x: 1.75, color: 0xb48b62, text: "CARDBOARD", ink: "#fffaf0" }
];
for (const bay of bays) {
box(table, [1.55, 0.055, 1.28], bay.color, [bay.x, 1.31, 0]);
panel(table, bay.text, 1.38, 0.3, [bay.x, 0.93, 0.87], "#fffaf0", bay.ink);
}
box(table, [0.08, 0.11, 1.46], 0x8e6543, [-0.87, 1.34, 0]);
box(table, [0.08, 0.11, 1.46], 0x8e6543, [0.87, 1.34, 0]);
badge(
"SORTING TABLE",
"Match each material to its bay",
"#2b8f79",
"",
3.55,
[0, 2.4, 0.05],
table
);
// A small compost thermometer and clipboard make the workbench legible.
box(table, [0.48, 0.05, 0.68], 0xf1e8d2, [-2.05, 1.37, -0.2]);
cylinder(table, 0.035, 0.035, 0.62, 0xd2644e, [-2.05, 1.65, -0.2], 7);
ball(table, 0.075, 0xe8d3aa, [-2.05, 1.98, -0.2]);
// ------------------------------------------------------------
// Compost bins
// ------------------------------------------------------------
function makeBin(x, accent, title, subtitle, kicker, content) {
const bin = group(scene, [x, 0.1, -4.7]);
const width = 1.88;
const depth = 1.58;
box(bin, [width, 0.16, depth], 0x765137, [0, 0.08, 0]);
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
box(
bin,
[0.15, 1.58, 0.15],
0x805b3d,
[sx * (width / 2 - 0.08), 0.82, sz * (depth / 2 - 0.08)]
);
}
}
for (let row = 0; row < 4; row++) {
const y = 0.32 + row * 0.34;
const shade = row % 2 ? 0xb38656 : 0xc19561;
box(bin, [width, 0.24, 0.11], shade, [0, y, depth / 2]);
box(bin, [width, 0.24, 0.11], shade, [0, y, -depth / 2]);
box(bin, [0.11, 0.24, depth], shade, [-width / 2, y, 0]);
box(bin, [0.11, 0.24, depth], shade, [width / 2, y, 0]);
}
box(bin, [width + 0.08, 0.13, depth + 0.08], accent, [0, 1.58, 0]);
box(bin, [1.52, 0.55, 0.075], accent, [0, 0.83, depth / 2 + 0.07]);
panel(
bin,
kicker,
0.62,
0.34,
[0, 0.84, depth / 2 + 0.12],
"#fffaf0",
accent
);
// Fill material visible from above.
box(bin, [1.61, 0.09, 1.31], 0x46372a, [0, 1.28, 0]);
if (content === "green") {
for (let i = 0; i < 16; i++) {
const leaf = ball(
bin,
0.19,
i % 3 === 0 ? 0x85b953 : 0x4f914e,
[
(random() - 0.5) * 1.4,
1.38 + random() * 0.16,
(random() - 0.5) * 1.05
],
[1.15, 0.25, 0.62],
0
);
leaf.rotation.y = random() * Math.PI;
leaf.rotation.z = (random() - 0.5) * 0.5;
}
} else if (content === "food") {
for (let i = 0; i < 13; i++) {
ball(
bin,
0.13 + random() * 0.06,
i % 2 ? 0xe7a23e : 0xc95b48,
[
(random() - 0.5) * 1.35,
1.42 + random() * 0.12,
(random() - 0.5) * 1.05
],
[1, 0.75, 1],
0
);
}
} else {
for (let i = 0; i < 14; i++) {
ball(
bin,
0.14 + random() * 0.08,
i % 3 === 0 ? 0x5c432b : 0x765233,
[
(random() - 0.5) * 1.34,
1.39 + random() * 0.13,
(random() - 0.5) * 1.04
],
[1, 0.65, 1],
0
);
}
}
badge(
title,
subtitle,
accent,
kicker,
2.82,
[0, 2.33, 0],
bin
);
return bin;
}
makeBin(-7.4, 0x58a85b, "LEAVES INTAKE", "Carbon-rich dry greens", "01", "green");
makeBin(-4.6, 0xe1a13d, "FOOD SCRAPS", "Nitrogen-rich kitchen waste", "02", "food");
makeBin(-1.6, 0x8b6847, "ACTIVE COMPOST", "Mixing and curing stage", "03", "compost");
makeBin(1.45, 0x367f56, "READY COMPOST", "Finished soil amendment", "04", "compost");
// Teal sorting arrows lead from the table toward the correct intake bins.
groundArrow(-7.4, -2.25, Math.PI / 2, 0x2b8f79, 1.15);
groundArrow(-4.6, -2.15, Math.PI / 2, 0x2b8f79, 1.15);
// Subtle process arrows between compost stages.
groundArrow(-3.1, -4.65, -Math.PI / 2, 0x8b9e78, 0.78);
groundArrow(0.0, -4.65, -Math.PI / 2, 0x8b9e78, 0.78);
// ------------------------------------------------------------
// Garden beds and crops
// ------------------------------------------------------------
function makePlant(x, z, type = "lettuce") {
const plant = group(scene, [x, 0.39, z]);
if (type === "tomato") {
cylinder(plant, 0.035, 0.055, 0.95, 0x477b3c, [0, 0.48, 0], 6);
beam(plant, [0, 0.7, 0], [-0.27, 0.98, 0.05], 0.025, 0x477b3c);
beam(plant, [0, 0.88, 0], [0.3, 1.08, -0.03], 0.025, 0x477b3c);
ball(plant, 0.11, 0xd95d48, [-0.17, 0.87, 0.12], [1, 0.9, 1], 0);
ball(plant, 0.105, 0xe46b50, [0.2, 1.02, -0.08], [1, 0.9, 1], 0);
ball(plant, 0.09, 0xd95743, [0.04, 0.55, 0.15], [1, 0.9, 1], 0);
} else if (type === "beans") {
cylinder(plant, 0.025, 0.04, 1.28, 0x548744, [0, 0.64, 0], 6);
ball(plant, 0.3, 0x68a653, [-0.18, 0.78, 0], [1, 0.35, 0.65], 0);
ball(plant, 0.28, 0x78b25d, [0.2, 1.02, 0.03], [1, 0.35, 0.65], 0);
} else {
ball(plant, 0.27, 0x70a958, [0, 0.15, 0], [1, 0.65, 1], 0);
ball(plant, 0.2, 0x89bd65, [-0.2, 0.18, 0.05], [1, 0.55, 1], 0);
ball(plant, 0.19, 0x95c975, [0.2, 0.19, -0.04], [1, 0.55, 1], 0);
ball(plant, 0.13, 0x5b974d, [0, 0.31, 0.02], [1, 0.55, 1], 0);
}
}
function makeGardenBed(x, z, crop) {
const bed = group(scene, [x, 0.1, z]);
const width = 4.45;
const depth = 2.48;
box(bed, [width, 0.42, depth], 0x795338, [0, 0.21, 0]);
box(bed, [width - 0.18, 0.18, depth - 0.18], 0x4d3929, [0, 0.43, 0]);
for (const sy of [-1, 1]) {
box(bed, [width + 0.12, 0.27, 0.14], 0xb08050, [0, 0.23, sy * depth / 2]);
box(bed, [width + 0.12, 0.27, 0.14], 0xc09562, [0, 0.47, sy * depth / 2]);
}
for (const sx of [-1, 1]) {
box(bed, [0.14, 0.27, depth + 0.12], 0xa97c4e, [sx * width / 2, 0.23, 0]);
box(bed, [0.14, 0.27, depth + 0.12], 0xc09562, [sx * width / 2, 0.47, 0]);
}
for (let row = 0; row < 2; row++) {
for (let col = 0; col < 4; col++) {
makePlant(
x - 1.42 + col * 0.94,
z - 0.55 + row * 1.1,
crop
);
}
}
return bed;
}
makeGardenBed(8.0, -2.65, "tomato");
makeGardenBed(8.0, 3.65, "lettuce");
// Fresh compost patch at the receiving end of the lower bed.
for (let i = 0; i < 16; i++) {
ball(
scene,
0.12 + random() * 0.07,
i % 3 === 0 ? 0x60452d : 0x7b5937,
[
6.08 + random() * 0.9,
0.66 + random() * 0.06,
3.2 + random() * 0.85
],
[1.2, 0.55, 1],
0
);
}
// Garden sign.
const gardenSign = group(scene, [8.3, 0, 6.55]);
for (const x of [-0.65, 0.65]) {
box(gardenSign, [0.12, 1.75, 0.12], 0x8d6745, [x, 0.88, 0]);
}
box(gardenSign, [1.75, 0.75, 0.13], 0xf4ead2, [0, 1.65, 0]);
panel(gardenSign, "GROW", 1.45, 0.52, [0, 1.65, 0.075], "#367f56", "#fffaf0");
// ------------------------------------------------------------
// Finished-compost route and wheelbarrow
// ------------------------------------------------------------
const compostRoute = new THREE.CatmullRomCurve3([
new THREE.Vector3(1.45, 0, -3.22),
new THREE.Vector3(2.55, 0, -2.35),
new THREE.Vector3(3.75, 0, -1.35),
new THREE.Vector3(4.25, 0, 0.55),
new THREE.Vector3(4.65, 0, 2.35),
new THREE.Vector3(5.25, 0, 3.48)
]);
flatRoute(compostRoute, 0xd58b38, 0.19, false);
for (const t of [0.18, 0.46, 0.74]) {
const p = compostRoute.getPointAt(t);
const tangent = compostRoute.getTangentAt(t);
groundArrow(
p.x,
p.z,
-Math.atan2(tangent.z, tangent.x),
0xe4a04b,
1.12
);
}
badge(
"FINISHED COMPOST",
"Separate route to garden soil",
"#d58b38",
"",
3.45,
[3.65, 1.65, 0.4]
);
function makeWheelbarrow() {
const barrow = group(scene, [1.45, 0, -3.22]);
// Tray.
box(barrow, [1.28, 0.1, 1.12], 0x3a8e83, [0, 0.91, 0]);
box(barrow, [1.28, 0.48, 0.09], 0x3a8e83, [0, 1.13, 0.54]);
box(barrow, [1.28, 0.48, 0.09], 0x3a8e83, [0, 1.13, -0.54]);
box(barrow, [0.09, 0.48, 1.08], 0x3a8e83, [-0.61, 1.13, 0]);
box(barrow, [0.09, 0.48, 1.08], 0x3a8e83, [0.61, 1.13, 0]);
// Frame and handles.
for (const x of [-0.48, 0.48]) {
beam(barrow, [x, 0.78, 0.65], [x, 0.83, -1.75], 0.055, 0x46534c);
beam(barrow, [x, 0.72, -0.15], [x, 0.12, -0.38], 0.045, 0x46534c);
box(barrow, [0.14, 0.13, 0.43], 0x77563b, [x, 0.83, -1.78]);
}
// Wheel.
const wheelSpin = group(barrow, [0, 0.43, 0.77]);
const wheel = new THREE.Mesh(
new THREE.TorusGeometry(0.32, 0.11, 8, 16),
standard(0x29322f, 0.95)
);
wheel.rotation.y = Math.PI / 2;
wheel.castShadow = true;
wheelSpin.add(wheel);
const hub = cylinder(wheelSpin, 0.11, 0.11, 0.25, 0xb0b6ad, [0, 0, 0], 10);
hub.rotation.z = Math.PI / 2;
// Compost load.
const load = group(barrow);
for (let i = 0; i < 14; i++) {
ball(
load,
0.16 + random() * 0.08,
i % 3 === 0 ? 0x5a4028 : 0x795436,
[
(random() - 0.5) * 0.95,
1.05 + random() * 0.15,
(random() - 0.5) * 0.78
],
[1.15, 0.6, 1],
0
);
}
barrow.userData = { wheelSpin, load };
return barrow;
}
const wheelbarrow = makeWheelbarrow();
const compostParticles = [];
let lastDumpCycle = -1;
function triggerCompostParticles() {
const start = new THREE.Vector3(0, 1.2, 0.25);
wheelbarrow.localToWorld(start);
for (let i = 0; i < 23; i++) {
const particle = ball(
scene,
0.065 + random() * 0.045,
i % 3 === 0 ? 0x503722 : 0x765237,
[0, -10, 0],
[1, 0.7, 1],
0
);
const end = new THREE.Vector3(
6.05 + random() * 0.95,
0.66 + random() * 0.08,
3.15 + random() * 0.85
);
compostParticles.push({
mesh: particle,
start: start.clone(),
end,
born: elapsed + i * 0.035
});
}
}
// ------------------------------------------------------------
// People and symbolic material
// ------------------------------------------------------------
function makeLeafBundle(scale = 1) {
const bundle = group();
bundle.scale.setScalar(scale);
beam(bundle, [0, 0, 0], [0, 0.1, 0.72], 0.022, 0x6c4c2f);
for (let i = 0; i < 5; i++) {
const leaf = ball(
bundle,
0.17,
i % 2 ? 0x5d9e4e : 0x79b45d,
[(i - 2) * 0.13, 0.05 + Math.abs(i - 2) * 0.025, i * 0.13],
[0.62, 0.16, 1.45],
0
);
leaf.rotation.y = (i - 2) * 0.2;
leaf.rotation.x = (i % 2 ? 1 : -1) * 0.13;
}
return bundle;
}
function makeAppleCore(scale = 1) {
const core = group();
core.scale.setScalar(scale);
ball(core, 0.16, 0xd9c096, [0, 0, 0], [1, 1.35, 0.95], 0);
ball(core, 0.13, 0xc85443, [0, 0.15, 0], [1, 0.36, 1], 0);
ball(core, 0.13, 0xc85443, [0, -0.15, 0], [1, 0.36, 1], 0);
beam(core, [0, 0.19, 0], [0.04, 0.37, 0], 0.025, 0x60442c);
const leaf = ball(
core,
0.11,
0x609b4d,
[0.11, 0.35, 0],
[0.55, 0.12, 1.15],
0
);
leaf.rotation.z = -0.3;
return core;
}
function makeCardboard(scale = 1) {
const cardboard = group();
cardboard.scale.setScalar(scale);
box(cardboard, [0.52, 0.28, 0.1], 0xc6965d, [0, 0, 0]);
box(cardboard, [0.48, 0.025, 0.012], 0x9c7044, [0, 0.03, 0.056]);
box(cardboard, [0.025, 0.25, 0.012], 0x9c7044, [0, 0, 0.056]);
return cardboard;
}
function makePerson(shirtColor, pantsColor, skinColor, hairColor) {
const person = group();
const torso = new THREE.Mesh(
new THREE.CapsuleGeometry(0.28, 0.38, 4, 8),
standard(shirtColor)
);
torso.position.y = 1.08;
torso.castShadow = true;
person.add(torso);
ball(person, 0.235, skinColor, [0, 1.76, 0], [1, 1.06, 0.96]);
const hair = new THREE.Mesh(
new THREE.SphereGeometry(0.242, 10, 6, 0, Math.PI * 2, 0, Math.PI * 0.56),
standard(hairColor)
);
hair.position.set(0, 1.79, -0.015);
hair.castShadow = true;
person.add(hair);
ball(person, 0.025, 0x26332f, [-0.077, 1.79, 0.215], [1, 1.15, 0.55]);
ball(person, 0.025, 0x26332f, [0.077, 1.79, 0.215], [1, 1.15, 0.55]);
const legs = [];
for (const side of [-1, 1]) {
const pivot = group(person, [side * 0.14, 0.7, 0]);
cylinder(pivot, 0.105, 0.12, 0.56, pantsColor, [0, -0.28, 0], 8);
box(pivot, [0.23, 0.16, 0.4], 0x39433d, [0, -0.59, 0.07]);
legs.push(pivot);
}
const arms = [];
for (const side of [-1, 1]) {
const pivot = group(person, [side * 0.34, 1.38, 0]);
cylinder(pivot, 0.09, 0.105, 0.45, shirtColor, [0, -0.22, 0], 8);
ball(pivot, 0.105, skinColor, [0, -0.48, 0]);
arms.push(pivot);
}
person.userData = { legs, arms };
return person;
}
function animatePerson(person, moving, phase, carrying = false) {
const { legs, arms } = person.userData;
const stride = moving ? Math.sin(phase * 9) * 0.58 : 0;
legs[0].rotation.x = stride;
legs[1].rotation.x = -stride;
arms[0].rotation.x = carrying
? -0.28 + Math.sin(phase * 9) * 0.22
: -stride * 0.72;
arms[1].rotation.x = carrying
? -1.08
: stride * 0.72;
arms[0].rotation.z = carrying ? -0.12 : 0;
arms[1].rotation.z = carrying ? 0.08 : 0;
}
const carryPosition = new THREE.Vector3(0.43, 1.02, 0.42);
function createDelivery(config) {
const person = makePerson(
config.shirt,
config.pants,
config.skin,
config.hair
);
const item = config.item();
person.add(item);
item.position.copy(carryPosition);
const inbound = new THREE.CatmullRomCurve3(
config.inbound.map(p => new THREE.Vector3(...p))
);
const outbound = new THREE.CatmullRomCurve3(
config.outbound.map(p => new THREE.Vector3(...p))
);
const delivery = {
person,
item,
inbound,
outbound,
target: new THREE.Vector3(...config.target),
config,
phase: "wait",
phaseTime: config.delay,
progress: 0,
targetLocal: carryPosition.clone()
};
person.visible = false;
return delivery;
}
const deliveries = [
createDelivery({
name: "Leaf resident",
destination: "the LEAVES bay",
shirt: 0xe2a846,
pants: 0x385a70,
skin: 0xc9825c,
hair: 0x3d302b,
item: () => makeLeafBundle(0.85),
inbound: [
[-11.5, 0, 7.2],
[-9.8, 0, 5.0],
[-8.2, 0, 3.3],
[-7.4, 0, 2.15]
],
outbound: [
[-7.4, 0, 2.15],
[-8.9, 0, 3.7],
[-11.7, 0, 5.8]
],
target: [-7.55, 1.34, 0.72],
delay: 0.3,
inDuration: 5.8,
outDuration: 4.7
}),
createDelivery({
name: "Food-scrap resident",
destination: "the SCRAPS bay",
shirt: 0x5d91b8,
pants: 0x735744,
skin: 0x8d5b42,
hair: 0x292623,
item: () => makeAppleCore(0.9),
inbound: [
[-1.7, 0, 8.4],
[-2.8, 0, 6.1],
[-4.0, 0, 3.7],
[-4.2, 0, 2.15]
],
outbound: [
[-4.2, 0, 2.15],
[-3.2, 0, 4.0],
[-1.2, 0, 6.1]
],
target: [-4.15, 1.34, 0.72],
delay: 4.0,
inDuration: 5.4,
outDuration: 4.5
}),
createDelivery({
name: "Cardboard resident",
destination: "the CARDBOARD bay",
shirt: 0x8a6caf,
pants: 0x3e6250,
skin: 0xe0aa7e,
hair: 0x78513a,
item: () => makeCardboard(0.9),
inbound: [
[-8.8, 0, 8.1],
[-7.5, 0, 6.1],
[-6.1, 0, 3.9],
[-5.8, 0, 2.15]
],
outbound: [
[-5.8, 0, 2.15],
[-6.5, 0, 4.1],
[-8.7, 0, 6.5]
],
target: [-5.8, 1.34, 0.72],
delay: 8.2,
inDuration: 5.2,
outDuration: 4.5
})
];
// Sorting attendant behind the table.
const attendant = makePerson(
0x385f52,
0x384b43,
0xa86e4d,
0x302a27
);
attendant.position.set(-5.8, 0, -0.65);
attendant.rotation.y = 0;
scene.add(attendant);
// Static materials waiting to be sorted.
const tableLeaf = makeLeafBundle(0.75);
tableLeaf.position.set(-6.95, 1.38, 0.35);
scene.add(tableLeaf);
const tableApple = makeAppleCore(0.8);
tableApple.position.set(-4.0, 1.38, -0.2);
scene.add(tableApple);
const tableCard = makeCardboard(0.75);
tableCard.position.set(-5.65, 1.38, -0.28);
scene.add(tableCard);
// ------------------------------------------------------------
// Delivery animation
// ------------------------------------------------------------
function easeOutCubic(t) {
return 1 - Math.pow(1 - t, 3);
}
function updateDeliveries(dt) {
for (const delivery of deliveries) {
const { person, item, inbound, outbound, config } = delivery;
delivery.phaseTime += dt;
if (delivery.phase === "wait") {
if (delivery.phaseTime >= config.delay) {
delivery.phase = "in";
delivery.phaseTime = 0;
delivery.progress = 0;
person.visible = true;
item.visible = true;
item.scale.setScalar(1);
}
continue;
}
if (delivery.phase === "in") {
delivery.progress += dt / config.inDuration;
const t = Math.min(delivery.progress, 1);
const position = inbound.getPointAt(t);
const tangent = inbound.getTangentAt(Math.min(t, 0.999));
person.position.copy(position);
person.rotation.y = Math.atan2(tangent.x, tangent.z);
animatePerson(person, true, delivery.phaseTime);
if (t >= 1) {
delivery.phase = "deposit";
delivery.phaseTime = 0;
delivery.targetLocal = person.worldToLocal(delivery.target.clone());
const direction = delivery.target.clone().sub(person.position);
person.rotation.y = Math.atan2(direction.x, direction.z);
}
} else if (delivery.phase === "deposit") {
const t = Math.min(delivery.phaseTime / 0.72, 1);
const eased = easeOutCubic(t);
item.position.lerpVectors(carryPosition, delivery.targetLocal, eased);
item.rotation.y = eased * 0.8;
if (t > 0.68) {
const scale = 1 - (t - 0.68) / 0.32;
item.scale.setScalar(Math.max(0.001, scale));
}
animatePerson(person, false, delivery.phaseTime, true);
if (delivery.phaseTime > 1.12) {
delivery.phase = "out";
delivery.phaseTime = 0;
delivery.progress = 0;
item.visible = false;
}
} else if (delivery.phase === "out") {
delivery.progress += dt / config.outDuration;
const t = Math.min(delivery.progress, 1);
const position = outbound.getPointAt(t);
const tangent = outbound.getTangentAt(Math.min(t, 0.999));
person.position.copy(position);
person.rotation.y = Math.atan2(tangent.x, tangent.z);
animatePerson(person, true, delivery.phaseTime);
if (t >= 1) {
delivery.phase = "wait";
delivery.phaseTime = 0;
person.visible = false;
item.visible = false;
}
}
}
}
// ------------------------------------------------------------
// Wheelbarrow animation and compost particles
// ------------------------------------------------------------
function updateWheelbarrow(dt) {
const cycleLength = 18;
const cycleTime = elapsed % cycleLength;
const cycleIndex = Math.floor(elapsed / cycleLength);
const start = compostRoute.getPointAt(0);
const end = compostRoute.getPointAt(1);
if (cycleTime < 8.3) {
const t = cycleTime / 8.3;
const p = compostRoute.getPointAt(t);
const tangent = compostRoute.getTangentAt(Math.min(t, 0.999));
wheelbarrow.position.copy(p);
wheelbarrow.rotation.y = Math.atan2(tangent.x, tangent.z);
wheelbarrow.rotation.x = 0;
wheelbarrow.userData.load.visible = true;
} else if (cycleTime < 10.5) {
wheelbarrow.position.copy(end);
wheelbarrow.rotation.x = 0.34;
wheelbarrow.userData.load.visible = false;
if (cycleIndex !== lastDumpCycle) {
lastDumpCycle = cycleIndex;
triggerCompostParticles();
}
} else if (cycleTime < 17.2) {
const t = (cycleTime - 10.5) / 6.7;
const p = compostRoute.getPointAt(1 - t);
const tangent = compostRoute.getTangentAt(Math.max(0.001, 1 - t));
wheelbarrow.position.copy(p);
wheelbarrow.rotation.y = Math.atan2(tangent.x, tangent.z);
wheelbarrow.rotation.x = 0;
wheelbarrow.userData.load.visible = false;
} else {
wheelbarrow.position.copy(start);
wheelbarrow.rotation.x = 0;
wheelbarrow.userData.load.visible = false;
}
wheelbarrow.userData.wheelSpin.rotation.x -= dt * 7;
}
function updateParticles() {
for (let i = compostParticles.length - 1; i >= 0; i--) {
const particle = compostParticles[i];
const age = elapsed - particle.born;
if (age < 0) {
particle.mesh.visible = false;
continue;
}
if (age > 1.35) {
scene.remove(particle.mesh);
particle.mesh.geometry.dispose();
compostParticles.splice(i, 1);
continue;
}
particle.mesh.visible = true;
const t = age / 1.35;
const position = particle.start.clone().lerp(particle.end, t);
position.y += Math.sin(t * Math.PI) * 0.72;
particle.mesh.position.copy(position);
particle.mesh.rotation.x += 0.07;
particle.mesh.rotation.z += 0.05;
particle.mesh.scale.setScalar(1 - t * 0.35);
}
}
// ------------------------------------------------------------
// Custom camera controls
// ------------------------------------------------------------
const pointer = {
down: false,
x: 0,
y: 0,
button: 0,
panning: false
};
const canvas = renderer.domElement;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
pointer.down = true;
pointer.x = event.clientX;
pointer.y = event.clientY;
pointer.button = event.button;
pointer.panning = event.button === 2 || event.shiftKey;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointerup", event => {
pointer.down = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
pointer.down = false;
});
canvas.addEventListener("pointermove", event => {
if (!pointer.down) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (pointer.panning || event.shiftKey) {
const right = new THREE.Vector3();
const forward = new THREE.Vector3();
camera.matrix.update();
right.setFromMatrixColumn(camera.matrix, 0);
forward.set(-camera.matrix.elements[8], 0, -camera.matrix.elements[10]);
const scale = orbit.radius * 0.00125;
orbit.target.addScaledVector(right, -dx * scale);
orbit.target.addScaledVector(forward, dy * scale);
} else {
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi + dy * 0.005, 0.38, 1.38);
}
updateCamera();
});
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.018,
13,
35
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
orbit.target.set(-0.5, 0.75, 0);
orbit.radius = 25.5;
orbit.theta = 0.67;
orbit.phi = 0.96;
updateCamera();
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
// ------------------------------------------------------------
// Main animation loop
// ------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
updateDeliveries(dt);
updateWheelbarrow(dt);
updateParticles();
// Sorting attendant moves material across the workbench.
const workerSwing = Math.sin(elapsed * 2.8);
attendant.userData.arms[0].rotation.x = -0.85 + workerSwing * 0.42;
attendant.userData.arms[1].rotation.x = -0.82 - workerSwing * 0.42;
tableLeaf.rotation.y = elapsed * 0.18;
tableApple.rotation.y = elapsed * 0.3;
// Dynamic status text.
const depositing = deliveries.find(d => d.phase === "deposit");
const cycleTime = elapsed % 18;
if (cycleTime >= 8.3 && cycleTime < 10.5) {
statusText.textContent = "Wheelbarrow delivering finished compost to garden soil";
} else if (depositing) {
statusText.textContent = `${depositing.config.name} → ${depositing.config.destination}`;
} else {
statusText.textContent = "Residents sorting feedstock • active compost curing";
}
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```