Prompt specification
Build or customize the Three.js 3D scene "Busy plaza lunch cart" 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: Busy plaza lunch cart
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/busy-plaza-lunch-cart-x0503
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows food-cart service flow. Compose a cart, short queue, shaded seating, and delivery crates; customer and restocking paths remain distinct while order tokens match the meals being handed over. Voxel style.
Working Three.js Starter (busy-plaza-lunch-cart-x0503):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Food-Cart Service Flow</title>
<style>
:root {
--ink: #17343a;
--muted: #577075;
--paper: rgba(255, 253, 246, 0.94);
--customer: #20b8b0;
--restock: #f2a43a;
--order: #ef655d;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eee9dc;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 10;
background: var(--paper);
border: 1px solid rgba(23, 52, 58, 0.12);
box-shadow: 0 12px 32px rgba(43, 58, 55, 0.12);
backdrop-filter: blur(10px);
}
#legend {
top: 18px;
left: 18px;
width: min(330px, calc(100vw - 36px));
padding: 17px 18px 16px;
border-radius: 16px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 5px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
color: var(--customer);
}
h1 {
margin: 0;
font-size: clamp(20px, 2.4vw, 29px);
line-height: 1.05;
letter-spacing: -0.04em;
}
.subtitle {
margin: 9px 0 14px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
font-size: 12px;
font-weight: 650;
}
.swatch {
width: 23px;
height: 9px;
flex: 0 0 auto;
border-radius: 2px;
box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.swatch.customer {
background: var(--customer);
}
.swatch.restock {
background: var(--restock);
}
.swatch.order {
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--order);
color: white;
display: grid;
place-items: center;
font-size: 9px;
font-weight: 900;
}
.match {
margin-top: 13px;
padding-top: 12px;
border-top: 1px solid rgba(23, 52, 58, 0.1);
font-size: 11px;
color: var(--muted);
}
.match strong {
color: var(--order);
}
#controls {
right: 18px;
bottom: 18px;
padding: 10px 13px;
border-radius: 12px;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
text-align: right;
pointer-events: none;
}
#status {
position: fixed;
z-index: 10;
left: 50%;
bottom: 18px;
transform: translateX(-50%);
padding: 9px 14px;
border-radius: 999px;
background: rgba(23, 52, 58, 0.9);
color: white;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.04em;
box-shadow: 0 8px 20px rgba(23, 52, 58, 0.18);
pointer-events: none;
white-space: nowrap;
}
#status .dot {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 7px;
border-radius: 50%;
background: #63e0b4;
box-shadow: 0 0 0 4px rgba(99, 224, 180, 0.13);
}
@media (max-width: 650px) {
#legend {
top: 10px;
left: 10px;
padding: 13px 14px;
}
.subtitle,
.match {
display: none;
}
.legend-row {
margin-top: 6px;
font-size: 10px;
}
#controls {
right: 10px;
bottom: 10px;
padding: 7px 9px;
font-size: 9px;
}
#status {
left: 10px;
bottom: 10px;
transform: none;
font-size: 9px;
}
}
</style>
</head>
<body>
<section id="legend" class="panel">
<p class="eyebrow">Service flow / live order</p>
<h1>Fresh Bites Cart</h1>
<p class="subtitle">
Separate customer and restocking routes keep the service lane clear while
numbered tokens connect each order to its meal.
</p>
<div class="legend-row">
<span class="swatch customer"></span>
Customer queue and pickup route
</div>
<div class="legend-row">
<span class="swatch restock"></span>
Back-of-house restocking route
</div>
<div class="legend-row">
<span class="swatch order">42</span>
Matching order token on meal and crate
</div>
<div class="match">
<strong>ORDER 42 MATCHED</strong><br />
Customer token → handoff meal → delivery crate
</div>
</section>
<div id="status"><span class="dot"></span>ORDER 42 · HANDOFF IN PROGRESS</div>
<div id="controls" class="panel">
Drag to orbit · Shift-drag to pan<br />
Scroll or pinch to zoom
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, and orthographic camera
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color("#eee9dc");
scene.fog = new THREE.Fog("#eee9dc", 42, 72);
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.15;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel-style food cart service flow diagram"
);
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-20, 20, 12, -12, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 1.2, -0.7);
const orbit = {
theta: 0.68,
phi: 0.92,
radius: 36,
zoom: 1
};
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const baseHeight = Math.max(20, 33 / aspect);
const halfHeight = (baseHeight * 0.5) / orbit.zoom;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
cameraTarget.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
cameraTarget.y + orbit.radius * Math.cos(orbit.phi),
cameraTarget.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(cameraTarget);
}
function resize() {
renderer.setSize(window.innerWidth, window.innerHeight);
updateCamera();
}
window.addEventListener("resize", resize);
updateCamera();
// Direct camera controls; no addons are used.
let dragging = false;
let lastX = 0;
let lastY = 0;
let panning = false;
const pointers = new Map();
let pinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
dragging = true;
panning = event.shiftKey || event.button === 2;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
} else if (pointers.size === 2) {
const values = [...pointers.values()];
pinchDistance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].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 values = [...pointers.values()];
const distance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
if (pinchDistance > 0) {
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * (distance / pinchDistance),
0.7,
2
);
updateCamera();
}
pinchDistance = distance;
return;
}
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (panning) {
const scale = camera.top / renderer.domElement.clientHeight;
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
cameraTarget.addScaledVector(right, -dx * scale);
cameraTarget.addScaledVector(up, dy * scale);
cameraTarget.x = THREE.MathUtils.clamp(cameraTarget.x, -10, 10);
cameraTarget.z = THREE.MathUtils.clamp(cameraTarget.z, -7, 7);
} else {
orbit.theta -= dx * 0.008;
orbit.phi = THREE.MathUtils.clamp(orbit.phi + dy * 0.006, 0.48, 1.25);
}
lastX = event.clientX;
lastY = event.clientY;
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 0) {
dragging = false;
panning = false;
pinchDistance = 0;
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.001),
0.7,
2
);
updateCamera();
},
{ passive: false }
);
// -------------------------------------------------------------------------
// Lighting and reusable voxel helpers
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight("#fff8df", "#8a9c91", 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff5d9", 3.3);
sun.position.set(-13, 22, 14);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b8dcff", 0.8);
fill.position.set(16, 9, -15);
scene.add(fill);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
flatShading: true
})
);
}
return materialCache.get(color);
}
function box(
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0,
parent = scene,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material(color)
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function groupAt(x, y, z, parent = scene) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
return group;
}
function makeLabel(
text,
width,
height,
{
background = "#17343a",
foreground = "#ffffff",
fontSize = 62,
border = null,
transparent = false,
parent = scene
} = {}
) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const context = canvas.getContext("2d");
if (background) {
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
}
if (border) {
context.strokeStyle = border;
context.lineWidth = 12;
context.strokeRect(6, 6, canvas.width - 12, canvas.height - 12);
}
context.fillStyle = foreground;
context.font = `900 ${fontSize}px ui-sans-serif, system-ui, sans-serif`;
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent,
side: THREE.DoubleSide,
toneMapped: false
})
);
parent.add(mesh);
return mesh;
}
function makeBadge(text, color, size = 0.62, parent = scene) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const context = canvas.getContext("2d");
context.fillStyle = color;
context.fillRect(12, 12, 232, 232);
context.strokeStyle = "#ffffff";
context.lineWidth = 14;
context.strokeRect(14, 14, 228, 228);
context.fillStyle = "#ffffff";
context.font = "900 116px ui-sans-serif, system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 128, 134);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
toneMapped: false
})
);
sprite.scale.set(size, size, 1);
parent.add(sprite);
return sprite;
}
function makeRoute(points, color, width = 0.52) {
for (let index = 0; index < points.length - 1; index++) {
const start = points[index];
const end = points[index + 1];
const dx = end.x - start.x;
const dz = end.z - start.z;
const length = Math.hypot(dx, dz);
const segment = box(
width,
0.055,
length,
color,
(start.x + end.x) / 2,
0.035,
(start.z + end.z) / 2,
scene,
false
);
segment.rotation.y = Math.atan2(dx, dz);
}
}
function makeArrow(x, z, angle, color) {
const arrow = groupAt(x, 0.105, z);
arrow.rotation.y = angle;
box(0.15, 0.08, 0.62, color, 0, 0, 0, arrow, false);
box(0.15, 0.08, 0.30, color, -0.17, 0, 0.25, arrow, false);
box(0.15, 0.08, 0.30, color, 0.17, 0, 0.25, arrow, false);
}
function makePerson({
shirt = "#20b8b0",
skin = "#d99b73",
hair = "#34323b",
scale = 1,
seated = false,
hat = null,
apron = null,
parent = scene
} = {}) {
const person = groupAt(0, 0, 0, parent);
person.scale.setScalar(scale);
if (seated) {
box(0.30, 0.27, 0.80, "#344b55", -0.22, 0.55, 0.08, person);
box(0.30, 0.27, 0.80, "#344b55", 0.22, 0.55, 0.08, person);
box(0.25, 0.48, 0.27, "#263b43", -0.22, 0.26, 0.38, person);
box(0.25, 0.48, 0.27, "#263b43", 0.22, 0.26, 0.38, person);
box(0.76, 0.78, 0.43, shirt, 0, 1.03, 0, person);
box(0.20, 0.65, 0.28, shirt, -0.49, 0.96, 0.02, person);
box(0.20, 0.65, 0.28, shirt, 0.49, 0.96, 0.02, person);
box(0.50, 0.50, 0.48, skin, 0, 1.70, 0, person);
box(0.52, 0.14, 0.50, hair, 0, 1.96, 0, person);
box(0.06, 0.06, 0.04, "#172c32", -0.11, 1.74, 0.25, person, false);
box(0.06, 0.06, 0.04, "#172c32", 0.11, 1.74, 0.25, person, false);
} else {
box(0.27, 0.66, 0.31, "#344b55", -0.21, 0.37, 0, person);
box(0.27, 0.66, 0.31, "#344b55", 0.21, 0.37, 0, person);
box(0.29, 0.15, 0.46, "#203139", -0.21, 0.08, 0.08, person);
box(0.29, 0.15, 0.46, "#203139", 0.21, 0.08, 0.08, person);
box(0.76, 0.85, 0.43, shirt, 0, 1.13, 0, person);
box(0.20, 0.68, 0.28, shirt, -0.49, 1.10, 0, person);
box(0.20, 0.68, 0.28, shirt, 0.49, 1.10, 0, person);
box(0.52, 0.52, 0.49, skin, 0, 1.87, 0, person);
box(0.55, 0.15, 0.52, hair, 0, 2.14, 0, person);
box(0.06, 0.06, 0.04, "#172c32", -0.11, 1.91, 0.255, person, false);
box(0.06, 0.06, 0.04, "#172c32", 0.11, 1.91, 0.255, person, false);
}
if (apron) {
box(0.58, 0.62, 0.07, apron, 0, 1.05, 0.245, person);
}
if (hat) {
box(0.61, 0.23, 0.57, hat, 0, 2.25, 0, person);
box(0.76, 0.10, 0.72, hat, 0, 2.13, 0, person);
}
return person;
}
function makeMeal(number, color, parent = scene, x = 0, y = 0, z = 0) {
const meal = groupAt(x, y, z, parent);
box(0.82, 0.40, 0.66, "#e8c58d", 0, 0.20, 0, meal);
box(0.86, 0.10, 0.70, "#fff0c8", 0, 0.44, 0, meal);
box(0.20, 0.12, 0.68, color, 0, 0.43, 0, meal);
box(0.17, 0.17, 0.17, "#62a957", -0.20, 0.54, -0.12, meal);
box(0.17, 0.17, 0.17, "#e96943", 0.19, 0.54, 0.10, meal);
const badge = makeBadge(number, color, 0.58, meal);
badge.position.set(0, 0.86, 0.03);
return meal;
}
function makeCrate(number, color, parent = scene, x = 0, y = 0, z = 0) {
const crate = groupAt(x, y, z, parent);
box(1.48, 0.18, 1.24, "#9f6c3e", 0, 0.12, 0, crate);
box(1.48, 0.62, 0.12, "#c58a4f", 0, 0.48, -0.56, crate);
box(1.48, 0.62, 0.12, "#c58a4f", 0, 0.48, 0.56, crate);
box(0.12, 0.62, 1.10, "#b87c46", -0.68, 0.48, 0, crate);
box(0.12, 0.62, 1.10, "#b87c46", 0.68, 0.48, 0, crate);
box(0.23, 0.20, 0.23, "#63a953", -0.34, 0.78, -0.20, crate);
box(0.23, 0.20, 0.23, "#e86a42", 0.28, 0.78, 0.20, crate);
const badge = makeBadge(number, color, 0.62, crate);
badge.position.set(0, 0.55, 0.72);
return crate;
}
function makeTree(x, z, scale = 1) {
const tree = groupAt(x, 0, z);
tree.scale.setScalar(scale);
box(0.55, 2.5, 0.55, "#8a603b", 0, 1.25, 0, tree);
box(2.25, 1.45, 2.0, "#4e9b62", 0, 2.65, 0, tree);
box(1.55, 1.35, 1.65, "#69b66d", -0.45, 3.45, 0.10, tree);
box(1.35, 1.10, 1.45, "#82c875", 0.45, 3.55, -0.05, tree);
return tree;
}
// -------------------------------------------------------------------------
// Ground, floor grid, and route layout
// -------------------------------------------------------------------------
box(34, 0.50, 24, "#ded8c8", 0, -0.30, -1.0);
const gridPositions = [];
for (let x = -16; x <= 16; x += 2) {
gridPositions.push(x, 0.002, -12, x, 0.002, 10);
}
for (let z = -12; z <= 10; z += 2) {
gridPositions.push(-16, 0.002, z, 16, 0.002, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridPositions, 3)
);
scene.add(
new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: "#b9b4a5",
transparent: true,
opacity: 0.28
})
)
);
const customerRoute = [
new THREE.Vector3(-12.3, 0, 9.8),
new THREE.Vector3(-7.0, 0, 9.0),
new THREE.Vector3(-3.0, 0, 7.8),
new THREE.Vector3(-1.0, 0, 6.8),
new THREE.Vector3(-1.0, 0, 4.3),
new THREE.Vector3(-1.0, 0, 2.1)
];
const restockRoute = [
new THREE.Vector3(10.0, 0, -7.1),
new THREE.Vector3(5.8, 0, -7.1),
new THREE.Vector3(4.1, 0, -5.5),
new THREE.Vector3(4.1, 0, -2.6),
new THREE.Vector3(2.3, 0, -2.6),
new THREE.Vector3(1.0, 0, -1.3)
];
makeRoute(customerRoute, "#20b8b0", 0.58);
makeRoute(restockRoute, "#f2a43a", 0.52);
makeArrow(-7.0, 9.0, -0.34, "#137f7b");
makeArrow(-2.6, 7.4, -0.92, "#137f7b");
makeArrow(6.0, -7.1, Math.PI / 2, "#b76d16");
makeArrow(4.1, -3.8, 0, "#b76d16");
const customerLabel = makeLabel("CUSTOMER", 2.5, 0.62, {
background: "#20b8b0",
foreground: "#ffffff",
fontSize: 70
});
customerLabel.rotation.x = -Math.PI / 2;
customerLabel.position.set(-7.6, 0.13, 8.45);
const restockLabel = makeLabel("RESTOCK", 2.25, 0.56, {
background: "#f2a43a",
foreground: "#17343a",
fontSize: 70
});
restockLabel.rotation.x = -Math.PI / 2;
restockLabel.position.set(4.75, 0.13, -4.0);
restockLabel.rotation.z = Math.PI / 2;
// -------------------------------------------------------------------------
// Food cart
// -------------------------------------------------------------------------
const cart = groupAt(0, 0, 0);
// Square voxel wheels.
for (const x of [-2.15, 2.15]) {
for (const z of [-0.83, 0.83]) {
box(0.52, 0.82, 0.82, "#26343a", x, 0.43, z, cart);
box(0.20, 0.20, 0.86, "#d2c9ad", x, 0.43, z, cart);
}
}
box(5.35, 0.30, 2.55, "#375b60", 0, 0.92, 0, cart);
box(5.05, 1.18, 2.35, "#218f8b", 0, 1.58, 0, cart);
box(5.15, 0.20, 2.52, "#e7dcc1", 0, 2.24, 0, cart);
// Front panels and pickup counter.
box(1.22, 0.75, 0.12, "#176e6b", -1.60, 1.55, 1.20, cart);
box(1.22, 0.75, 0.12, "#176e6b", 1.60, 1.55, 1.20, cart);
box(1.22, 0.75, 0.12, "#176e6b", 0, 1.55, 1.20, cart);
box(2.15, 0.16, 0.80, "#f4e7c8", -1.18, 2.37, 1.42, cart);
// Dark service window behind the counter.
box(4.55, 1.30, 0.12, "#24464b", 0, 3.02, 0.75, cart);
// Canopy posts.
for (const x of [-2.52, 2.52]) {
for (const z of [-1.02, 1.02]) {
box(0.16, 2.45, 0.16, "#f3e5c5", x, 3.43, z, cart);
}
}
// Alternating roof strips.
for (let index = 0; index < 8; index++) {
const color = index % 2 === 0 ? "#fff0ce" : "#20b8b0";
box(0.77, 0.25, 3.25, color, -2.75 + index * 0.79, 4.72, 0, cart);
}
const cartSign = makeLabel("FRESH BITES", 3.50, 0.66, {
background: "#173f43",
foreground: "#fff0ce",
fontSize: 67,
parent: cart
});
cartSign.position.set(0, 4.14, 1.67);
const pickupSign = makeLabel("PICKUP", 1.52, 0.43, {
background: "#173f43",
foreground: "#ffffff",
fontSize: 70,
parent: cart
});
pickupSign.position.set(1.30, 1.60, 1.28);
// Chef behind the counter.
const chef = makePerson({
shirt: "#fff3db",
skin: "#c9825d",
hair: "#3e2b26",
scale: 0.88,
hat: "#ffffff",
apron: "#d9e9df",
parent: cart
});
chef.position.set(0.45, 1.30, -0.05);
// A few cups and kitchen blocks on the counter.
for (let index = 0; index < 3; index++) {
box(
0.22,
0.35,
0.22,
index === 1 ? "#ef655d" : "#f4e7c8",
0.75 + index * 0.42,
2.55,
0.55,
cart
);
}
// The active order meal on the pickup shelf.
const pickupMeal = makeMeal("42", "#ef655d", scene, -1.28, 2.45, 1.44);
// -------------------------------------------------------------------------
// Customer queue and matching meals
// -------------------------------------------------------------------------
const orderColors = {
"42": "#ef655d",
"17": "#438bf2",
"08": "#e4aa35"
};
const customer42 = makePerson({
shirt: "#ef655d",
skin: "#b87552",
hair: "#2e2b31",
scale: 1.02
});
customer42.position.set(-1.0, 0, 3.25);
customer42.rotation.y = Math.PI;
const customer42Meal = makeMeal(
"42",
orderColors["42"],
customer42,
0.64,
1.20,
0.34
);
const customer17 = makePerson({
shirt: "#438bf2",
skin: "#e0a579",
hair: "#6b3f2e",
scale: 0.98
});
customer17.position.set(-1.0, 0, 5.05);
customer17.rotation.y = Math.PI;
makeMeal("17", orderColors["17"], customer17, 0.62, 1.18, 0.32);
const customer08 = makePerson({
shirt: "#e4aa35",
skin: "#8f593e",
hair: "#25272d",
scale: 0.96
});
customer08.position.set(-1.0, 0, 6.80);
customer08.rotation.y = Math.PI;
makeMeal("08", orderColors["08"], customer08, 0.62, 1.18, 0.32);
// Floating order-token trail emphasizes the match to the handoff meal.
const tokenTrail = [];
for (let index = 0; index < 5; index++) {
const token = box(
0.12,
0.12,
0.12,
orderColors["42"],
-1.45,
1.75 + index * 0.08,
2.85 - index * 0.30,
scene,
false
);
token.rotation.set(index * 0.35, index * 0.42, index * 0.25);
tokenTrail.push(token);
}
// -------------------------------------------------------------------------
// Shaded seating area
// -------------------------------------------------------------------------
const seating = groupAt(-8.2, 0, -2.0);
box(6.75, 0.18, 5.65, "#cdbda0", 0, 0.10, 0, seating);
// Tables and block benches.
box(2.15, 0.18, 1.12, "#f2dfb7", 0, 1.18, 0, seating);
box(0.30, 1.08, 0.30, "#89633e", 0, 0.63, 0, seating);
box(0.75, 0.16, 0.75, "#89633e", 0, 0.24, 0, seating);
box(2.45, 0.32, 0.48, "#9a6b43", 0, 0.70, -1.40, seating);
box(2.45, 0.32, 0.48, "#9a6b43", 0, 0.70, 1.40, seating);
box(0.48, 0.32, 2.15, "#9a6b43", -2.05, 0.70, 0, seating);
// Perimeter and canopy posts.
for (const x of [-2.75, 2.75]) {
for (const z of [-2.15, 2.15]) {
box(0.16, 3.85, 0.16, "#e6d5b4", x, 2.03, z, seating);
}
}
// Striped shade canopy.
for (let index = 0; index < 8; index++) {
const color = index % 2 === 0 ? "#f5e9ca" : "#4c9fa5";
box(0.84, 0.22, 5.70, color, -2.94 + index * 0.84, 4.08, 0, seating);
}
const seatingSign = makeLabel("SHADED SEATING", 2.55, 0.54, {
background: "#225f65",
foreground: "#ffffff",
fontSize: 64,
parent: seating
});
seatingSign.position.set(0, 3.54, 2.91);
// Seated voxel diners.
const seatedA = makePerson({
shirt: "#789ad6",
skin: "#dda078",
hair: "#3c2c29",
seated: true,
scale: 0.86,
parent: seating
});
seatedA.position.set(-0.55, 0.12, -1.35);
seatedA.rotation.y = Math.PI;
const seatedB = makePerson({
shirt: "#d98575",
skin: "#9c5f42",
hair: "#24252a",
seated: true,
scale: 0.84,
parent: seating
});
seatedB.position.set(0.70, 0.12, 1.38);
seatedB.rotation.y = 0;
// Small table items.
box(0.25, 0.35, 0.25, "#ef655d", -0.45, 1.45, -0.10, seating);
box(0.38, 0.08, 0.38, "#fff4da", 0.45, 1.32, 0.20, seating);
// -------------------------------------------------------------------------
// Delivery crates and back-of-house stock area
// -------------------------------------------------------------------------
const delivery = groupAt(10.0, 0, -6.1);
box(5.75, 0.18, 4.20, "#c8b79a", 0, 0.10, 0, delivery);
// Stock shelf.
for (const x of [-2.15, 2.15]) {
box(0.18, 2.55, 0.18, "#6e766f", x, 1.30, -1.40, delivery);
}
box(4.55, 0.18, 1.00, "#839185", 0, 1.25, -1.40, delivery);
box(4.55, 0.18, 1.00, "#839185", 0, 2.45, -1.40, delivery);
box(0.85, 0.70, 0.75, "#dfad70", -1.30, 1.68, -1.40, delivery);
box(0.85, 0.70, 0.75, "#e8c28c", 0, 1.68, -1.40, delivery);
box(0.85, 0.70, 0.75, "#d9a166", 1.30, 1.68, -1.40, delivery);
// Ready delivery crates.
makeCrate("17", orderColors["17"], delivery, -1.40, 0.20, 0.40);
makeCrate("08", orderColors["08"], delivery, 0.70, 0.20, 0.65);
const deliverySign = makeLabel("DELIVERY CRATES", 3.30, 0.62, {
background: "#173f43",
foreground: "#ffffff",
fontSize: 59
});
deliverySign.position.set(10.0, 2.80, -4.05);
const stockSign = makeLabel("BACK STOCK", 2.15, 0.52, {
background: "#f2a43a",
foreground: "#17343a",
fontSize: 66
});
stockSign.position.set(11.65, 3.00, -7.56);
// -------------------------------------------------------------------------
// Animated restocker and order crate
// -------------------------------------------------------------------------
const trolley = groupAt(0, 0, 0);
box(1.62, 0.18, 1.34, "#3c5459", 0, 0.35, 0, trolley);
for (const x of [-0.57, 0.57]) {
for (const z of [-0.43, 0.43]) {
box(0.32, 0.32, 0.32, "#26343a", x, 0.20, z, trolley);
}
}
box(0.13, 1.30, 0.13, "#e5d9bb", -0.70, 0.95, 0.55, trolley);
box(0.13, 1.30, 0.13, "#e5d9bb", 0.70, 0.95, 0.55, trolley);
box(1.55, 0.13, 0.13, "#e5d9bb", 0, 1.55, 0.55, trolley);
const movingCrate = makeCrate("42", orderColors["42"], trolley, 0, 0.43, 0);
const restocker = makePerson({
shirt: "#f2a43a",
skin: "#a96c48",
hair: "#252a2e",
scale: 0.92,
apron: "#c96f22"
});
// -------------------------------------------------------------------------
// Decorative voxel landscaping
// -------------------------------------------------------------------------
makeTree(-14.1, -8.8, 1.05);
makeTree(14.4, 2.2, 0.92);
makeTree(-14.3, 5.4, 0.72);
// Low planters.
for (const [x, z] of [[-13.0, -4.8], [13.6, -9.5], [12.7, 6.0]]) {
box(1.30, 0.65, 1.30, "#b78655", x, 0.32, z);
box(1.05, 0.20, 1.05, "#548d51", x, 0.70, z);
box(0.48, 0.60, 0.48, "#6eae5f", x - 0.22, 1.05, z);
box(0.48, 0.60, 0.48, "#80bd68", x + 0.25, 1.00, z + 0.15);
}
// -------------------------------------------------------------------------
// Route sampling and animation
// -------------------------------------------------------------------------
function sampleRoute(points, t) {
const lengths = [];
let total = 0;
for (let index = 0; index < points.length - 1; index++) {
const length = points[index].distanceTo(points[index + 1]);
lengths.push(length);
total += length;
}
let distance = THREE.MathUtils.clamp(t, 0, 1) * total;
for (let index = 0; index < lengths.length; index++) {
if (distance <= lengths[index] || index === lengths.length - 1) {
const start = points[index];
const end = points[index + 1];
const localT = lengths[index] === 0 ? 0 : distance / lengths[index];
const position = start.clone().lerp(end, localT);
const tangent = end.clone().sub(start).normalize();
return { position, tangent };
}
distance -= lengths[index];
}
return {
position: points[points.length - 1].clone(),
tangent: new THREE.Vector3(0, 0, 1)
};
}
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
// Queue movement is intentionally subtle so the spatial flow stays clear.
customer42.position.z = 3.25 + Math.sin(elapsed * 1.4) * 0.025;
customer17.position.z = 5.05 + Math.sin(elapsed * 1.2 + 1.2) * 0.02;
customer08.position.z = 6.80 + Math.sin(elapsed * 1.1 + 2.4) * 0.018;
// Order 42 token trail.
tokenTrail.forEach((token, index) => {
const pulse = 0.68 + Math.sin(elapsed * 3.4 - index * 0.55) * 0.22;
token.scale.setScalar(pulse);
token.position.y = 1.72 + index * 0.08 + Math.sin(elapsed * 3 - index) * 0.035;
});
// Active handoff meal has a subtle lift.
pickupMeal.position.y = 2.45 + Math.sin(elapsed * 2.6) * 0.018;
// Restocking cycle:
// 0–8 s outbound with crate, 8–9 s at cart, 9–17 s empty return.
const cycle = elapsed % 17;
let routeT;
let crateVisible = true;
if (cycle < 8) {
routeT = cycle / 8;
} else if (cycle < 9) {
routeT = 1;
} else {
routeT = 1 - (cycle - 9) / 8;
crateVisible = false;
}
const routeSample = sampleRoute(restockRoute, routeT);
trolley.position.copy(routeSample.position);
trolley.rotation.y = Math.atan2(routeSample.tangent.x, routeSample.tangent.z);
movingCrate.visible = crateVisible;
// Place the worker just behind the trolley.
const workerT = THREE.MathUtils.clamp(routeT - 0.055, 0, 1);
const workerSample = sampleRoute(restockRoute, workerT);
restocker.position.copy(workerSample.position);
restocker.rotation.y = Math.atan2(
workerSample.tangent.x,
workerSample.tangent.z
);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```