Prompt specification
Build or customize the Three.js 3D scene "Harvest-dry-sort-store sequence" 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: Harvest-dry-sort-store sequence
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/harvest-dry-sort-store-sequence-x1102
Scene Description Prompt:
Animate one low-poly seed batch through harvesting, drying, sorting, and storage trays without losing batch identity. One HTML file using Three.js from cdnjs.
Working Three.js Starter (harvest-dry-sort-store-sequence-x1102):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Seedline — Batch B-17</title>
<style>
:root {
--ink: #193b38;
--muted: #6e7e76;
--cream: #f5f0e6;
--paper: rgba(255, 253, 247, 0.88);
--teal: #147d73;
--orange: #ef9554;
--gold: #d7a844;
--line: rgba(25, 59, 56, 0.13);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--cream);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
display: block;
touch-action: none;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
header {
position: absolute;
top: 24px;
left: 28px;
right: 28px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
}
.brand {
max-width: 480px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 27px;
height: 2px;
background: var(--teal);
}
h1 {
margin: 0;
font-size: clamp(27px, 4vw, 49px);
line-height: 0.98;
letter-spacing: -0.055em;
}
.subtitle {
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.tracking-card {
min-width: 224px;
padding: 15px 17px;
border: 1px solid var(--line);
border-radius: 17px;
background: var(--paper);
box-shadow: 0 12px 34px rgba(39, 62, 53, 0.08);
backdrop-filter: blur(14px);
}
.tracking-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.live {
display: flex;
align-items: center;
gap: 6px;
color: var(--teal);
}
.live::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: #33a779;
box-shadow: 0 0 0 4px rgba(51, 167, 121, 0.12);
}
.metric-row {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 9px;
margin-top: 13px;
}
.metric span {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.metric strong {
display: block;
margin-top: 4px;
font-size: 16px;
font-weight: 750;
letter-spacing: -0.03em;
}
#batchTag {
position: absolute;
z-index: 5;
min-width: 112px;
padding: 8px 11px 8px 9px;
transform: translate(-50%, calc(-100% - 28px));
border: 1px solid rgba(20, 125, 115, 0.2);
border-radius: 11px;
background: rgba(255, 253, 247, 0.94);
box-shadow: 0 8px 24px rgba(25, 59, 56, 0.15);
color: var(--ink);
pointer-events: none;
text-align: center;
}
#batchTag::before {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 27px;
background: rgba(20, 125, 115, 0.45);
}
#batchTag::after {
content: "";
position: absolute;
left: calc(50% - 4px);
top: calc(100% + 24px);
width: 8px;
height: 8px;
border: 2px solid #f5f0e6;
border-radius: 50%;
background: var(--teal);
}
.batch-id {
display: flex;
align-items: center;
justify-content: center;
gap: 7px;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.batch-id i {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--gold);
box-shadow: inset 0 0 0 1px rgba(60, 42, 6, 0.12);
}
#batchStage {
margin-top: 2px;
color: var(--teal);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.bottom-panel {
position: absolute;
left: 50%;
bottom: 22px;
width: min(1040px, calc(100vw - 40px));
transform: translateX(-50%);
padding: 13px 15px 12px;
border: 1px solid var(--line);
border-radius: 20px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(39, 62, 53, 0.13);
backdrop-filter: blur(18px);
pointer-events: auto;
}
.timeline {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
}
.stage {
position: relative;
overflow: hidden;
min-width: 0;
padding: 10px 12px 9px;
border: 0;
border-radius: 11px;
background: transparent;
color: var(--muted);
cursor: pointer;
text-align: left;
transition: background 180ms ease, color 180ms ease;
}
.stage:hover {
background: rgba(20, 125, 115, 0.055);
}
.stage.active {
background: rgba(20, 125, 115, 0.09);
color: var(--teal);
}
.stage.done {
color: var(--ink);
}
.stage-fill {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 3px;
transform: scaleX(0);
transform-origin: left;
background: var(--teal);
}
.stage-number {
display: block;
margin-bottom: 3px;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
opacity: 0.65;
}
.stage-name {
display: block;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.02em;
}
.control-row {
display: flex;
align-items: center;
gap: 12px;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid var(--line);
}
.icon-button {
flex: 0 0 auto;
width: 35px;
height: 35px;
border: 0;
border-radius: 50%;
background: var(--ink);
color: white;
cursor: pointer;
font-size: 13px;
transition: transform 150ms ease, background 150ms ease;
}
.icon-button:hover {
transform: scale(1.05);
background: var(--teal);
}
.timecode {
min-width: 77px;
color: var(--muted);
font-size: 11px;
font-variant-numeric: tabular-nums;
font-weight: 700;
}
.speed-wrap {
display: flex;
align-items: center;
gap: 8px;
margin-left: auto;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
input[type="range"] {
width: 90px;
accent-color: var(--teal);
cursor: pointer;
}
.view-button {
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 9px;
background: transparent;
color: var(--ink);
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.view-button:hover {
border-color: rgba(20, 125, 115, 0.35);
color: var(--teal);
}
.hint {
position: absolute;
right: 28px;
bottom: 129px;
padding: 7px 10px;
border-radius: 9px;
background: rgba(255, 253, 247, 0.68);
color: var(--muted);
font-size: 10px;
font-weight: 650;
letter-spacing: 0.02em;
backdrop-filter: blur(10px);
}
@media (max-width: 760px) {
header {
top: 17px;
left: 18px;
right: 18px;
}
.subtitle,
.tracking-card,
.hint {
display: none;
}
.bottom-panel {
bottom: 12px;
width: calc(100vw - 24px);
padding: 9px;
}
.stage {
padding: 9px 7px;
}
.stage-name {
font-size: 10px;
}
.control-row {
gap: 8px;
}
.speed-wrap span:first-child {
display: none;
}
input[type="range"] {
width: 68px;
}
.view-button {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene"></canvas>
<div class="ui">
<header>
<div class="brand">
<div class="eyebrow">Seedline / Traceability Demo</div>
<h1>One batch.<br />Every step.</h1>
<p class="subtitle">
A low-poly seed lot moves from field harvest to dry, sort, and
storage while its identity remains locked.
</p>
</div>
<aside class="tracking-card">
<div class="tracking-top">
<span>Live traceability</span>
<span class="live">Tracking intact</span>
</div>
<div class="metric-row">
<div class="metric">
<span>Lot</span>
<strong>B-17</strong>
</div>
<div class="metric">
<span>Seeds</span>
<strong id="seedCount">30</strong>
</div>
<div class="metric">
<span>Moisture</span>
<strong id="moisture">18%</strong>
</div>
</div>
</aside>
</header>
<div id="batchTag">
<div class="batch-id"><i></i> Batch B-17</div>
<div id="batchStage">Harvesting</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom</div>
<section class="bottom-panel">
<div class="timeline">
<button class="stage active" data-stage="0">
<span class="stage-number">01</span>
<span class="stage-name">Harvest</span>
<span class="stage-fill"></span>
</button>
<button class="stage" data-stage="1">
<span class="stage-number">02</span>
<span class="stage-name">Dry</span>
<span class="stage-fill"></span>
</button>
<button class="stage" data-stage="2">
<span class="stage-number">03</span>
<span class="stage-name">Sort</span>
<span class="stage-fill"></span>
</button>
<button class="stage" data-stage="3">
<span class="stage-number">04</span>
<span class="stage-name">Store</span>
<span class="stage-fill"></span>
</button>
</div>
<div class="control-row">
<button class="icon-button" id="playButton" aria-label="Pause animation">
❚❚
</button>
<div class="timecode" id="timecode">00:00 / 00:20</div>
<div class="speed-wrap">
<span>Speed</span>
<input id="speed" type="range" min="0.5" max="2" step="0.1" value="1" />
<span id="speedValue">1×</span>
</div>
<button class="view-button" id="resetView">Reset view</button>
</div>
</section>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
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.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf4efe5);
scene.fog = new THREE.Fog(0xf4efe5, 23, 46);
const camera = new THREE.OrthographicCamera(-10, 10, 7, -7, 0.1, 100);
const target = new THREE.Vector3(0.35, 1.25, 0);
let cameraYaw = 0.28;
let cameraPitch = 0.67;
let cameraZoom = 1;
function updateCamera() {
const distance = 28;
const cosPitch = Math.cos(cameraPitch);
camera.position.set(
target.x + Math.sin(cameraYaw) * cosPitch * distance,
target.y + Math.sin(cameraPitch) * distance,
target.z + Math.cos(cameraYaw) * cosPitch * distance
);
camera.lookAt(target);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
}
function resize() {
const w = window.innerWidth;
const h = window.innerHeight;
const aspect = w / h;
const viewHeight = Math.max(12.8, 23 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(w, h);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", resize);
resize();
const hemisphere = new THREE.HemisphereLight(0xfff7df, 0x5e756d, 2.3);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff2d2, 3.1);
sun.position.set(-6, 14, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const rimLight = new THREE.DirectionalLight(0x83b9b0, 1.15);
rimLight.position.set(8, 7, -9);
scene.add(rimLight);
// ------------------------------------------------------------
// Materials and modeling helpers
// ------------------------------------------------------------
const palette = {
cream: 0xf3e9d4,
creamLight: 0xfff9e9,
dark: 0x254440,
teal: 0x147d73,
tealLight: 0x66b5a6,
orange: 0xef9554,
gold: 0xd7a844,
goldDark: 0x9d6c22,
green: 0x5d8950,
greenDark: 0x365e3d,
wood: 0x9b6c42,
woodLight: 0xc99460,
gray: 0x89958d,
charcoal: 0x304541,
white: 0xfffdf6
};
function standard(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.02,
flatShading: true,
...extra
});
}
const materials = {
cream: standard(palette.cream),
creamLight: standard(palette.creamLight),
dark: standard(palette.dark),
teal: standard(palette.teal),
tealLight: standard(palette.tealLight),
orange: standard(palette.orange),
gold: standard(palette.gold),
goldDark: standard(palette.goldDark),
green: standard(palette.green),
greenDark: standard(palette.greenDark),
wood: standard(palette.wood),
woodLight: standard(palette.woodLight),
gray: standard(palette.gray),
charcoal: standard(palette.charcoal),
white: standard(palette.white),
seed: standard(palette.gold, { roughness: 0.62 }),
seam: standard(0x8e6224)
};
function addBox(parent, w, h, d, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
topRadius,
bottomRadius,
height,
segments,
material,
x = 0,
y = 0,
z = 0
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addSphere(parent, radius, material, x = 0, y = 0, z = 0, detail = 1) {
const mesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, detail),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function createLabel(text, accent = "#147d73", width = 2.2) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 640;
labelCanvas.height = 160;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 640, 160);
ctx.fillStyle = "rgba(255, 253, 247, 0.94)";
ctx.beginPath();
ctx.roundRect(4, 4, 632, 152, 28);
ctx.fill();
ctx.fillStyle = accent;
ctx.beginPath();
ctx.roundRect(20, 27, 10, 106, 5);
ctx.fill();
ctx.fillStyle = "#193b38";
ctx.font = "800 47px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 340, 82);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, width * 0.25, 1);
sprite.renderOrder = 8;
return sprite;
}
// ------------------------------------------------------------
// Ground and conveyor
// ------------------------------------------------------------
const world = new THREE.Group();
scene.add(world);
addBox(world, 25, 0.32, 10.5, materials.cream, 0.1, -0.22, 0);
addBox(world, 25.4, 0.13, 10.9, materials.creamLight, 0.1, -0.41, 0);
const groundGrid = new THREE.GridHelper(30, 30, 0xb7b5a4, 0xd5d1c3);
groundGrid.position.y = -0.035;
groundGrid.material.transparent = true;
groundGrid.material.opacity = 0.17;
world.add(groundGrid);
const conveyor = new THREE.Group();
world.add(conveyor);
addBox(conveyor, 11.3, 0.28, 1.45, materials.charcoal, -1, 1.03, 0);
addBox(conveyor, 11.35, 0.08, 1.26, standard(0x4e625b), -1, 1.21, 0);
addBox(conveyor, 11.45, 0.14, 0.12, materials.teal, -1, 1.35, 0.77);
addBox(conveyor, 11.45, 0.14, 0.12, materials.teal, -1, 1.35, -0.77);
for (let x = -6.2; x <= 4.4; x += 0.72) {
const roller = addCylinder(
conveyor,
0.11,
0.11,
1.38,
10,
materials.gray,
x,
1.04,
0
);
roller.rotation.x = Math.PI / 2;
roller.userData.roller = true;
}
for (const x of [-5.4, -2.8, 0, 3.8]) {
addBox(conveyor, 0.16, 0.88, 0.16, materials.dark, x, 0.48, 0.58);
addBox(conveyor, 0.16, 0.88, 0.16, materials.dark, x, 0.48, -0.58);
addBox(conveyor, 0.2, 0.1, 1.35, materials.dark, x, 0.11, 0);
}
// ------------------------------------------------------------
// 01 — Harvest station
// ------------------------------------------------------------
const harvest = new THREE.Group();
harvest.position.set(-8.05, 0, 0);
world.add(harvest);
addBox(harvest, 2.15, 0.42, 2.1, materials.woodLight, 0, 0.22, 0);
addBox(harvest, 1.78, 0.12, 1.72, standard(0x6b5034), 0, 0.48, 0);
const plant = new THREE.Group();
plant.position.set(-0.15, 0.45, 0);
harvest.add(plant);
addCylinder(plant, 0.08, 0.12, 2.25, 7, materials.greenDark, 0, 1.12, 0);
for (let i = 0; i < 5; i++) {
const leaf = new THREE.Mesh(
new THREE.ConeGeometry(0.34, 0.92, 4),
i % 2 ? materials.green : materials.greenDark
);
leaf.position.set(
i % 2 ? 0.24 : -0.23,
0.62 + i * 0.25,
(i - 2) * 0.07
);
leaf.rotation.z = i % 2 ? -0.8 : 0.8;
leaf.rotation.y = i * 0.8;
leaf.castShadow = true;
plant.add(leaf);
}
const podGroup = new THREE.Group();
podGroup.position.set(-0.12, 2.15, 0);
plant.add(podGroup);
const podMaterial = standard(0xb99b45);
for (let i = 0; i < 7; i++) {
const pod = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.24, 0),
podMaterial
);
pod.scale.set(0.75, 1.55, 0.72);
pod.position.set(
(i % 3 - 1) * 0.24,
Math.floor(i / 3) * 0.25,
(Math.floor(i / 3) - 1) * 0.2
);
pod.rotation.set(i * 0.37, i * 0.61, i * 0.23);
pod.castShadow = true;
podGroup.add(pod);
}
// Simple articulated harvesting arm.
const armBase = new THREE.Group();
armBase.position.set(0.95, 0.4, 1.12);
harvest.add(armBase);
addCylinder(armBase, 0.28, 0.34, 0.22, 10, materials.dark, 0, 0.1, 0);
addCylinder(armBase, 0.12, 0.14, 0.58, 8, materials.orange, 0, 0.43, 0);
const shoulder = new THREE.Group();
shoulder.position.set(0, 0.68, 0);
armBase.add(shoulder);
addBox(shoulder, 0.24, 1.25, 0.25, materials.orange, 0, 0.58, 0);
addSphere(shoulder, 0.19, materials.dark, 0, 1.13, 0);
const forearm = new THREE.Group();
forearm.position.set(0, 1.12, 0);
shoulder.add(forearm);
addBox(forearm, 0.21, 1.05, 0.21, materials.orange, 0, 0.47, 0);
addSphere(forearm, 0.16, materials.dark, 0, 0.97, 0);
const claw = new THREE.Group();
claw.position.set(0, 0.98, 0);
forearm.add(claw);
addBox(claw, 0.07, 0.47, 0.08, materials.charcoal, -0.12, 0.2, 0);
addBox(claw, 0.07, 0.47, 0.08, materials.charcoal, 0.12, 0.2, 0);
// ------------------------------------------------------------
// 02 — Dryer
// ------------------------------------------------------------
const dryer = new THREE.Group();
dryer.position.set(-2.65, 0, 0);
world.add(dryer);
addBox(dryer, 2.35, 0.22, 2.35, materials.dark, 0, 0.25, 0);
addBox(dryer, 0.18, 2.55, 0.18, materials.teal, -1.02, 1.55, 0.93);
addBox(dryer, 0.18, 2.55, 0.18, materials.teal, 1.02, 1.55, 0.93);
addBox(dryer, 0.18, 2.55, 0.18, materials.teal, -1.02, 1.55, -0.93);
addBox(dryer, 0.18, 2.55, 0.18, materials.teal, 1.02, 1.55, -0.93);
addBox(dryer, 2.25, 0.28, 2.1, materials.teal, 0, 2.92, 0);
addBox(dryer, 1.78, 1.55, 0.08, standard(0xe8aa67, {
transparent: true,
opacity: 0.22,
depthWrite: false
}), 0, 1.83, -0.88);
addBox(dryer, 2.05, 0.08, 1.7, standard(0xef9554, {
emissive: 0x7c2f0c,
emissiveIntensity: 0.55
}), 0, 1.26, 0);
const dryerLamp = new THREE.PointLight(0xff9b4b, 2.5, 4.3);
dryerLamp.position.set(0, 2.35, 0);
dryer.add(dryerLamp);
const fan = new THREE.Group();
fan.position.set(0, 1.95, -0.77);
dryer.add(fan);
addCylinder(fan, 0.48, 0.48, 0.12, 16, materials.dark, 0, 0, 0);
fan.children[0].rotation.x = Math.PI / 2;
const fanBladeMaterial = materials.orange;
for (let i = 0; i < 4; i++) {
const blade = addBox(
fan,
0.11,
0.69,
0.07,
fanBladeMaterial,
0,
0,
0.08
);
blade.rotation.z = (i / 4) * Math.PI * 2;
blade.position.set(
Math.sin((i / 4) * Math.PI * 2) * 0.17,
Math.cos((i / 4) * Math.PI * 2) * 0.17,
0.08
);
}
const dryerCap = addCylinder(
dryer,
0.25,
0.25,
0.45,
8,
materials.orange,
0,
3.2,
0
);
// ------------------------------------------------------------
// 03 — Sorter and three quality channels
// ------------------------------------------------------------
const sorter = new THREE.Group();
sorter.position.set(2.05, 0, 0);
world.add(sorter);
addBox(sorter, 0.22, 2.45, 0.22, materials.dark, 0, 1.58, 1.04);
addBox(sorter, 0.22, 2.45, 0.22, materials.dark, 0, 1.58, -1.04);
addBox(sorter, 0.3, 0.28, 2.3, materials.dark, 0, 2.85, 0);
const scanner = addBox(
sorter,
0.08,
0.055,
1.94,
standard(0xff5f47, {
emissive: 0xff3b20,
emissiveIntensity: 1.8
}),
0.1,
2.55,
0
);
addSphere(sorter, 0.16, materials.orange, 0, 2.98, 0);
addCylinder(sorter, 0.035, 0.035, 0.45, 8, materials.dark, 0, 3.25, 0);
const laneZ = [-1.3, 0, 1.3];
const laneColors = [materials.tealLight, materials.orange, materials.gold];
const sorterFlaps = [];
laneZ.forEach((z, i) => {
const chute = new THREE.Group();
chute.position.set(1.25, 1.08, z);
sorter.add(chute);
addBox(chute, 2.2, 0.18, 0.83, materials.gray, 0, 0, 0);
addBox(chute, 2.2, 0.06, 0.1, laneColors[i], 0, 0.12, 0.43);
addBox(chute, 2.2, 0.06, 0.1, laneColors[i], 0, 0.12, -0.43);
const flap = addBox(
chute,
0.07,
0.48,
0.65,
materials.charcoal,
-0.56,
0.26,
0
);
sorterFlaps.push(flap);
});
// ------------------------------------------------------------
// 04 — Storage rack and labeled trays
// ------------------------------------------------------------
const storage = new THREE.Group();
storage.position.set(7.55, 0, 0);
world.add(storage);
for (const x of [-1.55, 1.55]) {
for (const z of [-2.0, 2.0]) {
addBox(storage, 0.16, 3.0, 0.16, materials.dark, x, 1.5, z);
}
}
addBox(storage, 3.35, 0.14, 0.16, materials.dark, 0, 2.83, -2.0);
addBox(storage, 3.35, 0.14, 0.16, materials.dark, 0, 2.83, 2.0);
addBox(storage, 3.35, 0.12, 0.16, materials.woodLight, 0, 1.32, -2.0);
addBox(storage, 3.35, 0.12, 0.16, materials.woodLight, 0, 1.32, 2.0);
const storageTrays = [];
laneZ.forEach((z, i) => {
const tray = new THREE.Group();
tray.position.set(0.1, 1.44, z);
storage.add(tray);
addBox(tray, 2.85, 0.16, 1.08, materials.woodLight, 0, 0, 0);
addBox(tray, 2.95, 0.1, 0.1, laneColors[i], 0, 0.12, 0.56);
addBox(tray, 2.95, 0.1, 0.1, laneColors[i], 0, 0.12, -0.56);
addBox(tray, 0.1, 0.1, 1.12, laneColors[i], -1.48, 0.12, 0);
addBox(tray, 0.1, 0.1, 1.12, laneColors[i], 1.48, 0.12, 0);
storageTrays.push(tray);
const label = createLabel("B-17", "#147d73", 0.74);
label.position.set(1.47, 0.46, 0);
tray.add(label);
});
// Station signs.
const harvestLabel = createLabel("01 HARVEST", "#147d73", 2.3);
harvestLabel.position.set(-8.05, 3.45, 0);
world.add(harvestLabel);
const dryLabel = createLabel("02 DRY", "#ef9554", 1.75);
dryLabel.position.set(-2.65, 3.75, 0);
world.add(dryLabel);
const sortLabel = createLabel("03 SORT", "#147d73", 1.75);
sortLabel.position.set(2.05, 3.65, 0);
world.add(sortLabel);
const storeLabel = createLabel("04 STORE", "#9d6c22", 1.85);
storeLabel.position.set(7.55, 3.4, 0);
world.add(storeLabel);
// ------------------------------------------------------------
// Particle accents
// ------------------------------------------------------------
const steamCount = 42;
const steamPositions = new Float32Array(steamCount * 3);
const steamGeometry = new THREE.BufferGeometry();
steamGeometry.setAttribute(
"position",
new THREE.BufferAttribute(steamPositions, 3)
);
const steamMaterial = new THREE.PointsMaterial({
color: 0xfff8e7,
size: 0.11,
transparent: true,
opacity: 0,
depthWrite: false
});
const steam = new THREE.Points(steamGeometry, steamMaterial);
world.add(steam);
const dustCount = 28;
const dustPositions = new Float32Array(dustCount * 3);
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dustMaterial = new THREE.PointsMaterial({
color: 0xd4a342,
size: 0.075,
transparent: true,
opacity: 0,
depthWrite: false
});
const dust = new THREE.Points(dustGeometry, dustMaterial);
world.add(dust);
// ------------------------------------------------------------
// The tracked seed batch
// ------------------------------------------------------------
const SEED_COUNT = 30;
const seedGeometry = new THREE.DodecahedronGeometry(0.13, 0);
const seamGeometry = new THREE.BoxGeometry(0.024, 0.2, 0.13);
const seeds = [];
for (let i = 0; i < SEED_COUNT; i++) {
const group = new THREE.Group();
const body = new THREE.Mesh(seedGeometry, materials.seed);
body.scale.set(0.72, 1.28, 0.66);
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const seam = new THREE.Mesh(seamGeometry, materials.seam);
seam.position.z = 0.073;
seam.castShadow = true;
group.add(seam);
const lane = i % 3;
const laneIndex = Math.floor(i / 3);
const gridX = (laneIndex % 5 - 2) * 0.39;
const gridZ = (Math.floor(laneIndex / 5) - 0.5) * 0.4;
const start = new THREE.Vector3(
-7.9 + (i % 5 - 2) * 0.12,
2.28 + (Math.floor(i / 5) % 3) * 0.13,
(Math.floor(i / 15) - 0.5) * 0.32
);
const gather = new THREE.Vector3(
-5.38 + (i % 5 - 2) * 0.17,
1.42 + Math.floor(i / 15) * 0.18,
(Math.floor(i / 5) % 3 - 1) * 0.2
);
const dryEnd = new THREE.Vector3(
-1.0 + (i % 5 - 2) * 0.12,
1.43 + Math.floor(i / 15) * 0.15,
(Math.floor(i / 5) % 3 - 1) * 0.15
);
const sortEnd = new THREE.Vector3(
4.15 + (laneIndex % 5 - 2) * 0.1,
1.43 + Math.floor(laneIndex / 5) * 0.1,
laneZ[lane] + (Math.floor(laneIndex / 5) - 0.5) * 0.13
);
const final = new THREE.Vector3(
7.62 + gridX,
1.69 + (laneIndex % 2) * 0.055,
laneZ[lane] + gridZ
);
group.position.copy(start);
group.rotation.set(
i * 0.21,
i * 0.47,
i * 0.13
);
scene.add(group);
seeds.push({
group,
start,
gather,
dryEnd,
sortEnd,
final,
lane,
laneIndex,
phase: i * 0.13
});
}
const batchHalo = new THREE.Mesh(
new THREE.TorusGeometry(0.8, 0.024, 6, 48),
new THREE.MeshBasicMaterial({
color: palette.teal,
transparent: true,
opacity: 0.68,
depthWrite: false
})
);
batchHalo.rotation.x = Math.PI / 2;
batchHalo.renderOrder = 3;
scene.add(batchHalo);
const batchHaloInner = new THREE.Mesh(
new THREE.TorusGeometry(0.58, 0.012, 5, 40),
new THREE.MeshBasicMaterial({
color: palette.tealLight,
transparent: true,
opacity: 0.45,
depthWrite: false
})
);
batchHaloInner.rotation.x = Math.PI / 2;
scene.add(batchHaloInner);
// ------------------------------------------------------------
// Timeline and UI state
// ------------------------------------------------------------
const DURATION = 20;
const stageStarts = [0, 3.5, 7.5, 11.5];
const stageEnds = [3.5, 7.5, 11.5, 20];
const stageNames = ["Harvesting", "Drying", "Sorting", "Storage"];
let timeline = 0;
let playing = true;
let playbackSpeed = 1;
let lastTime = performance.now();
const stageButtons = [...document.querySelectorAll(".stage")];
const playButton = document.querySelector("#playButton");
const speedInput = document.querySelector("#speed");
const speedValue = document.querySelector("#speedValue");
const timecode = document.querySelector("#timecode");
const moisture = document.querySelector("#moisture");
const batchStage = document.querySelector("#batchStage");
const batchTag = document.querySelector("#batchTag");
function getStage(time) {
if (time < 3.5) return 0;
if (time < 7.5) return 1;
if (time < 11.5) return 2;
return 3;
}
stageButtons.forEach((button, index) => {
button.addEventListener("click", () => {
timeline = stageStarts[index] + 0.03;
});
});
playButton.addEventListener("click", () => {
playing = !playing;
playButton.textContent = playing ? "❚❚" : "▶";
playButton.setAttribute(
"aria-label",
playing ? "Pause animation" : "Play animation"
);
});
speedInput.addEventListener("input", () => {
playbackSpeed = Number(speedInput.value);
speedValue.textContent = `${playbackSpeed.toFixed(1)}×`;
});
document.querySelector("#resetView").addEventListener("click", () => {
cameraYaw = 0.28;
cameraPitch = 0.67;
cameraZoom = 1;
updateCamera();
});
// ------------------------------------------------------------
// Custom pointer camera controls — no external addons
// ------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
cameraYaw -= dx * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + dy * 0.0045,
0.32,
1.12
);
pointerX = event.clientX;
pointerY = event.clientY;
updateCamera();
});
const stopDragging = () => {
dragging = false;
};
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("lostpointercapture", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.001),
0.68,
1.8
);
updateCamera();
},
{ passive: false }
);
// ------------------------------------------------------------
// Animation helpers
// ------------------------------------------------------------
const smoothstep = (edge0, edge1, value) => {
const x = THREE.MathUtils.clamp(
(value - edge0) / (edge1 - edge0),
0,
1
);
return x * x * (3 - 2 * x);
};
const lerp = THREE.MathUtils.lerp;
function quadratic(a, b, c, t) {
const inv = 1 - t;
return inv * inv * a + 2 * inv * t * b + t * t * c;
}
const centroid = new THREE.Vector3();
const projected = new THREE.Vector3();
function updateSeeds(time, dt) {
centroid.set(0, 0, 0);
for (const seed of seeds) {
const p = seed.group.position;
if (time < 3.5) {
// Harvest: detach from the pod and funnel onto the belt.
const u = smoothstep(0.15, 1, time / 3.5);
const controlX = (seed.start.x + seed.gather.x) * 0.5;
const controlY = Math.max(seed.start.y, seed.gather.y) + 0.65;
p.x = quadratic(seed.start.x, controlX, seed.gather.x, u);
p.y = quadratic(seed.start.y, controlY, seed.gather.y, u);
p.z = quadratic(seed.start.z, seed.start.z, seed.gather.z, u);
} else if (time < 7.5) {
// Drying: pass through the heated chamber.
const u = (time - 3.5) / 4;
p.x = lerp(seed.gather.x, seed.dryEnd.x, u);
p.y = lerp(seed.gather.y, seed.dryEnd.y, u);
p.z = lerp(seed.gather.z, seed.dryEnd.z, u);
p.y += Math.sin(time * 3 + seed.phase) * 0.022;
} else if (time < 11.5) {
// Sorting: remain visibly the same batch while entering
// one of three quality lanes.
const u = (time - 7.5) / 4;
const branch = smoothstep(0.45, 0.9, u);
p.x = lerp(seed.dryEnd.x, seed.sortEnd.x, u);
p.y = lerp(seed.dryEnd.y, seed.sortEnd.y, u);
p.z = lerp(seed.dryEnd.z, seed.sortEnd.z, branch);
} else {
// Storage: arc upward, then settle into the labeled trays.
const u = smoothstep(0, 1, (time - 11.5) / 7.2);
const controlX = 6.05;
const controlY = 3.25;
const controlZ = seed.laneZ ?? laneZ[seed.lane];
p.x = quadratic(seed.sortEnd.x, controlX, seed.final.x, u);
p.y = quadratic(seed.sortEnd.y, controlY, seed.final.y, u);
p.z = quadratic(seed.sortEnd.z, controlZ, seed.final.z, u);
}
seed.group.rotation.y += dt * (0.35 + seed.lane * 0.07);
seed.group.rotation.z = Math.sin(time * 1.6 + seed.phase) * 0.12;
centroid.add(p);
}
centroid.multiplyScalar(1 / seeds.length);
}
function updateStations(time, dt) {
const stage = getStage(time);
// Plant sway and harvesting arm.
plant.rotation.z = Math.sin(time * 1.8) * 0.035;
const harvestMotion =
stage === 0 ? Math.sin(time * 3.2) * 0.5 : -0.28;
shoulder.rotation.z = -0.48 + harvestMotion * 0.2;
forearm.rotation.z = 0.68 + harvestMotion * 0.48;
claw.rotation.y = harvestMotion * 0.35;
podGroup.scale.setScalar(
1 + Math.sin(time * 2.1) * 0.025
);
// Conveyor rollers.
conveyor.children.forEach((child) => {
if (child.userData.roller) {
child.rotation.y -= dt * 2.6;
}
});
// Dryer fan and heat.
fan.rotation.z += dt * (stage === 1 ? 8.5 : 2.2);
dryerLamp.intensity =
stage === 1 ? 2.3 + Math.sin(time * 7) * 0.5 : 0.75;
// Scanner pulse.
scanner.material.emissiveIntensity =
stage === 2 ? 1.3 + Math.sin(time * 11) * 0.8 : 0.35;
// Sorting flaps.
sorterFlaps.forEach((flap, i) => {
const targetAngle =
stage === 2 ? Math.sin(time * 4.4 + i * 1.7) * 0.38 : 0;
flap.rotation.y = lerp(flap.rotation.y, targetAngle, 0.12);
});
// Storage trays settle with a slight spring.
storageTrays.forEach((tray, i) => {
const arrival =
stage === 3
? smoothstep(11.5, 14.5 + i * 0.25, time)
: 0;
tray.position.x = 0.1 + (1 - arrival) * 0.18;
});
}
function updateParticles(time) {
const stage = getStage(time);
steamMaterial.opacity = lerp(
steamMaterial.opacity,
stage === 1 ? 0.62 : 0,
0.08
);
for (let i = 0; i < steamCount; i++) {
const seed = i / steamCount;
const age = (time * 0.42 + seed) % 1;
const spread = 0.25 + age * 0.55;
steamPositions[i * 3] =
-2.65 + Math.sin(i * 2.41 + age * 5) * spread;
steamPositions[i * 3 + 1] =
2.0 + age * 1.65 + Math.sin(i + age * 4) * 0.1;
steamPositions[i * 3 + 2] =
Math.cos(i * 1.77 + age * 4) * spread * 0.7;
}
steamGeometry.attributes.position.needsUpdate = true;
dustMaterial.opacity = lerp(
dustMaterial.opacity,
stage === 0 ? 0.58 : 0,
0.08
);
for (let i = 0; i < dustCount; i++) {
const age = (time * 0.6 + i / dustCount) % 1;
const angle = i * 2.399;
dustPositions[i * 3] =
-7.55 + Math.cos(angle) * (0.18 + age * 0.62);
dustPositions[i * 3 + 1] =
2.2 + age * 0.75 + Math.sin(i + age * 6) * 0.08;
dustPositions[i * 3 + 2] =
Math.sin(angle) * (0.18 + age * 0.62);
}
dustGeometry.attributes.position.needsUpdate = true;
}
function updateUI(time) {
const stage = getStage(time);
stageButtons.forEach((button, index) => {
const fill = button.querySelector(".stage-fill");
const localProgress = THREE.MathUtils.clamp(
(time - stageStarts[index]) /
(stageEnds[index] - stageStarts[index]),
0,
1
);
fill.style.transform = `scaleX(${localProgress})`;
button.classList.toggle("active", index === stage);
button.classList.toggle("done", index < stage);
});
const seconds = Math.floor(time);
timecode.textContent = `00:${String(seconds).padStart(2, "0")} / 00:20`;
batchStage.textContent = stageNames[stage];
let moistureValue = 18;
if (stage === 0) {
moistureValue = 18;
} else if (stage === 1) {
moistureValue = Math.round(lerp(18, 6, (time - 3.5) / 4));
} else {
moistureValue = 6;
}
moisture.textContent = `${moistureValue}%`;
projected.copy(centroid);
projected.y += 0.3;
projected.project(camera);
const screenX = (projected.x * 0.5 + 0.5) * window.innerWidth;
const screenY = (-projected.y * 0.5 + 0.5) * window.innerHeight;
batchTag.style.left = `${screenX}px`;
batchTag.style.top = `${screenY}px`;
batchTag.style.opacity = projected.z < 1 ? "1" : "0";
}
function updateBatchHalo(time) {
const stage = getStage(time);
batchHalo.position.copy(centroid);
batchHalo.position.y -= 0.24;
batchHaloInner.position.copy(centroid);
batchHaloInner.position.y -= 0.21;
const expansion =
stage === 0 ? 0.72 :
stage === 1 ? 1.0 :
stage === 2 ? 1.7 :
1.45;
batchHalo.scale.set(expansion, expansion * 0.72, 1);
batchHaloInner.scale.set(
expansion * 0.92,
expansion * 0.66,
1
);
batchHalo.rotation.z = time * 0.25;
batchHaloInner.rotation.z = -time * 0.32;
}
// ------------------------------------------------------------
// Main loop
// ------------------------------------------------------------
function animate(now) {
requestAnimationFrame(animate);
const dt = Math.min((now - lastTime) / 1000, 0.05);
lastTime = now;
if (playing) {
timeline += dt * playbackSpeed;
if (timeline >= DURATION) {
timeline %= DURATION;
}
}
updateSeeds(timeline, dt);
updateStations(timeline, dt);
updateParticles(timeline);
updateBatchHalo(timeline);
updateUI(timeline);
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```