Prompt specification
Build or customize the Three.js 3D scene "Morning neighborhood bakery" 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: Morning neighborhood bakery
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/morning-neighborhood-bakery-x0487
Scene Description Prompt:
Make a stylized Three.js scene in a self-contained HTML file using cdnjs: morning neighborhood bakery. Compose oven room, counter, bread shelves, and waiting customers; a continuous route connects baking, cooling, display, and sale without intersecting visitor circulation.
Working Three.js Starter (morning-neighborhood-bakery-x0487):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Morning Crumb — Neighborhood Bakery</title>
<style>
:root {
--ink: #49352d;
--muted: #806d62;
--cream: #fffaf0;
--paper: rgba(255, 250, 240, 0.92);
--orange: #dc6b3e;
--orange-light: #f3b071;
--teal: #287e79;
--teal-light: #8fc7bc;
--line: rgba(73, 53, 45, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eee4d4;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 10;
}
.brand {
position: absolute;
top: 26px;
left: 28px;
width: min(370px, calc(100vw - 56px));
padding: 20px 22px 18px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 22px;
background: var(--paper);
box-shadow:
0 18px 50px rgba(82, 57, 39, 0.12),
inset 0 1px 0 rgba(255, 255, 255, 0.72);
backdrop-filter: blur(12px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 7px;
color: var(--orange);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 21px;
height: 2px;
border-radius: 2px;
background: var(--orange);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(35px, 4vw, 54px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.open-pill {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 14px;
padding: 7px 10px;
border-radius: 999px;
background: #e8f1e8;
color: #41694e;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.open-pill i {
width: 7px;
height: 7px;
border-radius: 50%;
background: #5a936d;
box-shadow: 0 0 0 4px rgba(90, 147, 109, 0.12);
}
.process-card {
position: absolute;
left: 28px;
bottom: 26px;
width: min(580px, calc(100vw - 56px));
padding: 17px 20px 16px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 20px;
background: var(--paper);
box-shadow:
0 18px 50px rgba(82, 57, 39, 0.12),
inset 0 1px 0 rgba(255, 255, 255, 0.72);
backdrop-filter: blur(12px);
}
.card-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
margin-bottom: 13px;
}
.card-heading strong {
font-family: Georgia, "Times New Roman", serif;
font-size: 19px;
font-weight: 500;
}
.card-heading span {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.steps {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 7px;
}
.step {
position: relative;
display: grid;
grid-template-columns: 26px 1fr;
column-gap: 7px;
align-items: center;
min-width: 0;
}
.step:not(:last-child)::after {
content: "";
position: absolute;
top: 13px;
left: 28px;
right: -3px;
height: 2px;
background: linear-gradient(90deg, var(--orange-light), #e7a071);
}
.step-number {
position: relative;
z-index: 1;
display: grid;
width: 26px;
height: 26px;
place-items: center;
border: 2px solid #f2c09c;
border-radius: 50%;
background: #fff8ed;
color: var(--orange);
font-size: 10px;
font-weight: 900;
}
.step b,
.step small {
display: block;
position: relative;
z-index: 1;
width: fit-content;
background: var(--paper);
}
.step b {
font-size: 11px;
line-height: 1.1;
}
.step small {
margin-top: 2px;
color: var(--muted);
font-size: 9px;
white-space: nowrap;
}
.visitor-note {
position: absolute;
right: 28px;
bottom: 28px;
width: 270px;
padding: 16px 18px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 16px 44px rgba(82, 57, 39, 0.11);
backdrop-filter: blur(12px);
}
.visitor-note .label {
display: flex;
align-items: center;
gap: 8px;
color: var(--teal);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.visitor-note .swatch {
width: 25px;
height: 4px;
border-radius: 4px;
background: repeating-linear-gradient(
90deg,
var(--teal) 0 7px,
transparent 7px 11px
);
}
.visitor-note p {
margin: 9px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.controls {
position: absolute;
top: 28px;
right: 28px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(73, 53, 45, 0.13);
border-radius: 999px;
padding: 10px 14px;
background: rgba(255, 250, 240, 0.9);
color: var(--ink);
font: 700 10px/1 Inter, ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.05em;
text-transform: uppercase;
box-shadow: 0 8px 22px rgba(82, 57, 39, 0.08);
cursor: pointer;
transition: transform 160ms ease, background 160ms ease;
}
button:hover {
transform: translateY(-1px);
background: #fffdf7;
}
button:active {
transform: translateY(0);
}
.hint {
position: absolute;
top: 76px;
right: 30px;
color: rgba(73, 53, 45, 0.62);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #eee4d4;
color: var(--ink);
font-family: Georgia, serif;
font-size: 24px;
transition: opacity 500ms ease, visibility 500ms ease;
}
.loading.hidden {
opacity: 0;
visibility: hidden;
}
@media (max-width: 800px) {
.brand {
top: 14px;
left: 14px;
width: 270px;
padding: 15px 17px;
border-radius: 17px;
}
h1 {
font-size: 35px;
}
.subtitle {
display: none;
}
.open-pill {
margin-top: 10px;
}
.process-card {
left: 14px;
bottom: 14px;
width: calc(100vw - 28px);
padding: 13px 14px;
}
.steps {
gap: 4px;
}
.step {
display: block;
}
.step-number {
margin-bottom: 5px;
}
.step:not(:last-child)::after {
top: 13px;
left: 29px;
}
.step b,
.step small {
padding-right: 3px;
}
.visitor-note {
display: none;
}
.controls {
top: 16px;
right: 14px;
}
.hint {
display: none;
}
button {
padding: 9px 11px;
font-size: 9px;
}
}
@media (max-width: 520px) {
.brand {
width: 220px;
}
.brand h1 {
font-size: 30px;
}
.eyebrow {
font-size: 8px;
}
.card-heading span {
display: none;
}
.step small {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D neighborhood bakery scene"></canvas>
<div class="ui">
<header class="brand">
<div class="eyebrow">Neighborhood bakery · 07:10</div>
<h1>Morning<br />Crumb</h1>
<p class="subtitle">
A warm, working bakery where every loaf follows one clear path—from
oven to counter—while guests move comfortably on their own side.
</p>
<div class="open-pill"><i></i> Bakers at work</div>
</header>
<section class="process-card">
<div class="card-heading">
<strong>One continuous bake-day route</strong>
<span>Staff circulation</span>
</div>
<div class="steps">
<div class="step">
<span class="step-number">1</span>
<div><b>Bake</b><small>Oven room</small></div>
</div>
<div class="step">
<span class="step-number">2</span>
<div><b>Cool</b><small>Rack</small></div>
</div>
<div class="step">
<span class="step-number">3</span>
<div><b>Display</b><small>Shelves</small></div>
</div>
<div class="step">
<span class="step-number">4</span>
<div><b>Sell</b><small>Counter</small></div>
</div>
</div>
</section>
<aside class="visitor-note">
<div class="label"><span class="swatch"></span> Guest circulation</div>
<p>
The teal dashed path stays on the public side of the counter and rail.
It never crosses the orange production route.
</p>
</aside>
<div class="controls">
<button id="toggle-route" type="button">Guest path</button>
<button id="reset-view" type="button">Reset view</button>
</div>
<div class="hint">Drag to orbit · Scroll to zoom</div>
</div>
<div class="loading" id="loading">Warming the ovens…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#eee4d4");
scene.fog = new THREE.Fog("#eee4d4", 26, 48);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
100
);
const initialView = {
theta: 0.56,
phi: 1.02,
radius: window.innerWidth < 700 ? 25 : 21.5,
target: new THREE.Vector3(0, 1.05, -0.45)
};
const view = {
theta: initialView.theta,
phi: initialView.phi,
radius: initialView.radius,
target: initialView.target.clone()
};
const desired = {
theta: initialView.theta,
phi: initialView.phi,
radius: initialView.radius,
target: initialView.target.clone()
};
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
view.target.x + view.radius * sinPhi * Math.sin(view.theta),
view.target.y + view.radius * Math.cos(view.phi),
view.target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(view.target);
}
updateCamera();
// Lighting
scene.add(new THREE.HemisphereLight("#fff5df", "#8e7762", 2.1));
const sun = new THREE.DirectionalLight("#fff2d2", 4.3);
sun.position.set(-8, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b7d8d3", 1.1);
fill.position.set(12, 8, -6);
scene.add(fill);
// Material helpers
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
...options
});
}
const M = {
wall: material("#e9ddc9"),
wallTrim: material("#d1bca5"),
floor: material("#ffffff"),
clay: material("#b75f3f"),
clayDark: material("#8e4635"),
cream: material("#f1dfbd"),
wood: material("#ae7651"),
woodDark: material("#744d3c"),
woodLight: material("#d2a16d"),
dark: material("#3d3935"),
metal: material("#41544f", { metalness: 0.28, roughness: 0.48 }),
orange: material("#df6a3b", { emissive: "#5f1f0d", emissiveIntensity: 0.16 }),
teal: material("#287e79", { emissive: "#123d3a", emissiveIntensity: 0.1 }),
green: material("#789273"),
bread: material("#ce8244"),
breadLight: material("#e3a965"),
breadDark: material("#a95d32"),
flour: material("#f4e6ca"),
glass: material("#b9d9d5", {
transparent: true,
opacity: 0.18,
roughness: 0.15,
metalness: 0,
depthWrite: false
}),
glow: new THREE.MeshBasicMaterial({
color: "#f5a13a",
transparent: true,
opacity: 0.86
}),
ovenMouth: material("#402b25")
};
function addMesh(parent, geometry, mat, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = !mat.transparent;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(parent, w, h, d, mat, x = 0, y = 0, z = 0) {
return addMesh(parent, new THREE.BoxGeometry(w, h, d), mat, x, y, z);
}
function cylinder(
parent,
rt,
rb,
h,
mat,
x = 0,
y = 0,
z = 0,
segments = 16
) {
return addMesh(
parent,
new THREE.CylinderGeometry(rt, rb, h, segments),
mat,
x,
y,
z
);
}
function sphere(parent, radius, mat, x = 0, y = 0, z = 0, width = 16) {
return addMesh(
parent,
new THREE.SphereGeometry(radius, width, Math.max(8, width / 2)),
mat,
x,
y,
z
);
}
function cylinderBetween(parent, a, b, radius, mat, segments = 12) {
const av = new THREE.Vector3(...a);
const bv = new THREE.Vector3(...b);
const direction = bv.clone().sub(av);
const mesh = cylinder(
parent,
radius,
radius,
direction.length(),
mat,
0,
0,
0,
segments
);
mesh.position.copy(av.add(bv).multiplyScalar(0.5));
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeFloorTexture() {
const c = document.createElement("canvas");
c.width = c.height = 256;
const ctx = c.getContext("2d");
ctx.fillStyle = "#e8d9c1";
ctx.fillRect(0, 0, 256, 256);
for (let i = 0; i < 240; i++) {
const x = (i * 83) % 256;
const y = (i * 47) % 256;
ctx.fillStyle = i % 3 === 0 ? "rgba(132,105,78,.08)" : "rgba(255,255,255,.13)";
ctx.fillRect(x, y, 2, 2);
}
ctx.strokeStyle = "rgba(133,105,78,.18)";
ctx.lineWidth = 2;
ctx.strokeRect(0, 0, 256, 256);
const tex = new THREE.CanvasTexture(c);
tex.colorSpace = THREE.SRGBColorSpace;
tex.wrapS = tex.wrapT = THREE.RepeatWrapping;
tex.repeat.set(8, 5.5);
tex.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return tex;
}
function makeTileTexture() {
const c = document.createElement("canvas");
c.width = c.height = 256;
const ctx = c.getContext("2d");
ctx.fillStyle = "#c97855";
ctx.fillRect(0, 0, 256, 256);
for (let row = 0; row < 4; row++) {
for (let col = -1; col < 5; col++) {
const x = col * 64 + (row % 2 ? 32 : 0);
const y = row * 64;
ctx.fillStyle = row % 2 ? "#d88963" : "#d27e59";
ctx.fillRect(x + 3, y + 3, 58, 58);
ctx.fillStyle = "rgba(255,255,255,.08)";
ctx.fillRect(x + 6, y + 6, 52, 3);
}
}
const tex = new THREE.CanvasTexture(c);
tex.colorSpace = THREE.SRGBColorSpace;
tex.wrapS = tex.wrapT = THREE.RepeatWrapping;
tex.repeat.set(2.6, 2);
return tex;
}
function makeWindowTexture() {
const c = document.createElement("canvas");
c.width = 512;
c.height = 320;
const ctx = c.getContext("2d");
const gradient = ctx.createLinearGradient(0, 0, 0, 320);
gradient.addColorStop(0, "#c9e3e1");
gradient.addColorStop(1, "#edf0d8");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 512, 320);
ctx.fillStyle = "#f5d989";
ctx.beginPath();
ctx.arc(402, 67, 35, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#a8c19a";
ctx.beginPath();
ctx.moveTo(0, 252);
ctx.quadraticCurveTo(95, 171, 190, 252);
ctx.quadraticCurveTo(310, 158, 512, 244);
ctx.lineTo(512, 320);
ctx.lineTo(0, 320);
ctx.fill();
ctx.fillStyle = "#789a7b";
ctx.fillRect(30, 244, 70, 76);
ctx.fillRect(360, 237, 82, 83);
ctx.fillStyle = "#eed9ba";
ctx.fillRect(42, 253, 46, 67);
ctx.fillRect(372, 247, 58, 73);
ctx.fillStyle = "#6c7f73";
for (let i = 0; i < 7; i++) {
ctx.fillRect(68 + i * 7, 196, 5, 59);
}
const tex = new THREE.CanvasTexture(c);
tex.colorSpace = THREE.SRGBColorSpace;
return tex;
}
function textTexture(text, bg = "#fff7e9", fg = "#5b3b2e") {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 256;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
roundedRect(ctx, 8, 8, 1008, 240, 42);
ctx.fillStyle = bg;
ctx.fill();
ctx.strokeStyle = "rgba(90,57,42,.16)";
ctx.lineWidth = 5;
ctx.stroke();
ctx.fillStyle = fg;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "700 92px Georgia, serif";
ctx.fillText(text, 512, 136, 920);
const tex = new THREE.CanvasTexture(c);
tex.colorSpace = THREE.SRGBColorSpace;
tex.anisotropy = 4;
return tex;
}
function panel(parent, text, w, h, x, y, z, bg, fg) {
const mesh = addMesh(
parent,
new THREE.PlaneGeometry(w, h),
new THREE.MeshBasicMaterial({
map: textTexture(text, bg, fg),
transparent: true
}),
x,
y,
z
);
mesh.castShadow = false;
return mesh;
}
function label(parent, text, x, y, z, width = 2.0, bg = "#fff7e9", fg = "#5b3b2e") {
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: textTexture(text, bg, fg),
transparent: true,
depthWrite: false
})
);
sprite.position.set(x, y, z);
sprite.scale.set(width, width / 4, 1);
parent.add(sprite);
return sprite;
}
// Diorama shell
const diorama = new THREE.Group();
scene.add(diorama);
const ground = addMesh(
scene,
new THREE.PlaneGeometry(80, 80),
material("#eee4d4"),
0,
-0.36,
0
);
ground.rotation.x = -Math.PI / 2;
ground.castShadow = false;
M.floor.map = makeFloorTexture();
box(diorama, 16.2, 0.28, 11.1, M.floor, 0, -0.14, 0);
box(diorama, 16.4, 0.12, 11.3, M.woodLight, 0, -0.32, 0);
box(diorama, 16.2, 5.9, 0.24, M.wall, 0, 2.8, -5.55);
box(diorama, 0.24, 5.9, 11.1, M.wall, -8.05, 2.8, 0);
box(diorama, 16.15, 0.18, 0.08, M.wallTrim, 0, 0.1, -5.39);
box(diorama, 0.08, 0.18, 11, M.wallTrim, -7.9, 0.1, 0);
// Oven-room tiled splashback
const tileMat = material("#ffffff", { map: makeTileTexture() });
const splash = box(diorama, 6.4, 4.2, 0.06, tileMat, -4.8, 2.2, -5.39);
splash.castShadow = false;
panel(
diorama,
"MORNING CRUMB",
4.2,
1.02,
-4.8,
4.66,
-5.25,
"#f7ead2",
"#a95538"
);
// Window
const windowMat = material("#ffffff", {
map: makeWindowTexture(),
emissive: "#c6ddd6",
emissiveIntensity: 0.18
});
box(diorama, 3.5, 2.15, 0.07, windowMat, 4.9, 3.15, -5.34);
box(diorama, 3.72, 0.13, 0.16, M.cream, 4.9, 4.28, -5.23);
box(diorama, 3.72, 0.13, 0.16, M.cream, 4.9, 2.03, -5.23);
box(diorama, 0.13, 2.35, 0.16, M.cream, 3.12, 3.15, -5.23);
box(diorama, 0.13, 2.35, 0.16, M.cream, 6.68, 3.15, -5.23);
box(diorama, 0.09, 2.12, 0.16, M.cream, 4.9, 3.15, -5.21);
// Wall clock
const clock = new THREE.Group();
clock.position.set(0.05, 3.95, -5.18);
diorama.add(clock);
const clockBody = cylinder(clock, 0.55, 0.55, 0.11, M.cream, 0, 0, 0, 32);
clockBody.rotation.x = Math.PI / 2;
const clockInner = cylinder(clock, 0.46, 0.46, 0.12, M.flour, 0, 0, 0.025, 32);
clockInner.rotation.x = Math.PI / 2;
const minutePivot = new THREE.Group();
minutePivot.position.z = 0.1;
minutePivot.rotation.z = -Math.PI / 3;
clock.add(minutePivot);
box(minutePivot, 0.035, 0.39, 0.025, M.dark, 0, 0.17, 0);
const hourPivot = new THREE.Group();
hourPivot.position.z = 0.11;
hourPivot.rotation.z = -3.76;
clock.add(hourPivot);
box(hourPivot, 0.05, 0.29, 0.025, M.dark, 0, 0.12, 0);
sphere(clock, 0.055, M.orange, 0, 0, 0.13, 12);
// Procedural bread
function baguette(parent, x, y, z, rotation = 0, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
parent.add(group);
const body = sphere(group, 1, M.breadLight, 0, 0, 0, 16);
body.scale.set(0.13, 0.13, 0.53);
const slashMat = material("#f0bd7c");
for (let i = -1; i <= 1; i++) {
const slash = box(group, 0.2, 0.025, 0.045, slashMat, 0, 0.12, i * 0.22);
slash.rotation.y = -0.42;
}
return group;
}
function roundLoaf(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
const body = sphere(group, 0.3, M.bread, 0, 0.25, 0, 16);
body.scale.set(1.05, 0.72, 0.95);
for (let i = -1; i <= 1; i++) {
const mark = box(group, 0.16, 0.025, 0.035, M.breadLight, i * 0.1, 0.43, 0);
mark.rotation.y = i * 0.35;
}
return group;
}
function croissant(parent, x, y, z, scale = 1, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
group.rotation.y = rotation;
parent.add(group);
const curve = addMesh(
group,
new THREE.TorusGeometry(0.23, 0.085, 8, 18, Math.PI * 1.45),
M.breadLight,
0,
0.12,
0
);
curve.rotation.x = Math.PI / 2;
curve.rotation.z = -0.7;
sphere(group, 0.11, M.bread, 0.02, 0.13, -0.01, 12);
return group;
}
function brioche(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
sphere(group, 0.15, M.breadLight, 0, 0.15, 0, 12);
sphere(group, 0.13, M.breadLight, -0.12, 0.13, 0.04, 12);
sphere(group, 0.13, M.breadLight, 0.12, 0.13, 0.04, 12);
return group;
}
// Ovens
const ovenLights = [];
function archShape(radius, base, height) {
const shape = new THREE.Shape();
shape.moveTo(-radius, base);
shape.lineTo(radius, base);
shape.lineTo(radius, base + height * 0.55);
shape.quadraticCurveTo(radius, base + height, 0, base + height);
shape.quadraticCurveTo(-radius, base + height, -radius, base + height * 0.55);
shape.closePath();
return shape;
}
function makeOven(x) {
const group = new THREE.Group();
group.position.set(x, 0, -5.03);
diorama.add(group);
const bodyShape = new THREE.Shape();
bodyShape.moveTo(-1.05, 0);
bodyShape.lineTo(1.05, 0);
bodyShape.lineTo(1.05, 1.42);
bodyShape.quadraticCurveTo(1.05, 2.28, 0, 2.52);
bodyShape.quadraticCurveTo(-1.05, 2.28, -1.05, 1.42);
bodyShape.closePath();
const bodyGeo = new THREE.ExtrudeGeometry(bodyShape, {
depth: 1.64,
bevelEnabled: true,
bevelSize: 0.07,
bevelThickness: 0.07,
bevelSegments: 2,
steps: 1
});
addMesh(group, bodyGeo, M.clay);
const mouth = addMesh(
group,
new THREE.ShapeGeometry(archShape(0.66, 0.34, 1.42)),
M.ovenMouth,
0,
0,
1.71
);
mouth.castShadow = false;
const inner = addMesh(
group,
new THREE.ShapeGeometry(archShape(0.52, 0.4, 1.27)),
M.glow,
0,
0,
1.73
);
inner.castShadow = false;
box(group, 0.8, 0.11, 0.14, M.clayDark, -0.18, 0.48, 1.78);
box(group, 0.8, 0.11, 0.14, M.clayDark, 0.18, 0.5, 1.78);
box(group, 0.55, 1.1, 0.58, M.clayDark, 0, 2.85, 0.46);
box(group, 0.72, 0.14, 0.72, M.cream, 0, 3.4, 0.46);
const light = new THREE.PointLight("#ff9e39", 16, 5, 2);
light.position.set(0, 1, 2.05);
group.add(light);
ovenLights.push(light);
label(group, "OVEN", 0, 2.9, 1.83, 1.45, "#ffe6bd", "#9b4c2f");
}
makeOven(-6.1);
makeOven(-3.65);
// Cooling rack
const cooling = new THREE.Group();
cooling.position.set(-0.8, 0, -3.72);
diorama.add(cooling);
const rackWidth = 2.5;
const rackDepth = 1.15;
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
cylinder(
cooling,
0.045,
0.045,
2.55,
M.metal,
sx * rackWidth * 0.5,
1.275,
sz * rackDepth * 0.5,
10
);
}
}
[0.48, 1.14, 1.8, 2.46].forEach((y) => {
cylinderBetween(
cooling,
[-rackWidth / 2, y, -rackDepth / 2],
[rackWidth / 2, y, -rackDepth / 2],
0.026,
M.metal,
8
);
cylinderBetween(
cooling,
[-rackWidth / 2, y, rackDepth / 2],
[rackWidth / 2, y, rackDepth / 2],
0.026,
M.metal,
8
);
for (let i = 0; i < 7; i++) {
const x = -rackWidth / 2 + (i / 6) * rackWidth;
cylinderBetween(
cooling,
[x, y, -rackDepth / 2],
[x, y, rackDepth / 2],
0.018,
M.metal,
8
);
}
});
baguette(cooling, -0.65, 0.59, 0, Math.PI / 2, 1.05);
roundLoaf(cooling, 0.05, 0.52, 0.1, 1.05);
baguette(cooling, 0.72, 0.59, 0, Math.PI / 2, 0.95);
croissant(cooling, -0.65, 1.25, 0, 0.9, 0.4);
roundLoaf(cooling, 0, 1.19, 0, 1);
brioche(cooling, 0.68, 1.2, 0.05, 1);
baguette(cooling, -0.45, 1.91, 0, Math.PI / 2, 1);
baguette(cooling, 0.45, 1.91, 0, Math.PI / 2, 1);
// Bread display shelving
const display = new THREE.Group();
display.position.set(3.45, 0, -3.55);
diorama.add(display);
const dw = 3.7;
const dd = 1.05;
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
box(display, 0.12, 2.75, 0.12, M.woodDark, sx * dw / 2, 1.375, sz * dd / 2);
}
}
[0.52, 1.2, 1.88, 2.58].forEach((y) => {
box(display, dw + 0.12, 0.11, dd + 0.08, M.woodLight, 0, y, 0);
box(display, dw + 0.12, 0.07, 0.07, M.woodDark, 0, y - 0.09, dd / 2);
});
baguette(display, -1.15, 0.64, 0, Math.PI / 2, 1.05);
baguette(display, -0.15, 0.64, 0, Math.PI / 2, 1.05);
roundLoaf(display, 0.95, 0.58, 0, 1.15);
croissant(display, -1.25, 1.32, 0, 1, 0.1);
croissant(display, -0.72, 1.32, 0, 1, -0.35);
brioche(display, -0.05, 1.26, 0, 1.1);
roundLoaf(display, 0.7, 1.26, 0, 1);
roundLoaf(display, 1.2, 1.26, 0.05, 0.95);
baguette(display, -1.1, 2.0, 0, Math.PI / 2, 1);
baguette(display, -0.05, 2.0, 0, Math.PI / 2, 1);
baguette(display, 1.0, 2.0, 0, Math.PI / 2, 1);
// Glass sides and top
box(display, 0.035, 2.05, dd, M.glass, -dw / 2 - 0.08, 1.48, 0);
box(display, 0.035, 2.05, dd, M.glass, dw / 2 + 0.08, 1.48, 0);
box(display, dw + 0.18, 0.035, dd, M.glass, 0, 2.52, 0);
// Sale counter
const counter = new THREE.Group();
counter.position.set(2.3, 0, 0.95);
diorama.add(counter);
box(counter, 5.7, 1.2, 1.35, M.wood, 0, 0.62, 0);
box(counter, 5.95, 0.16, 1.52, M.woodLight, 0, 1.28, 0);
box(counter, 5.66, 0.12, 0.12, M.woodDark, 0, 0.16, 0.69);
for (let i = 0; i < 11; i++) {
box(
counter,
0.43,
0.86,
0.055,
i % 2 ? M.woodLight : M.cream,
-2.48 + i * 0.496,
0.65,
0.7
);
}
panel(
counter,
"FRESH & WARM",
2.25,
0.55,
0.3,
0.7,
0.735,
"#f5e5c7",
"#875038"
);
// Counter display case
const caseGroup = new THREE.Group();
caseGroup.position.set(-0.55, 1.38, 0);
counter.add(caseGroup);
box(caseGroup, 3.25, 0.08, 1.08, M.cream, 0, 0, 0);
box(caseGroup, 3.25, 0.08, 1.08, M.cream, 0, 0.68, 0);
box(caseGroup, 3.25, 0.68, 0.035, M.glass, 0, 0.34, -0.52);
box(caseGroup, 3.25, 0.68, 0.035, M.glass, 0, 0.34, 0.52);
box(caseGroup, 0.035, 0.68, 1.08, M.glass, -1.61, 0.34, 0);
box(caseGroup, 0.035, 0.68, 1.08, M.glass, 1.61, 0.34, 0);
baguette(caseGroup, -0.95, 0.1, 0, Math.PI / 2, 0.9);
roundLoaf(caseGroup, -0.1, 0.04, 0.05, 0.88);
croissant(caseGroup, 0.68, 0.1, 0, 0.85, 0.15);
croissant(caseGroup, 1.12, 0.1, 0, 0.8, -0.3);
// Register and till
box(counter, 0.7, 0.18, 0.55, M.dark, 2.25, 1.45, 0.02);
const registerScreen = box(
counter,
0.62,
0.43,
0.08,
material("#4d6d67", { emissive: "#153d36", emissiveIntensity: 0.2 }),
2.25,
1.72,
-0.18
);
registerScreen.rotation.x = -0.18;
box(counter, 0.42, 0.08, 0.3, M.cream, 2.22, 1.59, 0.25);
// Pendant lights
for (const x of [-0.4, 1.45, 3.3]) {
cylinder(diorama, 0.025, 0.025, 1.15, M.dark, x, 4.05, 0.6, 8);
const shade = cylinder(diorama, 0.13, 0.48, 0.38, M.green, x, 3.32, 0.6, 24);
shade.castShadow = true;
sphere(diorama, 0.11, M.glow, x, 3.1, 0.6, 12);
}
// Public/staff separator rail
for (const x of [-7.2, -5.55, -3.9, -2.25, -0.75]) {
cylinder(diorama, 0.055, 0.065, 1.05, M.green, x, 0.53, 2.05, 12);
sphere(diorama, 0.085, M.woodLight, x, 1.07, 2.05, 12);
}
cylinderBetween(
diorama,
[-7.2, 0.92, 2.05],
[-0.75, 0.92, 2.05],
0.045,
M.green,
12
);
cylinderBetween(
diorama,
[-7.2, 0.46, 2.05],
[-0.75, 0.46, 2.05],
0.028,
M.green,
12
);
// People
function makePerson({
x,
z,
rotation = 0,
shirt = "#8ca6a0",
pants = "#555b5b",
hair = "#4b3831",
skin = "#d9a278",
scale = 1,
staff = false,
bag = false
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
diorama.add(group);
const shirtMat = material(shirt);
const pantsMat = material(pants);
const skinMat = material(skin);
const hairMat = material(hair);
cylinderBetween(group, [-0.13, 0.08, 0], [-0.13, 0.69, 0], 0.09, pantsMat);
cylinderBetween(group, [0.13, 0.08, 0], [0.13, 0.69, 0], 0.09, pantsMat);
box(group, 0.2, 0.12, 0.33, M.dark, -0.13, 0.07, 0.06);
box(group, 0.2, 0.12, 0.33, M.dark, 0.13, 0.07, 0.06);
cylinder(group, 0.26, 0.31, 0.7, shirtMat, 0, 1.02, 0, 14);
cylinderBetween(group, [-0.28, 1.28, 0], [-0.39, 0.77, 0.03], 0.075, shirtMat);
cylinderBetween(group, [0.28, 1.28, 0], [0.39, 0.77, 0.03], 0.075, shirtMat);
sphere(group, 0.25, skinMat, 0, 1.57, 0, 16);
const hairCap = sphere(group, 0.255, hairMat, 0, 1.68, -0.035, 16);
hairCap.scale.set(1.02, 0.72, 1.02);
sphere(group, 0.055, skinMat, 0, 1.56, 0.245, 10);
if (staff) {
box(group, 0.39, 0.62, 0.04, M.flour, 0, 0.98, 0.29);
cylinder(group, 0.22, 0.2, 0.24, M.flour, 0, 1.87, 0, 16);
sphere(group, 0.13, M.flour, -0.13, 1.91, 0, 12);
sphere(group, 0.13, M.flour, 0.13, 1.91, 0, 12);
sphere(group, 0.13, M.flour, 0, 1.91, 0, 12);
}
if (bag) {
const bagMat = material("#c88b5e");
box(group, 0.28, 0.35, 0.15, bagMat, 0.4, 0.63, 0.02);
const handle = addMesh(
group,
new THREE.TorusGeometry(0.09, 0.018, 6, 12, Math.PI),
M.woodDark,
0.4,
0.82,
0.02
);
handle.rotation.z = Math.PI;
}
return group;
}
// Staff are always on the production side.
makePerson({
x: -6.95,
z: -2.05,
rotation: -0.3,
shirt: "#f3ead7",
pants: "#8b8073",
hair: "#4a352b",
scale: 1,
staff: true
});
makePerson({
x: 0.25,
z: -0.12,
rotation: 0.05,
shirt: "#f1e4cc",
pants: "#6d6259",
hair: "#53382f",
scale: 0.98,
staff: true
});
// Waiting customers, all on the public side.
makePerson({
x: 3.55,
z: 2.62,
rotation: Math.PI - 0.08,
shirt: "#b86f55",
pants: "#3f5153",
hair: "#3e2d29",
skin: "#d7a177",
bag: true
});
makePerson({
x: 2.65,
z: 3.03,
rotation: Math.PI + 0.05,
shirt: "#76928a",
pants: "#5d514a",
hair: "#735044",
skin: "#efbe95",
bag: true
});
makePerson({
x: 1.72,
z: 3.45,
rotation: Math.PI - 0.08,
shirt: "#d2a65b",
pants: "#46525a",
hair: "#332927",
skin: "#b97c59",
scale: 0.92
});
makePerson({
x: 0.78,
z: 3.75,
rotation: Math.PI + 0.14,
shirt: "#7888a3",
pants: "#4b4440",
hair: "#9a6b4a",
skin: "#f0c39e",
scale: 0.72
});
// Bench and plant in the waiting nook
const bench = new THREE.Group();
bench.position.set(-4.7, 0, 4.25);
diorama.add(bench);
box(bench, 2.6, 0.13, 0.58, M.wood, 0, 0.58, 0);
box(bench, 2.6, 0.55, 0.1, M.wood, 0, 0.92, -0.27);
for (const x of [-0.95, 0.95]) {
box(bench, 0.13, 0.56, 0.45, M.metal, x, 0.28, 0);
}
const plant = new THREE.Group();
plant.position.set(-7.1, 0, 4.15);
diorama.add(plant);
cylinder(plant, 0.38, 0.28, 0.65, M.clay, 0, 0.33, 0, 16);
cylinder(plant, 0.34, 0.34, 0.08, M.woodDark, 0, 0.65, 0, 16);
cylinderBetween(plant, [0, 0.6, 0], [0.05, 2.1, 0], 0.035, M.green);
const leafMat = material("#66866c");
for (let i = 0; i < 9; i++) {
const angle = (i / 9) * Math.PI * 2;
const leaf = sphere(plant, 0.34, leafMat, Math.cos(angle) * 0.33, 1.2 + i * 0.08, Math.sin(angle) * 0.33, 12);
leaf.scale.set(0.45, 1.05, 0.7);
leaf.rotation.z = Math.cos(angle) * 0.55;
leaf.rotation.x = Math.sin(angle) * 0.55;
}
// Flour sacks and a prep stool in the oven room
const sackMat = material("#ded1b3");
const sack = sphere(diorama, 0.52, sackMat, -7.25, 0.48, -1.25, 16);
sack.scale.set(0.78, 1.05, 0.72);
cylinder(diorama, 0.22, 0.22, 0.08, M.woodDark, -7.25, 0.98, -1.25, 14);
// Continuous staff route
const processRoute = new THREE.Group();
diorama.add(processRoute);
const routePoints = [
new THREE.Vector3(-5.15, 0.09, -2.68),
new THREE.Vector3(-3.35, 0.09, -2.68),
new THREE.Vector3(-1.5, 0.09, -2.58),
new THREE.Vector3(1.1, 0.09, -2.36),
new THREE.Vector3(3.35, 0.09, -2.18),
new THREE.Vector3(4.42, 0.09, -1.35),
new THREE.Vector3(4.42, 0.09, -0.25),
new THREE.Vector3(3.92, 0.09, 0.55)
];
const routeCurve = new THREE.CatmullRomCurve3(
routePoints,
false,
"centripetal",
0.35
);
const routeGeometry = new THREE.TubeGeometry(routeCurve, 120, 0.055, 10, false);
addMesh(processRoute, routeGeometry, M.orange);
function routeArrow(curve, t, colorMat, scale = 1) {
const point = curve.getPointAt(t);
const tangent = curve.getTangentAt(t).normalize();
const arrow = addMesh(
processRoute,
new THREE.ConeGeometry(0.13 * scale, 0.3 * scale, 3),
colorMat,
point.x,
0.17,
point.z
);
arrow.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), tangent);
arrow.castShadow = false;
}
[0.09, 0.29, 0.5, 0.7, 0.88].forEach((t) => routeArrow(routeCurve, t, M.orange));
function floorBadge(number, x, z) {
const c = document.createElement("canvas");
c.width = c.height = 128;
const ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(64, 64, 50, 0, Math.PI * 2);
ctx.fillStyle = "#fff7e9";
ctx.fill();
ctx.lineWidth = 8;
ctx.strokeStyle = "#df6a3b";
ctx.stroke();
ctx.fillStyle = "#b85332";
ctx.font = "900 58px Arial";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(String(number), 64, 67);
const tex = new THREE.CanvasTexture(c);
tex.colorSpace = THREE.SRGBColorSpace;
const badge = addMesh(
processRoute,
new THREE.PlaneGeometry(0.48, 0.48),
new THREE.MeshBasicMaterial({
map: tex,
transparent: true,
depthWrite: false
}),
x,
0.025,
z
);
badge.rotation.x = -Math.PI / 2;
badge.castShadow = false;
}
floorBadge(1, -5.15, -2.68);
floorBadge(2, -0.85, -2.61);
floorBadge(3, 3.35, -2.18);
floorBadge(4, 3.92, 0.55);
label(diorama, "01 BAKE", -5.15, 1.03, -2.68, 1.55);
label(diorama, "02 COOL", -0.85, 2.95, -3.45, 1.55);
label(diorama, "03 DISPLAY", 3.45, 3.03, -3.35, 1.8);
label(diorama, "04 SELL", 2.95, 2.5, 0.95, 1.55);
// Separate public route
const visitorRoute = new THREE.Group();
diorama.add(visitorRoute);
const publicZ = 3.62;
const dashStart = -7.05;
const dashEnd = 7.2;
const dashLength = 0.31;
const dashGap = 0.28;
for (let x = dashStart; x < dashEnd; x += dashLength + dashGap) {
const end = Math.min(x + dashLength, dashEnd);
cylinderBetween(
visitorRoute,
[x, 0.055, publicZ],
[end, 0.055, publicZ],
0.048,
M.teal,
10
);
}
[5.9, 3.9, 0.9, -2.1, -5.2].forEach((x) => {
const arrow = addMesh(
visitorRoute,
new THREE.ConeGeometry(0.12, 0.28, 3),
M.teal,
x,
0.15,
publicZ
);
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
new THREE.Vector3(-1, 0, 0)
);
arrow.castShadow = false;
});
// Entry mat
const matGroup = new THREE.Group();
matGroup.position.set(6.55, 0, 3.61);
visitorRoute.add(matGroup);
box(matGroup, 1.45, 0.035, 0.92, material("#cba47e"), 0, 0.025, 0);
label(matGroup, "WELCOME", 0, 0.11, 0, 1.22, "#cba47e", "#654536");
// Subtle color zoning on the public side
const publicZone = addMesh(
visitorRoute,
new THREE.PlaneGeometry(15.3, 2.25),
new THREE.MeshBasicMaterial({
color: "#78aaa0",
transparent: true,
opacity: 0.055,
depthWrite: false
}),
0,
0.012,
3.5
);
publicZone.rotation.x = -Math.PI / 2;
publicZone.castShadow = false;
// Steam puffs
const steam = [];
const steamGeo = new THREE.SphereGeometry(0.18, 10, 7);
[
[-6.1, -3.18],
[-3.65, -3.18],
[-0.8, -3.02]
].forEach(([x, z], ovenIndex) => {
for (let i = 0; i < 5; i++) {
const puffMat = new THREE.MeshBasicMaterial({
color: "#fff8e8",
transparent: true,
opacity: 0.12,
depthWrite: false
});
const puff = new THREE.Mesh(steamGeo, puffMat);
puff.position.set(x, 2.45 + i * 0.25, z + (i % 2) * 0.1);
puff.scale.setScalar(0.7 + i * 0.11);
puff.userData = {
baseX: x,
baseY: 2.45 + i * 0.25,
baseZ: z,
phase: i * 1.4 + ovenIndex,
speed: 0.24 + i * 0.035
};
diorama.add(puff);
steam.push(puff);
}
});
// Route-control interaction
let visitorRouteVisible = true;
document.querySelector("#toggle-route").addEventListener("click", (event) => {
visitorRouteVisible = !visitorRouteVisible;
visitorRoute.visible = visitorRouteVisible;
event.currentTarget.textContent = visitorRouteVisible ? "Guest path" : "Show path";
});
document.querySelector("#reset-view").addEventListener("click", () => {
desired.theta = initialView.theta;
desired.phi = initialView.phi;
desired.radius = initialView.radius;
desired.target.copy(initialView.target);
});
// Direct orbit controls: no addons or external examples.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let activePointer = null;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
activePointer = event.pointerId;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointer) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi + dy * 0.005,
0.52,
1.35
);
});
function stopDragging(event) {
if (activePointer === event.pointerId) {
dragging = false;
activePointer = null;
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius + event.deltaY * 0.012,
13.5,
30
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
desired.theta = initialView.theta;
desired.phi = initialView.phi;
desired.radius = initialView.radius;
desired.target.copy(initialView.target);
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clockTime = new THREE.Clock();
function animate() {
const elapsed = clockTime.getElapsedTime();
const dt = Math.min(clockTime.getDelta(), 0.04);
const smoothing = 1 - Math.pow(0.001, dt);
view.theta = THREE.MathUtils.lerp(view.theta, desired.theta, smoothing);
view.phi = THREE.MathUtils.lerp(view.phi, desired.phi, smoothing);
view.radius = THREE.MathUtils.lerp(view.radius, desired.radius, smoothing);
view.target.lerp(desired.target, smoothing);
updateCamera();
ovenLights.forEach((light, index) => {
light.intensity =
15 +
Math.sin(elapsed * 6.3 + index * 2.1) * 1.1 +
Math.sin(elapsed * 11.7 + index) * 0.65;
});
steam.forEach((puff) => {
const data = puff.userData;
const t = elapsed * data.speed + data.phase;
puff.position.x = data.baseX + Math.sin(t * 1.1) * 0.15;
puff.position.y = data.baseY + Math.sin(t) * 0.16 + t * 0.05;
puff.position.z = data.baseZ + Math.cos(t * 0.9) * 0.1;
const pulse = 0.78 + Math.sin(t * 0.8) * 0.12;
puff.scale.setScalar(pulse);
puff.material.opacity = 0.07 + (Math.sin(t) + 1) * 0.025;
});
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
});
</script>
</body>
</html>
```