Prompt specification
Build or customize the Three.js 3D scene "Family dinner preparation cutaway" 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: Family dinner preparation cutaway
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/family-dinner-preparation-cutaway-x3907
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing shared cooking tasks and meal-preparation dependencies. Build a kitchen and dining area with several household members performing distinct tasks; ingredients, utensils, and dishes follow coherent paths between worktop and table. Stylized solid forms.
Working Three.js Starter (family-dinner-preparation-cutaway-x3907):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>One Kitchen, Four Hands</title>
<style>
:root {
--ink: #26332f;
--muted: #64716c;
--paper: rgba(255, 252, 245, 0.91);
--line: rgba(38, 51, 47, 0.12);
--coral: #e9775b;
--teal: #3c9388;
--gold: #d7a63c;
--purple: #8b72b6;
--blue: #4d83b7;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eee6d8;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene.dragging {
cursor: grabbing;
}
.header {
position: fixed;
top: 24px;
left: 28px;
z-index: 10;
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 42px);
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
margin-top: 10px;
color: var(--muted);
font-size: 13px;
}
.panel {
border: 1px solid rgba(255, 255, 255, 0.72);
background: var(--paper);
box-shadow:
0 18px 50px rgba(62, 52, 39, 0.11),
inset 0 0 0 1px var(--line);
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
}
.task-panel {
position: fixed;
top: 24px;
right: 24px;
z-index: 10;
width: 292px;
padding: 16px;
border-radius: 18px;
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.panel-heading strong {
font-size: 12px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.live-pill {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 8px;
border-radius: 999px;
background: rgba(60, 147, 136, 0.1);
color: var(--teal);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.live-pill::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--teal);
content: "";
box-shadow: 0 0 0 4px rgba(60, 147, 136, 0.1);
animation: pulse 1.8s infinite;
}
@keyframes pulse {
50% {
box-shadow: 0 0 0 7px rgba(60, 147, 136, 0);
}
}
.task {
display: grid;
grid-template-columns: 31px 1fr;
gap: 10px;
align-items: center;
padding: 10px 0;
border-top: 1px solid var(--line);
}
.task:first-of-type {
border-top: 0;
}
.avatar {
display: grid;
width: 31px;
height: 31px;
place-items: center;
border-radius: 10px;
color: white;
font-size: 11px;
font-weight: 800;
box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}
.task-copy {
min-width: 0;
}
.task-name {
display: flex;
justify-content: space-between;
gap: 10px;
margin-bottom: 2px;
font-size: 12px;
font-weight: 800;
}
.task-role {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.phase {
overflow: hidden;
color: var(--muted);
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
.controls {
position: fixed;
left: 24px;
bottom: 24px;
z-index: 10;
display: flex;
align-items: center;
gap: 8px;
padding: 8px;
border-radius: 15px;
}
button,
.toggle {
min-height: 35px;
border: 0;
border-radius: 10px;
background: rgba(38, 51, 47, 0.07);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
user-select: none;
}
button {
padding: 0 13px;
}
button:hover,
.toggle:hover {
background: rgba(38, 51, 47, 0.13);
}
.toggle {
display: flex;
align-items: center;
gap: 7px;
padding: 0 11px;
}
.toggle input {
width: 14px;
height: 14px;
margin: 0;
accent-color: var(--teal);
}
.legend {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 10;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px 14px;
max-width: 380px;
padding: 12px 15px;
border-radius: 15px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.legend i {
display: block;
width: 16px;
border-top: 3px dashed currentColor;
}
.hint {
position: fixed;
left: 50%;
bottom: 28px;
z-index: 9;
transform: translateX(-50%);
color: rgba(38, 51, 47, 0.6);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.05em;
pointer-events: none;
}
.scene-label {
position: fixed;
z-index: 5;
transform: translate(-50%, -100%);
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 9px;
background: rgba(255, 252, 245, 0.82);
box-shadow: 0 7px 24px rgba(62, 52, 39, 0.09);
color: var(--ink);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
}
.scene-label::after {
position: absolute;
left: 50%;
bottom: -5px;
width: 8px;
height: 8px;
transform: translateX(-50%) rotate(45deg);
background: rgba(255, 252, 245, 0.82);
content: "";
}
@media (max-width: 800px) {
.header {
top: 17px;
left: 18px;
}
.task-panel {
top: auto;
right: 14px;
bottom: 76px;
width: 248px;
padding: 12px;
}
.task {
padding: 7px 0;
}
.controls {
left: 14px;
bottom: 14px;
}
.legend,
.hint {
display: none;
}
.subtitle {
max-width: 220px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Animated cutaway kitchen and dining room"></canvas>
<header class="header">
<div class="eyebrow">Shared meal preparation</div>
<h1>One kitchen,<br />four hands.</h1>
<div class="subtitle">A coordinated path from fresh ingredients to the family table.</div>
</header>
<aside class="task-panel panel" aria-label="Live household tasks">
<div class="panel-heading">
<strong>Live workflow</strong>
<span class="live-pill">Cooking</span>
</div>
<div class="task">
<div class="avatar" style="background:#e9775b">AN</div>
<div class="task-copy">
<div class="task-name"><span>Ana</span><span class="task-role">Prep</span></div>
<div class="phase" id="phase-ana">Chopping the tomato</div>
</div>
</div>
<div class="task">
<div class="avatar" style="background:#3c9388">BE</div>
<div class="task-copy">
<div class="task-name"><span>Ben</span><span class="task-role">Cook</span></div>
<div class="phase" id="phase-ben">Stirring the shared pot</div>
</div>
</div>
<div class="task">
<div class="avatar" style="background:#8b72b6">ME</div>
<div class="task-copy">
<div class="task-name"><span>Mei</span><span class="task-role">Serve</span></div>
<div class="phase" id="phase-mei">Carrying the finished bowl</div>
</div>
</div>
<div class="task">
<div class="avatar" style="background:#d7a63c">LE</div>
<div class="task-copy">
<div class="task-name"><span>Leo</span><span class="task-role">Table</span></div>
<div class="phase" id="phase-leo">Bringing a plate from the cupboard</div>
</div>
</div>
</aside>
<div class="controls panel">
<button id="reset-view" type="button">Reset view</button>
<button id="pause" type="button">Pause</button>
<label class="toggle">
<input id="show-routes" type="checkbox" checked />
Flow paths
</label>
</div>
<div class="legend panel" aria-label="Flow path legend">
<span style="color:#d39a32"><i></i>Ingredients</span>
<span style="color:#3c9388"><i></i>Prepared dish</span>
<span style="color:#4d83b7"><i></i>Utensil</span>
<span style="color:#8b72b6"><i></i>Tableware</span>
</div>
<div class="hint">DRAG TO ORBIT · SCROLL TO ZOOM</div>
<div class="scene-label" id="label-prep">Prep island</div>
<div class="scene-label" id="label-pot">Shared pot</div>
<div class="scene-label" id="label-table">Family table</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, camera
// -------------------------------------------------------------------------
const canvas = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
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.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#eee6d8");
scene.fog = new THREE.Fog("#eee6d8", 24, 38);
const camera = new THREE.OrthographicCamera(-8, 8, 6, -6, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.65, 0);
const cameraSettings = {
theta: 0.69,
phi: 0.91,
size: 10.4,
radius: 22
};
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const height = Math.max(cameraSettings.size, 15.7 / aspect);
const width = height * aspect;
camera.left = -width / 2;
camera.right = width / 2;
camera.top = height / 2;
camera.bottom = -height / 2;
camera.updateProjectionMatrix();
const { theta, phi, radius } = cameraSettings;
camera.position.set(
cameraTarget.x + radius * Math.sin(phi) * Math.sin(theta),
cameraTarget.y + radius * Math.cos(phi),
cameraTarget.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Direct orbit and zoom controls.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
cameraSettings.theta -= dx * 0.006;
cameraSettings.phi = THREE.MathUtils.clamp(
cameraSettings.phi + dy * 0.005,
0.42,
1.34
);
pointerX = event.clientX;
pointerY = event.clientY;
updateCamera();
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraSettings.size = THREE.MathUtils.clamp(
cameraSettings.size + event.deltaY * 0.008,
7.2,
15.5
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
cameraSettings.theta = 0.69;
cameraSettings.phi = 0.91;
cameraSettings.size = 10.4;
updateCamera();
});
document.getElementById("reset-view").addEventListener("click", () => {
cameraSettings.theta = 0.69;
cameraSettings.phi = 0.91;
cameraSettings.size = 10.4;
updateCamera();
});
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight("#fff7e8", "#8b9d93", 2.05));
const sunlight = new THREE.DirectionalLight("#fff0cf", 3.1);
sunlight.position.set(-6, 12, 7);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -12;
sunlight.shadow.camera.right = 12;
sunlight.shadow.camera.top = 12;
sunlight.shadow.camera.bottom = -12;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 35;
sunlight.shadow.bias = -0.0005;
sunlight.shadow.normalBias = 0.025;
scene.add(sunlight);
const fill = new THREE.DirectionalLight("#d9e7e2", 1.25);
fill.position.set(9, 7, -5);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials and modeling helpers
// -------------------------------------------------------------------------
const M = {
cream: new THREE.MeshStandardMaterial({ color: "#f7f0df", roughness: 0.82 }),
warmWhite: new THREE.MeshStandardMaterial({ color: "#fffaf0", roughness: 0.72 }),
wood: new THREE.MeshStandardMaterial({ color: "#b97c4f", roughness: 0.78 }),
darkWood: new THREE.MeshStandardMaterial({ color: "#754b35", roughness: 0.82 }),
teal: new THREE.MeshStandardMaterial({ color: "#4d8e83", roughness: 0.73 }),
darkTeal: new THREE.MeshStandardMaterial({ color: "#315f59", roughness: 0.78 }),
coral: new THREE.MeshStandardMaterial({ color: "#e9775b", roughness: 0.72 }),
gold: new THREE.MeshStandardMaterial({ color: "#d9a942", roughness: 0.7 }),
purple: new THREE.MeshStandardMaterial({ color: "#8b72b6", roughness: 0.75 }),
blue: new THREE.MeshStandardMaterial({ color: "#4d83b7", roughness: 0.68 }),
charcoal: new THREE.MeshStandardMaterial({ color: "#2d3735", roughness: 0.72 }),
metal: new THREE.MeshStandardMaterial({
color: "#aeb9b4",
roughness: 0.32,
metalness: 0.62
}),
black: new THREE.MeshStandardMaterial({ color: "#202725", roughness: 0.66 }),
green: new THREE.MeshStandardMaterial({ color: "#6f9f62", roughness: 0.8 }),
tomato: new THREE.MeshStandardMaterial({ color: "#dd5749", roughness: 0.55 }),
orange: new THREE.MeshStandardMaterial({ color: "#e69b47", roughness: 0.7 }),
blueGlass: new THREE.MeshStandardMaterial({
color: "#a9d3d7",
roughness: 0.25,
metalness: 0.05
}),
rug: new THREE.MeshStandardMaterial({ color: "#c9d9cf", roughness: 1 }),
rugStripe: new THREE.MeshStandardMaterial({ color: "#e7dcc7", roughness: 1 })
};
const skinColors = {
light: "#e8b895",
medium: "#c98964",
tan: "#b87554",
deep: "#8d573e"
};
function addMesh(parent, geometry, material, x = 0, y = 0, z = 0) {
const object = new THREE.Mesh(geometry, material);
object.position.set(x, y, z);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(parent, w, h, d, material, x = 0, y = 0, z = 0) {
return addMesh(
parent,
new THREE.BoxGeometry(w, h, d),
material,
x,
y,
z
);
}
function cylinder(parent, rTop, rBottom, h, material, x = 0, y = 0, z = 0, segments = 16) {
return addMesh(
parent,
new THREE.CylinderGeometry(rTop, rBottom, h, segments),
material,
x,
y,
z
);
}
function sphere(parent, radius, material, x = 0, y = 0, z = 0, width = 16) {
return addMesh(
parent,
new THREE.SphereGeometry(radius, width, 12),
material,
x,
y,
z
);
}
function torus(parent, radius, tube, material, x = 0, y = 0, z = 0) {
const object = addMesh(
parent,
new THREE.TorusGeometry(radius, tube, 8, 28),
material,
x,
y,
z
);
object.rotation.x = Math.PI / 2;
return object;
}
// -------------------------------------------------------------------------
// Room shell
// -------------------------------------------------------------------------
box(scene, 14.4, 0.28, 10.5, M.cream, 0, -0.18, 0);
box(scene, 14.7, 0.16, 10.8, M.darkWood, 0, -0.38, 0);
// Floor tile seams.
const seamMaterial = new THREE.MeshBasicMaterial({
color: "#d8cfbd",
transparent: true,
opacity: 0.46
});
for (let x = -6; x <= 6; x += 1) {
box(scene, 0.012, 0.008, 10.1, seamMaterial, x, 0.005, 0);
}
for (let z = -4.5; z <= 4.5; z += 1) {
box(scene, 14.1, 0.008, 0.012, seamMaterial, 0, 0.006, z);
}
// Cutaway walls.
box(scene, 14.2, 3.8, 0.2, M.cream, 0, 1.9, -5.12);
box(scene, 0.2, 3.8, 10.3, M.cream, -7.12, 1.9, 0);
box(scene, 14.2, 0.15, 0.25, M.wood, 0, 0.08, -5.0);
box(scene, 0.25, 0.15, 10.2, M.wood, -6.98, 0.08, 0);
// Back wall tile field.
for (let x = -6.7; x < 7; x += 0.72) {
box(scene, 0.015, 2.6, 0.012, seamMaterial, x, 2.05, -5.005);
}
for (let y = 0.8; y < 3.4; y += 0.65) {
box(scene, 14, 0.012, 0.012, seamMaterial, 0, y, -5.005);
}
// Window.
box(scene, 3.05, 1.65, 0.12, M.darkWood, 2.65, 2.55, -4.96);
box(scene, 2.82, 1.43, 0.08, M.blueGlass, 2.65, 2.55, -4.87);
box(scene, 0.08, 1.47, 0.12, M.warmWhite, 2.65, 2.55, -4.8);
box(scene, 2.85, 0.08, 0.12, M.warmWhite, 2.65, 2.55, -4.8);
box(scene, 3.35, 0.16, 0.42, M.wood, 2.65, 1.66, -4.75);
// Small framed wall art.
box(scene, 1.18, 1.45, 0.11, M.darkWood, -1.8, 2.68, -4.95);
box(scene, 1.02, 1.29, 0.07, M.warmWhite, -1.8, 2.68, -4.87);
cylinder(scene, 0.21, 0.21, 0.03, M.coral, -1.95, 2.82, -4.8);
box(scene, 0.68, 0.13, 0.03, M.teal, -1.72, 2.45, -4.79);
// -------------------------------------------------------------------------
// Kitchen cabinetry and appliances
// -------------------------------------------------------------------------
function cabinet(parent, x, z, width, depth = 1.08, height = 1.35) {
const group = new THREE.Group();
parent.add(group);
box(group, width, height, depth, M.teal, x, height / 2, z);
box(group, width + 0.08, 0.16, depth + 0.08, M.warmWhite, x, height + 0.06, z);
const doorCount = Math.max(1, Math.round(width / 0.8));
const doorWidth = width / doorCount;
for (let i = 0; i < doorCount; i++) {
const doorX = x - width / 2 + doorWidth * (i + 0.5);
box(group, doorWidth - 0.055, height - 0.16, 0.055, M.darkTeal, doorX, height / 2, z + depth / 2 + 0.025);
box(
group,
0.23,
0.035,
0.055,
M.gold,
doorX,
height * 0.78,
z + depth / 2 + 0.065
);
}
return group;
}
cabinet(scene, -4.35, -4.48, 1.0);
cabinet(scene, -3.18, -4.48, 1.05);
cabinet(scene, -2.0, -4.48, 1.0);
cabinet(scene, -0.82, -4.48, 1.05);
// Fridge.
box(scene, 1.18, 3.15, 1.28, M.warmWhite, -6.13, 1.58, -4.25);
box(scene, 1.08, 1.72, 0.06, M.cream, -6.13, 2.05, -3.58);
box(scene, 1.08, 0.93, 0.06, M.cream, -6.13, 0.86, -3.58);
box(scene, 0.055, 0.55, 0.08, M.metal, -5.7, 2.12, -3.51);
box(scene, 0.055, 0.38, 0.08, M.metal, -5.7, 1.03, -3.51);
// Countertop.
box(scene, 5.75, 0.16, 1.25, M.warmWhite, -2.8, 1.49, -4.43);
// Upper cabinets.
box(scene, 2.45, 1.05, 0.6, M.teal, -2.55, 3.0, -4.75);
box(scene, 2.55, 0.12, 0.68, M.warmWhite, -2.55, 3.57, -4.72);
box(scene, 0.035, 0.46, 0.06, M.gold, -2.52, 3.02, -4.42);
box(scene, 2.55, 0.12, 0.68, M.warmWhite, -0.78, 2.75, -4.72);
// Open dish shelf.
box(scene, 1.55, 0.12, 0.68, M.wood, 0.3, 2.78, -4.65);
box(scene, 1.55, 0.12, 0.68, M.wood, 0.3, 3.35, -4.65);
for (let i = 0; i < 4; i++) {
cylinder(scene, 0.26, 0.26, 0.045, M.warmWhite, -0.2 + i * 0.34, 2.88, -4.62);
}
sphere(scene, 0.19, M.coral, 0.55, 3.58, -4.63);
cylinder(scene, 0.12, 0.1, 0.23, M.gold, 0.05, 3.51, -4.65);
// Stove and oven.
box(scene, 1.48, 0.07, 1.12, M.black, -4.83, 1.61, -4.35);
box(scene, 1.28, 0.88, 0.08, M.charcoal, -4.83, 0.78, -3.87);
box(scene, 0.75, 0.45, 0.045, M.black, -4.83, 0.88, -3.81);
box(scene, 0.52, 0.055, 0.07, M.metal, -4.83, 0.88, -3.76);
for (const x of [-5.2, -4.5]) {
for (const z of [-4.62, -4.1]) {
torus(scene, 0.18, 0.025, M.metal, x, 1.665, z);
}
}
// Range hood.
box(scene, 1.66, 0.38, 1.1, M.warmWhite, -4.83, 3.43, -4.46);
box(scene, 1.25, 0.65, 0.58, M.cream, -4.83, 3.93, -4.68);
box(scene, 0.76, 0.07, 0.38, M.charcoal, -4.83, 3.22, -4.25);
// Shared pot.
const potGroup = new THREE.Group();
potGroup.position.set(-4.87, 1.67, -4.12);
scene.add(potGroup);
cylinder(potGroup, 0.42, 0.36, 0.38, M.metal, 0, 0.19, 0, 24);
torus(potGroup, 0.42, 0.035, M.charcoal, 0, 0.38, 0);
cylinder(potGroup, 0.37, 0.37, 0.025, M.orange, 0, 0.355, 0, 24);
for (let i = 0; i < 7; i++) {
const a = (i / 7) * Math.PI * 2;
sphere(potGroup, 0.08, M.tomato, Math.cos(a) * 0.2, 0.39, Math.sin(a) * 0.2, 10);
}
box(potGroup, 0.36, 0.055, 0.07, M.charcoal, 0, 0.52, 0);
// Sink.
box(scene, 1.1, 0.06, 0.73, M.metal, -2.28, 1.585, -4.4);
box(scene, 0.82, 0.07, 0.49, M.charcoal, -2.28, 1.625, -4.4);
cylinder(scene, 0.035, 0.035, 0.56, M.metal, -2.28, 1.84, -4.73);
const faucetArc = torus(scene, 0.2, 0.035, M.metal, -2.28, 2.08, -4.65);
faucetArc.rotation.x = Math.PI / 2;
faucetArc.rotation.z = Math.PI / 2;
cylinder(scene, 0.035, 0.035, 0.22, M.metal, -2.28, 1.99, -4.46);
// Utensil caddy.
cylinder(scene, 0.19, 0.16, 0.31, M.blue, -0.58, 1.72, -4.13, 16);
for (let i = 0; i < 3; i++) {
const handle = box(scene, 0.055, 0.52, 0.055, M.wood, -0.68 + i * 0.1, 2.03, -4.13);
handle.rotation.z = (i - 1) * 0.15;
sphere(scene, 0.09, M.metal, -0.69 + i * 0.1, 2.28, -4.13, 10);
}
// Stacked plates in the lower cupboard.
for (let i = 0; i < 4; i++) {
cylinder(scene, 0.3, 0.3, 0.045, M.warmWhite, 0.12, 1.62 + i * 0.055, -4.05, 24);
}
// -------------------------------------------------------------------------
// Prep island
// -------------------------------------------------------------------------
box(scene, 4.72, 1.24, 1.65, M.wood, -3.78, 0.66, -0.75);
box(scene, 4.92, 0.18, 1.84, M.warmWhite, -3.78, 1.38, -0.75);
for (let i = 0; i < 4; i++) {
const x = -5.53 + i * 1.17;
box(scene, 1.06, 1.02, 0.06, M.darkWood, x, 0.66, 0.105);
box(scene, 0.22, 0.045, 0.065, M.gold, x, 1.03, 0.15);
}
// Cutting board.
box(scene, 1.22, 0.09, 0.78, M.wood, -3.52, 1.525, -0.74);
box(scene, 0.18, 0.05, 0.26, M.darkWood, -3.02, 1.585, -0.74);
// Small herb pile and knife on board.
for (let i = 0; i < 4; i++) {
const herb = box(scene, 0.16, 0.025, 0.045, M.green, -3.78 + i * 0.11, 1.59, -0.52);
herb.rotation.y = i * 0.45;
}
box(scene, 0.42, 0.025, 0.07, M.metal, -3.25, 1.6, -0.88);
box(scene, 0.18, 0.065, 0.09, M.darkWood, -3.49, 1.61, -0.88);
// Produce crate.
box(scene, 0.84, 0.13, 0.76, M.darkWood, -5.35, 1.55, -0.74);
for (let i = 0; i < 3; i++) {
box(scene, 0.76, 0.18, 0.06, M.wood, -5.35, 1.66, -1.04 + i * 0.3);
}
for (let i = 0; i < 3; i++) {
sphere(scene, 0.13, i === 1 ? M.orange : M.tomato, -5.58 + i * 0.22, 1.71, -0.73, 12);
}
// -------------------------------------------------------------------------
// Dining area
// -------------------------------------------------------------------------
// Rug.
box(scene, 6.25, 0.025, 4.35, M.rug, 3.35, 0.025, 1.25);
for (let i = 0; i < 7; i++) {
box(scene, 0.11, 0.014, 4.1, M.rugStripe, 0.8 + i * 0.85, 0.045, 1.25);
}
// Table.
box(scene, 3.72, 0.22, 2.25, M.wood, 3.2, 1.35, 1.4);
box(scene, 3.48, 0.09, 2.02, M.darkWood, 3.2, 1.205, 1.4);
for (const x of [1.75, 4.65]) {
for (const z of [0.62, 2.18]) {
box(scene, 0.16, 1.22, 0.16, M.darkWood, x, 0.61, z);
}
}
function chair(x, z, rotation) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
box(group, 0.88, 0.16, 0.84, M.teal, 0, 0.83, 0);
box(group, 0.88, 0.95, 0.14, M.darkTeal, 0, 1.27, -0.36);
box(group, 0.62, 0.3, 0.08, M.teal, 0, 1.3, -0.27);
for (const lx of [-0.31, 0.31]) {
for (const lz of [-0.28, 0.28]) {
box(group, 0.09, 0.78, 0.09, M.darkWood, lx, 0.39, lz);
}
}
return group;
}
chair(2.05, -0.02, 0);
chair(4.35, -0.02, 0);
chair(2.05, 2.85, Math.PI);
chair(4.35, 2.85, Math.PI);
// Existing place settings.
for (const [x, z] of [[2.1, 0.83], [4.25, 0.83], [2.15, 1.95], [4.3, 1.95]]) {
cylinder(scene, 0.31, 0.31, 0.045, M.warmWhite, x, 1.49, z, 24);
torus(scene, 0.275, 0.018, M.gold, x, 1.52, z);
cylinder(scene, 0.075, 0.06, 0.14, M.blue, x + 0.48, 1.56, z, 12);
}
// Flower vase.
cylinder(scene, 0.17, 0.23, 0.38, M.blue, 3.2, 1.67, 1.4, 20);
for (let i = 0; i < 5; i++) {
const angle = (i / 5) * Math.PI * 2;
const stem = cylinder(
scene,
0.014,
0.014,
0.52,
M.green,
3.2 + Math.cos(angle) * 0.09,
2.08,
1.4 + Math.sin(angle) * 0.09,
8
);
stem.rotation.z = Math.cos(angle) * 0.18;
stem.rotation.x = Math.sin(angle) * 0.18;
sphere(scene, 0.095, i % 2 ? M.coral : M.gold, 3.2 + Math.cos(angle) * 0.14, 2.34, 1.4 + Math.sin(angle) * 0.14, 10);
}
// Pendant lamps.
function pendant(x, z, color) {
cylinder(scene, 0.015, 0.015, 1.35, M.charcoal, x, 4.35, z, 8);
cylinder(scene, 0.38, 0.18, 0.38, color, x, 3.52, z, 24);
cylinder(scene, 0.34, 0.34, 0.035, M.warmWhite, x, 3.32, z, 24);
const light = new THREE.PointLight("#ffd49a", 1.25, 7, 2);
light.position.set(x, 3.15, z);
scene.add(light);
}
pendant(2.35, 1.15, M.coral);
pendant(4.0, 1.15, M.gold);
// A small plant on the counter.
cylinder(scene, 0.18, 0.14, 0.3, M.cream, -0.95, 1.7, -4.05, 16);
for (let i = 0; i < 6; i++) {
const a = (i / 6) * Math.PI * 2;
const leaf = sphere(scene, 0.17, M.green, -0.95 + Math.cos(a) * 0.13, 2.02, -4.05 + Math.sin(a) * 0.13, 10);
leaf.scale.set(0.45, 1.2, 0.65);
leaf.rotation.z = Math.cos(a) * 0.45;
leaf.rotation.x = Math.sin(a) * 0.45;
}
// -------------------------------------------------------------------------
// Stylized household members
// -------------------------------------------------------------------------
function createPerson({ shirt, pants, hair, skin, apron = null, ponytail = false }) {
const root = new THREE.Group();
scene.add(root);
const torso = cylinder(root, 0.3, 0.36, 0.78, shirt, 0, 1.25, 0, 14);
torso.scale.z = 0.78;
box(root, 0.66, 0.3, 0.55, pants, 0, 0.8, 0);
if (apron) {
box(root, 0.53, 0.72, 0.06, apron, 0, 1.17, 0.285);
box(root, 0.06, 0.54, 0.06, apron, -0.17, 1.57, 0.28);
box(root, 0.06, 0.54, 0.06, apron, 0.17, 1.57, 0.28);
}
cylinder(root, 0.11, 0.12, 0.18, skin, 0, 1.71, 0, 12);
sphere(root, 0.28, skin, 0, 1.96, 0, 18);
const hairMesh = sphere(root, 0.295, hair, 0, 2.075, -0.045, 18);
hairMesh.scale.set(1, 0.67, 1);
sphere(root, 0.035, M.charcoal, -0.09, 1.99, 0.253, 8);
sphere(root, 0.035, M.charcoal, 0.09, 1.99, 0.253, 8);
sphere(root, 0.045, skin, 0, 1.91, 0.272, 8);
if (ponytail) {
const tail = sphere(root, 0.13, hair, 0, 2.04, -0.31, 12);
tail.scale.set(0.75, 1.4, 0.8);
}
function limb(x, y, material, length, radius, shoe = false) {
const pivot = new THREE.Group();
pivot.position.set(x, y, 0);
root.add(pivot);
cylinder(pivot, radius, radius * 0.9, length, material, 0, -length / 2, 0, 10);
if (shoe) {
box(pivot, 0.2, 0.13, 0.34, M.charcoal, 0, -length - 0.02, 0.08);
} else {
sphere(pivot, radius * 1.12, skin, 0, -length - 0.02, 0.02, 10);
}
return pivot;
}
const legL = limb(-0.18, 0.78, pants, 0.62, 0.105, true);
const legR = limb(0.18, 0.78, pants, 0.62, 0.105, true);
const armL = limb(-0.36, 1.54, shirt, 0.52, 0.085);
const armR = limb(0.36, 1.54, shirt, 0.52, 0.085);
// A subtle front pocket adds a readable uniform silhouette.
box(root, 0.23, 0.17, 0.045, apron || shirt, 0.14, 1.13, 0.33);
return { root, legL, legR, armL, armR };
}
const ana = createPerson({
shirt: M.coral,
pants: new THREE.MeshStandardMaterial({ color: "#46565b", roughness: 0.8 }),
hair: new THREE.MeshStandardMaterial({ color: "#49352f", roughness: 0.9 }),
skin: skinColors.light,
apron: M.warmWhite
});
ana.root.position.set(-3.52, 0, 0.72);
ana.root.rotation.y = Math.PI;
const ben = createPerson({
shirt: M.teal,
pants: new THREE.MeshStandardMaterial({ color: "#364b48", roughness: 0.82 }),
hair: new THREE.MeshStandardMaterial({ color: "#60453b", roughness: 0.9 }),
skin: skinColors.medium
});
ben.root.position.set(-4.87, 0, -2.94);
ben.root.rotation.y = Math.PI;
// Small glasses.
const glasses = new THREE.Group();
glasses.position.set(0, 1.99, 0.255);
ben.root.add(glasses);
const lensMaterial = new THREE.MeshBasicMaterial({
color: "#465d61",
transparent: true,
opacity: 0.55
});
torus(glasses, 0.075, 0.012, lensMaterial, -0.09, 0, 0);
torus(glasses, 0.075, 0.012, lensMaterial, 0.09, 0, 0);
box(glasses, 0.075, 0.012, 0.012, lensMaterial, 0, 0, 0);
const mei = createPerson({
shirt: M.purple,
pants: new THREE.MeshStandardMaterial({ color: "#4c455c", roughness: 0.82 }),
hair: new THREE.MeshStandardMaterial({ color: "#2d292c", roughness: 0.9 }),
skin: skinColors.tan,
ponytail: true
});
const leo = createPerson({
shirt: M.gold,
pants: new THREE.MeshStandardMaterial({ color: "#4c5149", roughness: 0.84 }),
hair: new THREE.MeshStandardMaterial({ color: "#8d6044", roughness: 0.9 }),
skin: skinColors.light
});
function animateWalker(person, moving, phase, carrying = false) {
if (moving) {
const stride = Math.sin(phase) * 0.5;
person.legL.rotation.x = stride;
person.legR.rotation.x = -stride;
person.root.position.y = Math.abs(Math.sin(phase)) * 0.035;
if (carrying) {
person.armL.rotation.x = -0.86;
person.armR.rotation.x = -0.86;
} else {
person.armL.rotation.x = -stride * 0.75;
person.armR.rotation.x = stride * 0.75;
}
} else {
person.legL.rotation.x *= 0.82;
person.legR.rotation.x *= 0.82;
person.armL.rotation.x *= 0.82;
person.armR.rotation.x *= 0.82;
person.root.position.y = 0;
}
}
// -------------------------------------------------------------------------
// Moving objects
// -------------------------------------------------------------------------
const tomatoGroup = new THREE.Group();
scene.add(tomatoGroup);
sphere(tomatoGroup, 0.18, M.tomato, 0, 0, 0, 16);
for (let i = 0; i < 4; i++) {
const a = (i / 4) * Math.PI * 2;
const leaf = box(tomatoGroup, 0.18, 0.025, 0.07, M.green, Math.cos(a) * 0.07, 0.16, Math.sin(a) * 0.07);
leaf.rotation.y = a;
}
const choppedGroup = new THREE.Group();
scene.add(choppedGroup);
for (let i = 0; i < 6; i++) {
const chunk = box(
choppedGroup,
0.09,
0.075,
0.1,
i % 2 ? M.tomato : M.orange,
(i % 3 - 1) * 0.095,
0,
(Math.floor(i / 3) - 0.5) * 0.11
);
chunk.rotation.y = i * 0.53;
}
const bowlGroup = new THREE.Group();
scene.add(bowlGroup);
const bowlProfile = [
new THREE.Vector2(0.025, 0),
new THREE.Vector2(0.24, 0.015),
new THREE.Vector2(0.33, 0.14),
new THREE.Vector2(0.34, 0.2),
new THREE.Vector2(0.3, 0.22),
new THREE.Vector2(0.27, 0.12),
new THREE.Vector2(0.15, 0.06),
new THREE.Vector2(0.025, 0.045)
];
addMesh(
bowlGroup,
new THREE.LatheGeometry(bowlProfile, 24),
M.blue
);
torus(bowlGroup, 0.315, 0.026, M.warmWhite, 0, 0.215, 0);
for (let i = 0; i < 7; i++) {
const a = (i / 7) * Math.PI * 2;
sphere(
bowlGroup,
0.07,
i % 3 === 0 ? M.green : M.orange,
Math.cos(a) * 0.15,
0.15,
Math.sin(a) * 0.15,
10
);
}
const plateGroup = new THREE.Group();
scene.add(plateGroup);
cylinder(plateGroup, 0.31, 0.31, 0.045, M.warmWhite, 0, 0, 0, 28);
torus(plateGroup, 0.275, 0.018, M.gold, 0, 0.026, 0);
cylinder(plateGroup, 0.17, 0.17, 0.018, M.cream, 0, 0.032, 0, 24);
const spoonGroup = new THREE.Group();
scene.add(spoonGroup);
box(spoonGroup, 0.055, 0.035, 0.45, M.wood, 0, 0, -0.08);
const spoonHead = sphere(spoonGroup, 0.1, M.metal, 0, 0, 0.19, 14);
spoonHead.scale.set(0.8, 0.28, 1.15);
// -------------------------------------------------------------------------
// Flow routes and dashed direction markers
// -------------------------------------------------------------------------
const routeGroup = new THREE.Group();
scene.add(routeGroup);
function makeCurve(points) {
return new THREE.CatmullRomCurve3(
points.map((p) => new THREE.Vector3(...p)),
false,
"catmullrom",
0.22
);
}
function addRoute(curve, color, showArrows = true) {
const points = curve.getPoints(100);
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineDashedMaterial({
color,
dashSize: 0.18,
gapSize: 0.12,
transparent: true,
opacity: 0.48,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
routeGroup.add(line);
if (showArrows) {
const arrowMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.72,
depthWrite: false
});
for (const u of [0.25, 0.53, 0.8]) {
const point = curve.getPointAt(u);
const tangent = curve.getTangentAt(u).normalize();
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.075, 0.22, 8),
arrowMaterial
);
arrow.position.copy(point);
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
tangent
);
routeGroup.add(arrow);
}
}
return curve;
}
const ingredientRoute = addRoute(
makeCurve([
[-5.35, 1.76, -0.74],
[-4.9, 1.76, -0.74],
[-4.25, 1.76, -0.74],
[-3.52, 1.76, -0.74]
]),
"#d39a32"
);
const choppedRoute = addRoute(
makeCurve([
[-3.52, 1.65, -0.74],
[-3.15, 1.65, -1.25],
[-4.0, 1.65, -2.25],
[-5.35, 1.65, -2.75],
[-4.87, 1.82, -4.12]
]),
"#d39a32"
);
const dishRoute = addRoute(
makeCurve([
[-4.87, 0.055, -2.72],
[-2.2, 0.055, -2.65],
[-0.65, 0.055, -2.15],
[0.0, 0.055, -0.85],
[0.35, 0.055, 0.45],
[0.9, 0.055, 1.25]
]),
"#3c9388"
);
const plateRoute = addRoute(
makeCurve([
[0.12, 0.055, -3.05],
[0.16, 0.055, -2.1],
[0.35, 0.055, -0.8],
[0.58, 0.055, 0.75],
[0.9, 0.055, 2.05],
[1.4, 0.055, 2.75]
]),
"#8b72b6"
);
const spoonPickupRoute = addRoute(
makeCurve([
[-0.58, 1.75, -4.13],
[-1.35, 1.75, -3.82],
[-2.85, 1.75, -3.55],
[-4.87, 1.75, -4.12]
]),
"#4d83b7"
);
const spoonServeRoute = addRoute(
makeCurve([
[-4.87, 1.75, -4.12],
[-4.25, 1.75, -2.85],
[-1.0, 1.75, -2.45],
[0.2, 1.75, -0.25],
[1.55, 1.75, 1.0],
[3.9, 1.75, 1.3]
]),
"#4d83b7"
);
// -------------------------------------------------------------------------
// World labels
// -------------------------------------------------------------------------
const labels = [
{
element: document.getElementById("label-prep"),
point: new THREE.Vector3(-3.75, 2.7, -0.74)
},
{
element: document.getElementById("label-pot"),
point: new THREE.Vector3(-4.87, 2.55, -4.12)
},
{
element: document.getElementById("label-table"),
point: new THREE.Vector3(3.2, 2.65, 1.4)
}
];
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const point = label.point.clone().project(camera);
const visible = point.z > -1 && point.z < 1;
label.element.style.display = visible ? "block" : "none";
label.element.style.left = `${(point.x * 0.5 + 0.5) * width}px`;
label.element.style.top = `${(-point.y * 0.5 + 0.5) * height}px`;
}
}
// -------------------------------------------------------------------------
// Animation helpers
// -------------------------------------------------------------------------
const clamp01 = (value) => THREE.MathUtils.clamp(value, 0, 1);
function smooth(value) {
const x = clamp01(value);
return x * x * (3 - 2 * x);
}
function pointOnCurve(curve, progress) {
return curve.getPointAt(clamp01(progress));
}
function orientPerson(person, curve, progress, reverse = false) {
const point = pointOnCurve(curve, reverse ? 1 - progress : progress);
let tangent = curve.getTangentAt(clamp01(reverse ? 1 - progress : progress));
if (reverse) tangent.multiplyScalar(-1);
person.root.position.set(point.x, 0, point.z);
person.root.rotation.y = Math.atan2(tangent.x, tangent.z);
return { point, tangent };
}
function forwardVector(person) {
return new THREE.Vector3(
Math.sin(person.root.rotation.y),
0,
Math.cos(person.root.rotation.y)
);
}
const phases = {
ana: document.getElementById("phase-ana"),
ben: document.getElementById("phase-ben"),
mei: document.getElementById("phase-mei"),
leo: document.getElementById("phase-leo")
};
function setPhase(key, text) {
if (phases[key].textContent !== text) {
phases[key].textContent = text;
}
}
// -------------------------------------------------------------------------
// Main animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
let paused = false;
const pauseButton = document.getElementById("pause");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
});
document.getElementById("show-routes").addEventListener("change", (event) => {
routeGroup.visible = event.target.checked;
});
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (!paused) elapsed += delta;
const t = elapsed;
// Ana chops continuously, with the ingredient itself following the prep route.
const ingredientTime = t % 9;
const chopMotion = Math.sin(t * 8.5);
ana.armL.rotation.x = -0.78 + chopMotion * 0.28;
ana.armR.rotation.x = -0.78 - chopMotion * 0.28;
ana.root.position.y = Math.abs(chopMotion) * 0.012;
if (ingredientTime < 2.8) {
const u = smooth(ingredientTime / 2.8);
const point = pointOnCurve(ingredientRoute, u);
tomatoGroup.position.copy(point);
tomatoGroup.visible = true;
tomatoGroup.scale.setScalar(1);
setPhase("ana", "Moving a tomato from the produce crate");
} else if (ingredientTime < 3.65) {
tomatoGroup.position.set(-3.52, 1.76, -0.74);
tomatoGroup.scale.setScalar(1 - smooth((ingredientTime - 2.8) / 0.85));
tomatoGroup.visible = true;
setPhase("ana", "Chopping the tomato on the board");
} else {
tomatoGroup.visible = false;
setPhase("ana", "Passing chopped ingredients to Ben");
}
if (ingredientTime >= 3.25 && ingredientTime < 6.8) {
choppedGroup.visible = true;
if (ingredientTime < 4.35) {
const u = smooth((ingredientTime - 3.25) / 1.1);
const point = pointOnCurve(choppedRoute, u);
choppedGroup.position.copy(point);
choppedGroup.scale.setScalar(1);
} else {
const u = smooth((ingredientTime - 4.35) / 2.45);
const point = pointOnCurve(choppedRoute, u);
choppedGroup.position.copy(point);
choppedGroup.scale.setScalar(1 - smooth((ingredientTime - 6.15) / 0.65));
}
} else {
choppedGroup.visible = false;
}
// Ben stirs the shared pot.
const stir = Math.sin(t * 3.3);
ben.armR.rotation.x = -1.04 + stir * 0.17;
ben.armR.rotation.z = -0.18;
ben.armL.rotation.x = -0.5 - stir * 0.08;
ben.root.position.y = Math.abs(stir) * 0.009;
setPhase("ben", "Stirring the shared pot with the passing spoon");
// Mei carries the prepared bowl from the kitchen to the table.
const meiCycle = (t % 12) / 12;
const bowlTarget = new THREE.Vector3(1.95, 1.49, 1.12);
let meiMoving = false;
let meiCarrying = false;
let meiReverse = false;
let bowlVisible = true;
if (meiCycle < 0.44) {
const u = smooth(meiCycle / 0.44);
orientPerson(mei, dishRoute, u);
meiMoving = true;
meiCarrying = true;
setPhase("mei", "Carrying the prepared bowl to the table");
} else if (meiCycle < 0.53) {
const u = smooth((meiCycle - 0.44) / 0.09);
orientPerson(mei, dishRoute, 1);
const forward = forwardVector(mei);
const carried = new THREE.Vector3(
mei.root.position.x + forward.x * 0.57,
1.38,
mei.root.position.z + forward.z * 0.57
);
bowlGroup.position.copy(carried).lerp(bowlTarget, u);
setPhase("mei", "Setting the prepared bowl on the table");
} else if (meiCycle < 0.9) {
const u = smooth((meiCycle - 0.53) / 0.37);
orientPerson(mei, dishRoute, u, true);
meiMoving = true;
meiReverse = true;
bowlGroup.position.copy(bowlTarget);
bowlVisible = meiCycle < 0.86;
setPhase("mei", "Returning to the kitchen for the next round");
} else {
orientPerson(mei, dishRoute, 0, true);
bowlVisible = false;
setPhase("mei", "Ready at the kitchen for the next round");
}
if (meiCycle < 0.44) {
const forward = forwardVector(mei);
bowlGroup.position.set(
mei.root.position.x + forward.x * 0.57,
1.38,
mei.root.position.z + forward.z * 0.57
);
}
bowlGroup.visible = bowlVisible;
animateWalker(mei, meiMoving, t * 8, meiCarrying);
// Leo brings a plate from the cupboard and places it at the table.
const leoCycle = ((t + 1.4) % 10) / 10;
const plateTarget = new THREE.Vector3(2.05, 1.49, 2.03);
let leoMoving = false;
let leoCarrying = false;
let plateVisible = true;
if (leoCycle < 0.4) {
const u = smooth(leoCycle / 0.4);
orientPerson(leo, plateRoute, u);
leoMoving = true;
leoCarrying = true;
setPhase("leo", "Bringing a plate from the cupboard");
} else if (leoCycle < 0.49) {
const u = smooth((leoCycle - 0.4) / 0.09);
orientPerson(leo, plateRoute, 1);
const forward = forwardVector(leo);
const carried = new THREE.Vector3(
leo.root.position.x + forward.x * 0.55,
1.43,
leo.root.position.z + forward.z * 0.55
);
plateGroup.position.copy(carried).lerp(plateTarget, u);
setPhase("leo", "Placing the plate at the family table");
} else if (leoCycle < 0.87) {
const u = smooth((leoCycle - 0.49) / 0.38);
orientPerson(leo, plateRoute, u, true);
leoMoving = true;
plateGroup.position.copy(plateTarget);
plateVisible = leoCycle < 0.84;
setPhase("leo", "Returning the empty-handed to the cupboard");
} else {
orientPerson(leo, plateRoute, 0, true);
plateVisible = false;
setPhase("leo", "Waiting for the next place setting");
}
if (leoCycle < 0.4) {
const forward = forwardVector(leo);
plateGroup.position.set(
leo.root.position.x + forward.x * 0.55,
1.43,
leo.root.position.z + forward.z * 0.55
);
}
plateGroup.visible = plateVisible;
animateWalker(leo, leoMoving, t * 8.5, leoCarrying);
// The serving spoon follows a coherent route:
// utensil caddy -> shared pot -> dining table -> reset.
const spoonCycle = t % 13;
spoonGroup.visible = true;
if (spoonCycle < 1.65) {
const point = pointOnCurve(spoonPickupRoute, smooth(spoonCycle / 1.65));
spoonGroup.position.copy(point);
} else if (spoonCycle < 3.25) {
const angle = t * 3.3;
spoonGroup.position.set(
-4.87 + Math.cos(angle) * 0.17,
2.08,
-4.12 + Math.sin(angle) * 0.17
);
spoonGroup.rotation.y = -angle;
} else if (spoonCycle < 9.4) {
const u = smooth((spoonCycle - 3.25) / 6.15);
const point = pointOnCurve(spoonServeRoute, u);
spoonGroup.position.copy(point);
const tangent = spoonServeRoute.getTangentAt(u);
spoonGroup.rotation.y = Math.atan2(tangent.x, tangent.z);
} else if (spoonCycle < 10.2) {
spoonGroup.position.set(3.95, 1.56, 1.12);
spoonGroup.rotation.y = Math.PI / 2;
} else {
spoonGroup.visible = false;
}
// Gentle ambient movement in the room.
const pendantObjects = [];
scene.traverse((object) => {
if (object.geometry?.type === "ConeGeometry" && object.parent?.type === "Group") {
// Route arrows are intentionally excluded from ambient movement.
}
});
updateLabels();
renderer.render(scene, camera);
}
animate();
window.addEventListener("resize", () => {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
updateCamera();
});
</script>
</body>
</html>
```