Prompt specification
Build or customize the Three.js 3D scene "Bakery proofing comparison 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: Bakery proofing comparison table
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/bakery-proofing-comparison-table-x0087
Scene Description Prompt:
A voxel bakery table tracks equal dough portions through resting and baking stages. Build one HTML file using Three.js from cdnjs.
Working Three.js Starter (bakery-proofing-comparison-table-x0087):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#f3e5cf" />
<title>DoughFlow — Voxel Bakery Tracker</title>
<style>
:root {
--ink: #3c2a20;
--muted: #8b7463;
--cream: #fffaf0;
--paper: rgba(255, 250, 240, 0.9);
--line: rgba(80, 53, 35, 0.12);
--orange: #d86d3e;
--orange-dark: #ad4d2c;
--sage: #789477;
--gold: #d49a42;
--shadow: 0 18px 45px rgba(78, 48, 28, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #f3e5cf;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 3;
}
.panel {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.78);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
}
.brand {
position: absolute;
top: 26px;
left: 28px;
display: flex;
align-items: center;
gap: 12px;
}
.brand-mark {
width: 42px;
height: 42px;
display: grid;
place-items: center;
border-radius: 13px;
color: white;
background: var(--orange);
box-shadow: 0 8px 20px rgba(190, 81, 40, 0.27);
font-family: Georgia, serif;
font-size: 20px;
font-weight: 700;
letter-spacing: -2px;
padding-right: 2px;
}
.brand-name {
font-size: 13px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.brand-subtitle {
margin-top: 3px;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.04em;
}
.intro {
position: absolute;
top: 91px;
left: 28px;
max-width: 390px;
}
.intro h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(36px, 4.2vw, 62px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.055em;
}
.intro h1 em {
color: var(--orange);
font-weight: 500;
}
.intro p {
width: 290px;
margin: 18px 0 0;
color: #725e50;
font-size: 13px;
line-height: 1.65;
}
.batch-card {
position: absolute;
top: 26px;
right: 28px;
width: 226px;
padding: 16px 17px;
border-radius: 18px;
}
.batch-top {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--muted);
}
.live-dot {
display: inline-flex;
align-items: center;
gap: 6px;
color: var(--sage);
}
.live-dot::before {
content: "";
width: 7px;
height: 7px;
border-radius: 2px;
background: currentColor;
box-shadow: 0 0 0 4px rgba(120, 148, 119, 0.13);
}
.batch-title {
display: flex;
align-items: baseline;
gap: 8px;
margin-top: 10px;
}
.batch-title strong {
font-family: Georgia, serif;
font-size: 29px;
font-weight: 500;
letter-spacing: -0.04em;
}
.batch-title span {
color: var(--muted);
font-size: 12px;
}
.batch-meta {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin-top: 13px;
padding-top: 13px;
border-top: 1px solid var(--line);
}
.batch-meta div {
min-width: 0;
}
.batch-meta strong {
display: block;
font-size: 13px;
}
.batch-meta span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.batch-progress {
height: 4px;
margin-top: 14px;
overflow: hidden;
border-radius: 4px;
background: rgba(80, 53, 35, 0.1);
}
#batch-progress-fill {
width: 33.333%;
height: 100%;
border-radius: inherit;
background: var(--orange);
transition: width 700ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.roster {
position: absolute;
top: 226px;
right: 28px;
width: 226px;
padding: 14px;
border-radius: 18px;
pointer-events: auto;
}
.roster-heading {
display: flex;
align-items: center;
justify-content: space-between;
padding: 2px 2px 10px;
}
.roster-heading strong {
font-size: 11px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.roster-heading span {
color: var(--muted);
font-size: 10px;
}
.portion-list {
display: grid;
gap: 4px;
}
.portion-row {
width: 100%;
display: grid;
grid-template-columns: 9px 1fr auto;
align-items: center;
gap: 9px;
padding: 8px 9px;
border: 1px solid transparent;
border-radius: 10px;
background: transparent;
color: var(--ink);
text-align: left;
cursor: pointer;
transition: 160ms ease;
}
.portion-row:hover {
background: rgba(216, 109, 62, 0.07);
}
.portion-row.selected {
border-color: rgba(216, 109, 62, 0.22);
background: rgba(216, 109, 62, 0.1);
}
.portion-dot {
width: 7px;
height: 7px;
border-radius: 2px;
background: var(--orange);
}
.portion-id {
font-size: 11px;
font-weight: 800;
letter-spacing: 0.06em;
}
.portion-state {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.roster-footer {
display: flex;
justify-content: space-between;
margin-top: 10px;
padding: 11px 2px 1px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
}
.roster-footer strong {
color: var(--ink);
}
.console {
position: absolute;
left: 50%;
bottom: 24px;
width: min(760px, calc(100vw - 48px));
padding: 17px;
border-radius: 22px;
transform: translateX(-50%);
pointer-events: auto;
}
.console-main {
display: grid;
grid-template-columns: minmax(210px, 0.85fr) minmax(360px, 1.45fr);
gap: 18px;
align-items: center;
}
.stage-copy {
padding: 0 5px;
}
#stage-kicker {
color: var(--orange);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#stage-title {
margin: 5px 0 3px;
font-family: Georgia, serif;
font-size: 28px;
font-weight: 500;
letter-spacing: -0.04em;
}
#stage-description {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.stage-steps {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}
.stage-step {
position: relative;
min-height: 74px;
padding: 12px 10px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.36);
color: var(--muted);
text-align: left;
cursor: pointer;
transition: 180ms ease;
}
.stage-step:hover {
transform: translateY(-2px);
border-color: rgba(216, 109, 62, 0.3);
}
.stage-step.active {
border-color: rgba(216, 109, 62, 0.4);
background: var(--orange);
color: white;
box-shadow: 0 10px 22px rgba(185, 77, 38, 0.22);
}
.stage-step .number {
display: block;
margin-bottom: 8px;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
opacity: 0.72;
}
.stage-step .name {
display: block;
font-family: Georgia, serif;
font-size: 17px;
}
.stage-step .time {
display: block;
margin-top: 4px;
font-size: 9px;
opacity: 0.72;
}
.console-bottom {
display: flex;
align-items: center;
gap: 10px;
margin-top: 14px;
padding-top: 13px;
border-top: 1px solid var(--line);
}
.small-button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
min-height: 36px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.55);
color: var(--ink);
font-size: 10px;
font-weight: 800;
cursor: pointer;
transition: 160ms ease;
}
.small-button:hover {
background: white;
transform: translateY(-1px);
}
.small-button.primary {
border-color: transparent;
background: var(--ink);
color: white;
}
.button-icon {
width: 0;
height: 0;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 7px solid currentColor;
}
.button-icon.pause {
width: 7px;
height: 8px;
border: 0;
border-left: 2px solid currentColor;
border-right: 2px solid currentColor;
}
.console-note {
margin-left: auto;
color: var(--muted);
font-size: 9px;
line-height: 1.45;
text-align: right;
}
.console-note strong {
color: var(--ink);
}
.world-label {
position: absolute;
z-index: 2;
display: flex;
align-items: center;
gap: 7px;
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.82);
border-radius: 9px;
background: rgba(255, 250, 240, 0.86);
box-shadow: 0 8px 22px rgba(75, 45, 25, 0.1);
color: var(--ink);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
transform: translate(-50%, -50%);
pointer-events: none;
white-space: nowrap;
backdrop-filter: blur(8px);
}
.world-label::before {
content: "";
width: 7px;
height: 7px;
border-radius: 2px;
background: var(--sage);
}
.world-label.baking::before {
background: var(--orange);
}
.world-label.baked::before {
background: var(--gold);
}
.camera-help {
position: absolute;
left: 28px;
bottom: 28px;
color: rgba(60, 42, 32, 0.58);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.camera-help span {
display: inline-block;
margin-right: 5px;
padding: 4px 6px;
border: 1px solid rgba(60, 42, 32, 0.12);
border-radius: 5px;
background: rgba(255, 250, 240, 0.45);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #f3e5cf;
transition: opacity 450ms ease, visibility 450ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
.loader-card {
text-align: center;
}
.loader-cube {
width: 42px;
height: 42px;
margin: 0 auto 16px;
border-radius: 9px;
background: var(--orange);
box-shadow: 11px 11px 0 #e3a35f, -11px -11px 0 #79937a;
animation: loader 1.2s ease-in-out infinite alternate;
}
.loader-card strong {
font-family: Georgia, serif;
font-size: 22px;
font-weight: 500;
}
.loader-card span {
display: block;
margin-top: 7px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
@keyframes loader {
to {
transform: translateY(-8px) rotate(4deg);
}
}
@media (max-width: 920px) {
.intro {
top: 82px;
}
.intro p {
display: none;
}
.roster {
top: 216px;
width: 190px;
}
.batch-card {
width: 190px;
}
.console-main {
grid-template-columns: 1fr;
gap: 12px;
}
.stage-copy {
display: grid;
grid-template-columns: auto 1fr;
column-gap: 12px;
align-items: center;
}
#stage-title {
margin: 0;
}
#stage-description {
grid-column: 1 / -1;
margin-top: 4px;
}
.stage-step {
min-height: 60px;
}
.camera-help {
display: none;
}
}
@media (max-width: 650px) {
.brand {
top: 17px;
left: 17px;
}
.brand-mark {
width: 36px;
height: 36px;
}
.brand-subtitle {
display: none;
}
.intro {
top: 69px;
left: 17px;
}
.intro h1 {
width: 220px;
font-size: 37px;
}
.batch-card {
top: 17px;
right: 17px;
width: 134px;
padding: 12px;
}
.batch-title strong {
font-size: 23px;
}
.batch-meta,
.batch-progress,
.live-dot {
display: none;
}
.roster {
display: none;
}
.console {
bottom: 12px;
width: calc(100vw - 24px);
padding: 13px;
border-radius: 18px;
}
.stage-copy {
display: block;
}
#stage-title {
margin: 4px 0 3px;
font-size: 23px;
}
.stage-step {
min-height: 57px;
padding: 9px 7px;
}
.stage-step .name {
font-size: 14px;
}
.stage-step .number {
margin-bottom: 5px;
}
.console-note {
display: none;
}
.world-label {
font-size: 8px;
padding: 5px 7px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="ui">
<div class="brand">
<div class="brand-mark">Df</div>
<div>
<div class="brand-name">DoughFlow</div>
<div class="brand-subtitle">Voxel bakery laboratory</div>
</div>
</div>
<header class="intro">
<h1>Proof & bake,<br /><em>portion by portion.</em></h1>
<p>
Follow eight precisely weighed dough portions from a gentle rest to a
perfectly golden finish.
</p>
</header>
<section class="batch-card panel" aria-label="Batch summary">
<div class="batch-top">
<span>Batch 024</span>
<span class="live-dot">Tracking</span>
</div>
<div class="batch-title">
<strong>720 g</strong>
<span>total dough</span>
</div>
<div class="batch-meta">
<div><strong>8</strong><span>portions</span></div>
<div><strong>90 g</strong><span>each</span></div>
<div><strong id="batch-stage">Rest</strong><span>stage</span></div>
</div>
<div class="batch-progress"><div id="batch-progress-fill"></div></div>
</section>
<aside class="roster panel" aria-label="Portion tracker">
<div class="roster-heading">
<strong>Portion tracker</strong>
<span>8 equal pieces</span>
</div>
<div id="portion-list" class="portion-list"></div>
<div class="roster-footer">
<span>Selected</span>
<strong id="selected-portion">P-01 · 90 g</strong>
</div>
</aside>
<div id="label-resting" class="world-label">01 · Resting</div>
<div id="label-baking" class="world-label baking">02 · Baking</div>
<div id="label-baked" class="world-label baked">03 · Baked</div>
<section class="console panel" aria-label="Bakery controls">
<div class="console-main">
<div class="stage-copy">
<div id="stage-kicker">Stage 01 · Proofing</div>
<h2 id="stage-title">Resting</h2>
<p id="stage-description">
Eight equal portions relax under a warm, steady proof.
</p>
</div>
<div class="stage-steps" role="group" aria-label="Bakery stage">
<button class="stage-step active" data-stage="0">
<span class="number">01</span>
<span class="name">Resting</span>
<span class="time">45 minutes</span>
</button>
<button class="stage-step" data-stage="1">
<span class="number">02</span>
<span class="name">Baking</span>
<span class="time">22 minutes</span>
</button>
<button class="stage-step" data-stage="2">
<span class="number">03</span>
<span class="name">Baked</span>
<span class="time">8 of 8</span>
</button>
</div>
</div>
<div class="console-bottom">
<button id="auto-button" class="small-button primary">
<span id="auto-icon" class="button-icon"></span>
<span id="auto-label">Auto cycle</span>
</button>
<button id="reset-camera" class="small-button">Reset view</button>
<div class="console-note">
<strong>Drag</strong> to orbit · <strong>Scroll</strong> to zoom<br />
Click any portion to inspect it
</div>
</div>
</section>
<div class="camera-help">
<span>Drag</span> orbit
<span>Scroll</span> zoom
<span>Double-click</span> reset
</div>
</div>
<div id="loading">
<div class="loader-card">
<div class="loader-cube"></div>
<strong>Warming the oven</strong>
<span>Preparing your bakery</span>
</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 and scene
// -------------------------------------------------------------------------
const container = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf3e5cf);
scene.fog = new THREE.Fog(0xf3e5cf, 24, 48);
const camera = new THREE.OrthographicCamera(-10, 10, 7, -7, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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;
container.appendChild(renderer.domElement);
const hemiLight = new THREE.HemisphereLight(0xfff7e8, 0xb77d5e, 2.2);
scene.add(hemiLight);
const sunLight = new THREE.DirectionalLight(0xfff0d5, 3.4);
sunLight.position.set(-7, 13, 8);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -14;
sunLight.shadow.camera.right = 14;
sunLight.shadow.camera.top = 14;
sunLight.shadow.camera.bottom = -14;
sunLight.shadow.camera.near = 0.5;
sunLight.shadow.camera.far = 40;
sunLight.shadow.bias = -0.00025;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0xffc99f, 1.1);
fillLight.position.set(8, 6, -7);
scene.add(fillLight);
const materialCache = new Map();
function material(color, roughness = 0.85, metalness = 0) {
const key = `${color}-${roughness}-${metalness}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({ color, roughness, metalness })
);
}
return materialCache.get(key);
}
function box(
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0,
parent = scene,
options = {}
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
options.material || material(color, options.roughness ?? 0.85, options.metalness ?? 0)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
parent.add(mesh);
return mesh;
}
function damp(current, target, smoothing, dt) {
return THREE.MathUtils.lerp(
current,
target,
1 - Math.exp(-smoothing * dt)
);
}
// -------------------------------------------------------------------------
// Pixel floor and bakery interior
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
material(0xe5c8a4)
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.08;
floor.receiveShadow = true;
scene.add(floor);
const tileGeometry = new THREE.BoxGeometry(1.42, 0.06, 1.42);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.95
});
const tileCountX = 18;
const tileCountZ = 12;
const tiles = new THREE.InstancedMesh(
tileGeometry,
tileMaterial,
tileCountX * tileCountZ
);
tiles.receiveShadow = true;
const dummy = new THREE.Object3D();
let tileIndex = 0;
for (let z = 0; z < tileCountZ; z++) {
for (let x = 0; x < tileCountX; x++) {
dummy.position.set(
(x - tileCountX / 2 + 0.5) * 1.42,
-0.045,
(z - tileCountZ / 2 + 0.5) * 1.42
);
dummy.updateMatrix();
tiles.setMatrixAt(tileIndex, dummy.matrix);
const warm = (x + z) % 2 === 0;
tiles.setColorAt(
tileIndex,
new THREE.Color(warm ? 0xe9d1ad : 0xf0ddbd)
);
tileIndex++;
}
}
tiles.instanceMatrix.needsUpdate = true;
if (tiles.instanceColor) tiles.instanceColor.needsUpdate = true;
scene.add(tiles);
// Back wall.
box(22, 8, 0.28, 0xe9c8aa, 0, 3.9, -6.4);
box(22, 0.36, 0.4, 0xb96f4a, 0, 0.2, -6.18);
// Decorative wall tiles.
for (let x = -9; x <= 9; x += 1.15) {
box(0.64, 0.64, 0.08, 0xf4dfc3, x, 2.35, -6.22, scene, {
castShadow: false
});
}
// Side wall suggestion.
box(0.25, 8, 12, 0xdcb795, -10.8, 3.9, -0.5);
// -------------------------------------------------------------------------
// Shelves and decorative bread
// -------------------------------------------------------------------------
function makeVoxelBread(parent, x, y, z, scale = 1, color = 0xc98243) {
const bread = new THREE.Group();
bread.position.set(x, y, z);
bread.scale.setScalar(scale);
parent.add(bread);
box(0.78, 0.32, 0.48, color, 0, 0.16, 0, bread);
box(0.58, 0.22, 0.38, color, 0, 0.4, 0, bread);
box(0.14, 0.12, 0.12, 0xe0a365, -0.24, 0.41, 0.15, bread);
box(0.14, 0.12, 0.12, 0xe0a365, 0.24, 0.41, 0.15, bread);
return bread;
}
function buildShelf(centerX) {
const shelf = new THREE.Group();
shelf.position.set(centerX, 0, -5.92);
scene.add(shelf);
box(4.4, 0.18, 0.75, 0x8a593e, 0, 2.55, 0, shelf);
box(4.4, 0.18, 0.75, 0x8a593e, 0, 3.78, 0, shelf);
box(0.18, 3.2, 0.2, 0x70442f, -2.02, 3.05, -0.08, shelf);
box(0.18, 3.2, 0.2, 0x70442f, 2.02, 3.05, -0.08, shelf);
makeVoxelBread(shelf, -1.3, 2.65, 0.02, 0.78, 0xc37b3e);
makeVoxelBread(shelf, -0.55, 2.65, 0.02, 0.78, 0xd2914c);
makeVoxelBread(shelf, 0.25, 2.65, 0.02, 0.78, 0xb96f39);
makeVoxelBread(shelf, 1.08, 2.65, 0.02, 0.78, 0xd59a54);
makeVoxelBread(shelf, -1.35, 3.88, 0.02, 0.72, 0xd69a55);
makeVoxelBread(shelf, -0.62, 3.88, 0.02, 0.72, 0xbb733c);
makeVoxelBread(shelf, 0.18, 3.88, 0.02, 0.72, 0xd89b57);
makeVoxelBread(shelf, 0.94, 3.88, 0.02, 0.72, 0xc98243);
}
buildShelf(-4.7);
buildShelf(4.7);
// -------------------------------------------------------------------------
// Voxel oven behind the table
// -------------------------------------------------------------------------
const oven = new THREE.Group();
oven.position.set(0, 0, -4.65);
scene.add(oven);
box(3.7, 3.9, 1.1, 0xb65f3d, 0, 2.05, 0, oven);
box(2.55, 2.35, 0.1, 0x3c2a24, 0, 2.02, 0.59, oven);
box(2.3, 2.08, 0.08, 0x6c2e1f, 0, 1.95, 0.66, oven);
box(0.36, 2.8, 0.25, 0xd47a4b, -1.48, 2.02, 0.69, oven);
box(0.36, 2.8, 0.25, 0xd47a4b, 1.48, 2.02, 0.69, oven);
box(3.3, 0.36, 0.25, 0xd47a4b, 0, 3.37, 0.69, oven);
box(3.7, 0.55, 1.45, 0x9e5035, 0, 4.06, -0.08, oven);
box(1.15, 1.1, 0.8, 0x8f4a33, 0, 4.83, -0.32, oven);
const ovenLight = new THREE.PointLight(0xff7b2e, 7, 8, 2);
ovenLight.position.set(0, 2.1, 1.1);
oven.add(ovenLight);
const flameMaterial = new THREE.MeshBasicMaterial({
color: 0xffad35,
transparent: true,
opacity: 0.9
});
const flames = [];
for (let i = 0; i < 7; i++) {
const flame = box(
0.16,
0.28 + (i % 3) * 0.08,
0.12,
0xff9b27,
-0.85 + i * 0.28,
1.2,
0.74,
oven,
{ material: flameMaterial, castShadow: false }
);
flames.push(flame);
}
// Oven handle.
box(2.35, 0.18, 0.22, 0x5b3b2e, 0, 2.88, 0.93, oven);
// Pendant lamps.
function makePendant(x, z) {
box(0.025, 2.1, 0.025, 0x5f493c, x, 6.45, z, scene, {
castShadow: false
});
box(1.05, 0.16, 1.05, 0xe5ad62, x, 5.36, z);
box(0.72, 0.2, 0.72, 0xffe0a1, x, 5.21, z, scene, {
castShadow: false
});
const lamp = new THREE.PointLight(0xffd69a, 8, 9, 2);
lamp.position.set(x, 5.05, z);
scene.add(lamp);
}
makePendant(-3.5, -1.6);
makePendant(3.5, -1.6);
// -------------------------------------------------------------------------
// Main worktable
// -------------------------------------------------------------------------
const table = new THREE.Group();
table.position.z = 0.15;
scene.add(table);
box(12, 0.56, 5.6, 0x9a5b3b, 0, 1.35, 0, table);
box(12.25, 0.16, 5.85, 0xc17a4f, 0, 1.67, 0, table);
box(11.75, 0.12, 5.3, 0xe5b989, 0, 1.76, 0, table);
box(12, 0.48, 0.18, 0x75432f, 0, 1.05, 2.73, table);
box(12, 0.48, 0.18, 0x75432f, 0, 1.05, -2.73, table);
for (const x of [-5.35, 5.35]) {
for (const z of [-2.22, 2.22]) {
box(0.58, 1.45, 0.58, 0x75432f, x, 0.62, z, table);
box(0.72, 0.17, 0.72, 0x5c3829, x, 0.08, z, table);
}
}
// -------------------------------------------------------------------------
// Three station trays
// -------------------------------------------------------------------------
const stationCenters = [-3.8, 0, 3.8];
const stationColors = [0x9daf95, 0xc77a49, 0xd8b37a];
stationCenters.forEach((x, index) => {
box(3.25, 0.1, 3.2, stationColors[index], x, 1.86, 0);
// Thin raised rims.
box(3.25, 0.16, 0.11, index === 1 ? 0x9b4e31 : 0x7b745e, x, 1.96, 1.57);
box(3.25, 0.16, 0.11, index === 1 ? 0x9b4e31 : 0x7b745e, x, 1.96, -1.57);
box(0.11, 0.16, 3.25, index === 1 ? 0x9b4e31 : 0x7b745e, x - 1.57, 1.96, 0);
box(0.11, 0.16, 3.25, index === 1 ? 0x9b4e31 : 0x7b745e, x + 1.57, 1.96, 0);
});
// Resting cloth folds.
for (let i = 0; i < 5; i++) {
box(
2.9,
0.025,
0.07,
0xe7dfc9,
-3.8,
1.925,
-1.15 + i * 0.52
);
}
// Baking deck grooves.
for (let i = 0; i < 8; i++) {
box(
0.055,
0.025,
2.8,
0x9f5637,
-1.25 + i * 0.36,
1.925,
0
);
}
// Cooling rack bars.
for (let i = 0; i < 9; i++) {
box(
0.055,
0.065,
2.95,
0x75675b,
3.8 - 1.32 + i * 0.33,
1.96,
0
);
}
// Small flour scatter near the resting side.
for (let i = 0; i < 18; i++) {
const angle = Math.random() * Math.PI * 2;
const radius = 1.4 + Math.random() * 0.75;
box(
0.035 + Math.random() * 0.035,
0.025,
0.035 + Math.random() * 0.035,
0xf7edda,
-3.8 + Math.cos(angle) * radius,
1.94,
Math.sin(angle) * radius,
scene,
{ castShadow: false }
);
}
// A little flour sack and scoop on the back-left of the table.
box(0.75, 0.85, 0.62, 0xd9c5a2, -5.05, 2.22, -1.65);
box(0.56, 0.22, 0.48, 0xc3a67e, -5.05, 2.72, -1.65);
box(0.45, 0.18, 0.36, 0xf2e5ce, -5.05, 2.84, -1.65);
box(0.55, 0.1, 0.12, 0x7c5b45, -5.05, 2.32, -1.31);
// -------------------------------------------------------------------------
// Eight equal dough portions
// -------------------------------------------------------------------------
const rawColor = new THREE.Color(0xf0d19c);
const bakingColor = new THREE.Color(0xd8913f);
const bakedColor = new THREE.Color(0xad5c2e);
const pieces = [];
const hitMeshes = [];
const pieceGeometryCache = {
main: new THREE.BoxGeometry(0.62, 0.31, 0.5),
top: new THREE.BoxGeometry(0.48, 0.18, 0.39),
side: new THREE.BoxGeometry(0.18, 0.19, 0.36),
corner: new THREE.BoxGeometry(0.16, 0.14, 0.16),
score: new THREE.BoxGeometry(0.035, 0.025, 0.32)
};
function makeDoughPiece(index) {
const group = new THREE.Group();
group.name = `Portion-${index + 1}`;
const doughMaterial = new THREE.MeshStandardMaterial({
color: rawColor,
roughness: 0.93
});
const piecesInGroup = [
box(0.62, 0.31, 0.5, 0xffffff, 0, 0.2, 0, group, {
material: doughMaterial
}),
box(0.48, 0.18, 0.39, 0xffffff, 0, 0.43, 0, group, {
material: doughMaterial
}),
box(0.18, 0.19, 0.36, 0xffffff, -0.31, 0.26, 0, group, {
material: doughMaterial
}),
box(0.18, 0.19, 0.36, 0xffffff, 0.31, 0.26, 0, group, {
material: doughMaterial
}),
box(0.16, 0.14, 0.16, 0xffffff, -0.23, 0.42, 0.16, group, {
material: doughMaterial
}),
box(0.16, 0.14, 0.16, 0xffffff, 0.23, 0.42, 0.16, group, {
material: doughMaterial
})
];
const scoreMaterial = new THREE.MeshStandardMaterial({
color: 0x7d3c20,
roughness: 1,
transparent: true,
opacity: 0
});
const scoreA = new THREE.Mesh(pieceGeometryCache.score, scoreMaterial);
scoreA.position.set(-0.15, 0.535, 0);
scoreA.rotation.y = 0.45;
scoreA.castShadow = false;
group.add(scoreA);
const scoreB = new THREE.Mesh(pieceGeometryCache.score, scoreMaterial);
scoreB.position.set(0.15, 0.535, 0);
scoreB.rotation.y = -0.45;
scoreB.castShadow = false;
group.add(scoreB);
for (const mesh of piecesInGroup) {
mesh.userData.pieceIndex = index;
hitMeshes.push(mesh);
}
scene.add(group);
return {
group,
material: doughMaterial,
scoreMaterial,
index
};
}
for (let i = 0; i < 8; i++) {
pieces.push(makeDoughPiece(i));
}
function targetForPiece(stage, index) {
const column = index % 4;
const row = Math.floor(index / 4);
const localX = -1.14 + column * 0.76;
const localZ = -0.68 + row * 1.36;
return new THREE.Vector3(
stationCenters[stage] + localX,
1.93,
localZ
);
}
pieces.forEach((piece, index) => {
const position = targetForPiece(0, index);
piece.group.position.copy(position);
piece.group.scale.setScalar(0.88);
});
// Selection marker.
const selection = new THREE.Group();
const selectionMaterial = new THREE.MeshBasicMaterial({
color: 0xdc6d38,
transparent: true,
opacity: 0.92,
depthTest: false
});
box(0.85, 0.025, 0.045, 0xffffff, 0, 0, -0.38, selection, {
material: selectionMaterial,
castShadow: false,
receiveShadow: false
});
box(0.85, 0.025, 0.045, 0xffffff, 0, 0, 0.38, selection, {
material: selectionMaterial,
castShadow: false,
receiveShadow: false
});
box(0.045, 0.025, 0.8, 0xffffff, -0.4, 0, 0, selection, {
material: selectionMaterial,
castShadow: false,
receiveShadow: false
});
box(0.045, 0.025, 0.8, 0xffffff, 0.4, 0, 0, selection, {
material: selectionMaterial,
castShadow: false,
receiveShadow: false
});
selection.renderOrder = 10;
scene.add(selection);
// -------------------------------------------------------------------------
// Pixel particles: flour, embers, steam
// -------------------------------------------------------------------------
function createParticleSystem(count, color, size) {
const positions = new Float32Array(count * 3);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
const pointsMaterial = new THREE.PointsMaterial({
color,
size,
transparent: true,
opacity: 0.8,
depthWrite: false,
sizeAttenuation: true
});
const points = new THREE.Points(geometry, pointsMaterial);
points.frustumCulled = false;
scene.add(points);
return {
points,
positions,
count,
velocities: new Float32Array(count)
};
}
const flourParticles = createParticleSystem(32, 0xffefd0, 0.075);
const emberParticles = createParticleSystem(30, 0xff8a2c, 0.085);
const steamParticles = createParticleSystem(28, 0xfff8eb, 0.11);
function resetParticle(system, centerX, centerZ, minY, maxY, horizontal = 1.4) {
for (let i = 0; i < system.count; i++) {
system.positions[i * 3] =
centerX + (Math.random() - 0.5) * horizontal;
system.positions[i * 3 + 1] =
minY + Math.random() * (maxY - minY);
system.positions[i * 3 + 2] =
centerZ + (Math.random() - 0.5) * horizontal;
system.velocities[i] = 0.15 + Math.random() * 0.35;
}
system.points.geometry.attributes.position.needsUpdate = true;
}
resetParticle(flourParticles, -3.8, 0, 1.9, 3.8, 3.3);
resetParticle(emberParticles, 0, -4.55, 1.2, 3.6, 2.1);
resetParticle(steamParticles, 3.8, 0, 1.95, 4.4, 3.2);
// -------------------------------------------------------------------------
// UI and state
// -------------------------------------------------------------------------
const stageData = [
{
kicker: "Stage 01 · Proofing",
title: "Resting",
description: "Eight equal portions relax under a warm, steady proof.",
short: "Resting",
progress: 33.333
},
{
kicker: "Stage 02 · Heat",
title: "Baking",
description: "The same 90 g portions turn golden on the hot deck.",
short: "Baking",
progress: 66.666
},
{
kicker: "Stage 03 · Finish",
title: "Baked",
description: "Every portion is evenly browned and ready for cooling.",
short: "Baked",
progress: 100
}
];
let targetStage = 0;
let selectedPiece = 0;
let autoCycle = false;
let autoElapsed = 0;
const autoDuration = 5.5;
const stageButtons = [...document.querySelectorAll(".stage-step")];
const portionList = document.getElementById("portion-list");
const selectedLabel = document.getElementById("selected-portion");
const stageKicker = document.getElementById("stage-kicker");
const stageTitle = document.getElementById("stage-title");
const stageDescription = document.getElementById("stage-description");
const batchStage = document.getElementById("batch-stage");
const progressFill = document.getElementById("batch-progress-fill");
const autoButton = document.getElementById("auto-button");
const autoIcon = document.getElementById("auto-icon");
const autoLabel = document.getElementById("auto-label");
for (let i = 0; i < 8; i++) {
const row = document.createElement("button");
row.className = "portion-row";
row.dataset.index = i;
row.innerHTML = `
<span class="portion-dot"></span>
<span class="portion-id">P-${String(i + 1).padStart(2, "0")}</span>
<span class="portion-state">Resting</span>
`;
row.addEventListener("click", () => selectPiece(i));
portionList.appendChild(row);
}
const portionRows = [...document.querySelectorAll(".portion-row")];
function selectPiece(index) {
selectedPiece = index;
selectedLabel.textContent = `P-${String(index + 1).padStart(2, "0")} · 90 g`;
portionRows.forEach((row, i) => {
row.classList.toggle("selected", i === index);
});
}
function updateStageUI() {
const data = stageData[targetStage];
stageKicker.textContent = data.kicker;
stageTitle.textContent = data.title;
stageDescription.textContent = data.description;
batchStage.textContent = data.short;
progressFill.style.width = `${data.progress}%`;
stageButtons.forEach((button, index) => {
button.classList.toggle("active", index === targetStage);
});
portionRows.forEach((row) => {
row.querySelector(".portion-state").textContent = data.short;
});
}
function setStage(stage, resetAutoTimer = true) {
targetStage = stage;
if (resetAutoTimer) autoElapsed = 0;
updateStageUI();
}
stageButtons.forEach((button) => {
button.addEventListener("click", () => {
setStage(Number(button.dataset.stage));
});
});
autoButton.addEventListener("click", () => {
autoCycle = !autoCycle;
autoElapsed = 0;
autoIcon.classList.toggle("pause", autoCycle);
autoIcon.classList.toggle("button-icon", true);
autoLabel.textContent = autoCycle ? "Pause cycle" : "Auto cycle";
});
// -------------------------------------------------------------------------
// Custom orbit camera controls — no external controls module
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 1.45, -0.3);
const defaultAzimuth = 0.63;
const defaultPolar = 0.83;
const defaultZoom = 1;
let desiredAzimuth = defaultAzimuth;
let desiredPolar = defaultPolar;
let desiredZoom = defaultZoom;
let currentAzimuth = defaultAzimuth;
let currentPolar = defaultPolar;
let currentZoom = defaultZoom;
let dragging = false;
let pointerMoved = false;
let pointerX = 0;
let pointerY = 0;
let activePointerId = null;
function resetCamera() {
desiredAzimuth = defaultAzimuth;
desiredPolar = defaultPolar;
desiredZoom = defaultZoom;
}
document.getElementById("reset-camera").addEventListener("click", resetCamera);
renderer.domElement.addEventListener("pointerdown", (event) => {
if (activePointerId !== null) return;
activePointerId = event.pointerId;
dragging = true;
pointerMoved = false;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointerId) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
if (Math.abs(dx) + Math.abs(dy) > 3) pointerMoved = true;
desiredAzimuth -= dx * 0.006;
desiredPolar = THREE.MathUtils.clamp(
desiredPolar + dy * 0.005,
0.42,
1.24
);
pointerX = event.clientX;
pointerY = event.clientY;
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (event.pointerId !== activePointerId) return;
if (!pointerMoved) {
const rect = renderer.domElement.getBoundingClientRect();
const mouse = new THREE.Vector2(
((event.clientX - rect.left) / rect.width) * 2 - 1,
-((event.clientY - rect.top) / rect.height) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, camera);
const hit = raycaster.intersectObjects(hitMeshes, false)[0];
if (hit) selectPiece(hit.object.userData.pieceIndex);
}
dragging = false;
activePointerId = null;
renderer.domElement.releasePointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
activePointerId = null;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredZoom = THREE.MathUtils.clamp(
desiredZoom - event.deltaY * 0.001,
0.72,
1.65
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
// -------------------------------------------------------------------------
// Responsive projection
// -------------------------------------------------------------------------
const frustumHeight = 13.6;
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
camera.left = (-frustumHeight * aspect) / 2;
camera.right = (frustumHeight * aspect) / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
// -------------------------------------------------------------------------
// World-space HTML labels
// -------------------------------------------------------------------------
const labels = [
{
element: document.getElementById("label-resting"),
position: new THREE.Vector3(-3.8, 2.28, 1.72)
},
{
element: document.getElementById("label-baking"),
position: new THREE.Vector3(0, 2.28, 1.72)
},
{
element: document.getElementById("label-baked"),
position: new THREE.Vector3(3.8, 2.28, 1.72)
}
];
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const projected = label.position.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.display = visible ? "flex" : "none";
label.element.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
label.element.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
}
}
// -------------------------------------------------------------------------
// Animation loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animateParticles(system, dt, minY, maxY, rise, drift = 0.1) {
for (let i = 0; i < system.count; i++) {
const offset = i * 3;
system.positions[offset + 1] +=
system.velocities[i] * rise * dt;
system.positions[offset] +=
Math.sin(elapsed * 1.4 + i) * drift * dt;
if (system.positions[offset + 1] > maxY) {
system.positions[offset + 1] = minY;
system.positions[offset] =
(system.positions[offset] > 0 ? -1 : 1) *
Math.random() * 1.4;
}
}
system.points.geometry.attributes.position.needsUpdate = true;
}
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
if (autoCycle) {
autoElapsed += dt;
if (autoElapsed >= autoDuration) {
autoElapsed = 0;
setStage((targetStage + 1) % 3, false);
}
}
// Camera orbit and zoom.
currentAzimuth = damp(currentAzimuth, desiredAzimuth, 8, dt);
currentPolar = damp(currentPolar, desiredPolar, 8, dt);
currentZoom = damp(currentZoom, desiredZoom, 8, dt);
const radius = 20;
camera.position.set(
cameraTarget.x +
radius *
Math.sin(currentPolar) *
Math.sin(currentAzimuth),
cameraTarget.y + radius * Math.cos(currentPolar),
cameraTarget.z +
radius *
Math.sin(currentPolar) *
Math.cos(currentAzimuth)
);
camera.zoom = currentZoom;
camera.lookAt(cameraTarget);
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
// Move each equal portion to its selected station.
pieces.forEach((piece, index) => {
const target = targetForPiece(targetStage, index);
piece.group.position.x = damp(
piece.group.position.x,
target.x,
4.4,
dt
);
piece.group.position.z = damp(
piece.group.position.z,
target.z,
4.4,
dt
);
piece.group.position.y = damp(
piece.group.position.y,
target.y,
4.4,
dt
);
const desiredColor =
targetStage === 0
? rawColor
: targetStage === 1
? bakingColor
: bakedColor;
piece.material.color.lerp(desiredColor, 1 - Math.exp(-3.5 * dt));
const desiredScale =
targetStage === 0 ? 0.89 : targetStage === 1 ? 1.01 : 0.97;
const pulse =
targetStage === 0
? 1 + Math.sin(elapsed * 1.9 + index * 0.8) * 0.018
: 1;
const nextScale = damp(
piece.group.scale.x,
desiredScale * pulse,
4,
dt
);
piece.group.scale.setScalar(nextScale);
const scoreOpacity = targetStage === 0 ? 0 : targetStage === 1 ? 0.7 : 1;
piece.scoreMaterial.opacity = damp(
piece.scoreMaterial.opacity,
scoreOpacity,
4,
dt
);
});
// Selection marker follows the selected portion.
const selected = pieces[selectedPiece];
selection.position.x = damp(
selection.position.x,
selected.group.position.x,
8,
dt
);
selection.position.z = damp(
selection.position.z,
selected.group.position.z,
8,
dt
);
selection.position.y = 1.965;
selection.rotation.y = elapsed * 0.35;
// Oven heat.
const ovenIntensity = targetStage === 1 ? 11 : 4.5;
ovenLight.intensity = damp(
ovenLight.intensity,
ovenIntensity,
3,
dt
);
flames.forEach((flame, index) => {
flame.visible = targetStage === 1;
const flicker = 0.82 + Math.sin(elapsed * 8 + index * 1.7) * 0.18;
flame.scale.y = flicker;
flame.position.y = 1.2 + Math.sin(elapsed * 4 + index) * 0.045;
});
flourParticles.points.visible = targetStage === 0;
emberParticles.points.visible = targetStage === 1;
steamParticles.points.visible = targetStage === 2;
if (targetStage === 0) {
animateParticles(flourParticles, dt, 1.95, 3.8, 0.18, 0.18);
} else if (targetStage === 1) {
animateParticles(emberParticles, dt, 1.25, 3.6, 0.65, 0.12);
} else {
animateParticles(steamParticles, dt, 1.95, 4.4, 0.52, 0.15);
}
updateLabels();
renderer.render(scene, camera);
}
selectPiece(0);
updateStageUI();
animate();
window.setTimeout(() => {
document.getElementById("loading").classList.add("hidden");
}, 500);
</script>
</body>
</html>
```