Prompt specification
Build or customize the Three.js 3D scene "Pompeii-inspired bakery work corner" 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: Pompeii-inspired bakery work corner
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/pompeii-inspired-bakery-work-corner-x2310
Scene Description Prompt:
I'd like to see this as a cutaway Three.js scene: Pompeii-inspired bakery work corner. Create a referenced bakery corner with a rotary mill, dough surface, and oven mouth. Animate ingredients moving through distinct work stations without reproducing an exact excavated interior. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (pompeii-inspired-bakery-work-corner-x2310):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Pompeii-Inspired Bakery Cutaway</title>
<style>
:root {
color-scheme: dark;
--ink: #f5ead4;
--muted: #c8b899;
--panel: rgba(32, 25, 18, 0.78);
--line: rgba(240, 218, 173, 0.22);
--gold: #d6a85d;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cbb996;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
touch-action: none;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.hud {
position: fixed;
z-index: 10;
pointer-events: none;
color: var(--ink);
text-shadow: 0 2px 18px rgba(35, 20, 10, 0.7);
}
#title {
top: 24px;
left: 26px;
max-width: min(470px, calc(100vw - 52px));
}
#title .eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
padding: 6px 10px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(39, 29, 19, 0.54);
color: #f3d9a7;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
#title .dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: #e8a94b;
box-shadow: 0 0 12px #e8a94b;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 48px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
#title p {
max-width: 410px;
margin: 12px 0 0;
color: #efe4d0;
font-size: 12px;
line-height: 1.55;
}
#legend {
left: 26px;
bottom: 24px;
display: flex;
flex-wrap: wrap;
gap: 8px;
max-width: min(570px, calc(100vw - 52px));
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 9px;
background: var(--panel);
color: #e9dcc5;
font-size: 10px;
letter-spacing: 0.045em;
backdrop-filter: blur(9px);
}
.swatch {
width: 8px;
height: 8px;
border-radius: 50%;
box-shadow: 0 0 10px currentColor;
}
.grain { color: #d6a144; background: #d6a144; }
.flour { color: #eee4d2; background: #eee4d2; }
.dough { color: #c88352; background: #c88352; }
.heat { color: #e55e28; background: #e55e28; }
#controls {
position: fixed;
z-index: 12;
right: 22px;
bottom: 22px;
display: flex;
gap: 8px;
}
button {
border: 1px solid rgba(245, 225, 188, 0.28);
border-radius: 9px;
padding: 9px 13px;
background: rgba(35, 27, 19, 0.78);
color: #f5ead4;
font: inherit;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(9px);
transition: background 160ms ease, transform 160ms ease;
}
button:hover {
background: rgba(74, 51, 29, 0.9);
transform: translateY(-1px);
}
#hint {
right: 24px;
top: 24px;
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(35, 27, 19, 0.55);
color: #eadfc9;
font-size: 10px;
letter-spacing: 0.06em;
backdrop-filter: blur(8px);
}
#loading {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
background: #b9a582;
color: #3a291b;
font-family: Georgia, serif;
font-size: 20px;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
#title { top: 17px; left: 17px; }
#title p { display: none; }
#legend { left: 17px; bottom: 17px; gap: 5px; }
.legend-item { padding: 7px 8px; font-size: 9px; }
#hint { display: none; }
#controls { right: 17px; bottom: 17px; }
button { padding: 8px 10px; font-size: 9px; }
}
</style>
</head>
<body>
<div id="stage"></div>
<div id="title" class="hud">
<div class="eyebrow"><span class="dot"></span> Interpretive live reconstruction</div>
<h1>Pompeii-Inspired<br>Bakery Corner</h1>
<p>
A cutaway study of grain milling, kneading, and wood-fired baking.
The arrangement is interpretive rather than a literal copy of an excavated interior.
</p>
</div>
<div id="hint" class="hud">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<div id="legend" class="hud">
<div class="legend-item"><span class="swatch grain"></span>Grain</div>
<div class="legend-item"><span class="swatch flour"></span>Fresh flour</div>
<div class="legend-item"><span class="swatch dough"></span>Worked dough</div>
<div class="legend-item"><span class="swatch heat"></span>Oven heat</div>
</div>
<div id="controls">
<button id="pause" type="button">Pause</button>
<button id="reset" type="button">Reset view</button>
</div>
<div id="loading">Preparing the bakery…</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 stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcbb996);
scene.fog = new THREE.Fog(0xcbb996, 15, 31);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
80
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
stage.appendChild(renderer.domElement);
const clock = new THREE.Clock();
let seed = 84291;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
const materials = {
stone: new THREE.MeshStandardMaterial({
color: 0xa99b82, roughness: 0.94, metalness: 0
}),
paleStone: new THREE.MeshStandardMaterial({
color: 0xc2b394, roughness: 0.96, metalness: 0
}),
darkStone: new THREE.MeshStandardMaterial({
color: 0x756a59, roughness: 0.98, metalness: 0
}),
plaster: new THREE.MeshStandardMaterial({
color: 0xd6c29a, roughness: 0.93, metalness: 0
}),
redPlaster: new THREE.MeshStandardMaterial({
color: 0x994b37, roughness: 0.91, metalness: 0
}),
brick: new THREE.MeshStandardMaterial({
color: 0x98553d, roughness: 0.96, metalness: 0
}),
wood: new THREE.MeshStandardMaterial({
color: 0x70462b, roughness: 0.88, metalness: 0
}),
darkWood: new THREE.MeshStandardMaterial({
color: 0x4a2f1f, roughness: 0.92, metalness: 0
}),
metal: new THREE.MeshStandardMaterial({
color: 0x45423b, roughness: 0.52, metalness: 0.72
}),
ceramic: new THREE.MeshStandardMaterial({
color: 0xb56f45, roughness: 0.72, metalness: 0
}),
charcoal: new THREE.MeshStandardMaterial({
color: 0x211b17, roughness: 1
}),
flour: new THREE.MeshStandardMaterial({
color: 0xf0e6d4, roughness: 1
}),
grain: new THREE.MeshStandardMaterial({
color: 0xd6a347, roughness: 0.83
}),
dough: new THREE.MeshStandardMaterial({
color: 0xd2a06c,
roughness: 0.88,
transparent: true,
opacity: 1
})
};
function mesh(geometry, material, parent = scene) {
const object = new THREE.Mesh(geometry, material);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(w, h, d, material, x, y, z, parent = scene) {
const object = mesh(new THREE.BoxGeometry(w, h, d), material, parent);
object.position.set(x, y, z);
return object;
}
function cylinder(
radiusTop, radiusBottom, height, material,
x, y, z, parent = scene, radialSegments = 32
) {
const object = mesh(
new THREE.CylinderGeometry(
radiusTop, radiusBottom, height, radialSegments
),
material,
parent
);
object.position.set(x, y, z);
return object;
}
function lathe(profile, material, parent = scene, segments = 36) {
const points = profile.map(([r, y]) => new THREE.Vector2(r, y));
return mesh(new THREE.LatheGeometry(points, segments), material, parent);
}
function torus(radius, tube, material, x, y, z, parent = scene) {
const object = mesh(
new THREE.TorusGeometry(radius, tube, 10, 40),
material,
parent
);
object.position.set(x, y, z);
object.rotation.x = Math.PI / 2;
return object;
}
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xffefd0, 0x5a5148, 2.1));
const sun = new THREE.DirectionalLight(0xffe2a8, 4.2);
sun.position.set(-5, 9, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -8;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 26;
sun.shadow.bias = -0.0003;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb6d0d5, 0.65);
fill.position.set(7, 4, -5);
scene.add(fill);
// ---------------------------------------------------------------------
// Procedural museum-style labels
// ---------------------------------------------------------------------
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 makeLabel(number, title, subtitle, accent = "#d5a552") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 168;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 5, 5, 630, 158, 20);
ctx.fillStyle = "rgba(31, 24, 17, 0.88)";
ctx.fill();
ctx.strokeStyle = "rgba(239, 218, 180, 0.36)";
ctx.lineWidth = 2;
ctx.stroke();
ctx.fillStyle = accent;
ctx.font = "700 27px Georgia";
ctx.fillText(number, 28, 52);
ctx.fillStyle = "#fff0d4";
ctx.font = "600 34px Georgia";
ctx.fillText(title, 94, 54);
ctx.fillStyle = "#cdbd9e";
ctx.font = "20px sans-serif";
ctx.fillText(subtitle, 28, 119);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(2.65, 0.695, 1);
sprite.renderOrder = 20;
scene.add(sprite);
return sprite;
}
// ---------------------------------------------------------------------
// Cutaway room and floor
// ---------------------------------------------------------------------
box(11.4, 0.22, 7.25, materials.darkStone, 0, -0.19, 0);
const floorColors = [0xb3a48b, 0xa99c84, 0xc0b091, 0x9f947f, 0xb8aa91];
for (let ix = 0; ix < 13; ix++) {
for (let iz = 0; iz < 8; iz++) {
const tileMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(floorColors[Math.floor(random() * floorColors.length)]),
roughness: 0.98
});
const tile = box(
0.83, 0.075, 0.83,
tileMaterial,
-5.1 + ix * 0.85,
-0.045,
-2.975 + iz * 0.85
);
tile.rotation.y = (random() - 0.5) * 0.012;
}
}
// Full rear wall.
box(11.15, 3.75, 0.24, materials.plaster, 0, 1.84, -3.48);
box(11.05, 1.03, 0.055, materials.redPlaster, 0, 0.56, -3.325);
box(11.08, 0.07, 0.075, materials.paleStone, 0, 1.105, -3.285);
// Left wall: tall rear section and low cutaway foreground section.
box(0.25, 3.75, 3.15, materials.plaster, -5.53, 1.84, -1.88);
box(0.055, 1.03, 3.05, materials.redPlaster, -5.385, 0.56, -1.88);
box(0.25, 0.68, 2.75, materials.plaster, -5.53, 0.31, 1.65);
box(0.055, 0.66, 2.68, materials.redPlaster, -5.385, 0.3, 1.65);
// Roof beam and wall edge stones.
box(11.25, 0.23, 0.31, materials.darkWood, 0, 3.68, -3.38);
box(0.31, 0.23, 6.9, materials.darkWood, -5.38, 3.68, -0.02);
box(0.34, 3.75, 0.25, materials.paleStone, -5.37, 1.84, -0.24);
// Decorative border.
for (let i = 0; i < 16; i++) {
box(
0.52, 0.025, 0.025,
materials.paleStone,
-4.8 + i * 0.64,
1.19,
-3.28
);
}
// Small exposed-brick repair patches.
for (let i = 0; i < 44; i++) {
const brick = box(
0.34 + random() * 0.22,
0.12,
0.035,
materials.brick,
-5.15 + random() * 10.2,
1.35 + random() * 2.05,
-3.325
);
brick.rotation.z = (random() - 0.5) * 0.08;
}
// ---------------------------------------------------------------------
// Rotary mill
// ---------------------------------------------------------------------
const mill = new THREE.Group();
mill.position.set(-3.72, 0, -1.25);
scene.add(mill);
cylinder(0.98, 1.05, 0.25, materials.darkStone, 0, 0.15, 0, mill);
cylinder(0.82, 0.91, 0.18, materials.stone, 0, 0.35, 0, mill);
const millRotor = new THREE.Group();
mill.add(millRotor);
const lowerStone = lathe([
[0.73, 0.00],
[0.72, 0.16],
[0.53, 0.47],
[0.44, 0.78],
[0.45, 1.02],
[0.64, 1.17]
], materials.paleStone, millRotor);
lowerStone.position.y = 0.75;
const upperStone = lathe([
[0.30, 0.00],
[0.38, 0.15],
[0.60, 0.42],
[0.70, 0.64],
[0.71, 0.73]
], materials.stone, millRotor);
upperStone.position.y = 1.96;
// Central shaft and radial drive bars.
cylinder(0.10, 0.10, 1.36, materials.darkWood, 0, 1.67, 0, mill);
torus(0.40, 0.045, materials.darkWood, 0, 2.03, 0, mill);
for (let i = 0; i < 6; i++) {
const angle = (i / 6) * Math.PI * 2;
const bar = box(
0.085, 0.055, 1.17,
materials.darkWood,
Math.sin(angle) * 0.32,
2.015,
Math.cos(angle) * 0.32,
millRotor
);
bar.rotation.y = angle;
}
// Supporting frame.
for (const x of [-0.83, 0.83]) {
for (const z of [-0.56, 0.56]) {
const leg = box(0.13, 1.85, 0.13, materials.darkWood, x, 1.18, z, mill);
leg.rotation.z = x < 0 ? -0.06 : 0.06;
}
}
box(2.05, 0.14, 0.17, materials.darkWood, 0, 2.11, -0.57, mill);
box(2.05, 0.14, 0.17, materials.darkWood, 0, 2.11, 0.57, mill);
// Wooden feed hopper.
const hopper = mesh(
new THREE.CylinderGeometry(0.73, 0.18, 0.62, 32, 1, true),
materials.wood,
mill
);
hopper.position.y = 3.03;
hopper.material.side = THREE.DoubleSide;
torus(0.73, 0.055, materials.darkWood, 0, 3.34, 0, mill);
cylinder(0.69, 0.69, 0.025, materials.darkWood, 0, 3.32, 0, mill);
// Short outlet chute.
const chute = box(
1.03, 0.12, 0.31,
materials.wood,
0.79, 1.06, 0.12,
mill
);
chute.rotation.z = -0.14;
const millLabel = makeLabel(
"01",
"Rotary Mill",
"Hourglass stone pair · powered by a sweep beam"
);
millLabel.position.set(-3.72, 3.98, -1.15);
// ---------------------------------------------------------------------
// Kneading and dough work surface
// ---------------------------------------------------------------------
const table = new THREE.Group();
table.position.set(-0.42, 0, 0.35);
scene.add(table);
box(3.65, 0.18, 1.43, materials.wood, 0, 1.17, 0, table);
box(3.50, 0.06, 1.30, materials.darkWood, 0, 1.07, 0, table);
for (const x of [-1.55, 1.55]) {
for (const z of [-0.54, 0.54]) {
box(0.18, 1.12, 0.18, materials.darkWood, x, 0.53, z, table);
}
}
box(3.18, 0.12, 0.15, materials.darkWood, 0, 0.40, 0, table);
box(0.15, 0.12, 1.03, materials.darkWood, 0, 0.40, 0, table);
// Flour spread on the worktop.
for (let i = 0; i < 11; i++) {
const patch = mesh(
new THREE.CircleGeometry(0.12 + random() * 0.22, 18),
new THREE.MeshStandardMaterial({
color: 0xeee5d5,
roughness: 1,
transparent: true,
opacity: 0.65,
depthWrite: false
}),
table
);
patch.rotation.x = -Math.PI / 2;
patch.position.set(
-0.95 + random() * 2.0,
1.268,
-0.39 + random() * 0.76
);
patch.scale.set(1.3, 0.7 + random() * 0.5, 1);
}
// Ceramic bowl.
const bowl = lathe([
[0.15, 0.00],
[0.24, 0.04],
[0.35, 0.21],
[0.39, 0.28],
[0.34, 0.30],
[0.29, 0.17],
[0.13, 0.04]
], materials.ceramic, table);
bowl.position.set(-1.35, 1.27, -0.14);
// Rolling pin.
const rollingPin = cylinder(
0.12, 0.12, 0.95,
materials.wood,
0.65, 1.36, 0.17,
table
);
rollingPin.rotation.z = Math.PI / 2;
rollingPin.rotation.y = -0.20;
const pinHandle = cylinder(
0.035, 0.035, 0.34,
materials.darkWood,
1.15, 1.36, 0.08,
table
);
pinHandle.rotation.z = Math.PI / 2;
pinHandle.rotation.y = -0.20;
// Static dough pieces for visual continuity.
for (const [x, z, s] of [
[-0.65, 0.17, 0.18],
[0.17, -0.24, 0.14],
[-0.15, 0.39, 0.11]
]) {
const lump = mesh(
new THREE.IcosahedronGeometry(s, 2),
materials.dough,
table
);
lump.position.set(x, 1.31, z);
lump.scale.y = 0.68;
}
// A flour sack tucked beneath the table.
const sack = lathe([
[0.26, 0.00],
[0.43, 0.18],
[0.46, 0.58],
[0.30, 0.84],
[0.18, 0.91],
[0.22, 1.02],
[0.12, 1.08]
], new THREE.MeshStandardMaterial({
color: 0xbba887, roughness: 1
}), table);
sack.position.set(-0.70, 0.03, 0.12);
sack.scale.set(1.1, 1.0, 0.85);
const tableLabel = makeLabel(
"02",
"Dough Surface",
"Mixing, kneading, shaping, and portioning"
);
tableLabel.position.set(-0.45, 2.48, 0.43);
// ---------------------------------------------------------------------
// Masonry oven with a real arched opening
// ---------------------------------------------------------------------
const oven = new THREE.Group();
oven.position.set(3.48, 0, -1.42);
scene.add(oven);
cylinder(1.56, 1.62, 0.42, materials.brick, 0, 0.22, -0.22, oven, 48);
// Rear half of the dome leaves the front open for the mouth.
const domeMaterial = materials.brick.clone();
domeMaterial.side = THREE.DoubleSide;
const dome = mesh(
new THREE.SphereGeometry(
1.47, 40, 22,
Math.PI, Math.PI,
0, Math.PI / 2
),
domeMaterial,
oven
);
dome.position.set(0, 1.25, -0.52);
const facadeShape = new THREE.Shape();
facadeShape.moveTo(-1.50, 0);
facadeShape.lineTo(1.50, 0);
facadeShape.lineTo(1.50, 2.48);
facadeShape.lineTo(-1.50, 2.48);
facadeShape.closePath();
const mouthHole = new THREE.Path();
mouthHole.moveTo(-0.63, 0.10);
mouthHole.lineTo(-0.63, 1.08);
mouthHole.absarc(0, 1.08, 0.63, Math.PI, 0, true);
mouthHole.lineTo(0.63, 0.10);
mouthHole.closePath();
facadeShape.holes.push(mouthHole);
const facade = mesh(
new THREE.ExtrudeGeometry(facadeShape, {
depth: 0.34,
bevelEnabled: false,
curveSegments: 30
}),
materials.redPlaster,
oven
);
facade.position.z = 0.16;
// Dark chamber visible through the opening.
const chamberShape = new THREE.Shape();
chamberShape.moveTo(-0.63, 0.10);
chamberShape.lineTo(-0.63, 1.08);
chamberShape.absarc(0, 1.08, 0.63, Math.PI, 0, true);
chamberShape.lineTo(0.63, 0.10);
chamberShape.closePath();
const chamber = mesh(
new THREE.ShapeGeometry(chamberShape, 30),
materials.charcoal,
oven
);
chamber.position.z = 0.12;
// Masonry courses around the opening.
for (let row = 0; row < 8; row++) {
const y = 0.13 + row * 0.28;
if (y < 1.8) {
box(0.63, 0.17, 0.035, materials.brick, -1.06, y, 0.515, oven);
box(0.63, 0.17, 0.035, materials.brick, 1.06, y, 0.515, oven);
} else {
box(2.92, 0.16, 0.035, materials.brick, 0, y, 0.515, oven);
}
}
// Short chimney.
cylinder(0.30, 0.36, 0.72, materials.brick, 0.43, 2.92, -0.88, oven);
torus(0.31, 0.055, materials.darkStone, 0.43, 3.28, -0.88, oven);
// Oven mouth frame stones.
for (const x of [-0.72, 0.72]) {
box(0.15, 1.22, 0.13, materials.paleStone, x, 0.67, 0.54, oven);
}
// Logs and embers.
const logA = cylinder(0.11, 0.13, 0.90, materials.darkWood, -0.21, 0.20, 0.27, oven);
logA.rotation.z = Math.PI / 2;
logA.rotation.y = 0.22;
const logB = cylinder(0.10, 0.12, 0.78, materials.darkWood, 0.19, 0.20, 0.27, oven);
logB.rotation.z = Math.PI / 2;
logB.rotation.y = -0.30;
const fireLight = new THREE.PointLight(0xff6a22, 4.0, 5.2, 2);
fireLight.position.set(0, 0.60, 0.35);
oven.add(fireLight);
const flames = [];
const flameGeometry = new THREE.ConeGeometry(0.12, 0.54, 7);
const flameMaterial = new THREE.MeshBasicMaterial({
color: 0xff8a2a,
transparent: true,
opacity: 0.78,
depthWrite: false
});
for (let i = 0; i < 9; i++) {
const flame = mesh(flameGeometry, flameMaterial.clone(), oven);
flame.position.set(
-0.42 + random() * 0.84,
0.42 + random() * 0.14,
0.27 + random() * 0.09
);
flame.scale.set(
0.65 + random() * 0.55,
0.65 + random() * 0.8,
0.65 + random() * 0.55
);
flame.castShadow = false;
flames.push(flame);
}
const emberGeometry = new THREE.BufferGeometry();
const emberCount = 34;
const emberPositions = new Float32Array(emberCount * 3);
const emberSeeds = [];
for (let i = 0; i < emberCount; i++) {
emberSeeds.push({
x: -0.46 + random() * 0.92,
z: 0.20 + random() * 0.18,
phase: random(),
speed: 0.30 + random() * 0.36
});
}
emberGeometry.setAttribute(
"position",
new THREE.BufferAttribute(emberPositions, 3)
);
const embers = new THREE.Points(
emberGeometry,
new THREE.PointsMaterial({
color: 0xffa044,
size: 0.045,
transparent: true,
opacity: 0.9,
depthWrite: false
})
);
oven.add(embers);
// Wooden peel leaning beside the oven.
const leaningPeel = new THREE.Group();
leaningPeel.position.set(2.17, 0.02, 0.35);
leaningPeel.rotation.z = -0.38;
leaningPeel.rotation.x = -0.12;
scene.add(leaningPeel);
box(0.62, 0.055, 0.48, materials.wood, 0, 1.04, 0, leaningPeel);
const leaningHandle = cylinder(
0.035, 0.045, 2.25,
materials.darkWood,
0, 1.58, 0,
leaningPeel
);
leaningHandle.rotation.x = -0.12;
const ovenLabel = makeLabel(
"03",
"Wood-Fired Oven",
"Masonry chamber · radiant heat and embers"
);
ovenLabel.position.set(3.48, 3.08, -1.25);
// ---------------------------------------------------------------------
// Grain basket, amphora, and storage
// ---------------------------------------------------------------------
const storage = new THREE.Group();
storage.position.set(-4.87, 0, 1.28);
scene.add(storage);
const basketMaterial = new THREE.MeshStandardMaterial({
color: 0x9b7445,
roughness: 0.98
});
const basket = mesh(
new THREE.CylinderGeometry(0.66, 0.54, 0.50, 24, 1, true),
basketMaterial,
storage
);
basket.position.y = 0.28;
basket.material.side = THREE.DoubleSide;
torus(0.66, 0.055, materials.darkWood, 0, 0.53, 0, storage);
torus(0.58, 0.035, materials.darkWood, 0, 0.19, 0, storage);
const grainMound = mesh(
new THREE.SphereGeometry(0.59, 28, 14),
materials.grain,
storage
);
grainMound.position.y = 0.48;
grainMound.scale.y = 0.26;
for (let i = 0; i < 35; i++) {
const kernel = mesh(
new THREE.SphereGeometry(0.052, 7, 5),
materials.grain,
storage
);
kernel.position.set(
(random() - 0.5) * 0.92,
0.60 + random() * 0.06,
(random() - 0.5) * 0.92
);
kernel.scale.set(1.25, 0.62, 0.78);
kernel.rotation.y = random() * Math.PI;
}
const amphora = lathe([
[0.12, 0.00],
[0.31, 0.12],
[0.43, 0.40],
[0.40, 0.72],
[0.24, 0.95],
[0.16, 1.15],
[0.20, 1.30],
[0.13, 1.38]
], materials.ceramic, storage);
amphora.position.set(-0.65, 0, -0.78);
amphora.scale.set(0.88, 1, 0.88);
const amphoraRim = torus(0.14, 0.035, materials.darkWood, -0.65, 1.38, -0.78, storage);
amphoraRim.rotation.x = 0;
const storageLabel = makeLabel(
"00",
"Stored Grain",
"Wheat kernels awaiting the mill"
);
storageLabel.position.set(-4.82, 1.42, 1.30);
storageLabel.scale.set(2.30, 0.605, 1);
// ---------------------------------------------------------------------
// Animated ingredient paths
// ---------------------------------------------------------------------
const grainPath = new THREE.CatmullRomCurve3([
new THREE.Vector3(-4.90, 0.67, 1.28),
new THREE.Vector3(-4.60, 1.12, 1.18),
new THREE.Vector3(-4.25, 1.90, 0.60),
new THREE.Vector3(-3.95, 2.90, -0.42),
new THREE.Vector3(-3.72, 3.31, -1.22)
]);
const movingGrains = [];
const grainGeometry = new THREE.SphereGeometry(0.064, 8, 6);
for (let i = 0; i < 24; i++) {
const kernel = mesh(grainGeometry, materials.grain);
kernel.scale.set(1.35, 0.65, 0.85);
movingGrains.push({
mesh: kernel,
offset: new THREE.Vector3(
(random() - 0.5) * 0.17,
(random() - 0.5) * 0.10,
(random() - 0.5) * 0.17
),
phase: i / 24
});
}
const flourPath = new THREE.CatmullRomCurve3([
new THREE.Vector3(-2.92, 1.10, -1.12),
new THREE.Vector3(-2.60, 1.00, -0.88),
new THREE.Vector3(-2.25, 1.28, -0.30),
new THREE.Vector3(-1.95, 1.51, 0.10),
new THREE.Vector3(-1.77, 1.49, 0.21)
]);
const flourParticles = [];
const flourGeometry = new THREE.SphereGeometry(0.035, 6, 5);
const flourParticleMaterial = new THREE.MeshStandardMaterial({
color: 0xf5ecdc,
roughness: 1,
transparent: true,
opacity: 0.72
});
for (let i = 0; i < 34; i++) {
const particle = mesh(flourGeometry, flourParticleMaterial);
flourParticles.push({
mesh: particle,
phase: i / 34,
offset: new THREE.Vector3(
(random() - 0.5) * 0.18,
(random() - 0.5) * 0.12,
(random() - 0.5) * 0.18
)
});
}
const millToTable = new THREE.CatmullRomCurve3([
new THREE.Vector3(-2.91, 1.18, -1.10),
new THREE.Vector3(-2.52, 1.37, -0.60),
new THREE.Vector3(-2.10, 1.45, 0.05),
new THREE.Vector3(-1.55, 1.45, 0.24)
]);
const tableToOven = new THREE.CatmullRomCurve3([
new THREE.Vector3(0.18, 1.44, 0.39),
new THREE.Vector3(1.05, 1.43, 0.32),
new THREE.Vector3(1.67, 1.10, -0.08),
new THREE.Vector3(2.40, 0.65, -0.50),
new THREE.Vector3(3.16, 0.34, -0.84),
new THREE.Vector3(3.48, 0.27, -1.12)
]);
const animatedDough = mesh(
new THREE.IcosahedronGeometry(0.26, 3),
materials.dough
);
animatedDough.scale.set(1.15, 0.74, 0.92);
// A peel that appears while the dough is carried to the oven.
const movingPeel = new THREE.Group();
scene.add(movingPeel);
box(0.66, 0.055, 0.48, materials.wood, 0, 0, 0, movingPeel);
const movingHandle = cylinder(
0.035, 0.045, 2.05,
materials.darkWood,
0, 0, 1.14,
movingPeel
);
movingHandle.rotation.x = Math.PI / 2;
// ---------------------------------------------------------------------
// Camera controls implemented directly with pointer events
// ---------------------------------------------------------------------
const controls = {
azimuth: 0.67,
polar: 1.03,
radius: 12.3,
target: new THREE.Vector3(-0.15, 1.28, 0),
dragging: false,
pointerX: 0,
pointerY: 0
};
function updateCamera() {
const sinPolar = Math.sin(controls.polar);
camera.position.set(
controls.target.x + controls.radius * sinPolar * Math.sin(controls.azimuth),
controls.target.y + controls.radius * Math.cos(controls.polar),
controls.target.z + controls.radius * sinPolar * Math.cos(controls.azimuth)
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.azimuth = 0.67;
controls.polar = 1.03;
controls.radius = 12.3;
controls.target.set(-0.15, 1.28, 0);
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.pointerX;
const dy = event.clientY - controls.pointerY;
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
controls.azimuth -= dx * 0.0052;
controls.polar = THREE.MathUtils.clamp(
controls.polar - dy * 0.0045,
0.47,
1.43
);
updateCamera();
});
function endDrag(event) {
controls.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();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
7.4,
18
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
document.getElementById("reset").addEventListener("click", resetCamera);
let paused = false;
const pauseButton = document.getElementById("pause");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
pauseButton.click();
}
if (event.key.toLowerCase() === "r") {
resetCamera();
}
});
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
let elapsed = 0;
const doughCycleLength = 11.5;
function updateDough(time) {
const cycle = (time % doughCycleLength) / doughCycleLength;
animatedDough.visible = true;
movingPeel.visible = false;
const rawColor = new THREE.Color(0xd2a06c);
const bakedColor = new THREE.Color(0xa75d2d);
if (cycle < 0.27) {
// Flour and water become a moving dough portion.
const u = cycle / 0.27;
animatedDough.position.copy(millToTable.getPointAt(u));
animatedDough.rotation.set(
time * 0.5,
time * 0.75,
time * 0.32
);
animatedDough.scale.set(1.10, 0.78, 0.92);
animatedDough.material.color.copy(rawColor);
animatedDough.material.opacity = 1;
} else if (cycle < 0.52) {
// Kneading: travel across the table while repeatedly compressing.
const u = (cycle - 0.27) / 0.25;
const bounce = Math.abs(Math.sin(u * Math.PI * 7));
animatedDough.position.set(
-1.48 + u * 1.66,
1.43 + bounce * 0.045,
0.26 + Math.sin(u * Math.PI * 4) * 0.13
);
animatedDough.rotation.y = time * 0.75;
animatedDough.rotation.z = Math.sin(time * 5) * 0.10;
animatedDough.scale.set(
1.08 + bounce * 0.13,
0.70 - bounce * 0.12,
0.92
);
animatedDough.material.color.copy(rawColor);
animatedDough.material.opacity = 1;
} else if (cycle < 0.94) {
// Carry the shaped portion to the oven on a wooden peel.
const u = (cycle - 0.52) / 0.42;
animatedDough.position.copy(tableToOven.getPointAt(u));
const tangent = tableToOven.getTangentAt(u);
animatedDough.rotation.y = Math.atan2(tangent.x, tangent.z);
animatedDough.rotation.z = 0.04;
const bake = THREE.MathUtils.smoothstep(u, 0.50, 1.0);
animatedDough.material.color.copy(rawColor).lerp(bakedColor, bake);
animatedDough.material.opacity = 1;
animatedDough.scale.set(1.05, 0.72, 0.90);
movingPeel.visible = true;
movingPeel.position.copy(animatedDough.position);
movingPeel.position.y -= 0.20;
movingPeel.rotation.y = Math.atan2(-tangent.x, -tangent.z);
movingPeel.rotation.z = -0.04 * (1 - u);
} else {
// The loaf disappears into the hot chamber.
animatedDough.visible = false;
movingPeel.visible = false;
}
}
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (!paused) elapsed += delta;
// Mill motion.
millRotor.rotation.y = elapsed * 0.31;
upperStone.rotation.y = -elapsed * 0.08;
// Grain travels from storage into the mill hopper.
for (const grain of movingGrains) {
const phase = (elapsed * 0.072 + grain.phase) % 1;
const point = grainPath.getPointAt(phase);
grain.mesh.position.copy(point).add(grain.offset);
grain.mesh.position.y += Math.sin(phase * Math.PI) * 0.05;
grain.mesh.rotation.set(
elapsed * 1.1 + grain.phase * 4,
elapsed * 0.8 + grain.phase * 2,
0
);
const appear = Math.min(1, phase / 0.08, (1 - phase) / 0.08);
grain.mesh.scale.set(1.35 * appear, 0.65 * appear, 0.85 * appear);
}
// Flour falls from the mill chute into the bowl.
for (const particle of flourParticles) {
const phase = (elapsed * 0.17 + particle.phase) % 1;
const point = flourPath.getPointAt(phase);
particle.mesh.position.copy(point).add(particle.offset);
particle.mesh.position.y -= Math.sin(phase * Math.PI) * 0.08;
const size = Math.sin(phase * Math.PI);
particle.mesh.scale.setScalar(0.25 + size * 0.95);
particle.mesh.rotation.set(phase * 4, phase * 6, 0);
}
updateDough(elapsed);
// Fire flicker.
flames.forEach((flame, i) => {
const flicker = 0.78 + Math.sin(elapsed * 9.3 + i * 1.7) * 0.16
+ Math.sin(elapsed * 15.1 + i) * 0.07;
flame.scale.y = 0.70 + flicker * 0.65;
flame.position.x += Math.sin(elapsed * 4.2 + i) * 0.0009;
flame.material.opacity = 0.54 + flicker * 0.23;
});
fireLight.intensity = 3.3 + Math.sin(elapsed * 11.2) * 0.55
+ Math.sin(elapsed * 17.7) * 0.28;
// Rising embers.
for (let i = 0; i < emberCount; i++) {
const seed = emberSeeds[i];
const life = (elapsed * seed.speed + seed.phase) % 1;
emberPositions[i * 3] = seed.x + Math.sin(life * 9 + i) * 0.10;
emberPositions[i * 3 + 1] = 0.35 + life * 1.25;
emberPositions[i * 3 + 2] = seed.z + Math.cos(life * 7 + i) * 0.05;
}
emberGeometry.attributes.position.needsUpdate = true;
// A nearly imperceptible atmospheric movement keeps the scene alive.
sun.position.x = -5 + Math.sin(elapsed * 0.07) * 0.25;
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
updateCamera();
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```