Prompt specification
Build or customize the Three.js 3D scene "Family dumpling-making table" 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 dumpling-making table
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/family-dumpling-making-table-x0099
Scene Description Prompt:
Create a voxel family dumpling table where different hands roll dough, add filling, and arrange trays. Three.js from cdnjs in one HTML file.
Working Three.js Starter (family-dumpling-making-table-x0099):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Dumpling Table</title>
<style>
:root {
--ink: #38251f;
--cream: #fff8e9;
--paper: rgba(255, 248, 233, 0.9);
--red: #d94c3d;
--green: #47725a;
--gold: #e8ad3f;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #ead7bd;
color: var(--ink);
font-family: ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.header {
position: fixed;
top: 24px;
left: 26px;
z-index: 5;
display: flex;
align-items: center;
gap: 14px;
pointer-events: none;
}
.logo {
position: relative;
width: 52px;
height: 48px;
filter: drop-shadow(0 5px 8px rgba(68, 39, 28, 0.16));
}
.logo i {
position: absolute;
display: block;
background: var(--cream);
border: 2px solid rgba(82, 48, 35, 0.22);
}
.logo i:nth-child(1) {
width: 34px;
height: 13px;
left: 9px;
top: 24px;
}
.logo i:nth-child(2) {
width: 27px;
height: 13px;
left: 12px;
top: 13px;
}
.logo i:nth-child(3) {
width: 18px;
height: 10px;
left: 17px;
top: 4px;
}
.logo i:nth-child(4) {
width: 26px;
height: 5px;
left: 13px;
top: 36px;
background: var(--red);
}
.eyebrow {
margin: 0 0 3px;
color: var(--red);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 36px);
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
margin: 6px 0 0;
font-size: 12px;
font-weight: 650;
opacity: 0.68;
}
.top-actions {
position: fixed;
top: 25px;
right: 26px;
z-index: 8;
display: flex;
gap: 8px;
}
.icon-button,
.task-button,
.pause-button {
border: 1px solid rgba(76, 47, 35, 0.15);
color: var(--ink);
background: var(--paper);
box-shadow: 0 8px 24px rgba(80, 46, 31, 0.11);
backdrop-filter: blur(12px);
cursor: pointer;
transition:
transform 160ms ease,
background 160ms ease,
color 160ms ease,
box-shadow 160ms ease;
}
.icon-button:hover,
.task-button:hover,
.pause-button:hover {
transform: translateY(-2px);
box-shadow: 0 12px 28px rgba(80, 46, 31, 0.16);
}
.icon-button {
height: 42px;
padding: 0 15px;
border-radius: 13px;
font-size: 12px;
font-weight: 850;
letter-spacing: 0.04em;
}
.task-panel {
position: fixed;
z-index: 8;
left: 50%;
bottom: 24px;
display: flex;
align-items: center;
gap: 7px;
max-width: calc(100vw - 28px);
padding: 7px;
border: 1px solid rgba(76, 47, 35, 0.14);
border-radius: 19px;
background: rgba(255, 248, 233, 0.82);
box-shadow: 0 14px 38px rgba(76, 43, 30, 0.17);
backdrop-filter: blur(14px);
transform: translateX(-50%);
}
.task-button,
.pause-button {
min-height: 45px;
border: 0;
border-radius: 13px;
background: transparent;
font: inherit;
white-space: nowrap;
}
.task-button {
display: flex;
align-items: center;
gap: 9px;
padding: 0 14px;
font-size: 12px;
font-weight: 850;
}
.task-button .number {
display: grid;
width: 24px;
height: 24px;
place-items: center;
border-radius: 8px;
background: rgba(77, 49, 36, 0.09);
font-size: 10px;
}
.task-button.active {
color: #fffaf0;
background: var(--green);
}
.task-button.active .number {
color: var(--green);
background: #fff7e7;
}
.pause-button {
width: 45px;
padding: 0;
color: #fffaf0;
background: var(--red);
font-size: 15px;
font-weight: 900;
}
.status {
position: fixed;
left: 27px;
bottom: 29px;
z-index: 5;
max-width: 300px;
pointer-events: none;
}
.status-label {
display: inline-flex;
align-items: center;
gap: 7px;
margin-bottom: 7px;
padding: 6px 9px;
border-radius: 8px;
color: #fffaf0;
background: var(--red);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.status-label::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: #fff4ca;
content: "";
animation: blink 1.8s infinite;
}
#sceneStatus {
font-size: 13px;
font-weight: 800;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.hint {
position: fixed;
right: 27px;
bottom: 30px;
z-index: 5;
color: rgba(56, 37, 31, 0.62);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-align: right;
text-transform: uppercase;
pointer-events: none;
}
.loader {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #ead7bd;
transition: opacity 500ms ease, visibility 500ms ease;
}
.loader.hide {
opacity: 0;
visibility: hidden;
}
.loader-cube {
width: 26px;
height: 26px;
background: var(--red);
box-shadow:
18px 0 0 var(--gold),
0 18px 0 #47725a,
18px 18px 0 #f2d09b;
animation: cube-hop 900ms infinite ease-in-out;
}
@keyframes cube-hop {
0%, 100% { transform: translateY(0) rotate(0); }
50% { transform: translateY(-10px) rotate(8deg); }
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0.35; }
}
@media (max-width: 760px) {
.header {
top: 17px;
left: 17px;
}
.logo {
display: none;
}
.subtitle,
.status,
.hint {
display: none;
}
.top-actions {
top: 17px;
right: 17px;
}
.task-panel {
bottom: 15px;
gap: 3px;
padding: 5px;
}
.task-button {
padding: 0 10px;
}
.task-button .number {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="header">
<div class="logo" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div>
<p class="eyebrow">A tiny family kitchen</p>
<h1>Dumpling Day</h1>
<p class="subtitle">Four hands, one table, a hundred little parcels.</p>
</div>
</header>
<div class="top-actions">
<button class="icon-button" id="resetView" type="button">Reset view</button>
</div>
<div class="status">
<div class="status-label">Kitchen live</div>
<div id="sceneStatus">Everyone is at work</div>
</div>
<nav class="task-panel" aria-label="Dumpling activities">
<button class="task-button active" data-task="all" type="button">
<span class="number">0</span>Whole table
</button>
<button class="task-button" data-task="roll" type="button">
<span class="number">1</span>Roll dough
</button>
<button class="task-button" data-task="fill" type="button">
<span class="number">2</span>Add filling
</button>
<button class="task-button" data-task="arrange" type="button">
<span class="number">3</span>Arrange trays
</button>
<button class="pause-button" id="pauseButton" type="button" aria-label="Pause animation">Ⅱ</button>
</nav>
<div class="hint">Drag to orbit · Scroll to zoom · Space to pause</div>
<div class="loader" id="loader">
<div class="loader-cube"></div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.querySelector("#scene");
const loader = document.querySelector("#loader");
const pauseButton = document.querySelector("#pauseButton");
const sceneStatus = document.querySelector("#sceneStatus");
const renderer = new THREE.WebGLRenderer({
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.12;
renderer.domElement.setAttribute("aria-label", "Animated voxel family making dumplings");
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xead7bd);
scene.fog = new THREE.Fog(0xead7bd, 18, 34);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
const hemiLight = new THREE.HemisphereLight(0xfff4dd, 0x87624d, 2.1);
scene.add(hemiLight);
const sunLight = new THREE.DirectionalLight(0xffedc4, 3.4);
sunLight.position.set(6, 11, 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.0004;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0x9fc6da, 1.0);
fillLight.position.set(-7, 6, -3);
scene.add(fillLight);
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
const UP = new THREE.Vector3(0, 1, 0);
const tempDirection = new THREE.Vector3();
const tempMidpoint = new THREE.Vector3();
function getMaterial(color) {
if (color && color.isMaterial) return color;
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0
})
);
}
return materialCache.get(color);
}
function box(parent, width, height, depth, x, y, z, material) {
const mesh = new THREE.Mesh(cubeGeometry, getMaterial(material));
mesh.position.set(x, y, z);
mesh.scale.set(width, height, depth);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function group(parent, x = 0, y = 0, z = 0) {
const result = new THREE.Group();
result.position.set(x, y, z);
parent.add(result);
return result;
}
function setSegment(mesh, from, to, width) {
tempDirection.subVectors(to, from);
const length = Math.max(tempDirection.length(), 0.001);
tempMidpoint.copy(from).add(to).multiplyScalar(0.5);
mesh.position.copy(tempMidpoint);
mesh.quaternion.setFromUnitVectors(UP, tempDirection.normalize());
mesh.scale.set(width, length, width);
}
function smooth(value) {
value = THREE.MathUtils.clamp(value, 0, 1);
return value * value * (3 - 2 * value);
}
function makeDumpling(parent, size = 1) {
const dumpling = group(parent);
dumpling.scale.setScalar(size);
box(dumpling, 0.36, 0.17, 0.29, 0, 0.09, 0, 0xffe4aa);
box(dumpling, 0.28, 0.10, 0.24, 0, 0.21, 0, 0xfff0c6);
box(dumpling, 0.09, 0.07, 0.10, -0.10, 0.27, 0, 0xf6d58f);
box(dumpling, 0.09, 0.07, 0.10, 0, 0.28, 0, 0xf6d58f);
box(dumpling, 0.09, 0.07, 0.10, 0.10, 0.27, 0, 0xf6d58f);
box(dumpling, 0.25, 0.035, 0.035, 0, 0.08, 0.152, 0xe9bd72);
return dumpling;
}
function makeDough(parent, size = 1) {
const dough = group(parent);
dough.scale.setScalar(size);
box(dough, 0.66, 0.075, 0.48, 0, 0, 0, 0xf5d897);
box(dough, 0.48, 0.075, 0.65, 0, 0, 0, 0xf5d897);
box(dough, 0.76, 0.055, 0.30, 0, 0, 0, 0xf8dfa4);
box(dough, 0.30, 0.055, 0.76, 0, 0, 0, 0xf8dfa4);
return dough;
}
function makeBowl(parent, x, y, z, ceramicColor = 0x668b7a) {
const bowl = group(parent, x, y, z);
box(bowl, 0.62, 0.14, 0.62, 0, 0.08, 0, ceramicColor);
box(bowl, 0.78, 0.14, 0.17, 0, 0.24, -0.31, ceramicColor);
box(bowl, 0.78, 0.14, 0.17, 0, 0.24, 0.31, ceramicColor);
box(bowl, 0.17, 0.14, 0.48, -0.31, 0.24, 0, ceramicColor);
box(bowl, 0.17, 0.14, 0.48, 0.31, 0.24, 0, ceramicColor);
return bowl;
}
// Room
box(scene, 18, 0.22, 15, 0, -0.15, 0, 0xd9b98f);
box(scene, 18, 7.2, 0.22, 0, 3.35, -6.25, 0xf1d5b5);
box(scene, 0.22, 7.2, 14, -8.8, 3.35, -0.1, 0xe8c9a6);
for (let x = -8; x <= 8; x += 1) {
box(scene, 0.025, 0.012, 13.8, x, -0.032, 0, 0xc8a57b);
}
// Wainscoting
box(scene, 17.8, 1.35, 0.08, 0, 0.6, -6.10, 0xb8795b);
for (let x = -8.2; x <= 8.2; x += 0.75) {
box(scene, 0.045, 1.25, 0.035, x, 0.62, -6.035, 0xd79b78);
}
// Window
const windowGroup = group(scene, 2.55, 4.35, -6.02);
box(windowGroup, 2.75, 2.45, 0.12, 0, 0, 0, 0x9fc8d3);
box(windowGroup, 0.16, 2.65, 0.22, -1.38, 0, 0.03, 0xfff1d8);
box(windowGroup, 0.16, 2.65, 0.22, 1.38, 0, 0.03, 0xfff1d8);
box(windowGroup, 2.92, 0.16, 0.22, 0, -1.25, 0.03, 0xfff1d8);
box(windowGroup, 2.92, 0.16, 0.22, 0, 1.25, 0.03, 0xfff1d8);
box(windowGroup, 0.12, 2.42, 0.20, 0, 0, 0.05, 0xfff1d8);
box(windowGroup, 2.55, 0.12, 0.20, 0, 0, 0.05, 0xfff1d8);
box(windowGroup, 3.15, 0.16, 0.48, 0, -1.35, 0.12, 0xd9a66f);
// Shelf and jars
box(scene, 3.4, 0.16, 0.60, -4.65, 3.70, -5.83, 0x9b5f43);
box(scene, 3.4, 0.10, 0.22, -4.65, 3.54, -5.61, 0x744334);
const jarColors = [0x6f9375, 0xd78a4a, 0xc65b4c, 0xe0b85c];
for (let i = 0; i < 4; i++) {
const x = -5.72 + i * 0.70;
box(scene, 0.43, 0.56, 0.40, x, 4.06, -5.78, jarColors[i]);
box(scene, 0.49, 0.10, 0.45, x, 4.38, -5.78, 0xe7c994);
}
// Wall hooks and utensils
box(scene, 1.85, 0.11, 0.14, -6.80, 4.25, -5.99, 0x8a5139);
for (let i = 0; i < 3; i++) {
const x = -7.35 + i * 0.55;
box(scene, 0.06, 0.22, 0.10, x, 4.18, -5.91, 0x58433a);
box(scene, 0.20, 0.68, 0.08, x, 3.72, -5.91, 0x68716a);
box(scene, 0.34, 0.20, 0.09, x, 3.40, -5.91, 0x68716a);
}
// Small plant
const plant = group(scene, -7.7, 0, -4.8);
box(plant, 0.85, 0.80, 0.85, 0, 0.4, 0, 0xb85f47);
box(plant, 0.55, 0.12, 0.55, 0, 0.85, 0, 0x604b37);
box(plant, 0.18, 1.15, 0.18, 0, 1.35, 0, 0x557554);
box(plant, 0.72, 0.35, 0.18, -0.23, 1.55, 0, 0x66875e);
box(plant, 0.68, 0.34, 0.18, 0.25, 1.88, 0, 0x769364);
box(plant, 0.55, 0.30, 0.18, 0.15, 2.18, 0, 0x5f8158);
// Pendant lights
for (const x of [-2.7, 2.7]) {
box(scene, 0.045, 1.55, 0.045, x, 6.65, -0.6, 0x4d4038);
box(scene, 0.65, 0.25, 0.65, x, 5.92, -0.6, 0xd16c4e);
box(scene, 0.42, 0.18, 0.42, x, 5.75, -0.6, 0xf3bd73);
const light = new THREE.PointLight(0xffc978, 12, 7, 2);
light.position.set(x, 5.6, -0.6);
scene.add(light);
}
// Table
const table = group(scene);
const plankColors = [0xb96f43, 0xc57a4b, 0xae633e, 0xc98250, 0xb66d43, 0xca7d4c, 0xb96e43];
for (let i = 0; i < 7; i++) {
box(table, 10.4, 0.28, 0.55, 0, 2.16, -1.51 + i * 0.57, plankColors[i]);
}
box(table, 10.15, 0.30, 0.18, 0, 1.77, 2.16, 0x8f4c35);
box(table, 10.15, 0.30, 0.18, 0, 1.77, -1.74, 0x8f4c35);
for (const x of [-4.65, 4.65]) {
for (const z of [-1.45, 1.82]) {
box(table, 0.38, 2.08, 0.38, x, 1.05, z, 0x884a34);
box(table, 0.47, 0.16, 0.47, x, 0.16, z, 0x673a2e);
}
}
// Checkered table runner
for (let x = 0; x < 25; x++) {
for (let z = 0; z < 2; z++) {
box(
table,
0.40,
0.025,
0.36,
-4.80 + x * 0.40,
2.315,
1.03 + z * 0.36,
(x + z) % 2 === 0 ? 0xc64c3f : 0xf3d9a4
);
}
}
// Rolling station
const rollingBoard = group(scene, -3.65, 2.315, -0.70);
box(rollingBoard, 2.00, 0.09, 1.32, 0, 0, 0, 0xd6a86b);
box(rollingBoard, 1.76, 0.08, 1.08, 0, 0.07, 0, 0xe3bd82);
const rollingDough = makeDough(rollingBoard, 0.86);
rollingDough.position.set(0, 0.14, 0);
const rollingPin = group(scene, -3.65, 2.57, -0.70);
box(rollingPin, 0.96, 0.19, 0.19, 0, 0, 0, 0xc28a50);
box(rollingPin, 0.54, 0.11, 0.11, -0.72, 0, 0, 0x7b5034);
box(rollingPin, 0.54, 0.11, 0.11, 0.72, 0, 0, 0x7b5034);
for (let i = 0; i < 14; i++) {
const x = -4.45 + (i % 7) * 0.27;
const z = -1.15 + Math.floor(i / 7) * 0.20;
box(rollingBoard, 0.055, 0.025, 0.055, x, 0.14, z, 0xf5dfaa);
}
// Filling station
const fillingBoard = group(scene, -0.65, 2.315, -0.78);
box(fillingBoard, 1.80, 0.09, 1.64, 0, 0, 0, 0xd3a165);
box(fillingBoard, 1.58, 0.07, 1.42, 0, 0.065, 0, 0xe0b77c);
const fillingBowl = makeBowl(scene, -0.65, 2.40, -1.23, 0x6d8e83);
box(fillingBowl, 0.50, 0.18, 0.50, 0, 0.25, 0, 0x7b4634);
box(fillingBowl, 0.24, 0.10, 0.24, -0.11, 0.36, 0.04, 0x965d43);
box(fillingBowl, 0.23, 0.10, 0.23, 0.12, 0.37, -0.06, 0x875039);
const wrapper = makeDough(fillingBoard, 0.64);
wrapper.position.set(0, 0.15, 0.63);
const fillingMound = group(fillingBoard, 0, 0.22, 0.63);
box(fillingMound, 0.42, 0.13, 0.32, 0, 0, 0, 0x7b4936);
box(fillingMound, 0.24, 0.14, 0.24, -0.08, 0.09, 0.04, 0x925a41);
box(fillingMound, 0.23, 0.13, 0.22, 0.09, 0.08, -0.05, 0x875039);
box(fillingMound, 0.16, 0.11, 0.15, 0, 0.16, 0.01, 0x9f6346);
const spoon = group(scene);
box(spoon, 0.09, 0.08, 0.58, 0, 0, 0.32, 0xb67843);
box(spoon, 0.27, 0.10, 0.24, 0, 0, -0.06, 0x65736c);
box(spoon, 0.18, 0.05, 0.15, 0, 0.07, -0.06, 0x554b43);
// Wooden dumpling tray
const tray = group(scene, 2.30, 2.315, -0.68);
box(tray, 2.55, 0.09, 1.42, 0, 0, 0, 0x9e613f);
box(tray, 2.30, 0.055, 1.18, 0, 0.065, 0, 0xe2b57a);
box(tray, 2.55, 0.17, 0.10, 0, 0.11, -0.69, 0xc58b54);
box(tray, 2.55, 0.17, 0.10, 0, 0.11, 0.69, 0xc58b54);
box(tray, 0.10, 0.17, 1.30, -1.23, 0.11, 0, 0xc58b54);
box(tray, 0.10, 0.17, 1.30, 1.23, 0.11, 0, 0xc58b54);
const trayDumplings = [];
const traySlots = [];
for (let row = 0; row < 2; row++) {
for (let col = 0; col < 3; col++) {
const slot = new THREE.Vector3(
2.30 - 0.64 + col * 0.64,
2.48,
-0.68 - 0.28 + row * 0.56
);
traySlots.push(slot);
const dumpling = makeDumpling(scene, 0.88);
dumpling.position.copy(slot);
dumpling.visible = false;
trayDumplings.push(dumpling);
}
}
// Child's tiny preparation board
const childBoard = group(scene, 4.55, 2.315, -0.88);
box(childBoard, 0.92, 0.08, 0.82, 0, 0, 0, 0xd5a46a);
const childDough = makeDough(childBoard, 0.43);
childDough.position.set(0, 0.12, 0);
// Bamboo steamer
const steamer = group(scene, 0.05, 2.32, 0.77);
box(steamer, 1.70, 0.12, 1.24, 0, 0, 0, 0xc28a4d);
box(steamer, 1.54, 0.10, 1.08, 0, 0.09, 0, 0xe0b66f);
box(steamer, 1.76, 0.18, 0.13, 0, 0.12, -0.62, 0xd7a45e);
box(steamer, 1.76, 0.18, 0.13, 0, 0.12, 0.62, 0xd7a45e);
box(steamer, 0.13, 0.18, 1.20, -0.83, 0.12, 0, 0xd7a45e);
box(steamer, 0.13, 0.18, 1.20, 0.83, 0.12, 0, 0xd7a45e);
for (let i = 0; i < 4; i++) {
const dumpling = makeDumpling(steamer, 0.84);
dumpling.position.set(
i % 2 === 0 ? -0.34 : 0.34,
0.24,
i < 2 ? -0.24 : 0.24
);
}
// Serving plate and tea things
const plate = group(scene, 2.25, 2.33, 1.28);
box(plate, 1.78, 0.09, 1.12, 0, 0, 0, 0xf3e6cf);
box(plate, 1.55, 0.055, 0.90, 0, 0.065, 0, 0xfff4df);
box(plate, 0.48, 0.30, 0.48, -0.30, 0.25, 0, 0xe2d2ba);
for (let i = 0; i < 3; i++) {
const cup = group(scene, -1.65 + i * 0.46, 2.32, 1.35);
box(cup, 0.26, 0.32, 0.26, 0, 0.16, 0, 0xf4ead6);
box(cup, 0.20, 0.04, 0.20, 0, 0.34, 0, 0x81513a);
}
// People
function createPerson(options) {
const {
x,
z,
scale = 1,
skin = 0xe5ae80,
hair = 0x4a3028,
shirt = 0x5b7e69,
apron = 0xe8d4ae,
hairStyle = "short",
heightOffset = 0
} = options;
const person = group(scene, x, 0, z);
person.scale.setScalar(scale);
box(person, 0.29, 0.76, 0.33, -0.20, 0.57, 0, 0x46566a);
box(person, 0.29, 0.76, 0.33, 0.20, 0.57, 0, 0x46566a);
box(person, 0.35, 0.16, 0.48, -0.20, 0.14, 0.10, 0x44332e);
box(person, 0.35, 0.16, 0.48, 0.20, 0.14, 0.10, 0x44332e);
box(person, 0.98, 1.05, 0.58, 0, 1.58, 0, shirt);
box(person, 0.73, 0.74, 0.07, 0, 1.42, 0.33, apron);
box(person, 0.10, 0.61, 0.07, -0.24, 1.80, 0.33, apron);
box(person, 0.10, 0.61, 0.07, 0.24, 1.80, 0.33, apron);
box(person, 0.28, 0.18, 0.27, 0, 2.20, 0, skin);
const headY = 2.79 + heightOffset;
box(person, 0.84, 0.78, 0.74, 0, headY, 0, skin);
box(person, 0.12, 0.12, 0.12, 0, headY - 0.02, 0.42, skin);
box(person, 0.08, 0.09, 0.035, -0.17, headY + 0.08, 0.39, 0x302521);
box(person, 0.08, 0.09, 0.035, 0.17, headY + 0.08, 0.39, 0x302521);
box(person, 0.20, 0.045, 0.035, 0, headY - 0.16, 0.395, 0x9b5147);
if (hairStyle === "bun") {
box(person, 0.91, 0.20, 0.79, 0, headY + 0.43, 0, hair);
box(person, 0.16, 0.65, 0.65, -0.39, headY + 0.13, -0.02, hair);
box(person, 0.16, 0.65, 0.65, 0.39, headY + 0.13, -0.02, hair);
box(person, 0.34, 0.34, 0.30, -0.49, headY + 0.48, -0.02, hair);
box(person, 0.34, 0.34, 0.30, 0.49, headY + 0.48, -0.02, hair);
box(person, 0.52, 0.035, 0.035, 0, headY + 0.08, 0.405, 0x58433a);
box(person, 0.035, 0.19, 0.035, 0, headY + 0.08, 0.405, 0x58433a);
box(person, 0.035, 0.19, 0.035, -0.26, headY + 0.08, 0.405, 0x58433a);
box(person, 0.035, 0.19, 0.035, 0.26, headY + 0.08, 0.405, 0x58433a);
} else if (hairStyle === "ponytail") {
box(person, 0.91, 0.22, 0.79, 0, headY + 0.42, 0, hair);
box(person, 0.17, 0.70, 0.67, -0.39, headY + 0.12, -0.02, hair);
box(person, 0.17, 0.70, 0.67, 0.39, headY + 0.12, -0.02, hair);
box(person, 0.38, 0.75, 0.34, 0, headY - 0.02, -0.50, hair);
} else if (hairStyle === "cap") {
box(person, 0.92, 0.19, 0.80, 0, headY + 0.40, 0, 0xc9503d);
box(person, 0.86, 0.10, 0.52, 0, headY + 0.34, 0.48, 0xe26951);
box(person, 0.31, 0.18, 0.28, 0, headY + 0.58, 0, 0xc9503d);
} else {
box(person, 0.91, 0.20, 0.79, 0, headY + 0.42, 0, hair);
box(person, 0.16, 0.49, 0.68, -0.40, headY + 0.20, -0.02, hair);
box(person, 0.16, 0.49, 0.68, 0.40, headY + 0.20, -0.02, hair);
box(person, 0.32, 0.08, 0.10, 0, headY - 0.04, 0.40, hair);
}
if (hairStyle === "short" && shirt === 0x4f755e) {
box(person, 0.29, 0.07, 0.05, 0, headY - 0.10, 0.42, hair);
}
const shoulderY = 2.08 * scale + heightOffset * scale;
const shoulders = {
left: new THREE.Vector3(x - 0.49 * scale, shoulderY, z + 0.19 * scale),
right: new THREE.Vector3(x + 0.49 * scale, shoulderY, z + 0.19 * scale)
};
return { person, shoulders };
}
const grandma = createPerson({
x: -3.65,
z: -2.55,
scale: 0.96,
skin: 0xe5ad83,
hair: 0xc7c4bd,
shirt: 0x795878,
apron: 0xf0dfbd,
hairStyle: "bun"
});
const dad = createPerson({
x: -0.65,
z: -2.55,
scale: 1.05,
skin: 0xd99a70,
hair: 0x382a27,
shirt: 0x4f755e,
apron: 0xd77a43,
hairStyle: "short"
});
const mom = createPerson({
x: 2.30,
z: -2.58,
scale: 0.99,
skin: 0xe8b18a,
hair: 0x743d2c,
shirt: 0xd66350,
apron: 0x466f62,
hairStyle: "ponytail"
});
const child = createPerson({
x: 4.55,
z: -2.62,
scale: 0.72,
skin: 0xefbd91,
hair: 0x9a6339,
shirt: 0xe0aa3e,
apron: 0x557791,
hairStyle: "cap"
});
function createArm(shoulder, sleeveColor, skinColor) {
const upper = box(scene, 1, 1, 1, 0, 0, 0, sleeveColor);
const lower = box(scene, 1, 1, 1, 0, 0, 0, skinColor);
const hand = box(scene, 0.23, 0.22, 0.23, 0, 0, 0, skinColor);
return {
shoulder: shoulder.clone(),
upper,
lower,
hand,
update(target, bendSide = 1) {
const elbow = shoulder.clone().lerp(target, 0.52);
elbow.y -= 0.22;
elbow.z -= 0.05 * bendSide;
elbow.x += 0.06 * bendSide;
setSegment(upper, shoulder, elbow, 0.24);
setSegment(lower, elbow, target, 0.18);
hand.position.copy(target);
hand.rotation.y = Math.atan2(target.x - shoulder.x, target.z - shoulder.z);
}
};
}
const grandmaLeftArm = createArm(grandma.shoulders.left, 0x795878, 0xe5ad83);
const grandmaRightArm = createArm(grandma.shoulders.right, 0x795878, 0xe5ad83);
const dadLeftArm = createArm(dad.shoulders.left, 0x4f755e, 0xd99a70);
const dadRightArm = createArm(dad.shoulders.right, 0x4f755e, 0xd99a70);
const momLeftArm = createArm(mom.shoulders.left, 0xd66350, 0xe8b18a);
const momRightArm = createArm(mom.shoulders.right, 0xd66350, 0xe8b18a);
const childLeftArm = createArm(child.shoulders.left, 0xe0aa3e, 0xefbd91);
const childRightArm = createArm(child.shoulders.right, 0xe0aa3e, 0xefbd91);
// Steam cubes above the bamboo basket
const steamCubes = [];
for (let i = 0; i < 9; i++) {
const material = new THREE.MeshBasicMaterial({
color: 0xfff8e8,
transparent: true,
opacity: 0.25,
depthWrite: false
});
const cube = box(scene, 0.16, 0.16, 0.16, 0, 3, 0, material);
cube.castShadow = false;
cube.receiveShadow = false;
steamCubes.push(cube);
}
// Station highlight frames
function makeHighlight(x, z, width, depth, color) {
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0,
depthWrite: false
});
const highlight = group(scene, x, 2.39, z);
box(highlight, width, 0.035, 0.045, 0, 0, -depth / 2, material);
box(highlight, width, 0.035, 0.045, 0, 0, depth / 2, material);
box(highlight, 0.045, 0.035, depth, -width / 2, 0, 0, material);
box(highlight, 0.045, 0.035, depth, width / 2, 0, 0, material);
return { group: highlight, material };
}
const highlights = {
roll: makeHighlight(-3.65, -0.70, 2.30, 1.65, 0xe8ad3f),
fill: makeHighlight(-0.65, -0.75, 2.10, 1.90, 0xd94c3d),
arrange: makeHighlight(2.30, -0.68, 2.90, 1.75, 0x47725a)
};
// Camera and direct controls
const orbit = {
theta: 0.72,
phi: 1.05,
radius: 16.2,
desiredRadius: 16.2
};
const cameraTarget = new THREE.Vector3(0, 1.65, 0);
const desiredTarget = cameraTarget.clone();
function updateCamera(delta) {
const smoothing = 1 - Math.exp(-delta * 5);
cameraTarget.lerp(desiredTarget, smoothing);
orbit.radius = THREE.MathUtils.lerp(
orbit.radius,
orbit.desiredRadius,
smoothing
);
const horizontal = Math.sin(orbit.phi) * orbit.radius;
camera.position.set(
cameraTarget.x + horizontal * Math.sin(orbit.theta),
cameraTarget.y + Math.cos(orbit.phi) * orbit.radius,
cameraTarget.z + horizontal * Math.cos(orbit.theta)
);
camera.lookAt(cameraTarget);
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.theta -= dx * 0.0055;
orbit.phi = THREE.MathUtils.clamp(orbit.phi + dy * 0.0045, 0.55, 1.38);
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.desiredRadius = THREE.MathUtils.clamp(
orbit.desiredRadius + event.deltaY * 0.012,
8.5,
23
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
const tasks = {
all: {
target: new THREE.Vector3(0, 1.65, 0),
radius: 16.2,
status: "Everyone is at work"
},
roll: {
target: new THREE.Vector3(-3.65, 2.35, -0.55),
radius: 10.6,
status: "Grandma is rolling perfect little circles"
},
fill: {
target: new THREE.Vector3(-0.65, 2.40, -0.55),
radius: 10.4,
status: "Dad is spooning in the savory filling"
},
arrange: {
target: new THREE.Vector3(2.30, 2.40, -0.55),
radius: 10.8,
status: "Mom is arranging the dumplings in neat rows"
}
};
let selectedTask = "all";
function selectTask(taskName) {
selectedTask = taskName;
const task = tasks[taskName];
desiredTarget.copy(task.target);
orbit.desiredRadius = task.radius;
sceneStatus.textContent = task.status;
document.querySelectorAll(".task-button").forEach((button) => {
button.classList.toggle("active", button.dataset.task === taskName);
});
}
function resetView() {
selectTask("all");
orbit.theta = 0.72;
orbit.phi = 1.05;
}
document.querySelectorAll(".task-button").forEach((button) => {
button.addEventListener("click", () => selectTask(button.dataset.task));
});
document.querySelector("#resetView").addEventListener("click", resetView);
let paused = false;
let animationTime = 0;
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "▶" : "Ⅱ";
pauseButton.setAttribute(
"aria-label",
paused ? "Resume animation" : "Pause animation"
);
sceneStatus.textContent = paused
? "The kitchen is paused for a snack"
: tasks[selectedTask].status;
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
pauseButton.click();
}
});
// Animated family activity
const bowlTarget = new THREE.Vector3(-0.65, 2.67, -1.22);
const wrapperTarget = new THREE.Vector3(-0.65, 2.57, -0.45);
const stagingPosition = new THREE.Vector3(3.62, 2.53, -1.23);
const leftHandTarget = new THREE.Vector3();
const rightHandTarget = new THREE.Vector3();
function updateScene(t) {
// Grandma rolls the pin back and forth.
const rollingX = -3.65 + Math.sin(t * 2.35) * 0.32;
rollingPin.position.x = rollingX;
const squash = Math.abs(Math.sin(t * 4.7));
rollingDough.scale.set(
0.86 * (1.06 - squash * 0.08),
0.86 * (0.84 + squash * 0.20),
0.86 * (1.06 - squash * 0.08)
);
leftHandTarget.set(rollingX - 0.70, 2.57, -0.70);
rightHandTarget.set(rollingX + 0.70, 2.57, -0.70);
grandmaLeftArm.update(leftHandTarget, 1);
grandmaRightArm.update(rightHandTarget, -1);
grandma.person.position.y = Math.sin(t * 2.35) * 0.012;
// Dad scoops filling and moves it to the wrapper.
const scoopPhase = (t * 0.58) % 1;
if (scoopPhase < 0.43) {
const q = smooth(scoopPhase / 0.43);
rightHandTarget.copy(bowlTarget).lerp(wrapperTarget, q);
rightHandTarget.y += Math.sin(q * Math.PI) * 0.42;
} else if (scoopPhase < 0.62) {
rightHandTarget.copy(wrapperTarget);
rightHandTarget.x += Math.sin((scoopPhase - 0.43) * 22) * 0.07;
rightHandTarget.y += 0.04;
} else {
const q = smooth((scoopPhase - 0.62) / 0.38);
rightHandTarget.copy(wrapperTarget).lerp(bowlTarget, q);
rightHandTarget.y += Math.sin(q * Math.PI) * 0.24;
}
spoon.position.copy(rightHandTarget);
spoon.rotation.x = -0.25 + Math.sin(t * 3.6) * 0.08;
spoon.rotation.y = Math.sin(t * 1.7) * 0.12;
leftHandTarget.set(-0.95, 2.45, -0.42);
dadLeftArm.update(leftHandTarget, 1);
dadRightArm.update(rightHandTarget, -1);
const fillCycle = t % 6.2;
let fillScale;
if (fillCycle < 4.1) {
fillScale = 0.18 + smooth(fillCycle / 3.7) * 0.82;
} else if (fillCycle < 5.55) {
fillScale = 1;
} else {
fillScale = 1 - smooth((fillCycle - 5.55) / 0.65) * 0.82;
}
fillingMound.scale.setScalar(fillScale);
dad.person.rotation.z = Math.sin(t * 1.8) * 0.006;
// Mom places dumplings into the tray one at a time.
const placedCount = Math.min(trayDumplings.length, Math.floor(t / 1.05));
for (let i = 0; i < trayDumplings.length; i++) {
const dumpling = trayDumplings[i];
dumpling.visible = i < placedCount;
if (i === placedCount && placedCount < trayDumplings.length) {
const progress = (t % 1.05) / 1.05;
const eased = smooth(progress);
dumpling.visible = true;
dumpling.position.copy(stagingPosition).lerp(traySlots[i], eased);
dumpling.position.y += Math.sin(eased * Math.PI) * 0.18;
dumpling.rotation.y = (1 - eased) * 0.8;
} else {
dumpling.position.copy(traySlots[i]);
dumpling.rotation.y = 0;
}
}
if (placedCount < trayDumplings.length) {
const activePosition = trayDumplings[placedCount].position;
leftHandTarget.copy(activePosition).add(new THREE.Vector3(-0.25, 0.08, 0));
rightHandTarget.copy(activePosition).add(new THREE.Vector3(0.25, 0.08, 0));
} else {
const hover = Math.sin(t * 2.2) * 0.10;
leftHandTarget.set(2.02 + hover, 2.61, -0.76);
rightHandTarget.set(2.58 - hover, 2.61, -0.62);
}
momLeftArm.update(leftHandTarget, 1);
momRightArm.update(rightHandTarget, -1);
mom.person.position.y = Math.sin(t * 2.2 + 0.8) * 0.012;
// The child taps a tiny piece of dough.
const tap = Math.abs(Math.sin(t * 4.0));
leftHandTarget.set(4.34, 2.47, -0.86);
rightHandTarget.set(
4.57 + Math.sin(t * 4.0) * 0.10,
2.56 - tap * 0.14,
-0.88 + Math.cos(t * 4.0) * 0.07
);
childLeftArm.update(leftHandTarget, 1);
childRightArm.update(rightHandTarget, -1);
childDough.scale.set(
0.43 * (1 + tap * 0.06),
0.43 * (1 - tap * 0.08),
0.43 * (1 + tap * 0.06)
);
child.person.rotation.z = Math.sin(t * 4.0) * 0.018;
// Steam rises in square puffs.
steamCubes.forEach((cube, i) => {
const phase = (t * 0.25 + i / steamCubes.length) % 1;
cube.position.set(
0.05 + Math.sin(phase * 7 + i * 1.8) * 0.11,
2.83 + phase * 1.15,
0.77 + Math.cos(phase * 6 + i) * 0.08
);
const size = 0.11 + phase * 0.18;
cube.scale.setScalar(size);
cube.material.opacity = Math.sin(phase * Math.PI) * 0.27;
});
// Highlight the selected activity.
for (const [name, highlight] of Object.entries(highlights)) {
const active = name === selectedTask;
const pulse = 0.5 + Math.sin(t * 4.2) * 0.5;
highlight.material.opacity = active ? 0.32 + pulse * 0.42 : 0;
highlight.group.position.y = 2.40 + (active ? Math.sin(t * 3.2) * 0.025 : 0);
}
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
let previousTime = performance.now();
let firstFrame = true;
function animate(now) {
requestAnimationFrame(animate);
const delta = THREE.MathUtils.clamp((now - previousTime) / 1000, 0, 0.05);
previousTime = now;
if (!paused) animationTime += delta;
updateScene(animationTime);
updateCamera(delta);
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
loader.classList.add("hide");
}
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```