Prompt specification
Build or customize the Three.js 3D scene "Meal Delivery With Confirmed Requests" 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: Meal Delivery With Confirmed Requests
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/meal-delivery-with-confirmed-requests-x3234
Scene Description Prompt:
A voxel neighborhood kitchen delivers meals to confirmed requests, updating each recipient and preserving food and container counts. One HTML file using Three.js from cdnjs.
Working Three.js Starter (meal-delivery-with-confirmed-requests-x3234):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Block & Ladle — Voxel Neighborhood Kitchen</title>
<style>
:root {
--ink: #26343b;
--muted: #718087;
--paper: #fffdf7;
--line: #dce2dc;
--orange: #ef8354;
--orange-dark: #c95f37;
--teal: #277f78;
--teal-dark: #175f5a;
--yellow: #f2c14e;
--green: #55a96b;
--blue: #4e8fc5;
--shadow: 0 18px 50px rgba(32, 53, 56, 0.16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9e5;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button { font: inherit; }
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas.dragging { cursor: grabbing; }
.topbar {
position: fixed;
z-index: 20;
top: 16px;
left: 16px;
right: 16px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 310px;
padding: 11px 15px 11px 11px;
border: 1px solid rgba(255,255,255,.72);
border-radius: 18px;
background: rgba(255, 253, 247, .9);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
}
.brand-mark {
position: relative;
width: 44px;
height: 44px;
flex: 0 0 auto;
border-radius: 13px;
background: var(--orange);
box-shadow: inset 0 -4px 0 rgba(117, 48, 26, .15);
}
.brand-mark::before {
content: "";
position: absolute;
width: 20px;
height: 12px;
left: 12px;
top: 15px;
border-radius: 3px 3px 10px 10px;
background: #fff8e7;
box-shadow: 0 -7px 0 -3px #fff8e7;
}
.brand h1 {
margin: 0;
font-size: 18px;
line-height: 1.05;
letter-spacing: -.02em;
}
.brand p {
margin: 4px 0 0;
color: var(--muted);
font-size: 11px;
font-weight: 700;
letter-spacing: .09em;
text-transform: uppercase;
}
.top-actions {
display: flex;
align-items: center;
gap: 8px;
margin-right: 390px;
}
.model-pill,
.icon-button {
border: 1px solid rgba(255,255,255,.72);
background: rgba(255, 253, 247, .9);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
}
.model-pill {
display: flex;
align-items: center;
gap: 8px;
height: 42px;
padding: 0 14px;
border-radius: 13px;
color: var(--teal-dark);
font-size: 12px;
font-weight: 800;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 5px rgba(85, 169, 107, .13);
}
.icon-button {
width: 42px;
height: 42px;
border-radius: 13px;
color: var(--ink);
cursor: pointer;
transition: transform .18s ease, background .18s ease;
}
.icon-button:hover {
transform: translateY(-2px);
background: #fff;
}
.panel {
position: fixed;
z-index: 30;
top: 86px;
right: 16px;
bottom: 16px;
width: 374px;
display: flex;
flex-direction: column;
overflow: hidden;
border: 1px solid rgba(255,255,255,.75);
border-radius: 24px;
background: rgba(255, 253, 247, .95);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.panel-head {
padding: 22px 22px 16px;
border-bottom: 1px solid var(--line);
}
.eyebrow {
color: var(--teal);
font-size: 10px;
font-weight: 900;
letter-spacing: .15em;
text-transform: uppercase;
}
.panel-head h2 {
margin: 5px 0 0;
font-size: 24px;
letter-spacing: -.035em;
}
.panel-head p {
margin: 7px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.panel-content {
flex: 1;
min-height: 0;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #c8d0ca transparent;
}
.panel-content::-webkit-scrollbar { width: 7px; }
.panel-content::-webkit-scrollbar-thumb {
border-radius: 8px;
background: #c8d0ca;
}
.section {
padding: 17px 18px;
border-bottom: 1px solid var(--line);
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.section-title h3 {
margin: 0;
font-size: 13px;
letter-spacing: -.01em;
}
.section-title small {
color: var(--muted);
font-size: 10px;
font-weight: 700;
}
.stock-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.stock-card {
position: relative;
overflow: hidden;
min-height: 91px;
padding: 12px;
border: 1px solid #e4e6dc;
border-radius: 16px;
background: #fffefa;
}
.stock-card::after {
content: "";
position: absolute;
right: -13px;
bottom: -18px;
width: 54px;
height: 54px;
border-radius: 15px;
background: rgba(242, 193, 78, .18);
transform: rotate(15deg);
}
.stock-label {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .06em;
text-transform: uppercase;
}
.stock-number {
display: block;
margin-top: 2px;
font-size: 29px;
line-height: 1;
font-weight: 900;
letter-spacing: -.05em;
}
.stock-caption {
display: block;
margin-top: 7px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
}
.ledger {
display: grid;
gap: 9px;
margin-top: 13px;
}
.ledger-row {
display: grid;
grid-template-columns: 50px 1fr auto;
align-items: center;
gap: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
}
.ledger-row b {
min-width: 28px;
color: var(--ink);
text-align: right;
}
.ledger-bar {
display: flex;
height: 7px;
overflow: hidden;
border-radius: 10px;
background: #edf0e9;
}
.ledger-bar span { height: 100%; }
.ledger-bar .available { background: var(--teal); }
.ledger-bar .packed { background: var(--yellow); }
.ledger-bar .transit { background: var(--blue); }
.ledger-bar .served { background: var(--green); }
.conservation {
margin-top: 13px;
padding: 10px 11px;
border-radius: 12px;
background: #eef5ef;
color: #4a6653;
font-size: 10px;
line-height: 1.45;
font-weight: 700;
}
.primary-button,
.secondary-button {
width: 100%;
border: 0;
border-radius: 13px;
padding: 12px 14px;
cursor: pointer;
font-weight: 850;
transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}
.primary-button {
margin-top: 13px;
background: var(--teal);
color: white;
box-shadow: 0 7px 0 var(--teal-dark);
}
.primary-button:hover:not(:disabled) {
transform: translateY(-2px);
filter: brightness(1.05);
}
.primary-button:active:not(:disabled) {
transform: translateY(3px);
box-shadow: 0 3px 0 var(--teal-dark);
}
.primary-button:disabled {
cursor: not-allowed;
opacity: .52;
box-shadow: 0 4px 0 #aebbb6;
}
.secondary-button {
margin-top: 9px;
border: 1px solid var(--line);
background: #f8f7f1;
color: var(--ink);
}
.secondary-button:hover {
background: #fff;
}
.flow {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.flow-step {
padding: 10px 7px;
border: 1px solid var(--line);
border-radius: 12px;
background: #fffefa;
text-align: center;
}
.flow-step span {
display: grid;
place-items: center;
width: 24px;
height: 24px;
margin: 0 auto 6px;
border-radius: 8px;
background: #edf2ed;
color: var(--teal-dark);
font-size: 11px;
font-weight: 900;
}
.flow-step b {
display: block;
font-size: 10px;
}
.flow-step small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.house-list {
display: grid;
gap: 9px;
padding: 14px 16px 18px;
}
.house-card {
display: grid;
grid-template-columns: 39px 1fr auto;
align-items: center;
gap: 10px;
padding: 11px;
border: 1px solid #e2e5de;
border-radius: 15px;
background: #fffefa;
transition: border-color .18s ease, transform .18s ease;
}
.house-card:hover {
border-color: #c9d3cc;
transform: translateY(-1px);
}
.avatar {
display: grid;
place-items: center;
width: 39px;
height: 39px;
border-radius: 12px;
color: white;
font-size: 14px;
font-weight: 900;
box-shadow: inset 0 -4px 0 rgba(0,0,0,.11);
}
.house-main { min-width: 0; }
.house-name {
overflow: hidden;
font-size: 12px;
font-weight: 850;
text-overflow: ellipsis;
white-space: nowrap;
}
.house-address {
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
.status {
display: inline-flex;
align-items: center;
gap: 5px;
margin-top: 5px;
padding: 3px 6px;
border-radius: 7px;
font-size: 8px;
font-weight: 900;
letter-spacing: .05em;
text-transform: uppercase;
}
.status::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: currentColor;
}
.status.idle { color: #748087; background: #edf0ed; }
.status.requested { color: #ad672f; background: #fff0dc; }
.status.confirmed { color: #9b7511; background: #fff5cd; }
.status.transit { color: #326f9e; background: #e1f0fb; }
.status.delivered { color: #397f4b; background: #e2f3e5; }
.house-action {
min-width: 72px;
padding: 8px 9px;
border: 1px solid #dce2dc;
border-radius: 10px;
background: #f7f6f0;
color: var(--ink);
cursor: pointer;
font-size: 9px;
font-weight: 850;
}
.house-action:hover:not(:disabled) {
background: #fff;
border-color: #bdc9c1;
}
.house-action.confirm {
border-color: #efc56b;
background: #fff5d5;
color: #8b6410;
}
.house-action.deliver {
border-color: #9bc3df;
background: #e7f3fb;
color: #326f9e;
}
.house-action:disabled {
cursor: default;
opacity: .55;
}
.scene-help {
position: fixed;
z-index: 8;
left: 18px;
bottom: 18px;
display: flex;
align-items: center;
gap: 11px;
padding: 9px 12px;
border: 1px solid rgba(255,255,255,.7);
border-radius: 13px;
background: rgba(255,253,247,.82);
color: #5d6b70;
box-shadow: 0 10px 28px rgba(40,57,60,.11);
backdrop-filter: blur(10px);
font-size: 10px;
font-weight: 750;
pointer-events: none;
}
.help-dot {
width: 5px;
height: 5px;
border-radius: 50%;
background: #aab6b3;
}
.world-label {
position: fixed;
z-index: 6;
min-width: 92px;
padding: 7px 9px;
border: 1px solid rgba(255,255,255,.8);
border-radius: 11px;
background: rgba(255,253,247,.9);
box-shadow: 0 8px 20px rgba(36,52,56,.13);
color: var(--ink);
text-align: center;
pointer-events: none;
transform: translate(-50%, -100%);
will-change: transform;
}
.world-label::after {
content: "";
position: absolute;
left: 50%;
bottom: -5px;
width: 9px;
height: 9px;
background: inherit;
transform: translateX(-50%) rotate(45deg);
z-index: -1;
}
.world-label strong {
display: block;
font-size: 10px;
line-height: 1.1;
white-space: nowrap;
}
.world-label small {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
margin-top: 4px;
color: var(--muted);
font-size: 8px;
font-weight: 800;
}
.world-label .label-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: #a5afac;
}
.world-label.kitchen {
border-color: rgba(239,131,84,.45);
}
.world-label.kitchen .label-dot { background: var(--orange); }
.toast {
position: fixed;
z-index: 60;
left: 50%;
bottom: 24px;
max-width: min(420px, calc(100vw - 32px));
padding: 12px 16px;
border-radius: 13px;
background: #26343b;
color: white;
box-shadow: 0 12px 35px rgba(25,38,42,.25);
font-size: 12px;
font-weight: 750;
text-align: center;
opacity: 0;
pointer-events: none;
transform: translate(-50%, 14px);
transition: opacity .22s ease, transform .22s ease;
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
@media (max-width: 850px) {
.topbar { top: 10px; left: 10px; right: 10px; }
.brand { min-width: 0; padding-right: 12px; }
.brand h1 { font-size: 15px; }
.brand p { display: none; }
.brand-mark { width: 39px; height: 39px; }
.brand-mark::before { left: 10px; top: 13px; }
.top-actions { margin-right: 0; }
.model-pill { display: none; }
.panel {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 48vh;
border-radius: 20px;
}
.panel-head { padding: 14px 16px 11px; }
.panel-head h2 { font-size: 19px; }
.panel-head p { display: none; }
.scene-help { display: none; }
.world-label { transform: translate(-50%, -100%) scale(.9); }
}
@media (max-width: 500px) {
.top-actions .icon-button { width: 39px; height: 39px; }
.brand { gap: 8px; }
.brand h1 { max-width: 135px; }
.section { padding: 13px 14px; }
.flow { display: none; }
.house-list { padding: 11px 12px 15px; }
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive 3D voxel neighborhood"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<h1>Block & Ladle</h1>
<p>Neighborhood meal service</p>
</div>
</div>
<div class="top-actions">
<div class="model-pill"><span class="live-dot"></span> Live service model</div>
<button class="icon-button" id="resetView" title="Reset camera" aria-label="Reset camera">⌂</button>
</div>
</header>
<aside class="panel">
<div class="panel-head">
<div class="eyebrow">Kitchen dashboard</div>
<h2>Meal service board</h2>
<p>Requests become meals only after the kitchen confirms them.</p>
</div>
<div class="panel-content">
<section class="section">
<div class="section-title">
<h3>Pantry ledger</h3>
<small>One portion + one container</small>
</div>
<div class="stock-grid">
<div class="stock-card">
<span class="stock-label">Food portions</span>
<strong class="stock-number" id="foodAvailable">10</strong>
<span class="stock-caption">available to pack</span>
</div>
<div class="stock-card">
<span class="stock-label">Containers</span>
<strong class="stock-number" id="containerAvailable">10</strong>
<span class="stock-caption">clean and ready</span>
</div>
</div>
<div class="ledger">
<div class="ledger-row">
<span>Food</span>
<div class="ledger-bar" id="foodBar"></div>
<b id="foodSummary">10/1/0/1</b>
</div>
<div class="ledger-row">
<span>Boxes</span>
<div class="ledger-bar" id="containerBar"></div>
<b id="containerSummary">10/1/0/1</b>
</div>
</div>
<div class="conservation" id="conservation">
Balanced ledger: 12 = 10 available + 1 packed + 0 moving + 1 served.
</div>
<button class="primary-button" id="deliverBtn">Deliver next meal</button>
<button class="secondary-button" id="quickRequest">Queue a request</button>
</section>
<section class="section">
<div class="section-title">
<h3>Service flow</h3>
<small>Counts update at each step</small>
</div>
<div class="flow">
<div class="flow-step">
<span>1</span><b>Request</b><small>No stock used</small>
</div>
<div class="flow-step">
<span>2</span><b>Confirm</b><small>Pack meal</small>
</div>
<div class="flow-step">
<span>3</span><b>Deliver</b><small>Update home</small>
</div>
</div>
</section>
<div class="section-title" style="padding: 16px 18px 0; margin-bottom: 0;">
<h3>Recipients</h3>
<small id="recipientCount">5 households</small>
</div>
<div class="house-list" id="houseList"></div>
</div>
</aside>
<div class="scene-help">
<span>Drag to orbit</span><span class="help-dot"></span>
<span>Scroll to zoom</span><span class="help-dot"></span>
<span>Shift-drag to pan</span><span class="help-dot"></span>
<span>Click a home to request</span>
</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const INITIAL_STOCK = 12;
const households = [
{
id: "maple",
name: "Maple House",
address: "14 Maple Street",
color: 0xef8354,
css: "#ef8354",
x: -6.1,
z: -4.7,
state: "idle"
},
{
id: "birch",
name: "Birch House",
address: "18 Birch Street",
color: 0x4e8fc5,
css: "#4e8fc5",
x: -2.8,
z: -4.7,
state: "requested"
},
{
id: "elm",
name: "Elm House",
address: "22 Elm Avenue",
color: 0x55a96b,
css: "#55a96b",
x: -6.1,
z: 4.7,
state: "confirmed"
},
{
id: "pine",
name: "Pine House",
address: "27 Pine Lane",
color: 0x8e75b5,
css: "#8e75b5",
x: -2.8,
z: 4.7,
state: "delivered"
},
{
id: "cedar",
name: "Cedar House",
address: "31 Cedar Court",
color: 0xe0a934,
css: "#e0a934",
x: 6.1,
z: 4.7,
state: "idle"
}
];
const ledger = {
food: { available: 10, packed: 1, transit: 0, served: 1 },
container: { available: 10, packed: 1, transit: 0, served: 1 }
};
const statusCopy = {
idle: "Needs a request",
requested: "Request sent",
confirmed: "Meal packed",
transit: "On the way",
delivered: "Meal delivered"
};
const statusColors = {
idle: 0x9ba6a3,
requested: 0xef9b52,
confirmed: 0xf2c14e,
transit: 0x4e8fc5,
delivered: 0x55a96b
};
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9e5);
scene.fog = new THREE.Fog(0xdce9e5, 38, 65);
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.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.getElementById("scene").appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-12, 12, 9, -9, 0.1, 100);
const cameraRig = {
target: new THREE.Vector3(0.2, 0.7, 0),
azimuth: 0.58,
elevation: 0.68,
zoom: 1,
radius: 30
};
const hemi = new THREE.HemisphereLight(0xf8fff8, 0x738477, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d6, 3.2);
sun.position.set(-12, 20, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 16;
sun.shadow.camera.bottom = -16;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xcce5ff, 0.75);
fill.position.set(12, 8, -12);
scene.add(fill);
const materialCache = new Map();
function material(color, options = {}) {
if (options.unique) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.92,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
});
}
const key = `${color}-${options.roughness ?? 0.92}-${options.metalness ?? 0}-${options.emissive ?? 0}-${options.emissiveIntensity ?? 0}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.92,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
}));
}
return materialCache.get(key);
}
function box(parent, w, h, d, x, y, z, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
options.material || material(color, options)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
if (options.rotation) mesh.rotation.set(...options.rotation);
if (options.name) mesh.name = options.name;
parent.add(mesh);
return mesh;
}
function makeTextPlane(text, bg = "#ef8354", fg = "#fffdf7", width = 512, height = 128) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
ctx.fillStyle = bg;
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = fg;
ctx.font = "900 48px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, width / 2, height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width / 95, height / 95),
new THREE.MeshBasicMaterial({ map: texture, side: THREE.DoubleSide })
);
return mesh;
}
// Neighborhood base.
box(scene, 24, 0.8, 18, 0, -0.48, 0, 0xd8d1b8);
box(scene, 23.7, 0.12, 17.7, 0, -0.02, 0, 0xa9c49a);
// Crossroads and sidewalks.
box(scene, 23.3, 0.12, 3.1, 0, 0.08, 0, 0xe8dfc8);
box(scene, 3.1, 0.12, 17.3, 0, 0.08, 0, 0xe8dfc8);
box(scene, 23.5, 0.1, 2.35, 0, 0.16, 0, 0x4d5b61);
box(scene, 2.35, 0.1, 17.5, 0, 0.16, 0, 0x4d5b61);
for (let x = -10; x <= 10; x += 2) {
if (Math.abs(x) > 1.1) box(scene, 0.8, 0.025, 0.08, x, 0.225, 0, 0xf5d981, { castShadow: false });
}
for (let z = -7; z <= 7; z += 2) {
if (Math.abs(z) > 1.1) box(scene, 0.08, 0.025, 0.8, 0, 0.225, z, 0xf5d981, { castShadow: false });
}
// Crosswalk stripes.
for (let i = 0; i < 5; i++) {
box(scene, 0.38, 0.03, 1.5, 1.65 + i * 0.58, 0.23, 0, 0xf4efe2, { castShadow: false });
}
function createTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.12, z);
group.scale.setScalar(scale);
box(group, 0.38, 1.8, 0.38, 0, 0.9, 0, 0x76513d);
box(group, 1.65, 1.15, 1.65, 0, 2.05, 0, 0x477f55);
box(group, 1.15, 0.85, 1.15, 0, 2.92, 0, 0x5c9867);
box(group, 0.65, 0.55, 0.65, 0.15, 3.55, -0.08, 0x74aa78);
scene.add(group);
return group;
}
[
[-9.4, -6.7, 1.0], [-9.4, 6.8, 1.1], [9.4, -6.7, 0.95],
[9.4, 6.8, 1.05], [-4.1, 7.1, 0.78], [3.8, -7.0, 0.83],
[9.0, 2.4, 0.72]
].forEach(p => createTree(...p));
function createLamp(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.18, z);
group.rotation.y = rotation;
box(group, 0.16, 2.7, 0.16, 0, 1.35, 0, 0x34454a);
box(group, 0.75, 0.14, 0.16, 0.3, 2.65, 0, 0x34454a);
box(group, 0.5, 0.38, 0.42, 0.58, 2.48, 0, 0xffe9a5, {
emissive: 0xf5b942,
emissiveIntensity: 0.35
});
scene.add(group);
}
createLamp(-1.8, -6.2);
createLamp(1.8, 5.7, Math.PI);
createLamp(-8.3, 1.8, Math.PI / 2);
createLamp(8.2, -1.8, -Math.PI / 2);
function createPerson(color, skin = 0xe7b68f) {
const person = new THREE.Group();
box(person, 0.52, 0.68, 0.38, 0, 0.92, 0, color);
box(person, 0.43, 0.43, 0.4, 0, 1.47, 0, skin);
box(person, 0.16, 0.48, 0.18, -0.15, 0.32, 0, 0x34454a);
box(person, 0.16, 0.48, 0.18, 0.15, 0.32, 0, 0x34454a);
box(person, 0.07, 0.07, 0.03, -0.1, 1.51, 0.205, 0x26343b);
box(person, 0.07, 0.07, 0.03, 0.1, 1.51, 0.205, 0x26343b);
const leftArm = new THREE.Group();
leftArm.position.set(-0.34, 1.18, 0);
box(leftArm, 0.17, 0.58, 0.2, 0, -0.25, 0, color);
person.add(leftArm);
const rightArm = new THREE.Group();
rightArm.position.set(0.34, 1.18, 0);
box(rightArm, 0.17, 0.58, 0.2, 0, -0.25, 0, color);
person.add(rightArm);
return { person, leftArm, rightArm };
}
function createMeal() {
const meal = new THREE.Group();
box(meal, 0.72, 0.12, 0.72, 0, 0.12, 0, 0xd9d2b8);
box(meal, 0.56, 0.18, 0.56, 0, 0.27, 0, 0xf1e7ca);
box(meal, 0.39, 0.08, 0.39, 0, 0.4, 0, 0xe98b4d);
box(meal, 0.12, 0.15, 0.12, 0.04, 0.49, -0.03, 0x5e9348);
return meal;
}
const houseVisuals = new Map();
const pickables = [];
const worldLabels = [];
function createLabel(title, subtitle, x, y, z, kitchen = false) {
const el = document.createElement("div");
el.className = `world-label${kitchen ? " kitchen" : ""}`;
el.innerHTML = `
<strong>${title}</strong>
<small><span class="label-dot"></span><span>${subtitle}</span></small>
`;
document.body.appendChild(el);
worldLabels.push({ el, position: new THREE.Vector3(x, y, z) });
return el;
}
function createHouse(house) {
const group = new THREE.Group();
group.position.set(house.x, 0.22, house.z);
scene.add(group);
const front = house.z < 0 ? 1 : -1;
const wallColor = new THREE.Color(house.color).lerp(new THREE.Color(0xffffff), 0.72).getHex();
const roofColor = new THREE.Color(house.color).lerp(new THREE.Color(0x26343b), 0.35).getHex();
box(group, 3.45, 0.22, 3.35, 0, 0.02, 0, 0xd9d1b8);
box(group, 2.65, 1.95, 2.55, 0, 1.12, 0, wallColor);
box(group, 2.4, 0.52, 2.3, 0, 2.34, 0, wallColor);
box(group, 3.12, 0.28, 3.0, 0, 2.72, 0, roofColor);
box(group, 2.68, 0.28, 2.58, 0, 3.0, 0, roofColor);
box(group, 2.1, 0.26, 2.03, 0, 3.26, 0, roofColor);
box(group, 0.38, 0.75, 0.42, 0.75, 3.75, -0.55, 0x6c5550);
// Door and windows face the shared street.
box(group, 0.68, 1.22, 0.09, 0, 0.72, front * 1.32, 0x3e5557);
box(group, 0.1, 0.1, 0.07, 0.22, 0.72, front * 1.39, 0xf2c14e);
box(group, 0.66, 0.64, 0.08, -0.82, 1.35, front * 1.32, 0x6fabb4, {
emissive: 0x74aeb7,
emissiveIntensity: 0.15
});
box(group, 0.72, 0.7, 0.08, 0.82, 1.35, front * 1.32, 0x6fabb4, {
emissive: 0x74aeb7,
emissiveIntensity: 0.15
});
box(group, 0.08, 0.64, 0.72, 1.36, 1.35, 0, 0x6fabb4);
// Small front step.
box(group, 0.95, 0.14, 0.58, 0, 0.11, front * 1.58, 0xeee3c8);
const personData = createPerson(house.color, house.id === "cedar" ? 0x9c6546 : 0xe7b68f);
personData.person.position.set(1.03, 0.08, front * 1.63);
personData.person.rotation.y = front > 0 ? Math.PI : 0;
group.add(personData.person);
const meal = createMeal();
meal.position.set(-0.86, 0.12, front * 1.62);
meal.visible = house.state === "delivered";
group.add(meal);
// Status post.
box(group, 0.12, 1.15, 0.12, -1.34, 0.65, front * 1.63, 0x536269);
const beaconMaterial = material(statusColors[house.state], { unique: true });
const beacon = box(group, 0.38, 0.38, 0.38, -1.34, 1.36, front * 1.63, statusColors[house.state], {
material: beaconMaterial
});
group.traverse(child => {
if (child.isMesh) child.userData.houseId = house.id;
});
pickables.push(group);
const label = createLabel(house.name, statusCopy[house.state], house.x, 4.25, house.z);
houseVisuals.set(house.id, {
group,
person: personData.person,
leftArm: personData.leftArm,
rightArm: personData.rightArm,
meal,
beacon,
beaconMaterial,
label
});
return group;
}
households.forEach(createHouse);
// The kitchen.
const kitchen = new THREE.Group();
kitchen.position.set(5.55, 0.22, -4.7);
scene.add(kitchen);
box(kitchen, 5.0, 0.24, 4.0, 0, 0.02, 0, 0xd9d1b8);
box(kitchen, 4.05, 2.15, 3.0, 0, 1.2, 0, 0xf0e5cd);
box(kitchen, 3.8, 0.58, 2.8, 0, 2.55, 0, 0xf7edda);
box(kitchen, 4.55, 0.32, 3.45, 0, 3.0, 0, 0xb95743);
box(kitchen, 3.9, 0.32, 2.82, 0, 3.3, 0, 0xc8674e);
box(kitchen, 3.1, 0.3, 2.18, 0, 3.58, 0, 0xd57659);
box(kitchen, 0.6, 1.35, 0.65, -1.15, 4.05, -0.55, 0x71504a);
// Serving window, door, and awning.
box(kitchen, 1.65, 1.0, 0.1, -0.72, 1.45, 1.55, 0x4d7275, {
emissive: 0x4d7275,
emissiveIntensity: 0.18
});
box(kitchen, 1.05, 1.62, 0.1, 1.18, 0.92, 1.55, 0x3c5b5c);
box(kitchen, 0.1, 0.1, 0.08, 1.48, 0.94, 1.63, 0xf2c14e);
box(kitchen, 2.8, 0.16, 0.8, 0, 2.05, 1.75, 0xef8354);
for (let i = -3; i <= 3; i++) {
box(kitchen, 0.28, 0.16, 0.82, i * 0.37, 2.05, 1.76, i % 2 === 0 ? 0xfff2d7 : 0xef8354);
}
const kitchenSign = makeTextPlane("BLOCK & LADLE", "#b95743", "#fff7df");
kitchenSign.position.set(0, 2.52, 1.63);
kitchen.add(kitchenSign);
// Chef visible behind the serving counter.
const chef = createPerson(0xf4efe3, 0xc98e63);
chef.person.position.set(-0.72, 0.62, 0.92);
chef.person.scale.setScalar(0.85);
kitchen.add(chef.person);
box(kitchen, 1.65, 0.18, 0.65, -0.72, 0.63, 1.22, 0xb9784c);
// Pantry crates beside the kitchen.
for (let i = 0; i < 3; i++) {
box(kitchen, 0.7, 0.55, 0.65, -2.15 + (i % 2) * 0.75, 0.4 + Math.floor(i / 2) * 0.58, 1.55, 0xc99552);
box(kitchen, 0.74, 0.08, 0.68, -2.15 + (i % 2) * 0.75, 0.68 + Math.floor(i / 2) * 0.58, 1.55, 0xe3b76e);
}
const kitchenLabel = createLabel("Neighborhood Kitchen", "Ledger balanced", 5.55, 5.0, -4.7, true);
// Smoke puffs.
const smoke = [];
for (let i = 0; i < 7; i++) {
const mat = material(0xffffff, {
unique: true,
transparent: true,
opacity: 0.34,
roughness: 1
});
const puff = box(scene, 0.28, 0.28, 0.28, 4.4, 4.7 + i * 0.55, -5.25, 0xffffff, {
material: mat,
castShadow: false
});
smoke.push({ mesh: puff, material: mat, phase: i / 7 });
}
// Small parked scooter and street furniture.
box(scene, 0.72, 0.52, 1.05, 8.5, 0.5, -1.8, 0xef8354);
box(scene, 0.18, 0.72, 0.18, 8.5, 0.88, -1.4, 0x34454a);
box(scene, 0.72, 0.13, 0.18, 8.5, 1.2, -1.25, 0x34454a);
box(scene, 0.42, 0.42, 0.52, 8.5, 0.72, -2.55, 0x40565c);
// Voxel delivery van.
const van = new THREE.Group();
van.visible = false;
scene.add(van);
box(van, 1.32, 0.62, 2.05, 0, 0.72, -0.1, 0x277f78);
box(van, 1.22, 0.72, 0.82, 0, 1.22, 0.6, 0xf5ead4);
box(van, 1.04, 0.42, 0.08, 0, 1.34, 1.03, 0x6ea8b2, {
emissive: 0x6ea8b2,
emissiveIntensity: 0.12
});
box(van, 1.38, 0.14, 1.5, 0, 0.99, -0.25, 0xf2c14e);
box(van, 0.14, 0.3, 0.05, -0.43, 0.68, 1.08, 0xffe8a0, {
emissive: 0xf2c14e,
emissiveIntensity: 0.35
});
box(van, 0.14, 0.3, 0.05, 0.43, 0.68, 1.08, 0xffe8a0, {
emissive: 0xf2c14e,
emissiveIntensity: 0.35
});
box(van, 0.12, 0.34, 0.12, 0, 1.62, 0.55, 0xf2c14e);
const vanWheels = [];
for (const x of [-0.69, 0.69]) {
for (const z of [-0.7, 0.75]) {
const wheel = box(van, 0.22, 0.48, 0.48, x, 0.38, z, 0x27363b);
vanWheels.push(wheel);
box(van, 0.24, 0.2, 0.2, x, 0.38, z, 0x9aa6a3);
}
}
let delivery = null;
let toastTimer = 0;
function showToast(message) {
const toast = document.getElementById("toast");
toast.textContent = message;
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 2700);
}
function assertLedger() {
const foodTotal = ledger.food.available + ledger.food.packed + ledger.food.transit + ledger.food.served;
const boxTotal = ledger.container.available + ledger.container.packed + ledger.container.transit + ledger.container.served;
console.assert(foodTotal === INITIAL_STOCK, "Food ledger must remain balanced");
console.assert(boxTotal === INITIAL_STOCK, "Container ledger must remain balanced");
}
function updateHouseVisual(house) {
const visual = houseVisuals.get(house.id);
visual.beaconMaterial.color.setHex(statusColors[house.state]);
visual.meal.visible = house.state === "delivered";
visual.rightArm.rotation.z = house.state === "delivered" ? -0.65 : 0;
visual.leftArm.rotation.z = house.state === "delivered" ? 0.65 : 0;
const dot = visual.label.querySelector(".label-dot");
const text = visual.label.querySelector("small span:last-child");
dot.style.background = statusColors[house.state];
text.textContent = statusCopy[house.state];
}
function renderPanel() {
const food = ledger.food;
const container = ledger.container;
document.getElementById("foodAvailable").textContent = food.available;
document.getElementById("containerAvailable").textContent = container.available;
document.getElementById("foodSummary").textContent = `${food.available}/${food.packed}/${food.transit}/${food.served}`;
document.getElementById("containerSummary").textContent = `${container.available}/${container.packed}/${container.transit}/${container.served}`;
function bar(item) {
const total = item.available + item.packed + item.transit + item.served;
return `
<span class="available" style="width:${item.available / total * 100}%"></span>
<span class="packed" style="width:${item.packed / total * 100}%"></span>
<span class="transit" style="width:${item.transit / total * 100}%"></span>
<span class="served" style="width:${item.served / total * 100}%"></span>
`;
}
document.getElementById("foodBar").innerHTML = bar(food);
document.getElementById("containerBar").innerHTML = bar(container);
document.getElementById("conservation").textContent =
`Balanced ledger: ${INITIAL_STOCK} = ${food.available} available + ${food.packed} packed + ${food.transit} moving + ${food.served} served.`;
const confirmed = households.filter(h => h.state === "confirmed");
const deliverBtn = document.getElementById("deliverBtn");
deliverBtn.disabled = delivery !== null || confirmed.length === 0;
deliverBtn.textContent = delivery
? "Courier is on the way"
: confirmed.length
? `Deliver next meal (${confirmed.length})`
: "No confirmed meals waiting";
const list = document.getElementById("houseList");
list.innerHTML = households.map(house => {
let action = "";
let actionClass = "";
let disabled = false;
if (house.state === "idle" || house.state === "delivered") {
action = house.state === "delivered" ? "Again" : "Request";
} else if (house.state === "requested") {
action = "Confirm";
actionClass = "confirm";
} else if (house.state === "confirmed") {
action = "Deliver";
actionClass = "deliver";
} else {
action = "On route";
disabled = true;
}
return `
<div class="house-card">
<div class="avatar" style="background:${house.css}">${house.name.charAt(0)}</div>
<div class="house-main">
<div class="house-name">${house.name}</div>
<div class="house-address">${house.address}</div>
<span class="status ${house.state}">${statusCopy[house.state]}</span>
</div>
<button class="house-action ${actionClass}"
data-house="${house.id}"
${disabled ? "disabled" : ""}>${action}</button>
</div>
`;
}).join("");
document.getElementById("recipientCount").textContent = `${households.length} households`;
}
function requestHouse(house) {
if (house.state !== "idle" && house.state !== "delivered") return;
house.state = "requested";
updateHouseVisual(house);
renderPanel();
showToast(`${house.name} requested a meal. No pantry items used yet.`);
}
function confirmHouse(house) {
if (house.state !== "requested") return;
if (ledger.food.available < 1 || ledger.container.available < 1) {
showToast("The pantry needs both a food portion and a clean container.");
return;
}
house.state = "confirmed";
ledger.food.available--;
ledger.container.available--;
ledger.food.packed++;
ledger.container.packed++;
updateHouseVisual(house);
assertLedger();
renderPanel();
showToast(`${house.name} confirmed: 1 food portion and 1 container packed.`);
}
function routeFor(house) {
const front = house.z < 0 ? 1 : -1;
const doorZ = house.z + front * 1.65;
return [
new THREE.Vector3(5.55, 0.22, -2.55),
new THREE.Vector3(5.55, 0.22, 0),
new THREE.Vector3(house.x, 0.22, 0),
new THREE.Vector3(house.x, 0.22, doorZ + front * 0.72)
];
}
function dispatchHouse(house) {
if (delivery) {
showToast("The courier is already delivering a meal.");
return;
}
if (house.state !== "confirmed") return;
house.state = "transit";
ledger.food.packed--;
ledger.container.packed--;
ledger.food.transit++;
ledger.container.transit++;
const path = routeFor(house);
let totalDistance = 0;
const segments = [];
for (let i = 0; i < path.length - 1; i++) {
const distance = path[i].distanceTo(path[i + 1]);
segments.push(distance);
totalDistance += distance;
}
delivery = {
house,
path,
segments,
totalDistance,
elapsed: 0,
duration: Math.max(3.5, totalDistance / 4.25),
completed: false,
arrivedFor: 0
};
van.visible = true;
van.position.copy(path[0]);
updateHouseVisual(house);
assertLedger();
renderPanel();
showToast(`Courier dispatched to ${house.name}.`);
}
function completeDelivery() {
const house = delivery.house;
house.state = "delivered";
ledger.food.transit--;
ledger.container.transit--;
ledger.food.served++;
ledger.container.served++;
updateHouseVisual(house);
assertLedger();
renderPanel();
showToast(`${house.name} received its meal. Food and container counts are balanced.`);
}
function sampleRoute(route, distance) {
let remaining = distance;
for (let i = 0; i < route.segments.length; i++) {
const length = route.segments[i];
if (remaining <= length || i === route.segments.length - 1) {
const t = Math.min(1, remaining / length);
const point = route.path[i].clone().lerp(route.path[i + 1], t);
const direction = route.path[i + 1].clone().sub(route.path[i]).normalize();
return { point, direction };
}
remaining -= length;
}
}
function updateDelivery(dt) {
if (!delivery) return;
if (!delivery.completed) {
delivery.elapsed += dt;
const distance = Math.min(delivery.totalDistance, delivery.elapsed / delivery.duration * delivery.totalDistance);
const { point, direction } = sampleRoute(delivery, distance);
van.position.copy(point);
van.rotation.y = Math.atan2(direction.x, direction.z);
if (delivery.elapsed >= delivery.duration) {
delivery.completed = true;
delivery.arrivedFor = 0;
completeDelivery();
}
} else {
delivery.arrivedFor += dt;
if (delivery.arrivedFor > 1.1) {
van.visible = false;
delivery = null;
renderPanel();
}
}
}
document.getElementById("houseList").addEventListener("click", event => {
const button = event.target.closest("button[data-house]");
if (!button) return;
const house = households.find(h => h.id === button.dataset.house);
if (!house) return;
if (house.state === "idle" || house.state === "delivered") requestHouse(house);
else if (house.state === "requested") confirmHouse(house);
else if (house.state === "confirmed") dispatchHouse(house);
});
document.getElementById("deliverBtn").addEventListener("click", () => {
const next = households.find(h => h.state === "confirmed");
if (next) dispatchHouse(next);
});
document.getElementById("quickRequest").addEventListener("click", () => {
const next = households.find(h => h.state === "idle");
if (next) requestHouse(next);
else showToast("Every household already has an open request or a completed meal.");
});
document.getElementById("resetView").addEventListener("click", () => {
cameraRig.target.set(0.2, 0.7, 0);
cameraRig.azimuth = 0.58;
cameraRig.elevation = 0.68;
cameraRig.zoom = 1;
updateCamera();
showToast("Camera reset.");
});
// Manual camera controls; no external controls/addons are used.
const pointer = {
down: false,
moved: false,
button: 0,
x: 0,
y: 0,
startX: 0,
startY: 0
};
const raycaster = new THREE.Raycaster();
const pointerNdc = new THREE.Vector2();
function pickHouse(clientX, clientY) {
pointerNdc.x = clientX / window.innerWidth * 2 - 1;
pointerNdc.y = -(clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(pointerNdc, camera);
const hits = raycaster.intersectObjects(pickables, true);
if (!hits.length) return null;
let object = hits[0].object;
while (object && !object.userData.houseId) object = object.parent;
return object ? households.find(h => h.id === object.userData.houseId) : null;
}
renderer.domElement.addEventListener("pointerdown", event => {
pointer.down = true;
pointer.moved = false;
pointer.button = event.button;
pointer.x = pointer.startX = event.clientX;
pointer.y = pointer.startY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointer.down) {
const house = pickHouse(event.clientX, event.clientY);
renderer.domElement.style.cursor = house ? "pointer" : "grab";
return;
}
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (Math.hypot(event.clientX - pointer.startX, event.clientY - pointer.startY) > 4) {
pointer.moved = true;
}
if (pointer.button === 2 || event.shiftKey) {
updateCamera();
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3().crossVectors(forward, camera.up).normalize();
const units = (camera.top - camera.bottom) / window.innerHeight;
cameraRig.target.addScaledVector(right, -dx * units);
cameraRig.target.addScaledVector(forward, -dy * units);
} else {
cameraRig.azimuth -= dx * 0.006;
cameraRig.elevation = THREE.MathUtils.clamp(cameraRig.elevation + dy * 0.0045, 0.3, 1.25);
}
updateCamera();
});
renderer.domElement.addEventListener("pointerup", event => {
const wasClick = !pointer.moved;
pointer.down = false;
renderer.domElement.releasePointerCapture(event.pointerId);
renderer.domElement.classList.remove("dragging");
if (wasClick) {
const house = pickHouse(event.clientX, event.clientY);
if (house && (house.state === "idle" || house.state === "delivered")) {
requestHouse(house);
} else if (house) {
showToast(`${house.name}: ${statusCopy[house.state]}.`);
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointer.down = false;
renderer.domElement.classList.remove("dragging");
});
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraRig.zoom = THREE.MathUtils.clamp(cameraRig.zoom * (event.deltaY > 0 ? 0.91 : 1.1), 0.65, 1.8);
updateCamera();
}, { passive: false });
function updateCamera() {
const halfHeight = 8.7 / cameraRig.zoom;
const aspect = window.innerWidth / window.innerHeight;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
const horizontal = cameraRig.radius * Math.cos(cameraRig.elevation);
camera.position.set(
cameraRig.target.x + horizontal * Math.sin(cameraRig.azimuth),
cameraRig.target.y + cameraRig.radius * Math.sin(cameraRig.elevation),
cameraRig.target.z + horizontal * Math.cos(cameraRig.azimuth)
);
camera.lookAt(cameraRig.target);
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
function resize() {
renderer.setSize(window.innerWidth, window.innerHeight);
updateCamera();
}
window.addEventListener("resize", resize);
const projected = new THREE.Vector3();
function updateLabels() {
for (const label of worldLabels) {
projected.copy(label.position).project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.el.style.display = visible ? "block" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
label.el.style.left = `${x}px`;
label.el.style.top = `${y}px`;
}
}
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
updateDelivery(dt);
smoke.forEach((puff, index) => {
const cycle = (elapsed * 0.22 + puff.phase) % 1;
puff.mesh.position.y = 4.75 + cycle * 2.3;
puff.mesh.position.x = 4.4 + Math.sin(cycle * 5 + index) * 0.3;
puff.mesh.position.z = -5.25 + Math.cos(cycle * 4 + index) * 0.18;
puff.mesh.scale.setScalar(0.65 + cycle * 1.15);
puff.material.opacity = Math.sin(cycle * Math.PI) * 0.28;
});
households.forEach(house => {
const visual = houseVisuals.get(house.id);
if (house.state === "transit") {
visual.rightArm.rotation.z = -1.1 + Math.sin(elapsed * 8) * 0.35;
visual.rightArm.rotation.x = Math.sin(elapsed * 5) * 0.18;
} else {
visual.rightArm.rotation.x = 0;
}
visual.beacon.rotation.y = elapsed * 0.8;
});
if (delivery) {
vanWheels.forEach(wheel => wheel.rotation.x += dt * 8);
van.position.y = 0.22 + Math.sin(elapsed * 12) * 0.015;
}
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
updateCamera();
renderPanel();
assertLedger();
animate();
</script>
</body>
</html>
```