Prompt specification
Build or customize the Three.js 3D scene "Community picnic assembly line" 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 picnic assembly line
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/community-picnic-assembly-line-x0152
Scene Description Prompt:
A low-poly community picnic assembly line keeps ingredient selections and dietary markers attached to each packed order. Three.js from cdnjs, one HTML file.
Working Three.js Starter (community-picnic-assembly-line-x0152):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Common Table — Picnic Assembly Line</title>
<style>
:root {
--ink: #24352d;
--muted: #66746c;
--cream: #fffdf7;
--panel: rgba(255, 253, 247, 0.9);
--green: #426b4e;
--orange: #e87845;
--shadow: 0 18px 50px rgba(42, 61, 48, 0.16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d9e8dc;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
button, select { font: inherit; }
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.brand {
position: absolute;
top: 24px;
left: 26px;
width: min(440px, calc(100vw - 52px));
pointer-events: auto;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: #426b4e;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
border-radius: 3px;
background: var(--orange);
transform: rotate(12deg);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 3.4vw, 48px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 370px;
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.live-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 16px;
}
.live-chip {
display: inline-flex;
align-items: center;
gap: 7px;
min-height: 31px;
padding: 7px 11px;
border: 1px solid rgba(68, 95, 77, 0.13);
border-radius: 999px;
background: rgba(255, 253, 247, 0.75);
box-shadow: 0 5px 20px rgba(42, 61, 48, 0.07);
color: #516158;
font-size: 11px;
font-weight: 750;
backdrop-filter: blur(12px);
}
.live-chip b { color: var(--ink); }
.pulse {
width: 7px;
height: 7px;
border-radius: 50%;
background: #63a66f;
box-shadow: 0 0 0 5px rgba(99, 166, 111, 0.12);
}
.inspector {
position: absolute;
top: 24px;
right: 24px;
width: 300px;
padding: 19px;
border: 1px solid rgba(56, 80, 63, 0.12);
border-radius: 22px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
pointer-events: auto;
}
.inspector-head {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 10px;
}
.inspector-kicker {
margin-bottom: 5px;
color: #849087;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.order-number {
font-family: Georgia, serif;
font-size: 25px;
line-height: 1;
}
.status {
padding: 6px 9px;
border-radius: 999px;
background: #e5f0df;
color: #426b4e;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
.order-name {
margin: 12px 0 3px;
font-size: 13px;
font-weight: 800;
}
.order-owner {
color: var(--muted);
font-size: 11px;
}
.section-label {
margin: 17px 0 8px;
color: #7b877f;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.manifest {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.ingredient {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 7px 9px;
border: 1px solid #e4e4d9;
border-radius: 10px;
background: #fffefa;
color: #4d5b53;
font-size: 10px;
font-weight: 700;
}
.ingredient i {
width: 6px;
height: 6px;
border-radius: 2px;
background: var(--food-color, #86a46b);
}
.diet-list {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.diet {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 29px;
height: 29px;
padding: 0 8px;
border-radius: 9px;
color: white;
font-size: 10px;
font-weight: 900;
box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.progress-wrap {
margin-top: 16px;
}
.progress-meta {
display: flex;
justify-content: space-between;
margin-bottom: 7px;
color: #7b877f;
font-size: 9px;
font-weight: 750;
}
.progress-track {
height: 5px;
overflow: hidden;
border-radius: 99px;
background: #e2e6dc;
}
.progress-fill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #5e8c69, #e1a45f);
transition: width .1s linear;
}
.label-layer, .leader-layer {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.leader-layer { z-index: 2; }
.label-layer { z-index: 3; }
.order-card {
position: absolute;
width: 190px;
padding: 10px 11px 9px;
border: 1px solid rgba(55, 75, 61, 0.13);
border-radius: 14px;
background: rgba(255, 253, 247, 0.94);
box-shadow: 0 9px 28px rgba(39, 59, 45, 0.13);
transform: translate(-50%, -100%);
pointer-events: auto;
cursor: pointer;
backdrop-filter: blur(10px);
transition: border-color .18s, box-shadow .18s, opacity .18s;
user-select: none;
}
.order-card:hover, .order-card.selected {
border-color: var(--order-color, #6b9274);
box-shadow: 0 12px 34px rgba(39, 59, 45, 0.2);
}
.order-card.selected {
outline: 2px solid color-mix(in srgb, var(--order-color) 30%, transparent);
outline-offset: 2px;
}
.card-top {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 7px;
}
.card-dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 3px;
background: var(--order-color);
transform: rotate(12deg);
}
.card-id {
font-size: 10px;
font-weight: 900;
letter-spacing: .04em;
}
.card-status {
margin-left: auto;
color: #849087;
font-size: 8px;
font-weight: 850;
text-transform: uppercase;
}
.card-ingredients {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-bottom: 7px;
}
.card-ingredients span {
padding: 4px 6px;
border-radius: 6px;
background: #f0f1e9;
color: #59665e;
font-size: 8px;
font-weight: 750;
}
.card-diet {
display: flex;
gap: 4px;
}
.card-diet b {
display: grid;
place-items: center;
min-width: 22px;
height: 19px;
padding: 0 5px;
border-radius: 6px;
color: white;
font-size: 8px;
font-weight: 900;
}
.dock {
position: absolute;
left: 50%;
bottom: 22px;
display: flex;
align-items: center;
gap: 7px;
padding: 8px;
border: 1px solid rgba(56, 80, 63, 0.13);
border-radius: 17px;
background: rgba(255, 253, 247, 0.91);
box-shadow: var(--shadow);
transform: translateX(-50%);
backdrop-filter: blur(16px);
pointer-events: auto;
}
.control {
height: 39px;
padding: 0 13px;
border: 0;
border-radius: 11px;
background: transparent;
color: #56645b;
font-size: 11px;
font-weight: 800;
cursor: pointer;
transition: background .16s, color .16s;
}
.control:hover { background: #edf1e8; color: #2f4538; }
.control.primary { background: #426b4e; color: white; }
.control.primary:hover { background: #365c43; }
.divider {
width: 1px;
height: 24px;
margin: 0 2px;
background: #dde1d8;
}
.speed-select {
height: 39px;
padding: 0 30px 0 10px;
border: 0;
border-radius: 11px;
outline: none;
background: #f0f2e9;
color: #526158;
font-size: 11px;
font-weight: 800;
cursor: pointer;
}
.hint {
position: absolute;
bottom: 27px;
left: 27px;
color: rgba(52, 75, 59, 0.68);
font-size: 10px;
font-weight: 700;
pointer-events: none;
}
.hint span { opacity: .65; }
.legend {
position: absolute;
right: 27px;
bottom: 28px;
display: flex;
gap: 13px;
align-items: center;
color: rgba(52, 75, 59, 0.75);
font-size: 9px;
font-weight: 800;
pointer-events: none;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 3px; }
@media (max-width: 900px) {
.inspector {
top: auto;
right: 12px;
bottom: 86px;
width: 260px;
padding: 15px;
}
.section-label { margin-top: 12px; }
.hint, .legend { display: none; }
.order-card { width: 168px; }
}
@media (max-width: 620px) {
.brand { top: 16px; left: 16px; }
.subtitle { display: none; }
.live-row { margin-top: 10px; }
.live-chip { min-height: 27px; padding: 5px 9px; font-size: 9px; }
.inspector { display: none; }
.dock { bottom: 12px; width: calc(100vw - 24px); justify-content: center; }
.control { padding: 0 9px; }
.order-card { width: 150px; padding: 8px; }
.card-ingredients span { font-size: 7px; }
}
</style>
</head>
<body>
<div class="ui">
<header class="brand">
<div class="eyebrow">Common Table Cooperative</div>
<h1>Pack a little joy.</h1>
<p class="subtitle">
A live view of our neighborhood picnic line. Every order keeps its
ingredients and dietary markers attached from prep to packing.
</p>
<div class="live-row">
<div class="live-chip"><span class="pulse"></span><b>5 orders</b> in motion</div>
<div class="live-chip">☀ <b>24°</b> picnic weather</div>
<div class="live-chip">▦ <b>18</b> meals today</div>
</div>
</header>
<aside class="inspector" aria-label="Selected order details">
<div class="inspector-head">
<div>
<div class="inspector-kicker">Order manifest</div>
<div class="order-number" id="inspectorNumber">P-104</div>
</div>
<div class="status" id="inspectorStatus">Building</div>
</div>
<div class="order-name" id="inspectorName">Garden lunch</div>
<div class="order-owner" id="inspectorOwner">For Mara · Community table 02</div>
<div class="section-label">Attached ingredients</div>
<div class="manifest" id="inspectorIngredients"></div>
<div class="section-label">Dietary markers</div>
<div class="diet-list" id="inspectorDiet"></div>
<div class="progress-wrap">
<div class="progress-meta">
<span id="progressStage">Gathering ingredients</span>
<span id="progressValue">0%</span>
</div>
<div class="progress-track">
<div class="progress-fill" id="progressFill"></div>
</div>
</div>
</aside>
<svg class="leader-layer" id="leaderLayer" aria-hidden="true"></svg>
<div class="label-layer" id="labelLayer"></div>
<div class="dock" aria-label="Simulation controls">
<button class="control primary" id="playButton" type="button">Ⅱ Pause</button>
<button class="control" id="resetOrders" type="button">↺ Reset</button>
<div class="divider"></div>
<select class="speed-select" id="speedSelect" aria-label="Line speed">
<option value="0.5">0.5× speed</option>
<option value="1" selected>1× speed</option>
<option value="1.5">1.5× speed</option>
<option value="2">2× speed</option>
</select>
<button class="control" id="toggleLabels" type="button">Tags on</button>
<button class="control" id="resetView" type="button">View</button>
</div>
<div class="hint">Drag to orbit <span>·</span> Scroll to zoom <span>·</span> Select an order</div>
<div class="legend">
<span><i style="background:#63a66f"></i>Plant-based</span>
<span><i style="background:#5f91ad"></i>Gluten-free</span>
<span><i style="background:#d28459"></i>Dairy-free</span>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene setup
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9dc);
scene.fog = new THREE.Fog(0xdce9dc, 18, 36);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
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.12;
document.body.prepend(renderer.domElement);
const camera = new THREE.PerspectiveCamera(38, innerWidth / innerHeight, 0.1, 100);
const hemisphere = new THREE.HemisphereLight(0xfff9e8, 0x58704d, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff4d5, 3.2);
sun.position.set(-7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xcfe1ff, 0.7);
fill.position.set(9, 6, -8);
scene.add(fill);
// -------------------------------------------------------------------------
// Custom camera controls: orbit, zoom, pinch
// -------------------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(0, 1.05, 0),
theta: 0.08,
phi: 1.08,
distance: 15.4
};
const defaultView = { ...cameraState, target: cameraState.target.clone() };
function updateCamera() {
const s = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.distance * s * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.distance * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.distance * s * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
const pointers = new Map();
let previousPinch = 0;
let dragDistance = 0;
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
dragDistance = 0;
if (pointers.size === 2) previousPinch = pinchDistance();
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const old = pointers.get(event.pointerId);
const dx = event.clientX - old.x;
const dy = event.clientY - old.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
dragDistance += Math.abs(dx) + Math.abs(dy);
if (pointers.size === 1) {
cameraState.theta -= dx * 0.005;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - dy * 0.004, 0.62, 1.34);
} else if (pointers.size === 2) {
const next = pinchDistance();
if (previousPinch > 0) {
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance * (previousPinch / next),
9,
23
);
}
previousPinch = next;
}
updateCamera();
});
function pinchDistance() {
const values = [...pointers.values()];
return Math.hypot(values[0].x - values[1].x, values[0].y - values[1].y);
}
renderer.domElement.addEventListener("pointerup", event => {
pointers.delete(event.pointerId);
if (pointers.size < 2) previousPinch = 0;
if (dragDistance < 6) selectFromCanvas(event);
});
renderer.domElement.addEventListener("pointercancel", event => {
pointers.delete(event.pointerId);
previousPinch = 0;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance + event.deltaY * 0.012,
9,
23
);
updateCamera();
}, { passive: false });
updateCamera();
// -------------------------------------------------------------------------
// Helpers
// -------------------------------------------------------------------------
const materialCache = new Map();
function mat(color, options = {}) {
const key = `${color}-${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0,
flatShading: true,
...options
}));
}
return materialCache.get(key);
}
function mesh(geometry, material, x = 0, y = 0, z = 0, parent = scene) {
const object = new THREE.Mesh(geometry, material);
object.position.set(x, y, z);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(w, h, d, color, x, y, z, parent = scene, options = {}) {
return mesh(new THREE.BoxGeometry(w, h, d), mat(color, options), x, y, z, parent);
}
function cylinder(r1, r2, h, color, x, y, z, parent = scene, segments = 8) {
return mesh(
new THREE.CylinderGeometry(r1, r2, h, segments),
mat(color),
x, y, z, parent
);
}
function sphere(r, color, x, y, z, parent = scene, detail = 1) {
return mesh(
new THREE.SphereGeometry(r, 10 * detail, 7 * detail),
mat(color),
x, y, z, parent
);
}
function groupAt(x = 0, y = 0, z = 0) {
const g = new THREE.Group();
g.position.set(x, y, z);
scene.add(g);
return g;
}
function makeSign(text, color) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#fffdf5";
ctx.beginPath();
ctx.roundRect(4, 4, 504, 120, 24);
ctx.fill();
ctx.fillStyle = color;
ctx.beginPath();
ctx.roundRect(20, 24, 9, 80, 5);
ctx.fill();
ctx.fillStyle = "#34463b";
ctx.font = "700 35px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 273, 66);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(4, renderer.capabilities.getMaxAnisotropy());
const sign = mesh(
new THREE.PlaneGeometry(1.75, 0.44),
new THREE.MeshBasicMaterial({ map: texture, transparent: true }),
0, 0, 0
);
sign.castShadow = false;
return sign;
}
// -------------------------------------------------------------------------
// Outdoor picnic setting
// -------------------------------------------------------------------------
const ground = mesh(
new THREE.CircleGeometry(22, 48),
mat(0x91ad76),
0, -0.025, 0
);
ground.rotation.x = -Math.PI / 2;
ground.castShadow = false;
const path = mesh(
new THREE.CircleGeometry(9.2, 48),
mat(0xd9cda7),
0, -0.008, 0
);
path.rotation.x = -Math.PI / 2;
path.scale.set(1, 0.56, 1);
path.castShadow = false;
function tree(x, z, scale = 1, hue = 0) {
const g = groupAt(x, 0, z);
cylinder(0.18 * scale, 0.26 * scale, 2.3 * scale, 0x765b3e, 0, 1.15 * scale, 0, g);
const foliage = [
[0, 2.7, 0, 1.15],
[-0.5, 2.45, 0.15, 0.82],
[0.48, 2.45, -0.08, 0.88],
[0.05, 3.25, 0.08, 0.78]
];
foliage.forEach(([fx, fy, fz, fs], i) => {
mesh(
new THREE.DodecahedronGeometry(fs * scale, 0),
mat(i % 2 ? 0x688c58 : 0x769b61),
fx * scale, fy * scale, fz * scale, g
);
});
return g;
}
tree(-8.5, -4.2, 1.18);
tree(-6.5, 4.4, 0.86);
tree(8.1, -3.7, 1.25);
tree(9.2, 3.1, 0.95);
tree(-11, 0.2, 0.82);
tree(11.5, -0.7, 0.8);
function picnicTable(x, z, rotation = 0) {
const g = groupAt(x, 0, z);
g.rotation.y = rotation;
box(2.6, 0.14, 1.05, 0xb98553, 0, 1.0, 0, g);
box(2.6, 0.42, 0.12, 0xa96f43, 0, 0.74, -0.48, g);
box(2.6, 0.42, 0.12, 0xa96f43, 0, 0.74, 0.48, g);
[-0.95, 0.95].forEach(xx => {
[-0.35, 0.35].forEach(zz => {
box(0.13, 1, 0.13, 0x795a3d, xx, 0.5, zz, g);
});
});
return g;
}
picnicTable(-6.8, -1.7, 0.1);
picnicTable(6.6, 1.9, -0.12);
function umbrella(x, z) {
const g = groupAt(x, 0, z);
cylinder(0.045, 0.055, 2.8, 0x765d43, 0, 1.4, 0, g, 6);
const canopy = mesh(
new THREE.ConeGeometry(1.45, 0.55, 10),
mat(0xe4a262),
0, 2.85, 0, g
);
canopy.rotation.y = 0.12;
const top = cylinder(0.05, 0.05, 0.18, 0x765d43, 0, 3.18, 0, g, 6);
top.castShadow = true;
}
umbrella(-5.1, 2.7);
umbrella(5.2, -2.2);
// -------------------------------------------------------------------------
// Conveyor assembly line
// -------------------------------------------------------------------------
const line = groupAt(0, 0, 0);
box(10.2, 0.24, 1.46, 0x45574b, 0, 1.04, 0, line);
box(10.35, 0.12, 0.12, 0xd6b77a, 0, 1.27, 0.77, line);
box(10.35, 0.12, 0.12, 0xd6b77a, 0, 1.27, -0.77, line);
for (let x = -4.8; x <= 4.8; x += 0.8) {
const roller = cylinder(0.13, 0.13, 1.45, 0x89968a, x, 1.2, 0, line, 10);
roller.rotation.x = Math.PI / 2;
}
[-4.35, -2.15, 0, 2.15, 4.35].forEach(x => {
[-0.55, 0.55].forEach(z => {
box(0.13, 1.0, 0.13, 0x69746a, x, 0.5, z, line);
});
box(0.15, 0.1, 1.35, 0x69746a, x, 0.13, 0, line);
});
const beltSlats = [];
for (let x = -5; x < 5; x += 0.31) {
const slat = box(0.035, 0.025, 1.28, 0x617164, x, 1.175, 0, line);
beltSlats.push(slat);
}
function stationTable(x, label, accent, kind) {
const g = groupAt(x, 0, -1.75);
box(2.05, 0.13, 1.05, 0xc69a63, 0, 1.27, 0, g);
[-0.82, 0.82].forEach(xx => {
[-0.36, 0.36].forEach(zz => {
box(0.12, 1.2, 0.12, 0x765f43, xx, 0.6, zz, g);
});
});
box(1.22, 0.22, 0.68, accent, 0, 1.43, 0, g);
box(1.08, 0.04, 0.55, 0xead9b6, 0, 1.56, 0, g);
if (kind === "bread") {
for (let i = 0; i < 4; i++) {
const bun = sphere(0.2, i % 2 ? 0xd6a35e : 0xe1b66f, -0.34 + i * 0.22, 1.68, 0, g);
bun.scale.set(1.35, 0.58, 0.68);
bun.rotation.z = -0.18;
}
} else if (kind === "produce") {
for (let i = 0; i < 7; i++) {
const tomato = sphere(0.14, i % 3 === 0 ? 0xe18b48 : 0xcf6545,
-0.42 + (i % 4) * 0.27, 1.7, -0.12 + Math.floor(i / 4) * 0.27, g);
const leaf = mesh(new THREE.ConeGeometry(0.07, 0.1, 5), mat(0x5e874f),
tomato.position.x, 1.84, tomato.position.z, g);
leaf.rotation.z = Math.PI;
}
} else if (kind === "protein") {
for (let i = 0; i < 3; i++) {
const item = cylinder(0.14, 0.14, 0.5, 0xd79b83, -0.35 + i * 0.35, 1.71, 0, g);
item.rotation.z = Math.PI / 2;
}
const lemon = sphere(0.16, 0xe6c94f, 0.35, 1.78, 0.22, g);
lemon.scale.set(1.25, 0.85, 0.85);
} else if (kind === "greens") {
for (let i = 0; i < 9; i++) {
const leaf = mesh(new THREE.ConeGeometry(0.12, 0.28, 5), mat(i % 2 ? 0x6f9a5b : 0x88aa63),
-0.42 + (i % 5) * 0.21, 1.72, -0.12 + Math.floor(i / 5) * 0.28, g);
leaf.rotation.z = (i % 2 ? 1 : -1) * 0.45;
}
}
const sign = makeSign(label, accent);
sign.position.set(x, 0.57, 0.88);
scene.add(sign);
const signPost = box(0.06, 0.6, 0.06, 0x78664b, x, 0.3, 0.86, scene);
signPost.castShadow = true;
}
stationTable(-3.45, "1 · BREAD", "#d99a50", "bread");
stationTable(-1.15, "2 · PRODUCE", "#d56d47", "produce");
stationTable(1.15, "3 · PROTEIN", "#c78c76", "protein");
stationTable(3.45, "4 · GREENS", "#72935d", "greens");
// -------------------------------------------------------------------------
// Low-poly volunteers
// -------------------------------------------------------------------------
const workers = [];
function worker(x, z, shirt, apron, skin = 0xc98f69) {
const g = groupAt(x, 0, z);
cylinder(0.19, 0.24, 0.72, shirt, 0, 1.47, 0, g, 6);
box(0.39, 0.48, 0.08, apron, 0, 1.38, 0.21, g);
const head = sphere(0.21, skin, 0, 2.02, 0, g);
head.scale.set(0.9, 1.08, 0.92);
const hair = sphere(0.215, 0x4a382a, 0, 2.1, -0.025, g);
hair.scale.set(0.94, 0.65, 0.94);
const hat = cylinder(0.23, 0.23, 0.08, 0xe4c66e, 0, 2.22, 0, g, 8);
hat.castShadow = true;
const armL = cylinder(0.07, 0.08, 0.55, shirt, -0.29, 1.5, 0.02, g, 6);
const armR = cylinder(0.07, 0.08, 0.55, shirt, 0.29, 1.5, 0.02, g, 6);
armL.rotation.z = -0.25;
armR.rotation.z = 0.25;
sphere(0.08, skin, -0.35, 1.19, 0.04, g);
sphere(0.08, skin, 0.35, 1.19, 0.04, g);
workers.push({ armL, armR, phase: Math.random() * Math.PI * 2 });
return g;
}
worker(-2.75, -2.65, 0xe8a15f, 0xf1e6c9, 0xbc7d55);
worker(0.1, -2.7, 0x6f9a86, 0xd8d9ba, 0xe0ad83);
worker(2.95, -2.62, 0x6d82a7, 0xe3d4aa, 0x855a43);
// Bunting
const poleL = cylinder(0.045, 0.06, 4.1, 0x80684b, -5.9, 2.05, -4.1, scene, 7);
const poleR = cylinder(0.045, 0.06, 4.1, 0x80684b, 5.9, 2.05, -4.1, scene, 7);
poleL.castShadow = poleR.castShadow = true;
const buntingColors = [0xe77d54, 0xe6bd62, 0x789c6a, 0x6c8eac, 0xc98576];
const buntingCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-5.9, 3.95, -4.1),
new THREE.Vector3(-2.9, 3.25, -4.1),
new THREE.Vector3(0, 2.85, -4.1),
new THREE.Vector3(2.9, 3.25, -4.1),
new THREE.Vector3(5.9, 3.95, -4.1)
]);
mesh(
new THREE.TubeGeometry(buntingCurve, 36, 0.018, 5, false),
mat(0x8c7655),
0, 0, 0
);
for (let i = 0; i < 11; i++) {
const p = buntingCurve.getPoint((i + 0.5) / 11);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute([
-0.19, 0, 0,
0.19, 0, 0,
0, -0.34, 0
], 3));
geometry.computeVertexNormals();
const flag = mesh(geometry, mat(buntingColors[i % buntingColors.length], { side: THREE.DoubleSide }),
p.x, p.y, p.z);
flag.rotation.y = 0.08;
}
// -------------------------------------------------------------------------
// Order data and packed boxes
// -------------------------------------------------------------------------
const dietaryColors = {
"VG": "#5f946c",
"V": "#8c7aaf",
"GF": "#5f91ad",
"DF": "#d28459"
};
const foodColors = {
"Sourdough": "#c99552",
"Flatbread": "#d7ad6b",
"Tuna": "#d89682",
"Lemon": "#e2c84e",
"Tomato": "#d45f42",
"Avocado": "#789b58",
"Baguette": "#d3a05b",
"Cheese": "#e2bd55",
"Basil": "#548151",
"Brown bread": "#a9794e",
"Hummus": "#c9a66c",
"Cucumber": "#6e9d62",
"Croissant": "#d8a864",
"Berry jam": "#aa5263",
"Pear": "#91a95b"
};
const orderData = [
{
id: "P-104", name: "Garden lunch", owner: "Mara", table: "Community table 02",
ingredients: ["Sourdough", "Tomato", "Avocado"], dietary: ["VG", "GF"], color: "#d5794f"
},
{
id: "P-105", name: "Harbor wrap", owner: "Jonas", table: "Community table 05",
ingredients: ["Flatbread", "Tuna", "Lemon"], dietary: ["DF", "GF"], color: "#5e8ea8"
},
{
id: "P-106", name: "Sunset box", owner: "Nora", table: "Community table 01",
ingredients: ["Baguette", "Cheese", "Basil"], dietary: ["V"], color: "#d19a4e"
},
{
id: "P-107", name: "Field plate", owner: "Amir", table: "Community table 04",
ingredients: ["Brown bread", "Hummus", "Cucumber"], dietary: ["VG"], color: "#729663"
},
{
id: "P-108", name: "Picnic trio", owner: "June", table: "Community table 03",
ingredients: ["Croissant", "Berry jam", "Pear"], dietary: ["V"], color: "#9b789d"
}
];
const labelLayer = document.getElementById("labelLayer");
const leaderLayer = document.getElementById("leaderLayer");
const svgNS = "http://www.w3.org/2000/svg";
function foodThreshold(name) {
if (/bread|flatbread|baguette|croissant/i.test(name)) return 0.14;
if (/tomato|lemon/i.test(name)) return 0.33;
if (/avocado|cucumber|hummus|basil/i.test(name)) return 0.52;
if (/tuna|cheese/i.test(name)) return 0.69;
return 0.79;
}
function addFood(parent, ingredient, index) {
const g = new THREE.Group();
const x = -0.23 + index * 0.23;
g.position.set(x, 0.2, 0);
parent.add(g);
const color = foodColors[ingredient] || "#91a56c";
if (/bread|baguette|croissant/i.test(ingredient)) {
const bun = sphere(0.18, color, 0, 0, 0, g);
bun.scale.set(1.25, 0.55, 0.72);
bun.rotation.z = -0.18;
} else if (/tomato/i.test(ingredient)) {
sphere(0.13, color, 0, 0.03, 0, g);
const leaf = mesh(new THREE.ConeGeometry(0.065, 0.09, 5), mat(0x56804c), 0, 0.15, 0, g);
leaf.rotation.z = Math.PI;
} else if (/avocado|cucumber|pear/i.test(ingredient)) {
const item = sphere(0.13, color, 0, 0.02, 0, g);
item.scale.set(0.8, 0.65, 1.35);
if (/pear/i.test(ingredient)) item.scale.set(0.8, 1.1, 0.8);
} else if (/hummus/i.test(ingredient)) {
cylinder(0.14, 0.14, 0.1, color, 0, 0.02, 0, g, 10);
} else if (/cheese/i.test(ingredient)) {
const cheese = box(0.24, 0.07, 0.2, color, 0, 0.03, 0, g);
cheese.rotation.y = 0.25;
} else if (/tuna/i.test(ingredient)) {
const meat = cylinder(0.12, 0.12, 0.28, color, 0, 0.03, 0, g, 8);
meat.rotation.z = Math.PI / 2;
} else if (/lemon/i.test(ingredient)) {
const lemon = sphere(0.13, color, 0, 0.03, 0, g);
lemon.scale.set(1.25, 0.8, 0.8);
} else if (/basil/i.test(ingredient)) {
for (let i = 0; i < 3; i++) {
const leaf = mesh(new THREE.ConeGeometry(0.075, 0.2, 5), mat(color),
(i - 1) * 0.07, 0.04, (i % 2) * 0.05, g);
leaf.rotation.z = (i - 1) * 0.45;
}
} else {
sphere(0.11, color, 0, 0.03, 0, g);
}
g.traverse(child => {
if (child.isMesh) {
child.castShadow = true;
child.receiveShadow = true;
}
});
return g;
}
const orders = [];
function createOrder(data, index) {
const g = groupAt(0, 1.34, 0);
g.userData.orderId = data.id;
box(0.88, 0.09, 0.72, 0xb98250, 0, 0, 0, g);
box(0.88, 0.28, 0.06, 0xd3a06a, 0, 0.13, -0.33, g);
box(0.88, 0.21, 0.06, 0xc99159, 0, 0.1, 0.33, g);
box(0.06, 0.25, 0.64, 0xd3a06a, -0.41, 0.12, 0, g);
box(0.06, 0.25, 0.64, 0xd3a06a, 0.41, 0.12, 0, g);
box(0.3, 0.15, 0.025, data.color, 0, 0.09, 0.372, g);
const foodItems = data.ingredients.map((ingredient, i) => {
const food = addFood(g, ingredient, i);
food.visible = false;
return { group: food, threshold: foodThreshold(ingredient) };
});
const lid = box(0.94, 0.065, 0.77, 0xe7c48c, 0, 0.28, 0, g);
lid.visible = false;
data.dietary.forEach((marker, i) => {
const markerColor = dietaryColors[marker];
const pole = cylinder(0.012, 0.012, 0.25, 0x826b4a, -0.27 + i * 0.54, 0.33, -0.26, g, 6);
pole.castShadow = true;
const flag = box(0.16, 0.12, 0.025, markerColor, -0.27 + i * 0.54, 0.44, -0.26, g);
flag.castShadow = true;
});
g.traverse(child => {
if (child.isMesh) child.userData.orderId = data.id;
});
const card = document.createElement("div");
card.className = "order-card";
card.style.setProperty("--order-color", data.color);
card.innerHTML = `
<div class="card-top">
<span class="card-dot"></span>
<span class="card-id">${data.id}</span>
<span class="card-status">Building</span>
</div>
<div class="card-ingredients">
${data.ingredients.map(item => `<span>${item}</span>`).join("")}
</div>
<div class="card-diet">
${data.dietary.map(marker =>
`<b style="background:${dietaryColors[marker]}" title="${marker}">${marker}</b>`
).join("")}
</div>
`;
card.addEventListener("click", () => selectOrder(data.id));
labelLayer.appendChild(card);
const line = document.createElementNS(svgNS, "line");
line.setAttribute("stroke", data.color);
line.setAttribute("stroke-width", "1.5");
line.setAttribute("stroke-opacity", "0.65");
leaderLayer.appendChild(line);
const dot = document.createElementNS(svgNS, "circle");
dot.setAttribute("r", "3.5");
dot.setAttribute("fill", data.color);
leaderLayer.appendChild(dot);
const order = {
...data, group: g, foodItems, lid, card, line, dot,
progress: index / orderData.length,
selected: index === 0
};
orders.push(order);
return order;
}
orderData.forEach(createOrder);
// -------------------------------------------------------------------------
// Inspector and controls
// -------------------------------------------------------------------------
const inspectorNumber = document.getElementById("inspectorNumber");
const inspectorStatus = document.getElementById("inspectorStatus");
const inspectorName = document.getElementById("inspectorName");
const inspectorOwner = document.getElementById("inspectorOwner");
const inspectorIngredients = document.getElementById("inspectorIngredients");
const inspectorDiet = document.getElementById("inspectorDiet");
const progressFill = document.getElementById("progressFill");
const progressValue = document.getElementById("progressValue");
const progressStage = document.getElementById("progressStage");
function selectOrder(id) {
const order = orders.find(item => item.id === id);
if (!order) return;
orders.forEach(item => item.card.classList.toggle("selected", item.id === id));
inspectorNumber.textContent = order.id;
inspectorName.textContent = order.name;
inspectorOwner.textContent = `For ${order.owner} · ${order.table}`;
inspectorIngredients.innerHTML = order.ingredients.map(name =>
`<span class="ingredient"><i style="--food-color:${foodColors[name]}"></i>${name}</span>`
).join("");
inspectorDiet.innerHTML = order.dietary.map(marker =>
`<span class="diet" style="background:${dietaryColors[marker]}" title="${marker}">${marker}</span>`
).join("");
}
selectOrder("P-104");
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function selectFromCanvas(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(orders.map(order => order.group), true);
if (hits.length) {
let object = hits[0].object;
while (object && !object.userData.orderId) object = object.parent;
if (object?.userData.orderId) selectOrder(object.userData.orderId);
}
}
let playing = true;
let speed = 1;
let labelsVisible = true;
const playButton = document.getElementById("playButton");
playButton.addEventListener("click", () => {
playing = !playing;
playButton.textContent = playing ? "Ⅱ Pause" : "▶ Play";
});
document.getElementById("speedSelect").addEventListener("change", event => {
speed = Number(event.target.value);
});
document.getElementById("toggleLabels").addEventListener("click", event => {
labelsVisible = !labelsVisible;
event.currentTarget.textContent = labelsVisible ? "Tags on" : "Tags off";
labelLayer.style.display = labelsVisible ? "block" : "none";
leaderLayer.style.display = labelsVisible ? "block" : "none";
});
document.getElementById("resetOrders").addEventListener("click", () => {
orders.forEach((order, i) => order.progress = i / orders.length);
selectOrder("P-104");
});
document.getElementById("resetView").addEventListener("click", () => {
cameraState.theta = defaultView.theta;
cameraState.phi = defaultView.phi;
cameraState.distance = defaultView.distance;
cameraState.target.copy(defaultView.target);
updateCamera();
});
// -------------------------------------------------------------------------
// Projection: every DOM tag stays physically attached to its order
// -------------------------------------------------------------------------
const projected = new THREE.Vector3();
const anchor = new THREE.Vector3();
function updateOrderLabels() {
const placed = [];
orders.forEach((order, index) => {
anchor.set(order.group.position.x, order.group.position.y + 1.12, order.group.position.z);
projected.copy(anchor).project(camera);
const screenX = (projected.x * 0.5 + 0.5) * innerWidth;
const screenY = (-projected.y * 0.5 + 0.5) * innerHeight;
const visible = projected.z > -1 && projected.z < 1;
order.card.style.visibility = visible ? "visible" : "hidden";
order.line.style.visibility = visible ? "visible" : "hidden";
order.dot.style.visibility = visible ? "visible" : "hidden";
if (!visible) return;
let cardX = screenX + [-28, 24, -15, 22, -20][index];
let cardBottom = screenY - 18 - (index % 2) * 34;
const cardWidth = innerWidth < 620 ? 150 : (innerWidth < 900 ? 168 : 190);
const cardHeight = 94;
// Simple collision lift so adjacent tags remain readable.
for (const previous of placed) {
const overlapX = Math.abs(cardX - previous.x) < cardWidth + 8;
const overlapY = Math.abs(cardBottom - previous.y) < cardHeight;
if (overlapX && overlapY) cardBottom -= cardHeight + 10;
}
cardBottom = THREE.MathUtils.clamp(cardBottom, 80, innerHeight - 110);
cardX = THREE.MathUtils.clamp(cardX, cardWidth / 2 + 8, innerWidth - cardWidth / 2 - 8);
placed.push({ x: cardX, y: cardBottom });
order.card.style.left = `${cardX}px`;
order.card.style.top = `${cardBottom}px`;
order.line.setAttribute("x1", cardX);
order.line.setAttribute("y1", cardBottom);
order.line.setAttribute("x2", screenX);
order.line.setAttribute("y2", screenY);
order.dot.setAttribute("cx", screenX);
order.dot.setAttribute("cy", screenY);
});
}
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
if (playing) {
orders.forEach(order => {
order.progress = (order.progress + dt * 0.022 * speed) % 1;
});
}
orders.forEach(order => {
const p = order.progress;
order.group.position.x = -4.62 + p * 9.24;
order.group.position.y = 1.34 + Math.sin(elapsed * 3 + order.progress * 7) * 0.008;
order.group.rotation.y = Math.sin(elapsed * 0.7 + order.progress * 4) * 0.025;
order.foodItems.forEach(item => {
item.group.visible = p >= item.threshold;
});
const packed = p >= 0.88;
order.lid.visible = packed;
order.card.querySelector(".card-status").textContent = packed ? "Packed" : "Building";
});
beltSlats.forEach((slat, i) => {
slat.position.x = ((i * 0.31 + elapsed * speed * 0.35) % 10) - 5;
});
workers.forEach((worker, i) => {
const movement = Math.sin(elapsed * 1.9 + worker.phase) * 0.12;
worker.armL.rotation.x = movement;
worker.armR.rotation.x = -movement;
worker.armL.rotation.z = -0.25 + movement * 0.15;
worker.armR.rotation.z = 0.25 - movement * 0.15;
});
const selected = orders.find(order => order.card.classList.contains("selected"));
if (selected) {
const percent = Math.round(selected.progress * 100);
progressFill.style.width = `${percent}%`;
progressValue.textContent = `${percent}%`;
if (selected.progress >= 0.88) {
inspectorStatus.textContent = "Packed";
progressStage.textContent = "Ready for the community table";
} else if (selected.progress >= 0.68) {
inspectorStatus.textContent = "Finishing";
progressStage.textContent = "Adding final ingredients";
} else if (selected.progress >= 0.34) {
inspectorStatus.textContent = "Building";
progressStage.textContent = "Gathering ingredients";
} else {
inspectorStatus.textContent = "Queued";
progressStage.textContent = "Waiting at the prep station";
}
}
updateOrderLabels();
renderer.render(scene, camera);
}
animate();
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
leaderLayer.setAttribute("viewBox", `0 0 ${innerWidth} ${innerHeight}`);
});
leaderLayer.setAttribute("viewBox", `0 0 ${innerWidth} ${innerHeight}`);
</script>
</body>
</html>
```