Prompt specification
Build or customize the Three.js 3D scene "Bread dough fermentation window" 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: Bread dough fermentation window
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/bread-dough-fermentation-window-x0879
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: bread dough fermentation window. Compose dough pores beside an enlarged yeast inset and gas-accumulation indicators; connect fermentation to bubbles conceptually without implying the cell-scale and kitchen-scale scenes share magnification.
Working Three.js Starter (bread-dough-fermentation-window-x0879):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Fermentation Window — Voxel Dough Study</title>
<style>
:root {
--ink: #302b29;
--muted: #756b63;
--paper: #f1e8d9;
--orange: #df7048;
--plum: #34374b;
--line: rgba(48, 43, 41, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 42%, #fbf6ec 0%, #eee2d0 62%, #dfcfb9 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#app {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
}
canvas {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
z-index: 0;
}
canvas:active {
cursor: grabbing;
}
.masthead {
position: absolute;
z-index: 5;
top: 28px;
left: 32px;
pointer-events: none;
max-width: min(480px, 44vw);
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 9px;
color: var(--orange);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 28px;
height: 2px;
background: currentColor;
}
h1 {
margin: 0;
font-size: clamp(25px, 3.2vw, 47px);
line-height: 0.98;
letter-spacing: -0.045em;
font-weight: 780;
}
.masthead p {
margin: 12px 0 0;
max-width: 390px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.scale-card {
position: absolute;
z-index: 5;
top: 28px;
right: 28px;
width: 286px;
padding: 16px 17px 15px;
border: 1px solid rgba(48, 43, 41, 0.13);
border-radius: 14px;
background: rgba(250, 245, 235, 0.76);
box-shadow: 0 14px 45px rgba(81, 61, 43, 0.08);
backdrop-filter: blur(12px);
pointer-events: none;
}
.scale-title {
margin-bottom: 12px;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.scale-row {
display: flex;
align-items: flex-start;
gap: 10px;
margin: 8px 0;
color: var(--muted);
font-size: 11px;
line-height: 1.35;
}
.scale-row b {
color: var(--ink);
font-weight: 750;
}
.scale-dot {
flex: 0 0 auto;
width: 11px;
height: 11px;
margin-top: 2px;
border: 2px solid var(--ink);
box-shadow: inset 0 0 0 2px var(--paper);
}
.scale-dot.bulk {
background: #d9a05e;
}
.scale-dot.cell {
background: #e98773;
}
.scale-card p {
margin: 13px 0 0;
padding-top: 12px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10.5px;
line-height: 1.45;
}
.scale-card strong {
color: var(--orange);
font-weight: 780;
}
.help {
position: absolute;
z-index: 5;
left: 28px;
bottom: 24px;
display: flex;
align-items: center;
gap: 12px;
color: var(--muted);
font-size: 11px;
pointer-events: none;
}
.help span {
padding: 9px 12px;
border: 1px solid rgba(48, 43, 41, 0.13);
border-radius: 10px;
background: rgba(250, 245, 235, 0.7);
backdrop-filter: blur(10px);
}
#reset {
pointer-events: auto;
cursor: pointer;
padding: 9px 13px;
border: 1px solid rgba(48, 43, 41, 0.17);
border-radius: 10px;
background: rgba(250, 245, 235, 0.84);
color: var(--ink);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
backdrop-filter: blur(10px);
}
#reset:hover {
background: #fff9ef;
transform: translateY(-1px);
}
#annotations {
position: absolute;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.scene-note {
position: absolute;
min-width: 132px;
max-width: 205px;
padding: 9px 11px;
transform: translate(-50%, -50%);
border: 1px solid rgba(48, 43, 41, 0.15);
border-radius: 10px;
background: rgba(250, 245, 235, 0.87);
box-shadow: 0 9px 24px rgba(76, 53, 34, 0.08);
backdrop-filter: blur(9px);
line-height: 1.15;
}
.scene-note::after {
content: "";
position: absolute;
left: 50%;
bottom: -12px;
width: 1px;
height: 12px;
background: rgba(48, 43, 41, 0.28);
}
.scene-note .kicker {
display: block;
margin-bottom: 4px;
color: var(--orange);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.scene-note strong {
display: block;
font-size: 12px;
font-weight: 780;
letter-spacing: -0.01em;
}
.scene-note small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9.5px;
line-height: 1.25;
}
.process-note {
min-width: 205px;
border-style: dashed;
border-color: rgba(223, 112, 72, 0.72);
background: rgba(255, 244, 231, 0.9);
text-align: center;
}
.process-note::after {
display: none;
}
.process-note strong {
color: #b95031;
font-size: 9px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.process-note small {
color: #8b6c5d;
}
@media (max-width: 760px) {
.masthead {
top: 18px;
left: 18px;
max-width: 72vw;
}
.masthead p {
display: none;
}
.scale-card {
display: none;
}
.help {
left: 16px;
bottom: 14px;
}
.help span {
display: none;
}
.scene-note {
min-width: 104px;
max-width: 145px;
padding: 7px 8px;
}
.scene-note strong {
font-size: 10px;
}
.scene-note small {
display: none;
}
.scene-note .kicker {
font-size: 7px;
}
.process-note {
min-width: 150px;
}
.gauge-note {
display: none !important;
}
}
</style>
</head>
<body>
<main id="app">
<header class="masthead">
<div class="eyebrow">Voxel field note · 03</div>
<h1>Fermentation<br />window</h1>
<p>
A kitchen-scale dough cutaway, an independently enlarged yeast inset,
and qualitative indicators of gas accumulation.
</p>
</header>
<aside class="scale-card" aria-label="Scale key">
<div class="scale-title">Read as two scales</div>
<div class="scale-row">
<i class="scale-dot bulk"></i>
<span><b>Bulk dough</b><br />kitchen-scale cutaway and porous crumb</span>
</div>
<div class="scale-row">
<i class="scale-dot cell"></i>
<span><b>Yeast inset</b><br />enlarged schematic on a separate scale</span>
</div>
<p>
The dashed arc is a <strong>conceptual process link</strong>, not a
spatial path or shared magnification. Bubble icons and the gauge are
explanatory rather than measured.
</p>
</aside>
<div class="help">
<span>Drag to orbit · scroll to zoom · double-click to reset</span>
<button id="reset" type="button">Reset view</button>
</div>
<div id="annotations"></div>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const annotationLayer = document.getElementById("annotations");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0xeee2d0, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel scene of bread dough fermentation, enlarged yeast, and gas accumulation."
);
app.prepend(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.OrthographicCamera(-8, 8, 5, -5, 0.1, 100);
const cameraTarget = new THREE.Vector3(-0.45, -0.1, 0);
let azimuth = 0.34;
let polar = 1.08;
let cameraZoom = 1;
let width = 1;
let height = 1;
const ambient = new THREE.HemisphereLight(0xfff7e9, 0x806c5b, 2.1);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight(0xffe0b6, 3.2);
keyLight.position.set(-5, 10, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xc7d9ed, 1.35);
fillLight.position.set(8, 5, 4);
scene.add(fillLight);
const rimLight = new THREE.PointLight(0xf29a72, 22, 13, 2);
rimLight.position.set(2.5, 3.2, 2.8);
scene.add(rimLight);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const vertexColorMultiplier = new Float32Array(unitBox.attributes.position.count * 3).fill(1);
unitBox.setAttribute("color", new THREE.BufferAttribute(vertexColorMultiplier, 3));
const materials = {
ground: new THREE.MeshStandardMaterial({
color: 0xe9ddcb,
roughness: 1
}),
wood: new THREE.MeshStandardMaterial({
color: 0xa9683f,
roughness: 0.9
}),
woodEdge: new THREE.MeshStandardMaterial({
color: 0x77452e,
roughness: 0.94
}),
woodLight: new THREE.MeshStandardMaterial({
color: 0xc88755,
roughness: 0.92
}),
panel: new THREE.MeshStandardMaterial({
color: 0x303447,
roughness: 0.8
}),
panelInset: new THREE.MeshStandardMaterial({
color: 0x252a3a,
roughness: 0.92
}),
frame: new THREE.MeshStandardMaterial({
color: 0xe8d4ad,
roughness: 0.66
}),
darkFrame: new THREE.MeshStandardMaterial({
color: 0x554c4b,
roughness: 0.82
}),
gauge: new THREE.MeshStandardMaterial({
color: 0xf2e8d4,
roughness: 0.82
}),
orange: new THREE.MeshStandardMaterial({
color: 0xdf7048,
roughness: 0.58,
emissive: 0x6b1f0e,
emissiveIntensity: 0.12
}),
cream: new THREE.MeshStandardMaterial({
color: 0xfff0d1,
roughness: 0.65
})
};
function addBox(
boxWidth,
boxHeight,
boxDepth,
x,
y,
z,
material,
parent = scene,
castShadow = true
) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(boxWidth, boxHeight, boxDepth);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const ground = new THREE.Mesh(new THREE.PlaneGeometry(40, 28), materials.ground);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -2.04;
ground.receiveShadow = true;
scene.add(ground);
// ---------------------------------------------------------------------
// Kitchen-scale dough cutaway
// ---------------------------------------------------------------------
const boardX = -4.1;
addBox(
7.1,
0.26,
3.1,
boardX,
-1.91,
0,
materials.wood
);
addBox(
7.18,
0.12,
0.16,
boardX,
-1.88,
1.52,
materials.woodEdge
);
addBox(
7.18,
0.12,
0.16,
boardX,
-1.88,
-1.52,
materials.woodEdge
);
let seed = 90317;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
for (let i = 0; i < 24; i++) {
const grain = addBox(
0.16 + random() * 0.46,
0.025,
0.035,
boardX - 3.2 + random() * 6.4,
-1.765,
-1.15 + random() * 2.3,
random() > 0.45 ? materials.woodLight : materials.woodEdge,
scene,
false
);
grain.rotation.y = (random() - 0.5) * 0.08;
}
const doughX = -4.1;
const doughBase = -1.76;
const step = 0.42;
const nx = 14;
const ny = 7;
const nz = 4;
const poreKeys = new Set([
"2,1",
"5,4",
"6,4",
"9,2",
"12,4",
"3,5",
"10,1",
"4,2",
"8,4"
]);
const doughPositions = [];
const doughColors = [];
for (let iz = 0; iz < nz; iz++) {
for (let iy = 0; iy < ny; iy++) {
for (let ix = 0; ix < nx; ix++) {
const key = `${ix},${iy}`;
// Missing front-layer voxels become visible pores.
if (iz === nz - 1 && poreKeys.has(key)) continue;
const x = doughX + (ix - (nx - 1) / 2) * step;
const y = doughBase + (iy + 0.5) * step;
const z = (iz - (nz - 1) / 2) * step;
doughPositions.push({ x, y, z });
const color = new THREE.Color(0xd9a361);
color.offsetHSL(
(random() - 0.5) * 0.018,
(random() - 0.5) * 0.07,
(random() - 0.5) * 0.095
);
if (iy === ny - 1) {
color.lerp(new THREE.Color(0xf0bf7f), 0.18);
}
// The voxel behind each opening is darker, suggesting depth.
if (iz === nz - 2 && poreKeys.has(key)) {
color.setHex(0x805038);
}
doughColors.push(color);
}
}
}
const doughMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.93,
vertexColors: true
});
const dough = new THREE.InstancedMesh(
unitBox,
doughMaterial,
doughPositions.length
);
const dummy = new THREE.Object3D();
doughPositions.forEach((position, index) => {
dummy.position.set(position.x, position.y, position.z);
dummy.scale.set(step * 0.955, step * 0.955, step * 0.955);
dummy.updateMatrix();
dough.setMatrixAt(index, dummy.matrix);
dough.setColorAt(index, doughColors[index]);
});
dough.instanceMatrix.needsUpdate = true;
if (dough.instanceColor) dough.instanceColor.needsUpdate = true;
dough.castShadow = true;
dough.receiveShadow = true;
scene.add(dough);
// ---------------------------------------------------------------------
// Enlarged yeast inset: a physically separate framed window
// ---------------------------------------------------------------------
const panelX = 1.45;
const panelY = 0.15;
const panelWidth = 4.2;
const panelHeight = 3.4;
addBox(
panelWidth,
panelHeight,
0.18,
panelX,
panelY,
-0.55,
materials.panel
);
addBox(
panelWidth - 0.3,
panelHeight - 0.3,
0.08,
panelX,
panelY,
-0.43,
materials.panelInset
);
const frameThickness = 0.16;
addBox(
panelWidth + frameThickness,
frameThickness,
0.25,
panelX,
panelY + panelHeight / 2,
-0.25,
materials.frame
);
addBox(
panelWidth + frameThickness,
frameThickness,
0.25,
panelX,
panelY - panelHeight / 2,
-0.25,
materials.frame
);
addBox(
frameThickness,
panelHeight,
0.25,
panelX - panelWidth / 2,
panelY,
-0.25,
materials.frame
);
addBox(
frameThickness,
panelHeight,
0.25,
panelX + panelWidth / 2,
panelY,
-0.25,
materials.frame
);
addBox(
4.55,
0.24,
1.3,
panelX,
-1.83,
-0.25,
materials.darkFrame
);
const yeastPositions = [];
const yeastColors = [];
function appendVoxelEllipsoid(
centerX,
centerY,
centerZ,
radiusX,
radiusY,
radiusZ,
size,
baseColor
) {
for (let iz = -Math.ceil(radiusZ); iz <= Math.ceil(radiusZ); iz++) {
for (let iy = -Math.ceil(radiusY); iy <= Math.ceil(radiusY); iy++) {
for (let ix = -Math.ceil(radiusX); ix <= Math.ceil(radiusX); ix++) {
const normalized =
(ix * ix) / (radiusX * radiusX) +
(iy * iy) / (radiusY * radiusY) +
(iz * iz) / (radiusZ * radiusZ);
if (normalized > 1.03) continue;
yeastPositions.push({
x: centerX + ix * size,
y: centerY + iy * size,
z: centerZ + iz * size
});
const color = new THREE.Color(baseColor);
const rim = normalized > 0.72;
if (rim) color.lerp(new THREE.Color(0xb84f50), 0.38);
else color.lerp(new THREE.Color(0xffc3a4), random() * 0.28);
color.offsetHSL(0, 0, (random() - 0.5) * 0.055);
yeastColors.push(color);
}
}
}
}
appendVoxelEllipsoid(
panelX - 0.72,
panelY - 0.28,
0.1,
4.2,
5.1,
2.2,
0.16,
0xe98773
);
appendVoxelEllipsoid(
panelX + 0.95,
panelY - 0.62,
0.06,
3.1,
3.6,
1.8,
0.16,
0xf09a7f
);
appendVoxelEllipsoid(
panelX + 0.34,
panelY + 0.88,
0.02,
2.0,
2.25,
1.4,
0.16,
0xf4ad91
);
const yeastMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.66,
vertexColors: true
});
const yeastMesh = new THREE.InstancedMesh(
unitBox,
yeastMaterial,
yeastPositions.length
);
yeastPositions.forEach((position, index) => {
dummy.position.set(position.x, position.y, position.z);
dummy.scale.set(0.153, 0.153, 0.153);
dummy.updateMatrix();
yeastMesh.setMatrixAt(index, dummy.matrix);
yeastMesh.setColorAt(index, yeastColors[index]);
});
yeastMesh.instanceMatrix.needsUpdate = true;
if (yeastMesh.instanceColor) yeastMesh.instanceColor.needsUpdate = true;
yeastMesh.castShadow = true;
yeastMesh.receiveShadow = true;
scene.add(yeastMesh);
const nucleusMaterial = new THREE.MeshStandardMaterial({
color: 0x6d2945,
roughness: 0.62
});
addBox(
0.29,
0.37,
0.12,
panelX - 0.72,
panelY - 0.25,
0.54,
nucleusMaterial
);
addBox(
0.22,
0.25,
0.11,
panelX + 0.95,
panelY - 0.63,
0.42,
nucleusMaterial
);
// Tiny block particles suggest metabolic gas production inside the inset.
const insetParticleMaterial = new THREE.MeshBasicMaterial({
color: 0xf5c16c
});
[
[panelX - 1.35, panelY + 0.76, 0.42],
[panelX - 1.08, panelY + 0.95, 0.38],
[panelX + 1.58, panelY + 0.3, 0.35]
].forEach((position) => {
addBox(
0.09,
0.09,
0.09,
position[0],
position[1],
position[2],
insetParticleMaterial,
scene,
false
);
});
// ---------------------------------------------------------------------
// Voxel gas bubbles and qualitative accumulation gauge
// ---------------------------------------------------------------------
const bubbleGroups = [];
function createVoxelBubble(radius, phase) {
const group = new THREE.Group();
const bubbleMaterial = new THREE.MeshBasicMaterial({
color: 0xe98252,
transparent: true,
opacity: 0.72,
depthWrite: false
});
const segment = Math.max(0.055, radius * 0.18);
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const piece = new THREE.Mesh(unitBox, bubbleMaterial);
piece.scale.set(segment * 1.45, segment * 1.12, segment * 1.35);
piece.position.set(
Math.cos(angle) * radius,
Math.sin(angle) * radius,
0
);
piece.rotation.z = angle;
group.add(piece);
}
const highlight = new THREE.Mesh(unitBox, bubbleMaterial);
highlight.scale.set(segment * 1.25, segment * 0.85, segment);
highlight.position.set(-radius * 0.35, radius * 0.38, 0.02);
group.add(highlight);
group.userData.phase = phase;
group.userData.baseY = group.position.y;
bubbleGroups.push(group);
scene.add(group);
return group;
}
const bubbleDefinitions = [
[-5.35, 0.03, 1.0, 0.27],
[-4.72, 0.57, 1.02, 0.36],
[-4.06, -0.03, 1.18, 0.20],
[-2.88, 0.35, 1.16, 0.29],
[-2.02, 0.95, 1.04, 0.39],
[-1.28, 0.41, 1.2, 0.24],
[-0.55, 1.35, 1.05, 0.31]
];
bubbleDefinitions.forEach((definition, index) => {
const bubble = createVoxelBubble(definition[3], index * 0.83);
bubble.position.set(definition[0], definition[1], definition[2]);
bubble.userData.baseY = definition[1];
});
// Short dashed traces inside the dough indicate gas moving into pockets.
const poreTraceMaterial = new THREE.LineDashedMaterial({
color: 0xc9633f,
dashSize: 0.08,
gapSize: 0.075,
transparent: true,
opacity: 0.65
});
function addDashedPath(points, material, parent = scene) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map((point) => new THREE.Vector3(...point))
);
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
parent.add(line);
return line;
}
addDashedPath(
[
[-4.21, -0.89, 0.71],
[-4.45, -0.35, 0.82],
[-4.72, 0.23, 1.02]
],
poreTraceMaterial
);
addDashedPath(
[
[-2.62, -0.89, 0.71],
[-2.42, -0.28, 0.9],
[-2.02, 0.61, 1.04]
],
poreTraceMaterial
);
addDashedPath(
[
[-1.99, -0.47, 0.73],
[-2.03, 0.15, 0.88],
[-1.28, 0.26, 1.2]
],
poreTraceMaterial
);
const gaugeX = 5.2;
const gaugeY = -0.12;
addBox(
1.75,
3.55,
0.16,
gaugeX,
gaugeY,
-0.25,
materials.gauge
);
addBox(
1.95,
0.14,
0.3,
gaugeX,
gaugeY + 1.79,
-0.12,
materials.darkFrame
);
addBox(
1.95,
0.14,
0.3,
gaugeX,
gaugeY - 1.79,
-0.12,
materials.darkFrame
);
addBox(
0.14,
3.55,
0.3,
gaugeX - 0.91,
gaugeY,
-0.12,
materials.darkFrame
);
addBox(
0.14,
3.55,
0.3,
gaugeX + 0.91,
gaugeY,
-0.12,
materials.darkFrame
);
addBox(
2.0,
0.22,
1.0,
gaugeX,
-1.91,
-0.15,
materials.darkFrame
);
const activeSegments = [];
for (let i = 0; i < 5; i++) {
const active = i < 3;
const segmentMaterial = active
? new THREE.MeshStandardMaterial({
color: 0xe5794d,
roughness: 0.48,
emissive: 0x8e2f16,
emissiveIntensity: 0.18
})
: new THREE.MeshStandardMaterial({
color: 0xd8ccb5,
roughness: 0.86
});
const segment = addBox(
0.98,
0.32,
0.2,
gaugeX,
gaugeY - 1.13 + i * 0.54,
-0.03,
segmentMaterial
);
if (active) activeSegments.push(segmentMaterial);
}
// ---------------------------------------------------------------------
// Conceptual connector: explicitly a process diagram, not a spatial path
// ---------------------------------------------------------------------
const conceptMaterial = new THREE.LineDashedMaterial({
color: 0xd86640,
dashSize: 0.16,
gapSize: 0.13,
transparent: true,
opacity: 0.9,
depthTest: false
});
const conceptCurve = new THREE.QuadraticBezierCurve3(
new THREE.Vector3(3.25, 2.12, -0.05),
new THREE.Vector3(1.05, 3.75, 0.3),
new THREE.Vector3(-0.78, 1.67, 1.0)
);
const conceptGeometry = new THREE.BufferGeometry().setFromPoints(
conceptCurve.getPoints(64)
);
const conceptLine = new THREE.Line(conceptGeometry, conceptMaterial);
conceptLine.computeLineDistances();
conceptLine.renderOrder = 8;
scene.add(conceptLine);
const endpoint = conceptCurve.getPoint(1);
const previous = conceptCurve.getPoint(0.965);
const arrowDirection = endpoint.clone().sub(previous).normalize();
const arrowSide = new THREE.Vector3(
-arrowDirection.y,
arrowDirection.x,
0
).normalize();
const arrowMaterial = new THREE.MeshBasicMaterial({
color: 0xd86640,
depthTest: false
});
addBox(
0.13,
0.13,
0.13,
endpoint.x,
endpoint.y,
endpoint.z,
arrowMaterial,
scene,
false
).renderOrder = 8;
addBox(
0.1,
0.1,
0.1,
endpoint.x - arrowDirection.x * 0.13 + arrowSide.x * 0.09,
endpoint.y - arrowDirection.y * 0.13 + arrowSide.y * 0.09,
endpoint.z,
arrowMaterial,
scene,
false
).renderOrder = 8;
addBox(
0.1,
0.1,
0.1,
endpoint.x - arrowDirection.x * 0.13 - arrowSide.x * 0.09,
endpoint.y - arrowDirection.y * 0.13 - arrowSide.y * 0.09,
endpoint.z,
arrowMaterial,
scene,
false
).renderOrder = 8;
// ---------------------------------------------------------------------
// Screen-space annotations projected from world anchors
// ---------------------------------------------------------------------
const annotations = [];
function addAnnotation({
className = "",
kicker,
title,
detail,
anchor,
offsetX = 0,
offsetY = 0
}) {
const element = document.createElement("div");
element.className = `scene-note ${className}`.trim();
element.innerHTML = `
<span class="kicker">${kicker}</span>
<strong>${title}</strong>
<small>${detail}</small>
`;
annotationLayer.appendChild(element);
annotations.push({
element,
anchor: new THREE.Vector3(...anchor),
offsetX,
offsetY
});
}
addAnnotation({
kicker: "01 / Kitchen view",
title: "Bulk dough",
detail: "Porous crumb at kitchen scale",
anchor: [-4.15, 1.55, 0.8],
offsetX: -40,
offsetY: -37
});
addAnnotation({
kicker: "02 / Enlarged schematic",
title: "Yeast detail",
detail: "Separate cell-scale inset",
anchor: [1.45, 2.08, -0.2],
offsetX: 0,
offsetY: -40
});
addAnnotation({
kicker: "03 / Gas accumulation",
title: "CO₂ pockets",
detail: "Illustrative bubbles, not measured size",
anchor: [-2.05, 1.48, 1.12],
offsetX: -10,
offsetY: 40
});
addAnnotation({
className: "gauge-note",
kicker: "Qualitative indicator",
title: "Gas load",
detail: "Three active states shown",
anchor: [5.2, 1.9, 0],
offsetX: 0,
offsetY: -38
});
addAnnotation({
className: "process-note",
kicker: "Process diagram",
title: "Conceptual link only",
detail: "Fermentation → gas · not a spatial path",
anchor: [1.1, 3.18, 0.28],
offsetX: 0,
offsetY: -18
});
const projected = new THREE.Vector3();
function updateAnnotations() {
annotations.forEach((annotation) => {
projected.copy(annotation.anchor).project(camera);
const x = (projected.x * 0.5 + 0.5) * width + annotation.offsetX;
const y = (-projected.y * 0.5 + 0.5) * height + annotation.offsetY;
annotation.element.style.left = `${x}px`;
annotation.element.style.top = `${y}px`;
annotation.element.style.visibility =
projected.z > -1 && projected.z < 1 ? "visible" : "hidden";
});
}
// ---------------------------------------------------------------------
// Direct camera controls — no external controls/addons
// ---------------------------------------------------------------------
function updateCamera() {
const radius = 20;
camera.position.set(
cameraTarget.x + radius * Math.sin(polar) * Math.sin(azimuth),
cameraTarget.y + radius * Math.cos(polar),
cameraTarget.z + radius * Math.sin(polar) * Math.cos(azimuth)
);
camera.lookAt(cameraTarget);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
updateAnnotations();
}
function resetView() {
azimuth = 0.34;
polar = 1.08;
cameraZoom = 1;
updateCamera();
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
azimuth -= deltaX * 0.006;
polar = THREE.MathUtils.clamp(polar + deltaY * 0.005, 0.55, 1.42);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (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();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.001),
0.72,
2.25
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.getElementById("reset").addEventListener("click", resetView);
function resize() {
width = app.clientWidth;
height = app.clientHeight;
renderer.setSize(width, height, false);
const aspect = width / height;
const viewHeight = Math.max(9.3, 15.2 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
updateCamera();
}
window.addEventListener("resize", resize);
resize();
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
bubbleGroups.forEach((bubble, index) => {
const phase = bubble.userData.phase;
const baseY = bubble.userData.baseY;
bubble.position.y = baseY + Math.sin(elapsed * 1.25 + phase) * 0.075;
bubble.position.x +=
Math.sin(elapsed * 0.42 + phase) * 0.00045;
const pulse = 1 + Math.sin(elapsed * 1.9 + phase) * 0.045;
bubble.scale.setScalar(pulse);
});
const yeastPulse = 1 + Math.sin(elapsed * 0.9) * 0.006;
yeastMesh.scale.set(yeastPulse, yeastPulse, yeastPulse);
activeSegments.forEach((material, index) => {
material.emissiveIntensity =
0.15 + Math.sin(elapsed * 1.5 + index * 0.55) * 0.055;
});
conceptMaterial.opacity = 0.78 + Math.sin(elapsed * 1.7) * 0.12;
renderer.render(scene, camera);
});
</script>
</body>
</html>
```