Prompt specification
Build or customize the Three.js 3D scene "Single-order assembly path" 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: Single-order assembly path
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/single-order-assembly-path-x0502
Scene Description Prompt:
Follow one low-poly meal order through three ingredient stations to pickup, keeping its tray and additions identifiable. One HTML file using Three.js from cdnjs.
Working Three.js Starter (single-order-assembly-path-x0502):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PlateFlow — Order 042</title>
<style>
:root {
--ink: #173e45;
--muted: #657b7d;
--paper: rgba(255, 252, 245, 0.92);
--line: rgba(23, 62, 69, 0.12);
--teal: #238c83;
--orange: #f29b63;
--green: #75ad62;
--red: #e56e55;
--progress: 0%;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #eadfce;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
#scene, #scene canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
}
.hud {
position: absolute;
inset: 0;
pointer-events: none;
}
.panel {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.72);
box-shadow: 0 18px 55px rgba(53, 61, 52, 0.13);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
pointer-events: auto;
}
.brand {
position: absolute;
top: 22px;
left: 24px;
display: flex;
align-items: center;
gap: 10px;
font-size: 13px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.brand-mark {
width: 34px;
height: 34px;
display: grid;
place-items: center;
border-radius: 11px;
color: white;
background: var(--teal);
box-shadow: 0 8px 20px rgba(35, 140, 131, 0.25);
}
.order-card {
position: absolute;
top: 72px;
left: 24px;
width: 310px;
border-radius: 22px;
padding: 20px;
}
.eyebrow {
margin: 0 0 7px;
color: var(--teal);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 28px;
line-height: 1.05;
letter-spacing: -0.045em;
}
.subtitle {
margin: 8px 0 15px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.status {
display: flex;
align-items: center;
gap: 9px;
min-height: 36px;
padding: 9px 11px;
border-radius: 12px;
background: #edf5ef;
color: #38664d;
font-size: 12px;
font-weight: 750;
}
.status-dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 5px rgba(117, 173, 98, 0.13);
}
.steps {
list-style: none;
padding: 0;
margin: 16px 0 14px;
display: grid;
gap: 7px;
}
.step {
width: 100%;
display: grid;
grid-template-columns: 27px 1fr auto;
align-items: center;
gap: 9px;
padding: 8px;
border: 1px solid transparent;
border-radius: 12px;
background: transparent;
text-align: left;
cursor: pointer;
transition: background 180ms, border-color 180ms, transform 180ms;
}
.step:hover { transform: translateX(2px); }
.step.active {
background: rgba(35, 140, 131, 0.08);
border-color: rgba(35, 140, 131, 0.12);
}
.step-number {
width: 27px;
height: 27px;
display: grid;
place-items: center;
border-radius: 9px;
color: #6d8080;
background: #e7ece8;
font-size: 11px;
font-weight: 850;
}
.step.active .step-number {
color: white;
background: var(--teal);
}
.step.done .step-number {
color: #3c6d43;
background: #dcebd9;
}
.step-name {
font-size: 12px;
font-weight: 760;
}
.step-note {
color: var(--muted);
font-size: 10px;
}
.step-state {
color: #8a9897;
font-size: 11px;
font-weight: 800;
}
.ingredient-title {
margin: 0 0 9px;
color: var(--muted);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.ingredients {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.ingredient {
display: flex;
align-items: center;
gap: 7px;
min-height: 31px;
padding: 7px 8px;
border: 1px solid var(--line);
border-radius: 10px;
color: #8a9795;
background: rgba(255, 255, 255, 0.52);
font-size: 10px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.04em;
transition: 180ms;
}
.ingredient.added {
color: var(--ink);
background: white;
border-color: rgba(23, 62, 69, 0.16);
}
.swatch {
width: 11px;
height: 11px;
border-radius: 4px;
opacity: 0.38;
box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.ingredient.added .swatch { opacity: 1; }
.controls {
position: absolute;
top: 22px;
right: 24px;
display: flex;
gap: 7px;
padding: 7px;
border-radius: 15px;
}
.control {
height: 36px;
padding: 0 12px;
border: 0;
border-radius: 10px;
background: transparent;
cursor: pointer;
font-size: 11px;
font-weight: 800;
transition: background 160ms, transform 160ms;
}
.control:hover {
background: rgba(35, 140, 131, 0.09);
transform: translateY(-1px);
}
.control.primary {
color: white;
background: var(--teal);
}
.timeline {
position: absolute;
left: 50%;
bottom: 22px;
width: min(680px, calc(100% - 48px));
transform: translateX(-50%);
display: grid;
grid-template-columns: 92px 1fr 78px;
align-items: center;
gap: 13px;
padding: 12px 15px;
border-radius: 18px;
}
.timeline-title {
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.timeline-sub {
margin-top: 3px;
color: var(--muted);
font-size: 10px;
}
#scrubber {
width: 100%;
height: 6px;
margin: 0;
appearance: none;
-webkit-appearance: none;
border-radius: 99px;
outline: none;
cursor: pointer;
background: linear-gradient(
to right,
var(--teal) 0%,
var(--teal) var(--progress),
#dfe6e1 var(--progress),
#dfe6e1 100%
);
}
#scrubber::-webkit-slider-thumb {
width: 18px;
height: 18px;
appearance: none;
-webkit-appearance: none;
border: 4px solid white;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 2px 8px rgba(23, 62, 69, 0.25);
}
#scrubber::-moz-range-thumb {
width: 11px;
height: 11px;
border: 4px solid white;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 2px 8px rgba(23, 62, 69, 0.25);
}
.time {
color: var(--muted);
text-align: right;
font-size: 11px;
font-variant-numeric: tabular-nums;
}
.hint {
position: absolute;
right: 24px;
bottom: 25px;
color: rgba(23, 62, 69, 0.66);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.02em;
}
@media (max-width: 760px) {
.brand { top: 15px; left: 15px; }
.order-card {
top: 61px;
left: 15px;
width: 260px;
padding: 15px;
}
h1 { font-size: 22px; }
.subtitle, .steps { display: none; }
.ingredients { margin-top: 12px; }
.controls { top: 14px; right: 14px; }
.control { padding: 0 9px; }
.hint { display: none; }
.timeline {
bottom: 14px;
width: calc(100% - 28px);
grid-template-columns: 72px 1fr 60px;
gap: 8px;
padding: 10px;
}
}
@media (max-width: 470px) {
.brand span:last-child { display: none; }
.order-card { width: 224px; }
.ingredient { font-size: 9px; }
.timeline-title { font-size: 9px; }
.timeline-sub { display: none; }
.timeline { grid-template-columns: 50px 1fr 52px; }
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="hud">
<div class="brand">
<span class="brand-mark">P</span>
<span>PlateFlow Kitchen</span>
</div>
<aside class="order-card panel">
<p class="eyebrow">Live order · Tray 07</p>
<h1>Harvest bowl</h1>
<p class="subtitle">
One order, three ingredient stops, one clearly labeled pickup.
</p>
<div class="status">
<span class="status-dot"></span>
<span id="statusText">Order received</span>
</div>
<ol class="steps">
<li>
<button class="step" data-jump="0.12" type="button">
<span class="step-number">01</span>
<span>
<span class="step-name">Rice station</span><br />
<span class="step-note">Warm jasmine rice</span>
</span>
<span class="step-state">Next</span>
</button>
</li>
<li>
<button class="step" data-jump="0.47" type="button">
<span class="step-number">02</span>
<span>
<span class="step-name">Market station</span><br />
<span class="step-note">Greens, tomato + corn</span>
</span>
<span class="step-state">Next</span>
</button>
</li>
<li>
<button class="step" data-jump="0.79" type="button">
<span class="step-number">03</span>
<span>
<span class="step-name">Grill station</span><br />
<span class="step-note">Chicken + sesame sauce</span>
</span>
<span class="step-state">Next</span>
</button>
</li>
<li>
<button class="step" data-jump="0.98" type="button">
<span class="step-number">✓</span>
<span>
<span class="step-name">Pickup counter</span><br />
<span class="step-note">Order #042</span>
</span>
<span class="step-state">Next</span>
</button>
</li>
</ol>
<p class="ingredient-title">Bowl contents</p>
<div class="ingredients">
<div class="ingredient" id="ingredient-rice">
<span class="swatch" style="background:#f4e6bc"></span>Rice
</div>
<div class="ingredient" id="ingredient-veg">
<span class="swatch" style="background:#75ad62"></span>Market veg
</div>
<div class="ingredient" id="ingredient-chicken">
<span class="swatch" style="background:#b86d3f"></span>Chicken
</div>
<div class="ingredient" id="ingredient-sauce">
<span class="swatch" style="background:#e56e55"></span>Sauce
</div>
</div>
</aside>
<nav class="controls panel" aria-label="Animation controls">
<button id="playButton" class="control primary" type="button">Pause</button>
<button id="replayButton" class="control" type="button">Replay</button>
<button id="viewButton" class="control" type="button">Reset view</button>
</nav>
<div class="timeline panel">
<div>
<div class="timeline-title">Order journey</div>
<div class="timeline-sub">Rice → Market → Grill</div>
</div>
<input id="scrubber" type="range" min="0" max="1000" value="0" aria-label="Order timeline" />
<div class="time" id="timeText">0.0 / 26s</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Space to pause</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
// -----------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeadfce);
scene.fog = new THREE.Fog(0xeadfce, 32, 58);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.querySelector("#scene").appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-14, 14, 8, -8, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 1.25, 0);
const cameraState = {
azimuth: 0.49,
polar: 0.97,
zoom: 1,
radius: 30
};
const hemisphere = new THREE.HemisphereLight(0xfff8e9, 0xb89f82, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d5, 3.1);
sun.position.set(7, 16, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 14;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 42;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xcce9ea, 1.0);
fill.position.set(-12, 8, 5);
scene.add(fill);
const flat = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
const materials = {
wall: flat(0xf2e8d9),
wallInset: flat(0xe5d7c4),
floor: flat(0xd8cbb7),
counter: flat(0x287d78),
counterTop: flat(0xf4e9d6),
cream: flat(0xfff8eb),
dark: flat(0x21484a),
wood: flat(0xb98258),
metal: flat(0xb8c1bb, { metalness: 0.25, roughness: 0.48 }),
rice: flat(0xf3e5bb),
green: flat(0x72a95c),
greenDark: flat(0x477e4a),
tomato: flat(0xe6604e),
corn: flat(0xf4bd45),
chicken: flat(0xb96d42),
grill: flat(0x744733),
sauce: flat(0xe66e50),
yellow: flat(0xf4c45b)
};
function addMesh(parent, geometry, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(parent, size, position, material) {
return addMesh(
parent,
new THREE.BoxGeometry(size[0], size[1], size[2]),
material,
position[0],
position[1],
position[2]
);
}
function addCylinder(parent, radii, height, segments, position, material) {
return addMesh(
parent,
new THREE.CylinderGeometry(radii[0], radii[1], height, segments),
material,
position[0],
position[1],
position[2]
);
}
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 makeTextSprite(text, background = "#ffffff", foreground = "#173e45") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 512, 128);
roundedRect(ctx, 5, 5, 502, 118, 24);
ctx.fillStyle = background;
ctx.fill();
ctx.strokeStyle = "rgba(23,62,69,.12)";
ctx.lineWidth = 5;
ctx.stroke();
const size = text.length > 18 ? 38 : text.length > 13 ? 44 : 54;
ctx.fillStyle = foreground;
ctx.font = `800 ${size}px system-ui, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 67);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.renderOrder = 10;
return sprite;
}
// -----------------------------------------------------------------------------
// Restaurant set
// -----------------------------------------------------------------------------
const room = new THREE.Group();
scene.add(room);
const floor = addMesh(
room,
new THREE.PlaneGeometry(60, 40),
materials.floor,
0,
-0.02,
0
);
floor.rotation.x = -Math.PI / 2;
floor.castShadow = false;
addBox(room, [31, 7.2, 0.3], [0, 3.45, -4.8], materials.wall);
addBox(room, [31, 0.32, 0.42], [0, 0.16, -4.55], materials.wallInset);
for (let x = -12; x <= 12; x += 3) {
addBox(room, [0.08, 5.5, 0.08], [x, 3.2, -4.61], materials.wallInset);
}
// Warm wall panels and geometric artwork.
for (let i = 0; i < 4; i++) {
const x = -10.8 + i * 7.2;
addBox(room, [3.8, 1.1, 0.08], [x, 4.6, -4.57], materials.wallInset);
const panel = addBox(
room,
[2.65, 0.65, 0.1],
[x, 4.6, -4.49],
flat([0xe9ad72, 0x7ba9a1, 0xd77d67, 0xd6b95c][i])
);
panel.rotation.z = (i % 2 ? 1 : -1) * 0.035;
}
// Main rail/counter.
addBox(room, [24.8, 1.02, 1.7], [0, 0.54, 0.65], materials.counter);
addBox(room, [25.0, 0.16, 1.9], [0, 1.13, 0.65], materials.counterTop);
// Front slats give the low-poly counter a crafted look.
for (let x = -11.9; x < 12.2; x += 0.78) {
addBox(room, [0.06, 0.68, 0.05], [x, 0.57, 1.515], flat(0x3d9690));
}
// Pickup and order-in mats.
const pickupMat = addCylinder(
room,
[1.18, 1.18],
0.035,
24,
[10.8, 1.225, 0.65],
flat(0xc9ddbd)
);
pickupMat.castShadow = false;
const orderInMat = addCylinder(
room,
[1.18, 1.18],
0.035,
24,
[-11.2, 1.225, 0.65],
flat(0xe8d8bf)
);
orderInMat.castShadow = false;
const stationXs = [-7, 0, 7];
const stationColors = [0xe7a35f, 0x70a861, 0xdf705a];
const stationNames = ["01 RICE", "02 MARKET", "03 GRILL"];
const workers = [];
function addLamp(x, color) {
addCylinder(room, [0.025, 0.025], 1.0, 6, [x, 4.35, -1.4], materials.dark);
const shade = addMesh(
room,
new THREE.ConeGeometry(0.47, 0.38, 8),
flat(color),
x,
3.72,
-1.4
);
shade.castShadow = true;
addMesh(
room,
new THREE.IcosahedronGeometry(0.12, 1),
flat(0xffefb1, { emissive: 0xffc85b, emissiveIntensity: 0.35 }),
x,
3.5,
-1.4
);
}
function addWorker(x, shirtColor, stationIndex) {
const worker = new THREE.Group();
worker.position.set(x, 0, -2.65);
room.add(worker);
addCylinder(worker, [0.29, 0.39], 0.82, 8, [0, 1.48, 0], flat(shirtColor));
addMesh(worker, new THREE.IcosahedronGeometry(0.24, 1), flat(0xdba67c), 0, 2.05, 0);
addCylinder(worker, [0.25, 0.27], 0.17, 8, [0, 2.27, 0], materials.cream);
addCylinder(worker, [0.29, 0.31], 0.27, 8, [0, 2.42, 0], materials.cream);
addBox(worker, [0.24, 0.06, 0.18], [0, 2.02, 0.21], flat(0x4b5c54));
const leftPivot = new THREE.Group();
const rightPivot = new THREE.Group();
leftPivot.position.set(-0.31, 1.68, 0);
rightPivot.position.set(0.31, 1.68, 0);
worker.add(leftPivot, rightPivot);
addCylinder(leftPivot, [0.075, 0.09], 0.62, 7, [0, -0.27, 0], materials.cream);
addCylinder(rightPivot, [0.075, 0.09], 0.62, 7, [0, -0.27, 0], materials.cream);
addMesh(leftPivot, new THREE.IcosahedronGeometry(0.1, 0), materials.cream, 0, -0.61, 0);
addMesh(rightPivot, new THREE.IcosahedronGeometry(0.1, 0), materials.cream, 0, -0.61, 0);
workers.push({ leftPivot, rightPivot, stationIndex });
}
stationXs.forEach((x, index) => {
const color = stationColors[index];
// Ingredient island behind the moving rail.
addBox(room, [3.55, 1.15, 1.25], [x, 0.6, -1.45], flat(index === 1 ? 0x396f62 : 0x315e59));
addBox(room, [3.72, 0.13, 1.35], [x, 1.24, -1.45], materials.counterTop);
addBox(room, [0.08, 0.75, 0.06], [x, 0.64, -0.80], flat(color));
// Station sign.
addBox(room, [3.18, 0.75, 0.16], [x, 3.05, -2.1], materials.dark);
const sign = makeTextSprite(stationNames[index], ["#f9e2c6", "#dfefd9", "#f7d8cf"][index]);
sign.scale.set(2.8, 0.6, 1);
sign.position.set(x, 3.05, -1.98);
room.add(sign);
addLamp(x, color);
addWorker(x + 1.08, [0xe9a663, 0x5f9c69, 0xcd6555][index], index);
// Number badge on the front of the rail.
const badge = makeTextSprite(`0${index + 1}`, ["#f8e4ca", "#e1efd9", "#f8dcd2"][index]);
badge.scale.set(0.64, 0.34, 1);
badge.position.set(x, 0.66, 1.56);
room.add(badge);
});
// Rice cooker.
addCylinder(room, [0.55, 0.48], 0.48, 12, [-7.85, 1.55, -1.42], materials.cream);
addCylinder(room, [0.58, 0.58], 0.1, 12, [-7.85, 1.83, -1.42], materials.metal);
addBox(room, [0.12, 0.12, 0.45], [-7.4, 1.92, -1.42], materials.wood);
// Market bins.
[-0.9, 0, 0.9].forEach((offset, i) => {
const binColor = [materials.green, materials.tomato, materials.corn][i];
addBox(room, [0.72, 0.34, 0.68], [offset, 1.48, -1.43], materials.cream);
for (let j = 0; j < 5; j++) {
const food = addMesh(
room,
new THREE.IcosahedronGeometry(0.11, 0),
binColor,
offset - 0.22 + j * 0.1,
1.71 + (j % 2) * 0.04,
-1.45 + (j % 3) * 0.08
);
food.scale.y = 0.75;
}
});
// Grill and sauce bottle.
addBox(room, [1.8, 0.18, 0.82], [-0.55, 1.47, -1.45], materials.dark);
for (let i = 0; i < 4; i++) {
const chunk = addMesh(
room,
new THREE.DodecahedronGeometry(0.17, 0),
materials.chicken,
-1.18 + i * 0.41,
1.67,
-1.45
);
chunk.scale.y = 0.65;
}
addCylinder(room, [0.14, 0.18], 0.46, 8, [1.16, 1.56, -1.43], materials.sauce);
addCylinder(room, [0.08, 0.1], 0.16, 8, [1.16, 1.87, -1.43], materials.cream);
// Pickup sign and service bell.
addBox(room, [2.75, 0.72, 0.15], [10.8, 3.08, -1.65], materials.dark);
const pickupSign = makeTextSprite("PICKUP", "#dcebd7");
pickupSign.scale.set(2.35, 0.58, 1);
pickupSign.position.set(10.8, 3.08, -1.53);
room.add(pickupSign);
const pickupBeacon = addCylinder(
room,
[0.11, 0.11],
0.3,
8,
[12.1, 1.42, 0.2],
flat(0xe5a963, { emissive: 0x000000, emissiveIntensity: 0 })
);
addMesh(room, new THREE.SphereGeometry(0.23, 10, 6), materials.metal, 10.8, 1.39, -0.25);
addCylinder(room, [0.03, 0.03], 0.18, 6, [10.8, 1.56, -0.25], materials.dark);
// Order-in sign.
const orderInSign = makeTextSprite("ORDER IN", "#f1e2cc");
orderInSign.scale.set(2.15, 0.52, 1);
orderInSign.position.set(-11.2, 2.7, -1.5);
room.add(orderInSign);
// Decorative low-poly plants.
function addPlant(x, z) {
addCylinder(room, [0.32, 0.23], 0.45, 8, [x, 0.23, z], flat(0xb66f50));
for (let i = 0; i < 6; i++) {
const angle = (i / 6) * Math.PI * 2;
const leaf = addMesh(
room,
new THREE.IcosahedronGeometry(0.28, 0),
i % 2 ? materials.green : materials.greenDark,
x + Math.cos(angle) * 0.18,
0.66 + (i % 2) * 0.12,
z + Math.sin(angle) * 0.18
);
leaf.scale.set(0.65, 1.4, 0.65);
leaf.rotation.z = Math.cos(angle) * 0.35;
}
}
addPlant(-13.1, -2.8);
addPlant(13.2, -2.8);
// -----------------------------------------------------------------------------
// The tracked order: tray, bowl, and ingredients
// -----------------------------------------------------------------------------
const tray = new THREE.Group();
tray.position.set(-11.2, 1.25, 0.65);
scene.add(tray);
addBox(tray, [2.05, 0.12, 1.36], [0, 0, 0], materials.teal);
addBox(tray, [2.08, 0.18, 0.10], [0, 0.12, 0.63], materials.teal);
addBox(tray, [2.08, 0.18, 0.10], [0, 0.12, -0.63], materials.teal);
addBox(tray, [0.10, 0.18, 1.16], [0.98, 0.12, 0], materials.teal);
addBox(tray, [0.10, 0.18, 1.16], [-0.98, 0.12, 0], materials.teal);
const orderBadge = makeTextSprite("ORDER #042", "#287f78", "#ffffff");
orderBadge.scale.set(1.45, 0.32, 1);
orderBadge.position.set(0, 1.02, 0.05);
orderBadge.renderOrder = 24;
tray.add(orderBadge);
const bowlGroup = new THREE.Group();
bowlGroup.position.y = 0.10;
tray.add(bowlGroup);
const bowlMaterial = flat(0xfffaf0, { side: THREE.DoubleSide });
addCylinder(bowlGroup, [0.79, 0.55], 0.44, 12, [0, 0.25, 0], bowlMaterial);
const rim = addMesh(
bowlGroup,
new THREE.TorusGeometry(0.765, 0.052, 5, 18),
materials.cream,
0,
0.47,
0
);
rim.rotation.x = Math.PI / 2;
const foodGroups = {};
function addFoodTag(parent, text, background, position) {
const tag = makeTextSprite(text, background);
tag.scale.set(0.78, 0.18, 1);
tag.position.set(...position);
tag.renderOrder = 22;
parent.add(tag);
return tag;
}
// Rice.
const riceGroup = new THREE.Group();
riceGroup.position.y = 0.42;
bowlGroup.add(riceGroup);
foodGroups.rice = riceGroup;
addCylinder(riceGroup, [0.63, 0.55], 0.14, 12, [0, 0.03, 0], materials.rice);
let seed = 42;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < 17; i++) {
const angle = random() * Math.PI * 2;
const radius = Math.sqrt(random()) * 0.49;
const grain = addMesh(
riceGroup,
new THREE.IcosahedronGeometry(0.075, 0),
flat(i % 3 ? 0xf6e8c1 : 0xe9d6a6),
Math.cos(angle) * radius,
0.12 + random() * 0.045,
Math.sin(angle) * radius
);
grain.scale.set(1.5, 0.45, 0.65);
grain.rotation.y = random() * Math.PI;
}
addFoodTag(riceGroup, "RICE", "#fff0cc", [-0.92, 0.12, 0.3]);
// Market vegetables.
const vegGroup = new THREE.Group();
vegGroup.position.y = 0.52;
bowlGroup.add(vegGroup);
foodGroups.veg = vegGroup;
const vegPositions = [
[-0.34, 0.02, -0.17], [-0.12, 0.06, 0.18], [0.22, 0.02, -0.2],
[0.39, 0.04, 0.15], [-0.43, 0.03, 0.19], [0.02, 0.03, -0.24]
];
vegPositions.forEach((p, i) => {
const leaf = addMesh(
vegGroup,
new THREE.IcosahedronGeometry(0.16, 0),
i % 2 ? materials.green : materials.greenDark,
p[0], p[1], p[2]
);
leaf.scale.set(1.2, 0.55, 0.8);
leaf.rotation.y = i * 0.9;
});
[-0.15, 0.28].forEach((x, i) => {
const tomato = addCylinder(
vegGroup,
[0.12, 0.12],
0.075,
8,
[x, 0.08, i ? -0.18 : 0.16],
materials.tomato
);
tomato.rotation.x = Math.PI / 2;
});
[0.1, 0.32, -0.32].forEach((x, i) => {
const corn = addBox(
vegGroup,
[0.13, 0.075, 0.09],
[x, 0.1, i % 2 ? 0.12 : -0.12],
materials.corn
);
corn.rotation.y = i * 0.7;
});
addFoodTag(vegGroup, "VEG", "#dfefd9", [0.93, 0.12, 0.28]);
// Chicken.
const chickenGroup = new THREE.Group();
chickenGroup.position.y = 0.61;
bowlGroup.add(chickenGroup);
foodGroups.chicken = chickenGroup;
const chickenPositions = [
[-0.33, 0.05, -0.16], [-0.08, 0.08, 0.15], [0.19, 0.05, -0.13],
[0.36, 0.08, 0.14], [-0.15, 0.12, -0.06]
];
chickenPositions.forEach((p, i) => {
const chunk = addMesh(
chickenGroup,
new THREE.DodecahedronGeometry(0.17, 0),
i % 2 ? materials.chicken : flat(0xc7814f),
p[0], p[1], p[2]
);
chunk.scale.set(1.1, 0.7, 0.9);
chunk.rotation.y = i * 0.55;
});
for (let i = 0; i < 3; i++) {
addBox(
chickenGroup,
[0.19, 0.025, 0.035],
[-0.29 + i * 0.27, 0.16, -0.08],
materials.grill
);
}
addFoodTag(chickenGroup, "CHICKEN", "#f3dfcf", [-0.98, 0.15, -0.18]);
// Sesame sauce.
const sauceGroup = new THREE.Group();
sauceGroup.position.y = 0.69;
bowlGroup.add(sauceGroup);
foodGroups.sauce = sauceGroup;
const sauceCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.5, 0, -0.22),
new THREE.Vector3(-0.28, 0.02, 0.05),
new THREE.Vector3(-0.08, 0.01, -0.08),
new THREE.Vector3(0.12, 0.02, 0.08),
new THREE.Vector3(0.33, 0, -0.04),
new THREE.Vector3(0.52, 0.01, 0.1)
]);
addMesh(sauceGroup, new THREE.TubeGeometry(sauceCurve, 28, 0.035, 4, false), materials.sauce);
for (let i = 0; i < 8; i++) {
addMesh(
sauceGroup,
new THREE.IcosahedronGeometry(0.027, 0),
materials.cream,
-0.4 + random() * 0.8,
0.06,
-0.24 + random() * 0.48
);
}
addFoodTag(sauceGroup, "SAUCE", "#f8dcd1", [0.98, 0.15, -0.15]);
// -----------------------------------------------------------------------------
// Ingredient transfer particles
// -----------------------------------------------------------------------------
const transferParticles = [];
const particleGeometry = new THREE.IcosahedronGeometry(0.065, 0);
for (let i = 0; i < 15; i++) {
const mesh = new THREE.Mesh(particleGeometry, materials.rice);
mesh.castShadow = true;
mesh.visible = false;
scene.add(mesh);
transferParticles.push(mesh);
}
const activeMarker = addMesh(
scene,
new THREE.ConeGeometry(0.16, 0.34, 4),
flat(0xf3c75d, { emissive: 0x7b4b00, emissiveIntensity: 0.12 }),
-7,
3.85,
-1.05
);
activeMarker.rotation.z = Math.PI;
// -----------------------------------------------------------------------------
// Timeline
// -----------------------------------------------------------------------------
const DURATION = 26;
let progress = 0;
let playing = true;
let lastTime = performance.now();
const keyframes = [
{ p: 0.00, x: -11.2 },
{ p: 0.08, x: -7.0 },
{ p: 0.24, x: -7.0 },
{ p: 0.40, x: 0.0 },
{ p: 0.57, x: 0.0 },
{ p: 0.73, x: 7.0 },
{ p: 0.90, x: 7.0 },
{ p: 1.00, x: 10.8 }
];
const ease = t => t * t * (3 - 2 * t);
const clamp01 = v => Math.max(0, Math.min(1, v));
function sampleX(p) {
for (let i = 0; i < keyframes.length - 1; i++) {
const a = keyframes[i];
const b = keyframes[i + 1];
if (p >= a.p && p <= b.p) {
const t = ease((p - a.p) / (b.p - a.p));
return THREE.MathUtils.lerp(a.x, b.x, t);
}
}
return p <= 0 ? keyframes[0].x : keyframes[keyframes.length - 1].x;
}
function easeOutBack(t) {
const c1 = 1.70158;
const c3 = c1 + 1;
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
}
function setIngredient(group, p, start) {
const q = clamp01((p - start) / 0.04);
group.visible = q > 0.001;
const scale = Math.max(0.001, easeOutBack(q));
group.scale.setScalar(scale);
}
function updateParticles(p) {
const stages = [
{ start: 0.095, end: 0.225, x: -7, type: "rice" },
{ start: 0.425, end: 0.555, x: 0, type: "veg" },
{ start: 0.745, end: 0.875, x: 7, type: "grill" }
];
const stage = stages.find(s => p >= s.start && p <= s.end);
transferParticles.forEach((mesh, i) => {
mesh.visible = !!stage;
if (!stage) return;
const phase = ((p - stage.start) * 48 + i * 0.173) % 1;
const spread = ((i % 5) - 2) * 0.13;
mesh.position.set(
stage.x + spread,
2.68 + (1.7 - 2.68) * phase + Math.sin(phase * Math.PI) * 0.34,
-1.08 + (0.65 + 1.08) * phase
);
if (stage.type === "rice") {
mesh.material = i % 2 ? materials.rice : flat(0xe7d4a8);
mesh.scale.set(1.5, 0.6, 0.8);
} else if (stage.type === "veg") {
mesh.material = [materials.green, materials.tomato, materials.corn][i % 3];
mesh.scale.setScalar(1);
} else {
const local = (p - stage.start) / (stage.end - stage.start);
mesh.material = local < 0.58 ? materials.chicken : materials.sauce;
mesh.scale.set(local < 0.58 ? 1 : 0.55, local < 0.58 ? 0.75 : 1.4, 1);
}
});
}
// -----------------------------------------------------------------------------
// Camera controls implemented directly, without addons
// -----------------------------------------------------------------------------
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const halfWidth = 13.5 / cameraState.zoom;
const halfHeight = halfWidth / aspect;
camera.left = -halfWidth;
camera.right = halfWidth;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
const { azimuth, polar, radius } = cameraState;
camera.position.set(
cameraTarget.x + radius * Math.sin(polar) * Math.sin(azimuth),
cameraTarget.y + radius * Math.cos(polar),
cameraTarget.z + radius * Math.sin(polar) * Math.cos(azimuth)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraState.azimuth = 0.49;
cameraState.polar = 0.97;
cameraState.zoom = 1;
updateCamera();
}
const pointers = new Map();
let dragging = false;
let lastPointer = { x: 0, y: 0 };
let pinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
dragging = true;
lastPointer = { x: event.clientX, y: event.clientY };
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (pinchDistance > 0) {
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * (pinchDistance / Math.max(distance, 1)),
0.72,
1.8
);
updateCamera();
}
pinchDistance = distance;
} else if (dragging && pointers.size === 1) {
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
cameraState.azimuth -= dx * 0.006;
cameraState.polar = THREE.MathUtils.clamp(cameraState.polar - dy * 0.005, 0.52, 1.34);
lastPointer = { x: event.clientX, y: event.clientY };
updateCamera();
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
dragging = pointers.size > 0;
if (pointers.size < 2) pinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.8
);
updateCamera();
}, { passive: false });
window.addEventListener("resize", () => {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
updateCamera();
});
// -----------------------------------------------------------------------------
// UI
// -----------------------------------------------------------------------------
const playButton = document.querySelector("#playButton");
const replayButton = document.querySelector("#replayButton");
const viewButton = document.querySelector("#viewButton");
const scrubber = document.querySelector("#scrubber");
const timeText = document.querySelector("#timeText");
const statusText = document.querySelector("#statusText");
const stepButtons = [...document.querySelectorAll(".step")];
function togglePlayback() {
if (progress >= 1) progress = 0;
playing = !playing;
updateHUD();
}
playButton.addEventListener("click", togglePlayback);
replayButton.addEventListener("click", () => {
progress = 0;
playing = true;
updateHUD();
});
viewButton.addEventListener("click", resetCamera);
scrubber.addEventListener("input", () => {
progress = Number(scrubber.value) / 1000;
playing = false;
updateHUD();
});
stepButtons.forEach(button => {
button.addEventListener("click", () => {
progress = Number(button.dataset.jump);
playing = false;
updateHUD();
});
});
window.addEventListener("keydown", event => {
if (event.target instanceof HTMLInputElement) return;
if (event.code === "Space") {
event.preventDefault();
togglePlayback();
} else if (event.code === "ArrowLeft") {
cameraState.azimuth += 0.1;
updateCamera();
} else if (event.code === "ArrowRight") {
cameraState.azimuth -= 0.1;
updateCamera();
} else if (event.code === "ArrowUp") {
cameraState.polar = Math.max(0.52, cameraState.polar - 0.08);
updateCamera();
} else if (event.code === "ArrowDown") {
cameraState.polar = Math.min(1.34, cameraState.polar + 0.08);
updateCamera();
}
});
function updateHUD() {
let status = "Order received";
if (progress >= 0.08 && progress < 0.24) status = "Station 1 · Adding warm rice";
else if (progress >= 0.24 && progress < 0.40) status = "On the rail · Market station ahead";
else if (progress >= 0.40 && progress < 0.57) status = "Station 2 · Adding market vegetables";
else if (progress >= 0.57 && progress < 0.73) status = "On the rail · Grill station ahead";
else if (progress >= 0.73 && progress < 0.90) status = "Station 3 · Adding chicken + sauce";
else if (progress >= 0.90 && progress < 0.97) status = "Heading to pickup";
else if (progress >= 0.97) status = "Ready for pickup · Order #042";
statusText.textContent = status;
const states = [
{ active: progress >= 0.08 && progress < 0.24, done: progress >= 0.24 },
{ active: progress >= 0.24 && progress < 0.57, done: progress >= 0.57 },
{ active: progress >= 0.57 && progress < 0.90, done: progress >= 0.90 },
{ active: progress >= 0.90, done: false }
];
stepButtons.forEach((button, index) => {
button.classList.toggle("active", states[index].active);
button.classList.toggle("done", states[index].done);
const state = button.querySelector(".step-state");
state.textContent = states[index].done ? "Done" : states[index].active ? "Now" : "Next";
});
document.querySelector("#ingredient-rice").classList.toggle("added", progress >= 0.15);
document.querySelector("#ingredient-veg").classList.toggle("added", progress >= 0.48);
document.querySelector("#ingredient-chicken").classList.toggle("added", progress >= 0.77);
document.querySelector("#ingredient-sauce").classList.toggle("added", progress >= 0.80);
scrubber.value = String(Math.round(progress * 1000));
document.documentElement.style.setProperty("--progress", `${progress * 100}%`);
const seconds = progress * DURATION;
timeText.textContent = `${seconds.toFixed(1)} / ${DURATION}s`;
playButton.textContent = playing ? "Pause" : progress >= 1 ? "Play again" : "Play";
}
// -----------------------------------------------------------------------------
// Animation loop
// -----------------------------------------------------------------------------
updateCamera();
updateHUD();
renderer.setAnimationLoop(now => {
const dt = Math.min(0.05, (now - lastTime) / 1000);
lastTime = now;
if (playing) {
progress = Math.min(1, progress + dt / DURATION);
if (progress >= 1) {
playing = false;
updateHUD();
}
}
const x = sampleX(progress);
tray.position.x = x;
tray.position.y = 1.25 + (progress > 0.94 ? Math.sin(now * 0.004) * 0.018 : 0);
tray.rotation.y = THREE.MathUtils.lerp(-0.035, 0.035, Math.sin(progress * Math.PI));
setIngredient(foodGroups.rice, progress, 0.11);
setIngredient(foodGroups.veg, progress, 0.45);
setIngredient(foodGroups.chicken, progress, 0.76);
setIngredient(foodGroups.sauce, progress, 0.79);
updateParticles(progress);
const markerX = progress < 0.24 ? -7 : progress < 0.57 ? 0 : progress < 0.90 ? 7 : 10.8;
activeMarker.position.x = markerX;
activeMarker.position.y = 3.85 + Math.sin(now * 0.004) * 0.06;
activeMarker.visible = progress < 0.98;
workers.forEach((worker, index) => {
const active = (index === 0 && progress >= 0.08 && progress < 0.24) ||
(index === 1 && progress >= 0.40 && progress < 0.57) ||
(index === 2 && progress >= 0.73 && progress < 0.90);
const target = active ? -0.65 + Math.sin(now * 0.008 + index) * 0.18 : -0.12;
worker.rightPivot.rotation.z = THREE.MathUtils.lerp(worker.rightPivot.rotation.z, target, 0.08);
worker.leftPivot.rotation.z = THREE.MathUtils.lerp(worker.leftPivot.rotation.z, -target * 0.65, 0.08);
});
if (progress > 0.97) {
pickupBeacon.material.emissive.setHex(0x6bc35d);
pickupBeacon.material.emissiveIntensity = 0.5 + Math.sin(now * 0.006) * 0.18;
} else {
pickupBeacon.material.emissive.setHex(0x000000);
pickupBeacon.material.emissiveIntensity = 0;
}
updateHUD();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```