Prompt specification
Build or customize the Three.js 3D scene "Winter soup kitchen service" 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: Winter soup kitchen service
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/winter-soup-kitchen-service-x0155
Scene Description Prompt:
I'd like to see this as a stylized Three.js scene: winter soup kitchen service. Compose a communal serving counter with pot, ladles, bowls, and waiting visitors; portions move into bowls and the pot's remaining level decreases consistently. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (winter-soup-kitchen-service-x0155):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Winter Soup Kitchen</title>
<style>
:root {
color-scheme: dark;
--cream: #fff1d4;
--ink: #17313a;
--orange: #ef8b3c;
--panel: rgba(20, 38, 43, 0.82);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #91aab5;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
#ui {
position: fixed;
inset: 0;
pointer-events: none;
color: var(--cream);
}
.title-card {
position: absolute;
top: 22px;
left: 24px;
max-width: min(440px, calc(100vw - 48px));
padding: 16px 20px 17px;
border: 1px solid rgba(255, 239, 208, 0.22);
border-radius: 18px;
background: linear-gradient(135deg, rgba(20, 38, 43, 0.92), rgba(32, 52, 54, 0.72));
box-shadow: 0 12px 40px rgba(10, 24, 28, 0.25);
backdrop-filter: blur(12px);
}
.kicker {
margin-bottom: 6px;
color: #ffc47a;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 43px);
font-weight: 500;
line-height: 1;
letter-spacing: -0.025em;
}
.subtitle {
margin: 8px 0 0;
color: rgba(255, 241, 212, 0.72);
font-size: 13px;
}
.status {
position: absolute;
top: 22px;
right: 24px;
width: 235px;
padding: 15px 16px;
border: 1px solid rgba(255, 239, 208, 0.22);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 12px 40px rgba(10, 24, 28, 0.25);
backdrop-filter: blur(12px);
}
.status-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
}
.status-label {
color: rgba(255, 241, 212, 0.62);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#pot-value {
color: #ffc47a;
font-size: 17px;
font-weight: 800;
}
.track {
height: 7px;
margin: 10px 0 9px;
overflow: hidden;
border-radius: 999px;
background: rgba(255, 255, 255, 0.12);
}
#pot-fill {
display: block;
width: 100%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #f5a13d, #ffd27b);
transition: width 0.08s linear;
}
#service-detail {
color: rgba(255, 241, 212, 0.72);
font-size: 11px;
line-height: 1.45;
}
.controls {
position: absolute;
right: 24px;
bottom: 22px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
pointer-events: auto;
}
button {
padding: 10px 14px;
border: 1px solid rgba(255, 239, 208, 0.24);
border-radius: 11px;
color: var(--cream);
background: rgba(20, 38, 43, 0.86);
box-shadow: 0 7px 24px rgba(10, 24, 28, 0.22);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(10px);
}
button:hover { background: rgba(42, 67, 70, 0.94); }
button:active { transform: translateY(1px); }
.camera-hint {
position: absolute;
bottom: 24px;
left: 24px;
padding: 9px 12px;
border-radius: 10px;
color: rgba(255, 241, 212, 0.75);
background: rgba(20, 38, 43, 0.62);
font-size: 11px;
letter-spacing: 0.02em;
backdrop-filter: blur(8px);
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
color: #fff1d4;
background: #243d43;
font-family: Georgia, serif;
font-size: 24px;
transition: opacity 0.5s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
@media (max-width: 700px) {
.title-card { top: 12px; left: 12px; padding: 13px 15px; }
.subtitle { display: none; }
.status { top: 12px; right: 12px; width: 170px; padding: 11px 12px; }
#service-detail { display: none; }
.controls { right: 12px; bottom: 12px; }
.camera-hint { bottom: 60px; left: 12px; }
}
</style>
</head>
<body>
<div id="loading">Lighting the stove…</div>
<div id="ui">
<section class="title-card">
<div class="kicker">Community Kitchen · 7 PM</div>
<h1>Winter Soup Service</h1>
<p class="subtitle">A warm bowl for everyone on a cold night.</p>
</section>
<section class="status" aria-live="polite">
<div class="status-row">
<span class="status-label">Pot remaining</span>
<strong id="pot-value">12 / 12</strong>
</div>
<div class="track"><i id="pot-fill"></i></div>
<div id="service-detail">Preparing the first serving…</div>
</section>
<div class="camera-hint">Drag to orbit · Scroll to zoom · Double-click to reset view</div>
<div class="controls">
<button id="pause" type="button">Pause service</button>
<button id="refill" type="button">New pot</button>
<button id="camera-reset" type="button">Reset view</button>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, and camera
// -------------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x9bb1bc);
scene.fog = new THREE.Fog(0x9bb1bc, 13, 29);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
60
);
const cameraTarget = new THREE.Vector3(0.1, 1.7, 0.05);
let cameraYaw = 0.67;
let cameraPitch = 0.34;
let cameraRadius = 12.8;
const defaultCamera = {
yaw: 0.67,
pitch: 0.34,
radius: 12.8
};
function updateCamera() {
const horizontal = Math.cos(cameraPitch) * cameraRadius;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontal,
cameraTarget.y + Math.sin(cameraPitch) * cameraRadius,
cameraTarget.z + Math.cos(cameraYaw) * horizontal
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Small custom orbit implementation; no external controls are used.
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;
cameraYaw = THREE.MathUtils.clamp(cameraYaw - dx * 0.006, -0.35, 1.25);
cameraPitch = THREE.MathUtils.clamp(cameraPitch + dy * 0.005, 0.14, 0.76);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(cameraRadius + event.deltaY * 0.009, 7.2, 18);
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
cameraYaw = defaultCamera.yaw;
cameraPitch = defaultCamera.pitch;
cameraRadius = defaultCamera.radius;
});
// -------------------------------------------------------------------------
// Lighting and materials
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xd8efff, 0x68452f, 1.9));
const ambient = new THREE.AmbientLight(0xffe9cc, 0.34);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight(0xffd1a0, 3.0);
keyLight.position.set(-4, 8, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const stoveLight = new THREE.PointLight(0xff9a43, 58, 9, 2);
stoveLight.position.set(-1.9, 3.3, 0.8);
scene.add(stoveLight);
const windowLight = new THREE.PointLight(0x9dcfff, 30, 10, 2);
windowLight.position.set(-1.4, 3.4, -2.7);
scene.add(windowLight);
const mat = {
wall: new THREE.MeshStandardMaterial({ color: 0xd8c5a4, roughness: 0.92 }),
floor: new THREE.MeshStandardMaterial({ color: 0x735342, roughness: 0.9 }),
counter: new THREE.MeshStandardMaterial({ color: 0x945937, roughness: 0.72 }),
counterTop: new THREE.MeshStandardMaterial({ color: 0xc17c45, roughness: 0.62 }),
darkWood: new THREE.MeshStandardMaterial({ color: 0x563a31, roughness: 0.86 }),
trim: new THREE.MeshStandardMaterial({ color: 0xead6b2, roughness: 0.8 }),
teal: new THREE.MeshStandardMaterial({ color: 0x285d61, roughness: 0.3, metalness: 0.42 }),
metal: new THREE.MeshStandardMaterial({ color: 0x8d9a96, roughness: 0.28, metalness: 0.75 }),
brass: new THREE.MeshStandardMaterial({ color: 0xc08a45, roughness: 0.3, metalness: 0.68 }),
soup: new THREE.MeshStandardMaterial({
color: 0xe9862f,
roughness: 0.38,
emissive: 0x5f1e05,
emissiveIntensity: 0.32
}),
ceramicA: new THREE.MeshStandardMaterial({ color: 0xf2d7ac, roughness: 0.52 }),
ceramicB: new THREE.MeshStandardMaterial({ color: 0x83aaa2, roughness: 0.56 }),
ceramicC: new THREE.MeshStandardMaterial({ color: 0xc86f51, roughness: 0.58 }),
snow: new THREE.MeshBasicMaterial({ color: 0xe8f4fa }),
pine: new THREE.MeshBasicMaterial({ color: 0x36525b }),
bulb: new THREE.MeshStandardMaterial({
color: 0xffd48b,
emissive: 0xffa23c,
emissiveIntensity: 1.5,
roughness: 0.35
})
};
function addMesh(geometry, material, x = 0, y = 0, z = 0, parent = scene) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(w, h, d, material, x = 0, y = 0, z = 0, parent = scene) {
return addMesh(new THREE.BoxGeometry(w, h, d), material, x, y, z, parent);
}
function cylinder(rt, rb, h, material, x = 0, y = 0, z = 0, parent = scene, segments = 20) {
return addMesh(new THREE.CylinderGeometry(rt, rb, h, segments), material, x, y, z, parent);
}
function sphere(r, material, x = 0, y = 0, z = 0, parent = scene, width = 18) {
return addMesh(new THREE.SphereGeometry(r, width, Math.max(10, width / 2)), material, x, y, z, parent);
}
function cylinderBetween(mesh, a, b) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.scale.set(1, length, 1);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
}
// -------------------------------------------------------------------------
// Canvas-generated signs, with no image assets
// -------------------------------------------------------------------------
function makeSign(lines, width = 3.4, height = 1.0, background = "#24464a") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 320;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = "#e8c994";
ctx.lineWidth = 8;
ctx.strokeRect(16, 16, canvas.width - 32, canvas.height - 32);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
lines.forEach((line, index) => {
ctx.fillStyle = index === 0 ? "#fff0d1" : "#edbe7d";
ctx.font = index === 0
? "700 88px Georgia"
: "700 38px system-ui";
ctx.fillText(line, canvas.width / 2, canvas.height / 2 + (index === 0 ? -40 : 68));
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
}
// -------------------------------------------------------------------------
// Kitchen set
// -------------------------------------------------------------------------
box(17, 0.18, 15, mat.floor, 0, -0.1, 0);
box(16, 5.4, 0.22, mat.wall, 0, 2.6, -4.15);
box(0.22, 5.4, 12, mat.wall, -7.9, 2.6, -0.5);
// Window with a winter view.
const windowGroup = new THREE.Group();
scene.add(windowGroup);
const sky = new THREE.Mesh(
new THREE.PlaneGeometry(5.15, 2.72),
new THREE.MeshBasicMaterial({ color: 0x789bab })
);
sky.position.set(-1.2, 3.02, -4.01);
windowGroup.add(sky);
const snowBank = box(5.12, 0.72, 0.04, mat.snow, -1.2, 1.79, -3.97, windowGroup);
snowBank.castShadow = false;
const mountainGeometry = new THREE.ConeGeometry(1.1, 2.1, 4);
const mountainMat = new THREE.MeshBasicMaterial({ color: 0xaec2c8 });
for (const [x, y, z, scale] of [
[-2.8, 2.1, -3.96, 1.0],
[-1.5, 2.25, -3.95, 1.25],
[-0.25, 2.0, -3.96, 0.9],
[0.85, 2.2, -3.95, 1.15]
]) {
const mountain = addMesh(mountainGeometry, mountainMat, x, y, z, windowGroup);
mountain.scale.set(scale, scale, 1);
mountain.castShadow = false;
}
for (const [x, y, scale] of [
[-2.65, 2.05, 0.7], [-0.5, 2.15, 0.85], [0.5, 2.0, 0.65]
]) {
const tree = addMesh(
new THREE.ConeGeometry(0.34 * scale, 1.25 * scale, 7),
mat.pine,
x, y, -3.94, windowGroup
);
tree.castShadow = false;
}
box(0.16, 2.9, 0.15, mat.trim, -3.84, 3.02, -3.88, windowGroup);
box(0.16, 2.9, 0.15, mat.trim, 1.44, 3.02, -3.88, windowGroup);
box(5.44, 0.16, 0.15, mat.trim, -1.2, 1.6, -3.88, windowGroup);
box(5.44, 0.16, 0.15, mat.trim, -1.2, 4.44, -3.88, windowGroup);
box(0.11, 2.72, 0.12, mat.trim, -1.2, 3.02, -3.87, windowGroup);
// Falling snow, restricted to the window.
const snowCount = 110;
const snowPositions = new Float32Array(snowCount * 3);
const snowSpeeds = new Float32Array(snowCount);
for (let i = 0; i < snowCount; i++) {
snowPositions[i * 3] = -3.72 + Math.random() * 5.0;
snowPositions[i * 3 + 1] = 1.7 + Math.random() * 2.65;
snowPositions[i * 3 + 2] = -3.88 + Math.random() * 0.035;
snowSpeeds[i] = 0.13 + Math.random() * 0.2;
}
const snowGeometry = new THREE.BufferGeometry();
snowGeometry.setAttribute("position", new THREE.BufferAttribute(snowPositions, 3));
const snow = new THREE.Points(
snowGeometry,
new THREE.PointsMaterial({
color: 0xffffff,
size: 0.055,
transparent: true,
opacity: 0.85,
depthWrite: false
})
);
scene.add(snow);
// Warm string lights.
const lightCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-5.4, 4.8, -2.7),
new THREE.Vector3(-3.2, 4.35, -2.55),
new THREE.Vector3(-0.7, 4.12, -2.45),
new THREE.Vector3(1.8, 4.3, -2.55),
new THREE.Vector3(4.3, 4.65, -2.7),
new THREE.Vector3(6.4, 4.9, -2.8)
]);
const wire = addMesh(
new THREE.TubeGeometry(lightCurve, 72, 0.022, 6, false),
mat.darkWood
);
wire.castShadow = false;
for (let i = 0; i < 14; i++) {
const p = lightCurve.getPoint(i / 13);
sphere(0.075, mat.bulb, p.x, p.y - 0.12, p.z, scene, 12);
if (i % 4 === 0) {
const glow = new THREE.PointLight(0xffb257, 8, 3.8, 2);
glow.position.set(p.x, p.y - 0.15, p.z);
scene.add(glow);
}
}
const wallSign = makeSign(["WINTER KITCHEN", "SOUP · BROTH · WARMTH"], 3.25, 1.02, "#31565a");
wallSign.position.set(3.15, 3.55, -3.99);
scene.add(wallSign);
// Counter and wood details.
box(8.05, 1.34, 1.85, mat.counter, -0.48, 0.78, 0);
box(8.42, 0.18, 2.08, mat.counterTop, -0.48, 1.53, 0);
box(8.0, 0.12, 0.13, mat.darkWood, -0.48, 1.43, 0.96);
for (let i = 0; i < 13; i++) {
const x = -4.15 + i * 0.61;
box(0.045, 1.13, 0.035, mat.darkWood, x, 0.77, 0.947);
}
const counterLabel = makeSign(
["COMMUNITY SOUP", "PAY WHAT YOU CAN"],
3.15,
0.74,
"#70452f"
);
counterLabel.position.set(-0.45, 0.78, 0.975);
scene.add(counterLabel);
for (let i = 0; i < 7; i++) {
box(0.025, 0.006, 1.55, mat.darkWood, -3.8 + i * 1.05, 1.626, 0);
}
// Small rug near the queue.
const rug = box(4.7, 0.018, 2.1, new THREE.MeshStandardMaterial({
color: 0x7e3f3d, roughness: 0.95
}), 4.35, 0.012, 0.3);
rug.castShadow = false;
// -------------------------------------------------------------------------
// Pot and soup
// -------------------------------------------------------------------------
const POT_X = -2.45;
const POT_Z = 0.05;
const POT_BOTTOM = 1.72;
const POT_MAX_HEIGHT = 0.76;
const POT_CAPACITY = 12;
const burner = addMesh(
new THREE.TorusGeometry(0.95, 0.075, 10, 40),
mat.metal,
POT_X, 1.67, POT_Z
);
burner.rotation.x = Math.PI / 2;
const potBody = addMesh(
new THREE.CylinderGeometry(1.03, 0.9, 0.94, 48, 1, true),
mat.teal,
POT_X, 2.12, POT_Z
);
potBody.material.side = THREE.DoubleSide;
const potBottom = addMesh(
new THREE.CylinderGeometry(0.9, 0.9, 0.08, 40),
mat.teal,
POT_X, 1.67, POT_Z
);
const potRim = addMesh(
new THREE.TorusGeometry(1.03, 0.075, 12, 48),
mat.metal,
POT_X, 2.6, POT_Z
);
potRim.rotation.x = Math.PI / 2;
for (const side of [-1, 1]) {
const handle = addMesh(
new THREE.TorusGeometry(0.29, 0.065, 8, 24, Math.PI),
mat.metal,
POT_X + side * 1.12, 2.25, POT_Z
);
handle.rotation.z = side > 0 ? -Math.PI / 2 : Math.PI / 2;
}
const soupVolume = cylinder(0.9, 0.86, 1, mat.soup, POT_X, 2.1, POT_Z, scene, 48);
const soupSurface = addMesh(
new THREE.CircleGeometry(0.9, 48),
mat.soup,
POT_X, 2.46, POT_Z
);
soupSurface.rotation.x = -Math.PI / 2;
const rippleMaterial = new THREE.MeshBasicMaterial({
color: 0xffbc69,
transparent: true,
opacity: 0.25,
depthWrite: false
});
const ripple = addMesh(
new THREE.TorusGeometry(0.46, 0.012, 6, 48),
rippleMaterial,
POT_X, 2.47, POT_Z
);
ripple.rotation.x = Math.PI / 2;
ripple.castShadow = false;
// -------------------------------------------------------------------------
// Bowls
// -------------------------------------------------------------------------
const bowlProfile = [
new THREE.Vector2(0.0, 0.015),
new THREE.Vector2(0.18, 0.0),
new THREE.Vector2(0.35, 0.05),
new THREE.Vector2(0.48, 0.16),
new THREE.Vector2(0.53, 0.25),
new THREE.Vector2(0.48, 0.27),
new THREE.Vector2(0.43, 0.22),
new THREE.Vector2(0.34, 0.11),
new THREE.Vector2(0.22, 0.075),
new THREE.Vector2(0.0, 0.075)
];
function createBowl(home, ceramic, stripeMaterial) {
const group = new THREE.Group();
group.position.copy(home);
scene.add(group);
const body = addMesh(
new THREE.LatheGeometry(bowlProfile, 48),
ceramic,
0, 0, 0, group
);
const rim = addMesh(
new THREE.TorusGeometry(0.49, 0.022, 8, 48),
stripeMaterial,
0, 0.245, 0, group
);
rim.rotation.x = Math.PI / 2;
const liquid = cylinder(
0.395, 0.31, 1,
mat.soup.clone(),
0, 0.12, 0, group, 40
);
return {
group,
liquid,
home: home.clone(),
fill: 0,
baseY: home.y
};
}
const bowlMaterials = [mat.ceramicA, mat.ceramicB, mat.ceramicC];
const bowlStripeMaterials = [mat.teal, mat.counterTop, mat.teal];
const bowls = [
createBowl(new THREE.Vector3(0.05, 1.63, 0.14), bowlMaterials[0], bowlStripeMaterials[0]),
createBowl(new THREE.Vector3(1.17, 1.63, 0.14), bowlMaterials[1], bowlStripeMaterials[1]),
createBowl(new THREE.Vector3(2.29, 1.63, 0.14), bowlMaterials[2], bowlStripeMaterials[2])
];
// A small stack of spare bowls.
for (let i = 0; i < 3; i++) {
const spare = createBowl(
new THREE.Vector3(-3.63 + i * 0.035, 1.64 + i * 0.105, 0.42 + i * 0.035),
mat.ceramicA,
mat.teal
);
spare.group.scale.setScalar(0.78 - i * 0.025);
spare.liquid.visible = false;
}
// Wooden utensils in a crock.
const crock = cylinder(0.23, 0.18, 0.44, mat.trim, 3.02, 1.84, 0.45);
for (let i = 0; i < 3; i++) {
const spoon = new THREE.Group();
spoon.position.set(3.02 + (i - 1) * 0.09, 2.14, 0.45);
spoon.rotation.z = (i - 1) * 0.18;
scene.add(spoon);
cylinder(0.025, 0.025, 0.7, mat.counterTop, 0, 0, 0, spoon, 10);
const spoonHead = addMesh(
new THREE.SphereGeometry(0.105, 14, 10),
mat.counterTop,
0, 0.36, 0, spoon
);
spoonHead.scale.set(0.7, 1.15, 0.35);
}
// -------------------------------------------------------------------------
// Waiting visitors
// -------------------------------------------------------------------------
const visitors = [];
function createVisitor(coatColor, scarfColor, hatColor, skinColor) {
const group = new THREE.Group();
scene.add(group);
const coat = new THREE.MeshStandardMaterial({
color: coatColor,
roughness: 0.88,
flatShading: true
});
const scarf = new THREE.MeshStandardMaterial({
color: scarfColor,
roughness: 0.86
});
const hat = new THREE.MeshStandardMaterial({
color: hatColor,
roughness: 0.92
});
const skin = new THREE.MeshStandardMaterial({
color: skinColor,
roughness: 0.9
});
const dark = new THREE.MeshStandardMaterial({ color: 0x243039, roughness: 0.85 });
cylinder(0.25, 0.35, 0.86, coat, 0, 1.07, 0, group, 8);
sphere(0.22, skin, 0, 1.72, 0.01, group, 16);
cylinder(0.3, 0.3, 0.055, hat, 0, 1.92, 0, group, 16);
sphere(0.22, hat, 0, 2.0, 0, group, 16).scale.y = 0.58;
sphere(0.07, hat, 0, 2.15, 0, group, 12);
const scarfRing = addMesh(
new THREE.TorusGeometry(0.19, 0.055, 7, 20),
scarf,
0, 1.5, 0, group
);
scarfRing.rotation.x = Math.PI / 2;
box(0.11, 0.37, 0.055, scarf, 0.12, 1.31, 0.205, group);
for (const side of [-1, 1]) {
cylinder(0.075, 0.085, 0.58, coat, side * 0.13, 0.42, 0, group, 10);
box(0.18, 0.12, 0.3, dark, side * 0.13, 0.1, 0.055, group);
}
const armLeft = new THREE.Group();
const armRight = new THREE.Group();
armLeft.position.set(-0.31, 1.42, 0);
armRight.position.set(0.31, 1.42, 0);
group.add(armLeft, armRight);
cylinder(0.085, 0.095, 0.48, coat, 0, -0.23, 0, armLeft, 10);
cylinder(0.085, 0.095, 0.48, coat, 0, -0.23, 0, armRight, 10);
sphere(0.085, skin, 0, -0.51, 0, armLeft, 12);
sphere(0.085, skin, 0, -0.51, 0, armRight, 12);
for (const side of [-1, 1]) {
sphere(0.021, dark, side * 0.075, 1.75, 0.205, group, 8);
}
const visitor = {
group,
armLeft,
armRight,
phase: Math.random() * Math.PI * 2,
receive: 0,
baseY: 0,
baseRotation: -Math.PI / 2
};
visitors.push(visitor);
return visitor;
}
createVisitor(0x3b6f78, 0xe4a247, 0x713f46, 0xc98768);
createVisitor(0xa34f42, 0x8eb6a5, 0x345461, 0x8f5f49);
createVisitor(0x4e637e, 0xd07a4f, 0x746957, 0xe0aa83);
createVisitor(0x9b7042, 0x587f7a, 0x603c4b, 0xb9785e);
const visitorPositions = [
new THREE.Vector3(3.85, 0, -1.85),
new THREE.Vector3(4.2, 0, -0.55),
new THREE.Vector3(4.55, 0, 0.8),
new THREE.Vector3(4.9, 0, 2.18)
];
visitors.forEach((visitor, index) => {
visitor.group.position.copy(visitorPositions[index]);
visitor.group.rotation.y = visitor.baseRotation;
const scale = 0.92 + (index % 3) * 0.055;
visitor.group.scale.setScalar(scale);
});
// -------------------------------------------------------------------------
// Ladle, scoop, and pouring stream
// -------------------------------------------------------------------------
const ladle = new THREE.Group();
scene.add(ladle);
const cupProfile = [
new THREE.Vector2(0.0, 0.0),
new THREE.Vector2(0.10, -0.01),
new THREE.Vector2(0.18, -0.07),
new THREE.Vector2(0.205, -0.15),
new THREE.Vector2(0.17, -0.16),
new THREE.Vector2(0.12, -0.10),
new THREE.Vector2(0.0, -0.085)
];
addMesh(new THREE.LatheGeometry(cupProfile, 32), mat.brass, 0, 0, 0, ladle);
const ladleHandle = cylinder(0.035, 0.045, 1.45, mat.metal, 0.7, 0.05, 0, ladle, 12);
ladleHandle.rotation.z = Math.PI / 2;
const handleTip = sphere(0.065, mat.metal, 1.42, 0.05, 0, ladle, 12);
const scoop = sphere(0.16, mat.soup.clone(), POT_X, 2.8, POT_Z, scene, 18);
scoop.scale.set(1, 0.65, 1);
scoop.visible = false;
const stream = cylinder(0.045, 0.06, 1, mat.soup.clone(), 0, 0, 0, scene, 12);
stream.visible = false;
stream.castShadow = false;
// -------------------------------------------------------------------------
// Steam sprites
// -------------------------------------------------------------------------
const steamCanvas = document.createElement("canvas");
steamCanvas.width = steamCanvas.height = 64;
const steamContext = steamCanvas.getContext("2d");
const steamGradient = steamContext.createRadialGradient(32, 32, 0, 32, 32, 32);
steamGradient.addColorStop(0, "rgba(255,255,255,0.8)");
steamGradient.addColorStop(0.45, "rgba(255,255,255,0.3)");
steamGradient.addColorStop(1, "rgba(255,255,255,0)");
steamContext.fillStyle = steamGradient;
steamContext.fillRect(0, 0, 64, 64);
const steamTexture = new THREE.CanvasTexture(steamCanvas);
const steamPuffs = [];
for (let i = 0; i < 13; i++) {
const material = new THREE.SpriteMaterial({
map: steamTexture,
transparent: true,
opacity: 0,
depthWrite: false,
color: 0xffe8c8
});
const sprite = new THREE.Sprite(material);
scene.add(sprite);
steamPuffs.push({
sprite,
offset: Math.random(),
drift: (Math.random() - 0.5) * 0.45,
speed: 0.11 + Math.random() * 0.08,
size: 0.32 + Math.random() * 0.24
});
}
// -------------------------------------------------------------------------
// Serving state machine
//
// Each serving removes exactly one unit from the pot while it is scooped.
// The in-flight scoop then transfers that same unit into a bowl. This keeps
// pot + ladle + bowl quantities consistent throughout the animation.
// -------------------------------------------------------------------------
const BOWL_CAPACITY = 2;
let remainingServings = POT_CAPACITY;
let servicePaused = false;
let phase = "idle";
let phaseTime = 0;
let bowlIndex = 0;
let targetBowl = bowls[0];
let dipStartRemaining = remainingServings;
let dipEndPosition = new THREE.Vector3();
let bowlPourStart = 0;
let recipientIndex = 0;
let handoffStart = new THREE.Vector3();
let handoffEnd = new THREE.Vector3();
const phaseDurations = {
idle: 0.55,
dip: 1.15,
carry: 1.25,
pour: 1.35,
settle: 0.65,
handoff: 1.45,
replace: 0.45,
empty: Infinity
};
const ladleRest = new THREE.Vector3(POT_X, 2.85, POT_Z);
const bowlAbove = new THREE.Vector3();
function smooth01(value) {
const t = THREE.MathUtils.clamp(value, 0, 1);
return t * t * (3 - 2 * t);
}
function quadraticBezier(a, b, c, t, output) {
const inv = 1 - t;
output.set(
inv * inv * a.x + 2 * inv * t * b.x + t * t * c.x,
inv * inv * a.y + 2 * inv * t * b.y + t * t * c.y,
inv * inv * a.z + 2 * inv * t * b.z + t * t * c.z
);
return output;
}
function beginPhase(name) {
phase = name;
phaseTime = 0;
if (name === "dip") {
dipStartRemaining = remainingServings;
const top = POT_BOTTOM + POT_MAX_HEIGHT * (remainingServings / POT_CAPACITY);
dipEndPosition.set(POT_X, top + 0.08, POT_Z);
}
if (name === "pour") {
bowlPourStart = targetBowl.fill;
}
if (name === "handoff") {
handoffStart.copy(targetBowl.group.position);
const visitor = visitors[recipientIndex % visitors.length];
handoffEnd.set(
visitor.group.position.x - 0.34,
1.43,
visitor.group.position.z + 0.2
);
}
if (name === "replace") {
targetBowl.group.visible = true;
targetBowl.group.position.copy(targetBowl.home);
targetBowl.group.scale.setScalar(0.72);
targetBowl.fill = 0;
updateBowlVisual(targetBowl);
}
}
function resetService() {
remainingServings = POT_CAPACITY;
phase = "idle";
phaseTime = 0;
bowlIndex = 0;
recipientIndex = 0;
targetBowl = bowls[0];
bowls.forEach(bowl => {
bowl.fill = 0;
bowl.group.visible = true;
bowl.group.position.copy(bowl.home);
bowl.group.scale.setScalar(1);
updateBowlVisual(bowl);
});
ladle.position.copy(ladleRest);
ladle.rotation.set(0, 0, 0);
scoop.visible = false;
stream.visible = false;
}
function updateBowlVisual(bowl) {
const ratio = THREE.MathUtils.clamp(bowl.fill / BOWL_CAPACITY, 0, 1);
const height = 0.035 + 0.14 * ratio;
bowl.liquid.visible = bowl.fill > 0.001;
bowl.liquid.scale.y = height;
bowl.liquid.position.y = 0.085 + height * 0.5;
}
function updateService(dt) {
if (servicePaused) return;
phaseTime += dt;
const duration = phaseDurations[phase];
if (phase === "idle") {
ladle.position.copy(ladleRest);
ladle.rotation.z = THREE.MathUtils.lerp(ladle.rotation.z, 0, 0.15);
scoop.visible = false;
stream.visible = false;
if (phaseTime >= duration) {
if (remainingServings < 1) {
phase = "empty";
phaseTime = 0;
} else {
beginPhase("dip");
}
}
} else if (phase === "dip") {
const u = smooth01(phaseTime / duration);
ladle.position.lerpVectors(ladleRest, dipEndPosition, u);
ladle.rotation.z = 0;
// The exact serving amount is removed from the pot as the scoop fills.
remainingServings = Math.max(0, dipStartRemaining - u);
scoop.visible = true;
scoop.position.copy(ladle.position).add(new THREE.Vector3(0, -0.12, 0));
const scoopScale = 0.3 + u * 0.7;
scoop.scale.set(scoopScale, scoopScale * 0.65, scoopScale);
if (phaseTime >= duration) beginPhase("carry");
} else if (phase === "carry") {
const u = smooth01(phaseTime / duration);
const end = bowlAbove.set(targetBowl.home.x, 2.19, targetBowl.home.z);
const control = dipEndPosition.clone().lerp(end, 0.5);
control.y += 1.05;
quadraticBezier(dipEndPosition, control, end, u, ladle.position);
ladle.rotation.z = THREE.MathUtils.lerp(ladle.rotation.z, -0.12, 0.08);
scoop.visible = true;
scoop.position.copy(ladle.position).add(new THREE.Vector3(0, -0.12, 0));
if (phaseTime >= duration) beginPhase("pour");
} else if (phase === "pour") {
const u = smooth01(phaseTime / duration);
ladle.position.set(targetBowl.home.x, 2.18 - u * 0.07, targetBowl.home.z);
ladle.rotation.z = 0.82 * u;
targetBowl.fill = bowlPourStart + u;
updateBowlVisual(targetBowl);
const remainingScoop = Math.max(0.001, 1 - u);
scoop.visible = u < 0.995;
scoop.scale.set(remainingScoop, remainingScoop * 0.65, remainingScoop);
scoop.position.copy(ladle.position).lerp(
new THREE.Vector3(targetBowl.home.x, targetBowl.baseY + 0.2, targetBowl.home.z),
u * 0.65
);
stream.visible = u > 0.025 && u < 0.985;
if (stream.visible) {
const start = ladle.position.clone().add(new THREE.Vector3(0.09, -0.12, 0));
const end = new THREE.Vector3(
targetBowl.home.x,
targetBowl.baseY + 0.1 + 0.14 * (targetBowl.fill / BOWL_CAPACITY),
targetBowl.home.z
);
cylinderBetween(stream, start, end);
}
if (phaseTime >= duration) {
targetBowl.fill = Math.min(BOWL_CAPACITY, bowlPourStart + 1);
updateBowlVisual(targetBowl);
scoop.visible = false;
stream.visible = false;
beginPhase("settle");
}
} else if (phase === "settle") {
const u = smooth01(phaseTime / duration);
const start = new THREE.Vector3(targetBowl.home.x, 2.11, targetBowl.home.z);
ladle.position.lerpVectors(start, ladleRest, u);
ladle.rotation.z = THREE.MathUtils.lerp(0.82, 0, u);
if (phaseTime >= duration) {
if (targetBowl.fill >= BOWL_CAPACITY - 0.001) {
beginPhase("handoff");
} else {
bowlIndex = (bowlIndex + 1) % bowls.length;
targetBowl = bowls[bowlIndex];
beginPhase("idle");
}
}
} else if (phase === "handoff") {
const u = smooth01(phaseTime / duration);
const control = handoffStart.clone().lerp(handoffEnd, 0.5);
control.y += 1.0;
quadraticBezier(handoffStart, control, handoffEnd, u, targetBowl.group.position);
targetBowl.group.scale.setScalar(1 - u * 0.22);
const visitor = visitors[recipientIndex % visitors.length];
visitor.receive = Math.sin(u * Math.PI);
if (phaseTime >= duration) {
targetBowl.group.visible = false;
recipientIndex++;
beginPhase("replace");
}
} else if (phase === "replace") {
const u = smooth01(phaseTime / duration);
targetBowl.group.scale.setScalar(0.72 + u * 0.28);
if (phaseTime >= duration) {
targetBowl.group.scale.setScalar(1);
targetBowl.group.position.copy(targetBowl.home);
targetBowl.fill = 0;
updateBowlVisual(targetBowl);
bowlIndex = (bowlIndex + 1) % bowls.length;
targetBowl = bowls[bowlIndex];
beginPhase("idle");
}
}
}
// -------------------------------------------------------------------------
// Animation updates
// -------------------------------------------------------------------------
function updatePot(time) {
const ratio = THREE.MathUtils.clamp(remainingServings / POT_CAPACITY, 0, 1);
const height = POT_MAX_HEIGHT * ratio;
const top = POT_BOTTOM + height;
soupVolume.visible = height > 0.008;
soupVolume.scale.y = Math.max(height, 0.001);
soupVolume.position.y = POT_BOTTOM + height * 0.5;
soupSurface.visible = height > 0.008;
soupSurface.position.y = top + 0.008;
soupSurface.scale.setScalar(1 + Math.sin(time * 2.2) * 0.006);
ripple.visible = height > 0.008;
ripple.position.y = top + 0.015;
const rippleScale = 1 + ((time * 0.28) % 1) * 0.8;
ripple.scale.setScalar(rippleScale);
rippleMaterial.opacity = 0.23 * (1 - ((time * 0.28) % 1));
}
function updateSteam(time) {
const top = POT_BOTTOM + POT_MAX_HEIGHT * (remainingServings / POT_CAPACITY);
steamPuffs.forEach((puff, index) => {
const life = (time * puff.speed + puff.offset) % 1;
puff.sprite.position.set(
POT_X + Math.sin(time * 0.75 + index) * 0.18 + puff.drift * life,
top + 0.08 + life * 1.55,
POT_Z + Math.cos(time * 0.55 + index * 1.7) * 0.13
);
const size = puff.size * (0.55 + life * 1.65);
puff.sprite.scale.set(size, size * 1.25, 1);
puff.sprite.material.opacity =
Math.sin(life * Math.PI) * 0.24 * (remainingServings > 0 ? 1 : 0);
});
}
function updateSnow(dt, time) {
const positions = snowGeometry.attributes.position.array;
for (let i = 0; i < snowCount; i++) {
positions[i * 3 + 1] -= snowSpeeds[i] * dt;
positions[i * 3] += Math.sin(time * 0.45 + i) * dt * 0.018;
if (positions[i * 3 + 1] < 1.72) {
positions[i * 3 + 1] = 4.32;
positions[i * 3] = -3.72 + Math.random() * 5.0;
}
}
snowGeometry.attributes.position.needsUpdate = true;
}
function updateVisitors(time, dt) {
visitors.forEach((visitor, index) => {
visitor.receive = Math.max(0, visitor.receive - dt * 1.6);
const bob = Math.sin(time * 1.45 + visitor.phase) * 0.012;
visitor.group.position.y = visitor.baseY + bob;
visitor.group.rotation.y =
visitor.baseRotation + Math.sin(time * 0.42 + visitor.phase) * 0.025;
const raise = visitor.receive * 1.12;
visitor.armLeft.rotation.x = -raise;
visitor.armRight.rotation.x = -raise;
visitor.armLeft.rotation.z = 0.06;
visitor.armRight.rotation.z = -0.06;
if (index === 0) {
visitor.group.rotation.y += Math.sin(time * 0.7) * 0.025;
}
});
}
const phaseNames = {
idle: "Preparing the next serving",
dip: "Scooping warm broth",
carry: "Carrying a fresh portion",
pour: "Pouring into the bowl",
settle: "Finishing the serving",
handoff: "Handing over a warm bowl",
replace: "Setting out a fresh bowl",
empty: "The pot is empty — refill it below"
};
const potValue = document.getElementById("pot-value");
const potFill = document.getElementById("pot-fill");
const serviceDetail = document.getElementById("service-detail");
const pauseButton = document.getElementById("pause");
function updateUI() {
potValue.textContent = `${Math.round(remainingServings * 10) / 10} / ${POT_CAPACITY}`;
potFill.style.width = `${(remainingServings / POT_CAPACITY) * 100}%`;
const served = POT_CAPACITY - remainingServings;
const bowlProgress = targetBowl ? `${targetBowl.fill.toFixed(1)} / ${BOWL_CAPACITY}` : "0";
serviceDetail.textContent = `${phaseNames[phase]} · ${Math.round(served * 10) / 10} served · bowl ${bowlProgress}`;
}
pauseButton.addEventListener("click", () => {
servicePaused = !servicePaused;
pauseButton.textContent = servicePaused ? "Resume service" : "Pause service";
});
document.getElementById("refill").addEventListener("click", resetService);
document.getElementById("camera-reset").addEventListener("click", () => {
cameraYaw = defaultCamera.yaw;
cameraPitch = defaultCamera.pitch;
cameraRadius = defaultCamera.radius;
});
// -------------------------------------------------------------------------
// Main loop and resize handling
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
updateService(dt);
updatePot(time);
updateSteam(time);
updateSnow(dt, time);
updateVisitors(time, dt);
updateCamera();
updateUI();
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
const loading = document.getElementById("loading");
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 600);
}
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
resetService();
animate();
</script>
</body>
</html>
```