Prompt specification
Build or customize the Three.js 3D scene "Harvest grain collection yard" 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 grain collection yard
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/harvest-grain-collection-yard-x1067
Scene Description Prompt:
Create a standalone stylized scene in one HTML file using Three.js from cdnjs. Compose sacks, small silo, weighing platform, and covered loading area; grain moves through receiving and storage stages while each batch retains a clear identity marker.
Working Three.js Starter (harvest-grain-collection-yard-x1067):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Grain Trace — Batch Handling Yard</title>
<style>
:root {
--ink: #183a38;
--muted: #6c7770;
--paper: #fffaf0;
--line: rgba(24, 58, 56, 0.16);
--coral: #d96048;
--teal: #3b8f8a;
--gold: #d79c32;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8dfcf;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#app {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.glass {
background: rgba(255, 250, 240, 0.9);
border: 1px solid rgba(255, 255, 255, 0.72);
box-shadow: 0 14px 40px rgba(53, 58, 47, 0.13);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
header {
position: absolute;
top: 22px;
left: 24px;
z-index: 5;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
color: #45625d;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #4a9d67;
box-shadow: 0 0 0 5px rgba(74, 157, 103, 0.13);
animation: pulse 1.8s infinite;
}
@keyframes pulse {
50% { box-shadow: 0 0 0 9px rgba(74, 157, 103, 0); }
}
h1 {
margin: 0;
font-size: clamp(26px, 3vw, 42px);
line-height: 0.98;
letter-spacing: -0.045em;
font-weight: 850;
}
.subtitle {
max-width: 440px;
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
#trace-panel {
position: absolute;
top: 22px;
right: 24px;
z-index: 6;
width: 285px;
border-radius: 18px;
padding: 17px;
}
.panel-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 13px;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.panel-title span:last-child {
color: var(--muted);
font-size: 9px;
letter-spacing: 0.08em;
}
.batch-row {
position: relative;
display: grid;
grid-template-columns: 12px 1fr;
gap: 10px;
padding: 10px;
margin: 4px 0;
border-radius: 12px;
cursor: pointer;
transition: background 160ms ease, transform 160ms ease;
}
.batch-row:hover,
.batch-row.active {
background: rgba(24, 58, 56, 0.065);
}
.batch-row.active { transform: translateX(-2px); }
.batch-dot {
width: 10px;
height: 10px;
margin-top: 4px;
border-radius: 50%;
box-shadow: 0 0 0 4px color-mix(in srgb, var(--batch) 18%, transparent);
}
.batch-main {
min-width: 0;
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
}
.batch-main b {
font-size: 14px;
letter-spacing: 0.025em;
}
.batch-main small {
color: var(--muted);
font-size: 10px;
white-space: nowrap;
}
.mini-track {
height: 3px;
margin-top: 8px;
overflow: hidden;
border-radius: 4px;
background: rgba(24, 58, 56, 0.09);
}
.mini-track i {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--batch);
transition: width 120ms linear;
}
.panel-note {
margin-top: 10px;
padding-top: 11px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
#flow-legend {
position: absolute;
left: 24px;
bottom: 22px;
z-index: 5;
display: flex;
align-items: center;
gap: 9px;
padding: 12px 15px;
border-radius: 14px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.legend-step {
display: flex;
align-items: center;
gap: 6px;
white-space: nowrap;
}
.legend-step em {
display: grid;
place-items: center;
width: 19px;
height: 19px;
border-radius: 50%;
background: var(--ink);
color: var(--paper);
font-style: normal;
font-size: 9px;
}
.legend-arrow {
color: #9aa49c;
font-weight: 400;
}
#controls {
position: absolute;
right: 24px;
bottom: 22px;
z-index: 7;
display: flex;
align-items: center;
gap: 7px;
padding: 8px;
border-radius: 14px;
}
button {
border: 0;
border-radius: 9px;
padding: 9px 12px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: background 150ms ease, transform 150ms ease;
}
button:hover {
background: rgba(24, 58, 56, 0.09);
}
button:active { transform: scale(0.96); }
button.primary {
background: var(--ink);
color: var(--paper);
}
button.primary:hover { background: #28504d; }
.hint {
position: absolute;
right: 26px;
bottom: 75px;
z-index: 5;
color: rgba(24, 58, 56, 0.58);
font-size: 10px;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #e8dfcf;
transition: opacity 500ms ease;
}
#loading.hide { opacity: 0; pointer-events: none; }
.loader {
width: 42px;
height: 42px;
border: 3px solid rgba(24, 58, 56, 0.16);
border-top-color: var(--ink);
border-radius: 50%;
animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 780px) {
header { top: 16px; left: 16px; }
.subtitle { max-width: 280px; font-size: 11px; }
#trace-panel {
top: auto;
right: 14px;
bottom: 76px;
width: 235px;
padding: 12px;
}
.panel-note { display: none; }
#flow-legend { display: none; }
#controls { right: 14px; bottom: 14px; }
.hint { display: none; }
}
@media (max-width: 470px) {
.eyebrow { font-size: 9px; }
h1 { font-size: 28px; }
.subtitle { display: none; }
#trace-panel {
width: 205px;
bottom: 72px;
}
.batch-row { padding: 7px; }
.batch-main small { font-size: 9px; }
}
</style>
</head>
<body>
<div id="app"></div>
<header>
<div class="eyebrow">
<span class="live-dot"></span>
Live material flow · Yard 04
</div>
<h1>Grain in motion.</h1>
<p class="subtitle">
Follow every lot from receiving and weighing into storage and covered loading.
</p>
</header>
<aside id="trace-panel" class="glass">
<div class="panel-title">
<span>Live lot trace</span>
<span>3 active batches</span>
</div>
<div class="batch-row active" data-batch="0" style="--batch: var(--coral)">
<span class="batch-dot" style="background: var(--coral)"></span>
<div>
<div class="batch-main">
<b>A-17</b>
<small id="stage-0">Receiving</small>
</div>
<div class="mini-track"><i id="bar-0"></i></div>
</div>
</div>
<div class="batch-row" data-batch="1" style="--batch: var(--teal)">
<span class="batch-dot" style="background: var(--teal)"></span>
<div>
<div class="batch-main">
<b>B-23</b>
<small id="stage-1">Storage</small>
</div>
<div class="mini-track"><i id="bar-1"></i></div>
</div>
</div>
<div class="batch-row" data-batch="2" style="--batch: var(--gold)">
<span class="batch-dot" style="background: var(--gold)"></span>
<div>
<div class="batch-main">
<b>C-08</b>
<small id="stage-2">Outbound</small>
</div>
<div class="mini-track"><i id="bar-2"></i></div>
</div>
</div>
<div class="panel-note">
Select a batch to follow its marker. Color and lot code remain attached
through every handling stage.
</div>
</aside>
<div id="flow-legend" class="glass">
<div class="legend-step"><em>1</em> Receive</div>
<span class="legend-arrow">→</span>
<div class="legend-step"><em>2</em> Weigh</div>
<span class="legend-arrow">→</span>
<div class="legend-step"><em>3</em> Store</div>
<span class="legend-arrow">→</span>
<div class="legend-step"><em>4</em> Load</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Select a lot to follow</div>
<div id="controls" class="glass">
<button id="pause" class="primary" aria-label="Pause grain flow">Pause flow</button>
<button id="zoom-in" aria-label="Zoom in">+</button>
<button id="zoom-out" aria-label="Zoom out">−</button>
<button id="reset">Overview</button>
</div>
<div id="loading"><div class="loader"></div></div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const loadingOverlay = document.getElementById("loading");
// ---------------------------------------------------------------------
// Renderer, scene and camera
// ---------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8dfcf);
scene.fog = new THREE.Fog(0xe8dfcf, 30, 52);
const camera = new THREE.OrthographicCamera(-10, 10, 7, -7, 0.1, 100);
const hemi = new THREE.HemisphereLight(0xfff6df, 0x788276, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0cf, 3.3);
sun.position.set(9, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 38;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc5e4df, 0.8);
fill.position.set(-8, 7, -7);
scene.add(fill);
// ---------------------------------------------------------------------
// Palette and helpers
// ---------------------------------------------------------------------
const C = {
ink: 0x183a38,
deep: 0x244845,
teal: 0x477d78,
paleTeal: 0x9dbab1,
cream: 0xf2e5cc,
paper: 0xfff9ec,
sand: 0xd7c39e,
concrete: 0xb9b9a8,
darkConcrete: 0x8d9185,
steel: 0x6f8079,
yellow: 0xe8b74a,
gold: 0xe0a42d,
rust: 0xb85f42,
coral: 0xd96048,
batchTeal: 0x3b8f8a,
batchGold: 0xd79c32,
black: 0x263432
};
const mat = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.76,
metalness: 0,
...options
});
const M = {
ink: mat(C.ink),
deep: mat(C.deep),
teal: mat(C.teal),
paleTeal: mat(C.paleTeal),
cream: mat(C.cream),
paper: mat(C.paper),
sand: mat(C.sand),
concrete: mat(C.concrete),
darkConcrete: mat(C.darkConcrete),
steel: mat(C.steel, { metalness: 0.28, roughness: 0.58 }),
yellow: mat(C.yellow),
gold: mat(C.gold, { roughness: 0.58 }),
rust: mat(C.rust),
black: mat(C.black),
belt: mat(0x3d4742, { roughness: 0.9 }),
grain: mat(0xe8ac37, { roughness: 0.72 }),
glass: mat(0xb8d7cf, {
transparent: true,
opacity: 0.35,
roughness: 0.18,
metalness: 0.05
})
};
function box(w, h, d, x, y, z, material, parent = scene, shadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = shadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(rt, rb, h, x, y, z, material, parent = scene, segments = 24) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rt, rb, h, segments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(a, b, radius, material, parent = scene) {
const av = new THREE.Vector3(...a);
const bv = new THREE.Vector3(...b);
const direction = bv.clone().sub(av);
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, direction.length(), 12),
material
);
mesh.position.copy(av).add(bv).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function outline(mesh, color = 0x284542, opacity = 0.34) {
const edges = new THREE.EdgesGeometry(mesh.geometry, 25);
const lines = new THREE.LineSegments(
edges,
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
mesh.add(lines);
return lines;
}
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 textureFromCanvas(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function batchTexture(code, color) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 144;
const ctx = canvas.getContext("2d");
ctx.shadowColor = "rgba(20,40,38,.20)";
ctx.shadowBlur = 16;
ctx.shadowOffsetY = 6;
roundedRect(ctx, 8, 8, 496, 128, 24);
ctx.fillStyle = "#fffaf0";
ctx.fill();
ctx.shadowColor = "transparent";
roundedRect(ctx, 8, 8, 28, 128, 18);
ctx.fillStyle = color;
ctx.fill();
ctx.strokeStyle = "rgba(24,58,56,.16)";
ctx.lineWidth = 3;
roundedRect(ctx, 8, 8, 496, 128, 24);
ctx.stroke();
ctx.fillStyle = "#183a38";
ctx.font = "800 54px system-ui, sans-serif";
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillText(code, 58, 69);
ctx.fillStyle = "#6c7770";
ctx.font = "700 18px system-ui, sans-serif";
ctx.letterSpacing = "3px";
ctx.fillText("ACTIVE LOT", 302, 72);
return textureFromCanvas(canvas);
}
function worldLabelTexture(title, subtitle, accent = "#183a38") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 180;
const ctx = canvas.getContext("2d");
roundedRect(ctx, 10, 10, 620, 160, 28);
ctx.fillStyle = "rgba(255,250,240,.96)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 8;
ctx.stroke();
ctx.fillStyle = accent;
ctx.font = "850 47px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(title, 320, 69);
ctx.fillStyle = "#6c7770";
ctx.font = "700 23px system-ui, sans-serif";
ctx.fillText(subtitle, 320, 122);
return textureFromCanvas(canvas);
}
function labelSprite(texture, width, height, alwaysVisible = false) {
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: !alwaysVisible
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, height, 1);
if (alwaysVisible) sprite.renderOrder = 30;
return sprite;
}
// ---------------------------------------------------------------------
// Ground and yard
// ---------------------------------------------------------------------
const ground = box(17, 0.48, 11.5, 0, -0.31, 0, M.sand);
outline(ground, 0x927f61, 0.2);
const yard = box(12.6, 0.08, 6.7, -0.1, 0, 1.0, M.concrete);
yard.receiveShadow = true;
box(12.25, 0.025, 0.07, -0.1, 0.055, 4.15, M.paper, scene, false);
box(12.25, 0.025, 0.07, -0.1, 0.055, -2.15, M.paper, scene, false);
box(0.07, 0.025, 6.3, -6.25, 0.055, 1.0, M.paper, scene, false);
box(0.07, 0.025, 6.3, 6.05, 0.055, 1.0, M.paper, scene, false);
for (let i = 0; i < 7; i++) {
box(0.03, 0.018, 6.0, -5.5 + i * 1.65, 0.045, 1.0,
mat(0x9da095), scene, false);
}
// Soft decorative aggregate around the slab.
const stoneGeo = new THREE.IcosahedronGeometry(0.07, 0);
const stoneMat = mat(0xbba984);
for (let i = 0; i < 48; i++) {
const stone = new THREE.Mesh(stoneGeo, stoneMat);
stone.position.set(
-7.7 + Math.random() * 15.4,
0,
-4.9 + Math.random() * 10
);
if (Math.abs(stone.position.x) < 6.3 &&
stone.position.z > -2.2 && stone.position.z < 4.4) {
stone.position.x = Math.random() < 0.5 ? -7.3 : 7.3;
}
stone.scale.set(0.7 + Math.random(), 0.5, 0.8 + Math.random());
stone.rotation.set(Math.random(), Math.random(), Math.random());
stone.receiveShadow = true;
scene.add(stone);
}
// ---------------------------------------------------------------------
// Conveyor construction
// ---------------------------------------------------------------------
const zAxis = new THREE.Vector3(0, 0, 1);
function makeConveyor(startArray, endArray, width = 0.82) {
const start = new THREE.Vector3(...startArray);
const end = new THREE.Vector3(...endArray);
const direction = end.clone().sub(start);
const length = direction.length();
const group = new THREE.Group();
group.position.copy(start).add(end).multiplyScalar(0.5);
group.quaternion.setFromUnitVectors(zAxis, direction.clone().normalize());
scene.add(group);
box(width, 0.16, length, 0, 0, 0, M.belt, group);
box(0.11, 0.28, length, width / 2 + 0.03, 0.14, 0, M.steel, group);
box(0.11, 0.28, length, -width / 2 - 0.03, 0.14, 0, M.steel, group);
for (let z = -length / 2 + 0.3; z < length / 2; z += 0.64) {
const roller = new THREE.Mesh(
new THREE.CylinderGeometry(0.105, 0.105, width + 0.1, 12),
M.darkConcrete
);
roller.rotation.z = Math.PI / 2;
roller.position.set(0, 0.12, z);
roller.castShadow = true;
group.add(roller);
}
const count = Math.max(2, Math.floor(length / 1.1));
for (let i = 0; i < count; i++) {
const t = i / (count - 1);
const p = start.clone().lerp(end, t);
const side = new THREE.Vector3(width / 2 + 0.06, 0, 0);
const lateral = side.applyQuaternion(group.quaternion);
beam(
[p.x - lateral.x, 0.08, p.z - lateral.z],
[p.x + lateral.x, 0.08, p.z + lateral.z],
0.07,
M.darkConcrete
);
}
return group;
}
// ---------------------------------------------------------------------
// Receiving hopper
// ---------------------------------------------------------------------
const hopper = new THREE.Group();
hopper.position.set(-5.25, 0, 0.9);
scene.add(hopper);
const funnel = new THREE.Mesh(
new THREE.CylinderGeometry(1.08, 0.46, 1.28, 4, 1, true),
mat(C.teal, { side: THREE.DoubleSide })
);
funnel.rotation.y = Math.PI / 4;
funnel.position.y = 3.02;
funnel.castShadow = true;
funnel.receiveShadow = true;
hopper.add(funnel);
outline(funnel);
for (const x of [-0.72, 0.72]) {
for (const z of [-0.62, 0.62]) {
beam([x, 0.08, z], [x * 0.83, 2.65, z * 0.83], 0.075, M.ink, hopper);
}
}
beam([-0.66, 0.4, -0.58], [0.66, 2.25, -0.58], 0.045, M.steel, hopper);
beam([0.66, 0.4, -0.58], [-0.66, 2.25, -0.58], 0.045, M.steel, hopper);
const grainSurface = new THREE.Mesh(
new THREE.CircleGeometry(0.84, 32),
M.grain
);
grainSurface.rotation.x = -Math.PI / 2;
grainSurface.position.y = 3.46;
grainSurface.receiveShadow = true;
hopper.add(grainSurface);
for (let i = 0; i < 24; i++) {
const kernel = new THREE.Mesh(
new THREE.SphereGeometry(0.045 + Math.random() * 0.025, 7, 5),
M.grain
);
const a = Math.random() * Math.PI * 2;
const r = Math.sqrt(Math.random()) * 0.72;
kernel.position.set(Math.cos(a) * r, 3.5 + Math.random() * 0.06,
Math.sin(a) * r);
kernel.scale.y = 1.5;
hopper.add(kernel);
}
box(2.1, 0.16, 0.13, 0, 3.67, -0.84, M.ink, hopper);
box(2.1, 0.16, 0.13, 0, 3.67, 0.84, M.ink, hopper);
box(0.13, 0.16, 1.8, -0.98, 3.67, 0, M.ink, hopper);
box(0.13, 0.16, 1.8, 0.98, 3.67, 0, M.ink, hopper);
const receiveLabel = labelSprite(
worldLabelTexture("01 RECEIVING", "HOPPER INTAKE", "#477d78"),
2.15, 0.6
);
receiveLabel.position.set(-5.25, 4.42, 0.9);
scene.add(receiveLabel);
// ---------------------------------------------------------------------
// Weighing platform
// ---------------------------------------------------------------------
const scaleGroup = new THREE.Group();
scaleGroup.position.set(-1.72, 0, 0.9);
scene.add(scaleGroup);
box(2.05, 0.78, 1.65, 0, 0.45, 0, M.deep, scaleGroup);
box(2.18, 0.14, 1.78, 0, 0.9, 0, M.yellow, scaleGroup);
box(1.83, 0.09, 1.43, 0, 1.01, 0, M.steel, scaleGroup);
for (let i = 0; i < 6; i++) {
box(0.16, 0.04, 1.45, -0.78 + i * 0.31, 1.075, 0,
M.darkConcrete, scaleGroup, false);
}
beam([-2.9, 0.05, 1.6], [-2.9, 2.3, 1.6], 0.065, M.ink, scaleGroup);
box(1.35, 0.68, 0.12, -2.55, 2.25, 1.6, M.ink, scaleGroup);
const displayCanvas = document.createElement("canvas");
displayCanvas.width = 512;
displayCanvas.height = 220;
const displayCtx = displayCanvas.getContext("2d");
displayCtx.fillStyle = "#193b38";
displayCtx.fillRect(0, 0, 512, 220);
displayCtx.fillStyle = "#e8c65d";
displayCtx.font = "800 64px monospace";
displayCtx.textAlign = "center";
displayCtx.fillText("128.4 kg", 256, 102);
displayCtx.fillStyle = "#92b8ae";
displayCtx.font = "700 25px system-ui";
displayCtx.fillText("NET WEIGHT · A-17", 256, 158);
const displayTexture = textureFromCanvas(displayCanvas);
const display = new THREE.Mesh(
new THREE.PlaneGeometry(1.2, 0.52),
new THREE.MeshBasicMaterial({ map: displayTexture })
);
display.position.set(-2.55, 2.25, 1.67);
scaleGroup.add(display);
const scaleLabel = labelSprite(
worldLabelTexture("02 WEIGHING", "CALIBRATED PLATFORM", "#d79c32"),
2.0, 0.56
);
scaleLabel.position.set(-1.65, 2.92, 0.85);
scene.add(scaleLabel);
// ---------------------------------------------------------------------
// Small silo
// ---------------------------------------------------------------------
const silo = new THREE.Group();
silo.position.set(0.35, 0, -2.65);
scene.add(silo);
cylinder(1.42, 1.42, 0.28, 0, 0.19, 0, M.darkConcrete, silo);
cylinder(1.24, 1.24, 4.0, 0, 2.62, 0, M.cream, silo, 32);
cylinder(1.36, 1.36, 0.18, 0, 1.05, 0, M.teal, silo, 32);
cylinder(1.36, 1.36, 0.16, 0, 3.73, 0, M.teal, silo, 32);
const roof = new THREE.Mesh(
new THREE.ConeGeometry(1.48, 1.03, 32),
M.teal
);
roof.position.y = 5.12;
roof.castShadow = true;
silo.add(roof);
cylinder(0.18, 0.18, 0.46, 0, 5.82, 0, M.steel, silo);
cylinder(0.27, 0.27, 0.12, 0, 6.08, 0, M.yellow, silo);
// Front access door.
box(0.85, 1.4, 0.12, -0.42, 1.25, 1.245, M.deep, silo);
box(0.1, 0.1, 0.1, -0.13, 1.27, 1.33, M.yellow, silo);
// Grain sight glass.
const sight = new THREE.Mesh(
new THREE.CircleGeometry(0.2, 24),
M.gold
);
sight.position.set(0.48, 3.15, 1.245);
silo.add(sight);
const sightRim = new THREE.Mesh(
new THREE.TorusGeometry(0.23, 0.045, 10, 24),
M.ink
);
sightRim.position.set(0.48, 3.15, 1.25);
silo.add(sightRim);
// Ladder.
for (const x of [-1.35, -1.68]) {
beam([x, 0.2, 0.18], [x, 4.6, 0.18], 0.035, M.ink, silo);
}
for (let y = 0.48; y < 4.5; y += 0.42) {
beam([-1.35, y, 0.19], [-1.68, y, 0.19], 0.027, M.ink, silo);
}
// Intake pipe.
beam([0, 4.72, 0], [0, 5.28, 0], 0.16, M.steel, silo);
box(0.46, 0.16, 0.46, 0, 5.28, 0, M.yellow, silo);
const siloLabel = labelSprite(
worldLabelTexture("03 STORAGE", "SILO 01 · LOT SIGHT GLASS", "#477d78"),
2.3, 0.64
);
siloLabel.position.set(0.45, 6.65, -2.55);
scene.add(siloLabel);
// Colored storage-level ticks echo the live batch colors.
[C.coral, C.batchTeal, C.batchGold].forEach((color, i) => {
box(0.28, 0.055, 0.035, 0.78, 2.35 + i * 0.3, 1.25,
mat(color), silo, false);
});
// ---------------------------------------------------------------------
// Conveyors linking the stages
// ---------------------------------------------------------------------
makeConveyor([-4.67, 2.03, 0.9], [-2.55, 1.37, 0.9], 0.82);
makeConveyor([-0.72, 1.42, 0.86], [0.35, 4.92, -2.48], 0.68);
makeConveyor([1.2, 1.18, -1.63], [4.62, 1.27, 0.77], 0.72);
// Outbound belt support legs.
beam([2.1, 0.05, -0.5], [2.1, 1.16, -0.5], 0.06, M.ink);
beam([3.55, 0.05, 0.23], [3.55, 1.2, 0.23], 0.06, M.ink);
// ---------------------------------------------------------------------
// Covered loading area
// ---------------------------------------------------------------------
const loading = new THREE.Group();
loading.position.set(5.0, 0, 1.0);
scene.add(loading);
box(4.35, 0.56, 4.1, 0, 0.3, 0, M.darkConcrete, loading);
box(4.05, 0.11, 3.82, 0, 0.63, 0, M.concrete, loading);
// Rear wall and roller door.
box(4.0, 2.8, 0.15, 0, 2.08, -1.95, M.paleTeal, loading);
box(2.15, 2.05, 0.1, 0, 1.75, -1.84, M.cream, loading);
for (let y = 0.85; y < 2.7; y += 0.19) {
box(2.0, 0.035, 0.025, 0, y, -1.775, M.steel, loading, false);
}
// Four posts.
for (const x of [-1.82, 1.82]) {
for (const z of [-1.7, 1.7]) {
box(0.17, 3.55, 0.17, x, 2.42, z, M.ink, loading);
box(0.3, 0.13, 0.3, x, 0.73, z, M.yellow, loading);
}
}
// Broad shallow canopy with visible corrugation.
const canopy = box(4.75, 0.25, 4.35, 0, 4.24, 0, M.teal, loading);
outline(canopy);
for (let z = -2.0; z <= 2.01; z += 0.34) {
box(4.55, 0.055, 0.055, 0, 4.39, z, M.paleTeal, loading, false);
}
box(4.85, 0.26, 0.15, 0, 4.12, 2.12, M.ink, loading);
box(4.85, 0.26, 0.15, 0, 4.12, -2.12, M.ink, loading);
// Safety bumpers.
for (const x of [-1.48, 1.48]) {
for (let i = 0; i < 4; i++) {
const bumper = box(0.2, 0.62, 0.18, x, 1.08, 1.55 + i * 0.1,
i % 2 ? M.ink : M.yellow, loading);
bumper.rotation.x = -0.16;
}
}
const loadingLabel = labelSprite(
worldLabelTexture("04 COVERED LOADING", "CLEAN & PROTECTED", "#477d78"),
2.8, 0.75
);
loadingLabel.position.set(5.0, 4.95, 1.65);
scene.add(loadingLabel);
// Pallets.
function makePallet(x, z, parent = scene) {
for (let i = 0; i < 5; i++) {
box(1.6, 0.08, 0.17, x, 0.12, z - 0.45 + i * 0.225,
mat(0xa87b4e), parent);
}
box(1.45, 0.12, 0.12, x, 0.02, z - 0.36, mat(0x7f5b3b), parent);
box(1.45, 0.12, 0.12, x, 0.02, z + 0.36, mat(0x7f5b3b), parent);
}
makePallet(0.45, 4.05);
makePallet(2.55, 4.05);
makePallet(4.72, 4.05);
// ---------------------------------------------------------------------
// Identity-tagged sacks
// ---------------------------------------------------------------------
const sackGeo = new THREE.SphereGeometry(0.48, 18, 12);
const knotGeo = new THREE.SphereGeometry(0.13, 12, 8);
function makeSack(x, z, code, color, rotation = 0, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.12, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
const sackMat = mat(0xd7c39c, { roughness: 0.96 });
const body = new THREE.Mesh(sackGeo, sackMat);
body.scale.set(1, 1.32, 0.83);
body.position.y = 0.58;
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const neck = cylinder(0.13, 0.18, 0.22, 0, 1.21, 0,
mat(color), group, 12);
const knot = new THREE.Mesh(knotGeo, mat(color));
knot.position.set(0.04, 1.34, 0);
knot.scale.set(1.2, 0.7, 0.8);
knot.castShadow = true;
group.add(knot);
const tag = labelSprite(batchTexture(code, color), 0.86, 0.24);
tag.position.set(0, 1.67, 0);
group.add(tag);
return group;
}
makeSack(-0.12, 4.03, "A-17", "#d96048", -0.08, 1.02);
makeSack(0.67, 4.08, "A-17", "#d96048", 0.12, 0.98);
makeSack(1.43, 4.04, "A-17", "#d96048", -0.1, 1.03);
makeSack(2.08, 4.04, "B-23", "#3b8f8a", 0.08, 1.0);
makeSack(2.83, 4.08, "B-23", "#3b8f8a", -0.13, 1.04);
makeSack(3.56, 4.04, "B-23", "#3b8f8a", 0.12, 0.97);
makeSack(4.32, 4.04, "C-08", "#d79c32", -0.08, 1.02);
makeSack(5.08, 4.04, "C-08", "#d79c32", 0.1, 1.0);
makeSack(5.81, 4.04, "C-08", "#d79c32", -0.12, 0.97);
// A few stored bags under the canopy.
makeSack(4.22, 1.38, "A-17", "#d96048", 0.12, 0.92);
makeSack(5.02, 1.4, "B-23", "#3b8f8a", -0.1, 0.92);
makeSack(5.82, 1.38, "C-08", "#d79c32", 0.08, 0.92);
// ---------------------------------------------------------------------
// Continuous grain route and visible moving grain
// ---------------------------------------------------------------------
const routePoints = [
new THREE.Vector3(-5.25, 3.46, 0.90),
new THREE.Vector3(-4.67, 2.03, 0.90),
new THREE.Vector3(-3.35, 1.59, 0.90),
new THREE.Vector3(-1.72, 1.35, 0.90),
new THREE.Vector3(-0.60, 1.52, 0.65),
new THREE.Vector3(0.35, 4.92, -2.48),
new THREE.Vector3(0.35, 5.32, -2.48),
new THREE.Vector3(0.48, 3.20, -2.48),
new THREE.Vector3(1.20, 1.18, -1.63),
new THREE.Vector3(2.65, 1.20, -0.67),
new THREE.Vector3(4.62, 1.27, 0.77)
];
const route = new THREE.CatmullRomCurve3(
routePoints,
false,
"centripetal",
0.5
);
const grainCount = 230;
const grainPositions = new Float32Array(grainCount * 3);
const grainOffsets = [];
for (let i = 0; i < grainCount; i++) {
grainOffsets.push({
x: (Math.random() - 0.5) * 0.26,
y: (Math.random() - 0.5) * 0.11,
z: (Math.random() - 0.5) * 0.26,
phase: Math.random()
});
}
const grainGeometry = new THREE.BufferGeometry();
grainGeometry.setAttribute(
"position",
new THREE.BufferAttribute(grainPositions, 3)
.setUsage(THREE.DynamicDrawUsage)
);
const grainMaterial = new THREE.PointsMaterial({
color: 0xf0b638,
size: 0.085,
transparent: true,
opacity: 0.94,
depthWrite: false
});
const grainPoints = new THREE.Points(grainGeometry, grainMaterial);
scene.add(grainPoints);
// ---------------------------------------------------------------------
// Live batch identity markers
// ---------------------------------------------------------------------
const batchDefinitions = [
{ code: "A-17", color: "#d96048", offset: 0.04 },
{ code: "B-23", color: "#3b8f8a", offset: 0.39 },
{ code: "C-08", color: "#d79c32", offset: 0.73 }
];
const batches = batchDefinitions.map((definition, index) => {
const group = new THREE.Group();
scene.add(group);
const color = new THREE.Color(definition.color);
const bead = new THREE.Mesh(
new THREE.SphereGeometry(0.145, 16, 12),
mat(color, {
emissive: color,
emissiveIntensity: 0.28,
roughness: 0.35
})
);
bead.position.y = 0.24;
bead.castShadow = true;
group.add(bead);
const stem = cylinder(
0.014, 0.014, 0.55, 0, 0.57, 0,
mat(definition.color, { emissive: definition.color, emissiveIntensity: 0.25 }),
group, 8
);
stem.castShadow = false;
const halo = new THREE.Mesh(
new THREE.TorusGeometry(0.25, 0.038, 8, 24),
mat(definition.color, {
emissive: definition.color,
emissiveIntensity: 0.3
})
);
halo.rotation.x = Math.PI / 2;
halo.position.y = 0.06;
group.add(halo);
const label = labelSprite(
batchTexture(definition.code, definition.color),
1.72,
0.48,
true
);
label.position.y = 1.04;
group.add(label);
return {
...definition,
index,
group,
bead,
halo,
label,
progress: definition.offset,
stage: "Receiving"
};
});
// Stage beacons.
function beacon(x, y, z, color) {
const material = mat(color, {
emissive: color,
emissiveIntensity: 0.5,
roughness: 0.4
});
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.32, 0.045, 10, 30),
material
);
ring.rotation.x = Math.PI / 2;
ring.position.set(x, y, z);
scene.add(ring);
return ring;
}
const receiveBeacon = beacon(-5.25, 0.09, 0.9, 0x78a878);
const scaleBeacon = beacon(-1.72, 1.1, 0.9, 0xe8b74a);
const siloBeacon = beacon(0.35, 0.1, -2.65, 0x4f9f96);
const loadBeacon = beacon(5.0, 0.7, 1.0, 0xd79c32);
// ---------------------------------------------------------------------
// UI and camera controls implemented directly in this file
// ---------------------------------------------------------------------
const rows = [...document.querySelectorAll(".batch-row")];
const stageLabels = [
document.getElementById("stage-0"),
document.getElementById("stage-1"),
document.getElementById("stage-2")
];
const progressBars = [
document.getElementById("bar-0"),
document.getElementById("bar-1"),
document.getElementById("bar-2")
];
let selectedBatch = 1;
let followBatch = 1;
let paused = false;
rows.forEach((row, index) => {
row.addEventListener("click", () => {
selectedBatch = index;
followBatch = index;
rows.forEach((item, i) => item.classList.toggle("active", i === index));
});
});
const pauseButton = document.getElementById("pause");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume flow" : "Pause flow";
});
let azimuth = 0.72;
let polar = 0.86;
let zoom = 1;
const baseTarget = new THREE.Vector3(0, 1.55, 0.35);
const cameraTarget = baseTarget.clone();
function resetCamera() {
azimuth = 0.72;
polar = 0.86;
zoom = 1;
followBatch = null;
cameraTarget.copy(baseTarget);
}
document.getElementById("reset").addEventListener("click", resetCamera);
document.getElementById("zoom-in").addEventListener("click", () => {
zoom = Math.max(0.62, zoom * 0.86);
});
document.getElementById("zoom-out").addEventListener("click", () => {
zoom = Math.min(1.8, zoom / 0.86);
});
window.addEventListener("keydown", (event) => {
if (event.key === "Escape") resetCamera();
});
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;
azimuth -= dx * 0.006;
polar = THREE.MathUtils.clamp(polar + dy * 0.0045, 0.35, 1.25);
});
function endDrag() { dragging = false; }
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(event.deltaY * 0.001),
0.62,
1.8
);
}, { passive: false });
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
const viewHeight = (aspect < 1 ? 18 / aspect : 14) * zoom;
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
function updateCamera(delta) {
let desiredTarget = baseTarget;
if (followBatch !== null && batches[followBatch]) {
desiredTarget = batches[followBatch].group.position.clone();
desiredTarget.y += 0.65;
}
cameraTarget.lerp(
desiredTarget,
1 - Math.exp(-delta * (followBatch === null ? 6 : 3.4))
);
const radius = 22;
camera.position.set(
cameraTarget.x + Math.sin(azimuth) * Math.cos(polar) * radius,
cameraTarget.y + Math.sin(polar) * radius,
cameraTarget.z + Math.cos(azimuth) * Math.cos(polar) * radius
);
camera.lookAt(cameraTarget);
}
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
function stageFor(progress) {
if (progress < 0.22) return "Receiving";
if (progress < 0.42) return "Weighing";
if (progress < 0.72) return "Storage";
return "Outbound";
}
const clock = new THREE.Clock();
let flowTime = 0;
let animationTime = 0;
let uiTimer = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
animationTime += delta;
if (!paused) flowTime += delta;
// Grain particles travel continuously through the whole route.
const positionAttribute = grainGeometry.attributes.position;
for (let i = 0; i < grainCount; i++) {
const offset = grainOffsets[i];
const progress = (offset.phase + flowTime * 0.045) % 1;
const point = route.getPointAt(progress);
positionAttribute.setXYZ(
i,
point.x + offset.x,
point.y + offset.y + 0.08,
point.z + offset.z
);
}
positionAttribute.needsUpdate = true;
// Each batch follows the same route while retaining its own marker.
for (const batch of batches) {
const progress = (flowTime * 0.028 + batch.offset) % 1;
batch.progress = progress;
batch.stage = stageFor(progress);
const point = route.getPointAt(progress);
batch.group.position.copy(point);
batch.group.position.y += 0.06;
const bob = Math.sin(animationTime * 2.7 + batch.index * 2) * 0.035;
batch.label.position.y = 1.04 + bob;
batch.bead.position.y = 0.24 + bob * 0.4;
const pulse = 1 + Math.sin(animationTime * 3.2 + batch.index) * 0.09;
batch.halo.scale.setScalar(pulse);
batch.halo.rotation.z += delta * 0.8;
if (batch.index === selectedBatch) {
batch.halo.scale.multiplyScalar(1.2);
}
}
// Gentle beacon animation.
const beaconPulse = 1 + Math.sin(animationTime * 2.5) * 0.08;
receiveBeacon.scale.setScalar(beaconPulse);
siloBeacon.scale.setScalar(1 + Math.sin(animationTime * 2.5 + 1) * 0.08);
loadBeacon.scale.setScalar(1 + Math.sin(animationTime * 2.5 + 2) * 0.08);
updateCamera(delta);
uiTimer += delta;
if (uiTimer > 0.1) {
uiTimer = 0;
for (const batch of batches) {
stageLabels[batch.index].textContent = batch.stage;
progressBars[batch.index].style.width = `${batch.progress * 100}%`;
}
}
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
loadingOverlay.classList.add("hide");
setTimeout(() => loadingOverlay.remove(), 550);
});
</script>
</body>
</html>
```