Prompt specification
Build or customize the Three.js 3D scene "Food preservation museum shelf" 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: Food preservation museum shelf
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/food-preservation-museum-shelf-x0107
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: food preservation museum shelf. Arrange labeled exhibits for drying, cooling, and fermentation, each with representative foods and a process diagram; animate one characteristic change at a time for comparison. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (food-preservation-museum-shelf-x0107):
```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="#d8cdb8">
<title>Food Preservation Museum — Voxel Shelf</title>
<style>
:root {
--ink: #26312b;
--paper: #f5ecd9;
--paper-2: #e9ddc7;
--muted: #6c7168;
--line: rgba(38, 49, 43, 0.18);
--dry: #cf553d;
--cool: #4b9cac;
--ferment: #8d8741;
--shadow: 0 16px 50px rgba(43, 38, 28, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8cdb8;
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%;
cursor: grab;
touch-action: none;
outline: none;
}
#scene canvas:active {
cursor: grabbing;
}
.masthead {
position: fixed;
z-index: 5;
top: 24px;
left: 26px;
max-width: 560px;
pointer-events: none;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
padding: 7px 10px;
border: 1px solid rgba(38, 49, 43, 0.26);
background: rgba(245, 236, 217, 0.8);
box-shadow: 4px 4px 0 rgba(38, 49, 43, 0.12);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.eyebrow::before {
width: 7px;
height: 7px;
background: var(--dry);
content: "";
box-shadow: 9px 0 0 var(--cool), 18px 0 0 var(--ferment);
margin-right: 18px;
}
h1 {
max-width: 500px;
margin: 0;
font-size: clamp(30px, 4vw, 54px);
font-weight: 850;
line-height: 0.98;
letter-spacing: -0.055em;
}
.masthead p {
max-width: 430px;
margin: 12px 0 0;
color: #505b54;
font-size: 13px;
font-weight: 600;
line-height: 1.5;
}
.camera-hint {
position: fixed;
z-index: 5;
top: 25px;
right: 25px;
display: flex;
align-items: center;
gap: 10px;
padding: 9px 12px;
border: 1px solid rgba(38, 49, 43, 0.18);
background: rgba(245, 236, 217, 0.78);
color: #526059;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(8px);
}
.mouse-icon {
position: relative;
width: 17px;
height: 23px;
border: 2px solid currentColor;
border-radius: 8px;
}
.mouse-icon::before {
position: absolute;
top: 4px;
left: 6px;
width: 2px;
height: 5px;
background: currentColor;
content: "";
}
.control-deck {
position: fixed;
z-index: 10;
left: 50%;
bottom: 20px;
width: min(1080px, calc(100vw - 32px));
transform: translateX(-50%);
border: 1px solid rgba(38, 49, 43, 0.25);
background: rgba(245, 236, 217, 0.94);
box-shadow: var(--shadow), 6px 6px 0 rgba(38, 49, 43, 0.13);
backdrop-filter: blur(14px);
}
.deck-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 11px 15px 9px;
border-bottom: 1px solid var(--line);
}
.deck-title {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.deck-note {
color: var(--muted);
font-size: 11px;
font-weight: 650;
}
.mode-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 9px;
padding: 10px 12px 8px;
}
.mode-button {
position: relative;
display: grid;
grid-template-columns: 34px 1fr auto;
grid-template-rows: auto auto;
gap: 1px 10px;
align-items: center;
min-width: 0;
padding: 12px 13px;
border: 1px solid rgba(38, 49, 43, 0.2);
border-radius: 2px;
background: rgba(255, 255, 255, 0.38);
color: var(--ink);
text-align: left;
cursor: pointer;
transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}
.mode-button:hover {
transform: translateY(-2px);
border-color: rgba(38, 49, 43, 0.48);
background: rgba(255, 255, 255, 0.7);
}
.mode-button:focus-visible,
.action-button:focus-visible {
outline: 3px solid rgba(38, 49, 43, 0.42);
outline-offset: 2px;
}
.mode-button.active {
color: #fffdf5;
border-color: var(--mode-color);
background: var(--mode-color);
box-shadow: 4px 4px 0 rgba(38, 49, 43, 0.17);
transform: translate(-1px, -1px);
}
.mode-number {
grid-row: 1 / 3;
display: grid;
width: 30px;
height: 30px;
place-items: center;
border: 1px solid currentColor;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 900;
}
.mode-name {
align-self: end;
font-size: 14px;
font-weight: 850;
}
.mode-subtitle {
align-self: start;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.active .mode-subtitle {
color: rgba(255, 255, 255, 0.76);
}
.mode-value {
grid-row: 1 / 3;
min-width: 76px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 17px;
font-weight: 900;
text-align: right;
letter-spacing: -0.05em;
}
.deck-actions {
display: grid;
grid-template-columns: auto auto 1fr;
align-items: center;
gap: 9px;
padding: 0 12px 11px;
}
.action-button {
padding: 9px 12px;
border: 1px solid rgba(38, 49, 43, 0.35);
border-radius: 1px;
background: var(--ink);
color: var(--paper);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.06em;
text-transform: uppercase;
cursor: pointer;
}
.action-button.secondary {
background: transparent;
color: var(--ink);
}
.action-button:hover {
background: #3b4a42;
color: white;
}
.action-button.secondary:hover {
background: rgba(38, 49, 43, 0.09);
color: var(--ink);
}
.progress-track {
position: relative;
height: 7px;
overflow: hidden;
border: 1px solid rgba(38, 49, 43, 0.25);
background: rgba(38, 49, 43, 0.09);
}
#progress-fill {
width: 0;
height: 100%;
background: var(--ink);
transition: width 80ms linear;
}
.status-line {
margin: 7px 0 0;
color: #59635d;
font-size: 10px;
font-weight: 650;
text-align: center;
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #d8cdb8;
color: var(--ink);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
font-weight: 900;
letter-spacing: 0.14em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.masthead {
top: 15px;
left: 15px;
}
.masthead p,
.camera-hint {
display: none;
}
h1 {
font-size: 32px;
}
.eyebrow {
margin-bottom: 7px;
font-size: 8px;
}
.control-deck {
bottom: 10px;
width: calc(100vw - 18px);
}
.deck-header {
padding: 8px 10px;
}
.deck-note {
display: none;
}
.mode-grid {
gap: 5px;
padding: 7px;
}
.mode-button {
grid-template-columns: 1fr;
grid-template-rows: auto auto auto;
gap: 3px;
padding: 9px 7px;
}
.mode-number {
display: none;
}
.mode-value {
grid-row: 3;
min-width: 0;
font-size: 14px;
text-align: left;
}
.deck-actions {
grid-template-columns: 1fr 1fr;
gap: 6px;
padding: 0 7px 8px;
}
.progress-track {
grid-column: 1 / 3;
grid-row: 2;
}
.status-line {
grid-column: 1 / 3;
font-size: 9px;
}
}
@media (prefers-reduced-motion: reduce) {
* {
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive voxel food preservation museum shelf"></main>
<header class="masthead">
<div class="eyebrow">Food Preservation Museum</div>
<h1>Three ways to hold time.</h1>
<p>
Compare drying, cooling, and fermentation on one museum shelf.
Only one characteristic changes at a time.
</p>
</header>
<aside class="camera-hint" aria-hidden="true">
<span class="mouse-icon"></span>
DRAG TO ORBIT · SCROLL TO ZOOM
</aside>
<section class="control-deck" aria-label="Comparison controls">
<div class="deck-header">
<span class="deck-title">Controlled Comparison / One Change at a Time</span>
<span class="deck-note">Select an exhibit to replay its transformation</span>
</div>
<div class="mode-grid">
<button class="mode-button" type="button" data-mode="dry" style="--mode-color: var(--dry)">
<span class="mode-number">01</span>
<span class="mode-name">Drying</span>
<span class="mode-subtitle">Moisture loss</span>
<strong class="mode-value" id="dry-value">68%</strong>
</button>
<button class="mode-button" type="button" data-mode="cool" style="--mode-color: var(--cool)">
<span class="mode-number">02</span>
<span class="mode-name">Cooling</span>
<span class="mode-subtitle">Temperature fall</span>
<strong class="mode-value" id="cool-value">12°C</strong>
</button>
<button class="mode-button" type="button" data-mode="ferment" style="--mode-color: var(--ferment)">
<span class="mode-number">03</span>
<span class="mode-name">Fermentation</span>
<span class="mode-subtitle">CO₂ activity</span>
<strong class="mode-value" id="ferment-value">0%</strong>
</button>
</div>
<div class="deck-actions">
<button class="action-button" type="button" id="auto-button">▶ Run comparison</button>
<button class="action-button secondary" type="button" id="reset-button">Reset shelf</button>
<div class="progress-track" aria-hidden="true">
<div id="progress-fill"></div>
</div>
<p class="status-line" id="status" aria-live="polite">
Choose a method, or run the full three-stage comparison.
</p>
</div>
</section>
<div class="loading" id="loading">Building the preservation gallery…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneRoot = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const statusLine = document.querySelector("#status");
const progressFill = document.querySelector("#progress-fill");
const autoButton = document.querySelector("#auto-button");
const resetButton = document.querySelector("#reset-button");
const modeButtons = [...document.querySelectorAll(".mode-button")];
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Voxel museum shelf with drying, cooling, and fermentation exhibits"
);
sceneRoot.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d8cdb8");
scene.fog = new THREE.Fog("#d8cdb8", 29, 52);
const camera = new THREE.OrthographicCamera(-10, 10, 6, -6, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 3.45, 0);
const controls = {
yaw: 0.20,
pitch: 0.25,
zoom: 1,
dragging: false,
lastX: 0,
lastY: 0
};
function updateCamera() {
const radius = 25;
camera.position.set(
cameraTarget.x + Math.sin(controls.yaw) * Math.cos(controls.pitch) * radius,
cameraTarget.y + Math.sin(controls.pitch) * radius,
cameraTarget.z + Math.cos(controls.yaw) * Math.cos(controls.pitch) * radius
);
camera.lookAt(cameraTarget);
camera.zoom = controls.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = Math.max(10.7, 18.8 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
updateCamera();
renderer.domElement.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
controls.yaw = THREE.MathUtils.clamp(controls.yaw - dx * 0.005, -0.66, 0.66);
controls.pitch = THREE.MathUtils.clamp(controls.pitch + dy * 0.004, 0.08, 0.66);
updateCamera();
});
function stopDragging(event) {
controls.dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.zoom = THREE.MathUtils.clamp(
controls.zoom * Math.exp(-event.deltaY * 0.001),
0.76,
1.8
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
controls.yaw = 0.20;
controls.pitch = 0.25;
controls.zoom = 1;
updateCamera();
});
const hemi = new THREE.HemisphereLight("#fff7e8", "#665743", 2.25);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight("#fff1d5", 3.4);
keyLight.position.set(-8, 15, 11);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -15;
keyLight.shadow.camera.right = 15;
keyLight.shadow.camera.top = 14;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 42;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight("#b7d4d3", 1.3);
rimLight.position.set(12, 8, -8);
scene.add(rimLight);
const warmLight = new THREE.PointLight("#ffc88c", 13, 16, 2);
warmLight.position.set(-7, 5, 4);
scene.add(warmLight);
const materialCache = new Map();
function getMaterial(color, options = {}) {
const key = `${color}:${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.78,
metalness: options.metalness ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
depthWrite: options.depthWrite ?? true,
emissive: options.emissive ?? "#000000",
emissiveIntensity: options.emissiveIntensity ?? 0
})
);
}
return materialCache.get(key);
}
function box(parent, width, height, depth, x, y, z, color, options = {}) {
const geometry = new THREE.BoxGeometry(width, height, depth);
const material = options.material ?? getMaterial(color, options);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
function group(parent, x = 0, y = 0, z = 0) {
const result = new THREE.Group();
result.position.set(x, y, z);
parent.add(result);
return result;
}
function makeCanvasTexture(width, height, draw) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
draw(context, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.needsUpdate = true;
return { canvas, context, texture };
}
function makeInfoPanel(title, subtitle, accent, width, height) {
const { texture } = makeCanvasTexture(1024, 300, (ctx, w, h) => {
ctx.fillStyle = "#f4ead6";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 25, h);
ctx.fillRect(38, 25, 150, 8);
ctx.strokeStyle = "rgba(38,49,43,0.22)";
ctx.lineWidth = 5;
ctx.strokeRect(2, 2, w - 4, h - 4);
ctx.fillStyle = "#26312b";
ctx.font = "900 76px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.textBaseline = "middle";
ctx.fillText(title, 38, 112);
ctx.fillStyle = "#606960";
ctx.font = "700 32px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.fillText(subtitle, 40, 196);
ctx.fillStyle = accent;
ctx.fillRect(40, 245, 250, 10);
ctx.fillStyle = "#7c8078";
ctx.font = "700 19px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.fillText("PRESERVATION STUDY", 320, 251);
});
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
toneMapped: false
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
mesh.position.z = -1.64;
scene.add(mesh);
return mesh;
}
function makeMiniLabel(text, color, width = 0.82, height = 0.30) {
const { texture } = makeCanvasTexture(256, 96, (ctx, w, h) => {
ctx.fillStyle = "#f4ead6";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = color;
ctx.fillRect(0, 0, 12, h);
ctx.strokeStyle = "rgba(38,49,43,0.25)";
ctx.lineWidth = 4;
ctx.strokeRect(2, 2, w - 4, h - 4);
ctx.fillStyle = "#26312b";
ctx.font = "900 35px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, w / 2 + 4, h / 2 + 2);
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture, transparent: true, toneMapped: false })
);
return mesh;
}
function makeMetricPanel(x, accent) {
const panel = makeCanvasTexture(1024, 180, () => {});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(4.65, 0.62),
new THREE.MeshBasicMaterial({
map: panel.texture,
transparent: true,
toneMapped: false
})
);
mesh.position.set(x, 5.28, -1.61);
scene.add(mesh);
return {
...panel,
mesh,
accent,
lastValue: ""
};
}
function updateMetricPanel(panel, label, value, detail) {
const key = `${label}|${value}|${detail}`;
if (panel.lastValue === key) return;
panel.lastValue = key;
const ctx = panel.context;
const w = panel.canvas.width;
const h = panel.canvas.height;
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#26312b";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = panel.accent;
ctx.fillRect(0, 0, 20, h);
ctx.fillStyle = "#f4ead6";
ctx.font = "900 31px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.textBaseline = "middle";
ctx.fillText(label, 45, 52);
ctx.fillStyle = "#aeb8af";
ctx.font = "700 22px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.fillText(detail, 45, 116);
ctx.textAlign = "right";
ctx.fillStyle = "#fff8e8";
ctx.font = "900 61px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.fillText(value, w - 40, 80);
ctx.textAlign = "left";
panel.texture.needsUpdate = true;
}
function addProcess(parent, x, steps, colors, icons) {
const process = group(parent, x);
box(process, 4.42, 1.60, 0.10, 0, 3.97, -1.57, "#e8dcc6", {
roughness: 0.9
});
const positions = [-1.34, 0, 1.34];
positions.forEach((nodeX, index) => {
box(process, 0.64, 0.64, 0.20, nodeX, 4.28, -1.38, colors[index]);
if (icons[index] === "sun") {
box(process, 0.25, 0.25, 0.08, nodeX, 4.28, -1.24, "#fff1a2");
box(process, 0.42, 0.07, 0.07, nodeX, 4.28, -1.20, "#f2b84b");
box(process, 0.07, 0.42, 0.07, nodeX, 4.28, -1.20, "#f2b84b");
} else if (icons[index] === "heat") {
box(process, 0.30, 0.18, 0.08, nodeX, 4.20, -1.24, "#ffe6a0");
box(process, 0.20, 0.22, 0.08, nodeX, 4.40, -1.24, "#f16b3d");
} else if (icons[index] === "air") {
box(process, 0.43, 0.07, 0.07, nodeX, 4.37, -1.23, "#d9f1ee");
box(process, 0.32, 0.07, 0.07, nodeX + 0.04, 4.27, -1.23, "#d9f1ee");
box(process, 0.25, 0.07, 0.07, nodeX - 0.05, 4.17, -1.23, "#d9f1ee");
} else if (icons[index] === "ice") {
box(process, 0.31, 0.31, 0.08, nodeX, 4.28, -1.23, "#eafaff", {
transparent: true,
opacity: 0.78,
roughness: 0.15
});
box(process, 0.08, 0.43, 0.07, nodeX, 4.28, -1.18, "#bce4e8");
box(process, 0.43, 0.08, 0.07, nodeX, 4.28, -1.18, "#bce4e8");
} else if (icons[index] === "chill") {
box(process, 0.36, 0.13, 0.08, nodeX, 4.23, -1.23, "#dff6f2");
box(process, 0.13, 0.36, 0.08, nodeX, 4.28, -1.23, "#dff6f2");
} else if (icons[index] === "store") {
box(process, 0.42, 0.42, 0.08, nodeX, 4.28, -1.23, "#b7d8dc");
box(process, 0.07, 0.35, 0.08, nodeX, 4.28, -1.17, "#f4ead6");
box(process, 0.28, 0.07, 0.08, nodeX, 4.28, -1.17, "#f4ead6");
} else if (icons[index] === "salt") {
for (let i = 0; i < 5; i++) {
box(
process,
0.07,
0.07,
0.07,
nodeX - 0.15 + i * 0.075,
4.20 + (i % 2) * 0.16,
-1.22,
"#fff8d5"
);
}
} else if (icons[index] === "seal") {
box(process, 0.46, 0.11, 0.08, nodeX, 4.33, -1.23, "#b49a63");
box(process, 0.38, 0.08, 0.08, nodeX, 4.18, -1.23, "#d4bb85");
} else if (icons[index] === "co2") {
box(process, 0.15, 0.15, 0.08, nodeX - 0.10, 4.24, -1.22, "#ead87a");
box(process, 0.11, 0.11, 0.08, nodeX + 0.12, 4.39, -1.22, "#f3e69e");
box(process, 0.08, 0.08, 0.08, nodeX + 0.03, 4.11, -1.22, "#d1bd56");
}
const label = makeMiniLabel(steps[index], colors[index]);
label.position.set(nodeX, 3.62, -1.43);
process.add(label);
});
[-0.67, 0.67].forEach((arrowX) => {
box(process, 0.31, 0.08, 0.08, arrowX - 0.04, 4.28, -1.29, "#6f746c");
box(process, 0.10, 0.10, 0.08, arrowX + 0.13, 4.33, -1.29, "#6f746c");
box(process, 0.10, 0.10, 0.08, arrowX + 0.13, 4.23, -1.29, "#6f746c");
});
}
function makeFish(parent, x, y, z, scale, bodyMaterial, dried = false) {
const fish = group(parent, x, y, z);
fish.scale.setScalar(scale);
box(fish, 0.78, 0.28, 0.25, 0, 0, 0, bodyMaterial);
box(fish, 0.25, 0.23, 0.23, 0.47, 0.01, 0, bodyMaterial);
box(fish, 0.28, 0.12, 0.08, -0.50, 0.08, 0, dried ? "#8f7550" : "#8fa8aa");
box(fish, 0.25, 0.12, 0.08, -0.48, -0.08, 0, dried ? "#8f7550" : "#8fa8aa");
box(fish, 0.11, 0.07, 0.06, 0.58, 0.07, 0.13, "#26312b");
box(fish, 0.44, 0.07, 0.25, -0.03, 0.16, 0, dried ? "#b38d57" : "#c6d8d8");
if (dried) {
for (let i = 0; i < 4; i++) {
box(fish, 0.05, 0.30, 0.26, -0.22 + i * 0.15, 0, 0, "#8e704b");
}
}
return fish;
}
function makeChili(parent, x, y, z, rotation, material) {
const chili = group(parent, x, y, z);
chili.rotation.z = rotation;
box(chili, 0.13, 0.17, 0.15, 0, 0.48, 0, "#638044");
box(chili, 0.24, 0.42, 0.22, 0, 0.17, 0, material);
box(chili, 0.16, 0.20, 0.17, 0.02, -0.12, 0, material);
box(chili, 0.10, 0.13, 0.12, 0.03, -0.27, 0, material);
return chili;
}
// Architecture and tiled museum floor.
box(scene, 26, 0.28, 13, 0, -0.16, 0.5, "#c6b89e", { roughness: 0.95 });
for (let x = -12; x <= 12; x += 2) {
box(scene, 0.035, 0.025, 12.6, x, 0.002, 0.5, "#aea38e", { castShadow: false });
}
for (let z = -5; z <= 6; z += 2) {
box(scene, 25.5, 0.025, 0.035, 0, 0.002, z + 0.5, "#aea38e", { castShadow: false });
}
box(scene, 18.4, 7.65, 0.34, 0, 4.05, -2.22, "#8a6442");
box(scene, 19.0, 0.36, 2.00, 0, 8.08, -1.35, "#755137");
box(scene, 18.2, 0.46, 3.20, 0, 0.72, -0.38, "#765238");
box(scene, 18.3, 0.13, 3.27, 0, 0.99, -0.38, "#a57a4e");
const bayCenters = [-5.55, 0, 5.55];
const bayColors = ["#ead8b4", "#d5e1dc", "#e2d6c5"];
bayCenters.forEach((x, index) => {
box(scene, 5.22, 6.50, 0.18, x, 4.15, -1.98, bayColors[index]);
box(scene, 4.92, 0.14, 2.28, x, 1.10, -0.10, "#d9c29b");
});
[-8.55, -2.78, 2.78, 8.55].forEach((x) => {
box(scene, 0.32, 6.68, 1.72, x, 4.22, -1.16, "#8b6241");
box(scene, 0.40, 0.17, 1.82, x, 7.50, -1.16, "#b18455");
});
const topPlaque = makeCanvasTexture(1024, 180, (ctx, w, h) => {
ctx.fillStyle = "#26312b";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#ead9b5";
ctx.font = "900 43px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("GALLERY 03 / PRESERVATION", w / 2, 73);
ctx.fillStyle = "#b68a58";
ctx.fillRect(w / 2 - 150, 125, 300, 7);
});
const plaqueMesh = new THREE.Mesh(
new THREE.PlaneGeometry(7.1, 0.92),
new THREE.MeshBasicMaterial({ map: topPlaque.texture, transparent: true, toneMapped: false })
);
plaqueMesh.position.set(0, 7.16, -1.72);
scene.add(plaqueMesh);
const dryingLabel = makeInfoPanel(
"01 DRYING",
"CHILLI PEPPERS + SALT FISH",
"#cf553d",
4.75,
1.10
);
dryingLabel.position.set(-5.55, 6.30, -1.64);
const coolingLabel = makeInfoPanel(
"02 COOLING",
"FRESH FISH + MILK + ICE",
"#4b9cac",
4.75,
1.10
);
coolingLabel.position.set(0, 6.30, -1.64);
const fermentationLabel = makeInfoPanel(
"03 FERMENTATION",
"KIMCHI + PICKLES IN SEALED JARS",
"#9a9046",
4.75,
1.10
);
fermentationLabel.position.set(5.55, 6.30, -1.64);
const dryMetric = makeMetricPanel(-5.55, "#cf553d");
const coolMetric = makeMetricPanel(0, "#6eb9c3");
const fermentMetric = makeMetricPanel(5.55, "#c0b65b");
addProcess(
scene,
-5.55,
["SUN", "WARM", "AIR"],
["#e8b34f", "#dc7445", "#80b7b3"],
["sun", "heat", "air"]
);
addProcess(
scene,
0,
["ICE", "CHILL", "STORE"],
["#94ced4", "#4b9cac", "#6b9d9d"],
["ice", "chill", "store"]
);
addProcess(
scene,
5.55,
["SALT", "SEAL", "CO₂"],
["#d3c675", "#a88a53", "#87934c"],
["salt", "seal", "co2"]
);
// DRYING EXHIBIT
const dryingRoot = group(scene, -5.55, 1.18, 0.38);
const dryingRack = group(dryingRoot);
[-1.62, 1.62].forEach((x) => {
[-0.40, 0.40].forEach((z) => {
box(dryingRack, 0.13, 2.72, 0.13, x, 1.36, z, "#8c633e");
});
});
[-0.40, 0.40].forEach((z) => {
box(dryingRack, 3.38, 0.13, 0.13, 0, 2.68, z, "#9c7046");
box(dryingRack, 3.38, 0.11, 0.11, 0, 0.65, z, "#8c633e");
});
box(dryingRack, 3.30, 0.09, 0.88, 0, 2.62, 0, "#b18454");
const dryPepperMaterial = new THREE.MeshStandardMaterial({
color: "#d84f37",
roughness: 0.8
});
const dryFishMaterial = new THREE.MeshStandardMaterial({
color: "#b7aaa0",
roughness: 0.9
});
const dryFoods = group(dryingRoot);
[-1.10, -0.46, 0.18].forEach((x, index) => {
box(dryFoods, 0.035, 1.03, 0.035, x, 2.08, 0.32, "#c9ad7c");
makeChili(
dryFoods,
x,
1.63 + (index % 2) * 0.08,
0.32,
index % 2 === 0 ? -0.13 : 0.15,
dryPepperMaterial
);
});
makeFish(dryFoods, 1.02, 1.64, 0.24, 1.18, dryFishMaterial, true);
box(dryFoods, 0.035, 0.84, 0.035, 1.02, 2.18, 0.24, "#c9ad7c");
const dryMoisture = [];
for (let i = 0; i < 9; i++) {
const dropMaterial = new THREE.MeshStandardMaterial({
color: "#76b9c4",
transparent: true,
opacity: 0.8,
roughness: 0.25
});
const drop = box(
dryFoods,
0.08,
0.12,
0.08,
-1.15 + i * 0.27,
1.2,
0.42 + (i % 2) * 0.12,
"#76b9c4",
{ material: dropMaterial }
);
dryMoisture.push({ mesh: drop, material: dropMaterial, offset: i * 0.113 });
}
// COOLING EXHIBIT
const coolingRoot = group(scene, 0, 1.18, 0.38);
const coolFrame = group(coolingRoot);
box(coolFrame, 3.38, 0.16, 1.62, 0, 0.08, 0.12, "#8aa7a6");
box(coolFrame, 0.14, 2.42, 0.14, -1.60, 1.29, -0.45, "#6b989d");
box(coolFrame, 0.14, 2.42, 0.14, 1.60, 1.29, -0.45, "#6b989d");
box(coolFrame, 3.34, 0.14, 0.14, 0, 2.45, -0.45, "#6b989d");
box(coolingRoot, 1.76, 0.10, 0.78, -0.55, 0.27, 0.26, "#c4d2d0");
box(coolingRoot, 1.60, 0.04, 0.65, -0.55, 0.34, 0.26, "#e5ece6");
const coolFishMaterial = new THREE.MeshStandardMaterial({
color: "#d8d1b9",
roughness: 0.72
});
makeFish(coolingRoot, -0.63, 0.57, 0.27, 1.13, coolFishMaterial, false);
const iceMaterial = new THREE.MeshStandardMaterial({
color: "#c8eef1",
transparent: true,
opacity: 0.68,
roughness: 0.14,
depthWrite: false
});
const iceGroup = group(coolingRoot);
const icePositions = [
[-1.18, 0.42, 0.52, 0.42],
[-0.78, 0.45, -0.14, 0.30],
[0.25, 0.40, 0.46, 0.34],
[0.55, 0.45, -0.03, 0.40],
[-0.20, 0.42, 0.67, 0.27]
];
icePositions.forEach(([x, y, z, size]) => {
box(iceGroup, size, size * 0.75, size, x, y, z, "#c8eef1", {
material: iceMaterial
});
});
const milkRoot = group(coolingRoot, 1.02, 0.32, 0.23);
box(milkRoot, 0.67, 1.05, 0.56, 0, 0.53, 0, "#f0e9d8");
box(milkRoot, 0.40, 0.19, 0.38, 0, 1.10, 0, "#f0e9d8");
box(milkRoot, 0.67, 0.18, 0.57, 0, 0.49, 0, "#4f9eaf");
box(milkRoot, 0.35, 0.12, 0.02, 0, 0.84, 0.29, "#56706c");
const thermometer = group(coolingRoot, 1.73, 0.17, -0.08);
box(thermometer, 0.24, 1.62, 0.18, 0, 0.82, 0, "#f4ead6");
box(thermometer, 0.08, 1.18, 0.08, 0, 0.81, 0.12, "#35413c");
const coolFillMaterial = new THREE.MeshStandardMaterial({
color: "#d95d4e",
roughness: 0.45
});
const coolFill = box(thermometer, 0.055, 1.18, 0.055, 0, 0.81, 0.18, "#d95d4e", {
material: coolFillMaterial
});
box(thermometer, 0.18, 0.18, 0.16, 0, 0.12, 0.12, "#d95d4e");
const frostGroup = group(coolingRoot);
for (let i = 0; i < 13; i++) {
const x = -1.48 + (i % 5) * 0.65;
const y = 0.22 + Math.floor(i / 5) * 0.42;
const z = -0.25 + (i % 2) * 0.35;
const frost = group(frostGroup, x, y, z);
box(frost, 0.26, 0.055, 0.055, 0, 0, 0, "#e5fbfb");
box(frost, 0.055, 0.25, 0.055, 0, 0, 0, "#e5fbfb");
}
frostGroup.scale.setScalar(0.001);
const coolSnow = [];
for (let i = 0; i < 16; i++) {
const snowMaterial = new THREE.MeshStandardMaterial({
color: "#e8fbfa",
transparent: true,
opacity: 0.8,
roughness: 0.2
});
const snow = box(
coolingRoot,
0.055,
0.055,
0.055,
-1.55 + (i % 6) * 0.55,
2.7,
-0.25 + (i % 3) * 0.28,
"#e8fbfa",
{ material: snowMaterial }
);
coolSnow.push({ mesh: snow, material: snowMaterial, offset: i * 0.081 });
}
// FERMENTATION EXHIBIT
const fermentationRoot = group(scene, 5.55, 1.18, 0.38);
const glassMaterial = new THREE.MeshStandardMaterial({
color: "#c7e2d8",
transparent: true,
opacity: 0.27,
roughness: 0.12,
depthWrite: false
});
const largeJar = group(fermentationRoot, -0.52, 0.02, 0.18);
box(largeJar, 1.14, 0.12, 1.02, 0, 0.09, 0, "#d8e7dc", { material: glassMaterial });
box(largeJar, 1.16, 0.12, 1.04, 0, 1.74, 0, "#d8e7dc", { material: glassMaterial });
box(largeJar, 0.09, 1.62, 1.02, -0.53, 0.91, 0, "#d8e7dc", { material: glassMaterial });
box(largeJar, 0.09, 1.62, 1.02, 0.53, 0.91, 0, "#d8e7dc", { material: glassMaterial });
box(largeJar, 1.16, 1.62, 0.09, 0, 0.91, -0.47, "#d8e7dc", { material: glassMaterial });
box(largeJar, 1.16, 1.62, 0.09, 0, 0.91, 0.47, "#d8e7dc", { material: glassMaterial });
box(largeJar, 1.26, 0.18, 1.14, 0, 1.83, 0, "#a47d47");
box(largeJar, 1.34, 0.08, 1.20, 0, 1.95, 0, "#c09558");
const fermentContent = group(largeJar);
const cabbageMaterial = new THREE.MeshStandardMaterial({
color: "#7e8e43",
roughness: 0.88
});
const chiliMaterial = new THREE.MeshStandardMaterial({
color: "#bd5139",
roughness: 0.84
});
const fermentBits = [
[-0.26, 0.35, -0.20, 0.34, cabbageMaterial],
[0.17, 0.42, -0.10, 0.39, cabbageMaterial],
[-0.10, 0.47, 0.22, 0.33, cabbageMaterial],
[0.28, 0.33, 0.20, 0.29, cabbageMaterial],
[-0.28, 0.69, 0.12, 0.34, cabbageMaterial],
[0.08, 0.73, -0.18, 0.31, chiliMaterial],
[0.32, 0.68, -0.12, 0.26, chiliMaterial],
[-0.12, 0.96, 0.08, 0.28, cabbageMaterial]
];
fermentBits.forEach(([x, y, z, size, material]) => {
box(fermentContent, size, size * 0.55, size, x, y, z, "#7e8e43", { material });
});
const smallJar = group(fermentationRoot, 1.24, 0.02, 0.16);
box(smallJar, 0.78, 0.10, 0.72, 0, 0.07, 0, "#d8e7dc", { material: glassMaterial });
box(smallJar, 0.08, 1.13, 0.72, -0.35, 0.66, 0, "#d8e7dc", { material: glassMaterial });
box(smallJar, 0.08, 1.13, 0.72, 0.35, 0.66, 0, "#d8e7dc", { material: glassMaterial });
box(smallJar, 0.78, 1.13, 0.08, 0, 0.66, -0.32, "#d8e7dc", { material: glassMaterial });
box(smallJar, 0.78, 1.13, 0.08, 0, 0.66, 0.32, "#d8e7dc", { material: glassMaterial });
box(smallJar, 0.86, 0.13, 0.80, 0, 1.28, 0, "#a47d47");
box(smallJar, 0.65, 0.50, 0.60, 0, 0.39, 0, "#8b9b47");
box(smallJar, 0.28, 0.16, 0.62, 0, 0.47, 0, "#c36a40");
const bubbleMaterial = new THREE.MeshStandardMaterial({
color: "#e8d775",
transparent: true,
opacity: 0.82,
roughness: 0.4
});
const bubbles = [];
for (let i = 0; i < 18; i++) {
const size = 0.055 + (i % 4) * 0.017;
const bubble = box(
largeJar,
size,
size,
size,
-0.30 + (i % 5) * 0.15,
0.4 + (i / 18) * 1.1,
-0.25 + (i % 3) * 0.23,
"#e8d775",
{ material: bubbleMaterial }
);
bubbles.push({ mesh: bubble, offset: i * 0.071 });
}
// Animation state: each exhibit advances independently, but only one can animate at once.
const duration = 5.2;
const progress = { dry: 0, cool: 0, ferment: 0 };
let activeKey = null;
let activeElapsed = 0;
let autoMode = false;
let autoIndex = -1;
let autoPause = 0;
const sequence = ["dry", "cool", "ferment"];
const names = {
dry: "Drying",
cool: "Cooling",
ferment: "Fermentation"
};
function announce(message) {
statusLine.textContent = message;
}
function activate(key, automatic = false) {
activeKey = key;
activeElapsed = 0;
progress[key] = 0;
autoPause = 0;
if (!automatic) {
autoMode = false;
announce(
`${names[key]} is changing now. The other two methods are paused for a fair comparison.`
);
}
}
function resetAll() {
activeKey = null;
activeElapsed = 0;
autoMode = false;
autoIndex = -1;
autoPause = 0;
progress.dry = 0;
progress.cool = 0;
progress.ferment = 0;
announce("Shelf reset. Choose a method, or run the full three-stage comparison.");
}
modeButtons.forEach((button) => {
button.addEventListener("click", () => {
const key = button.dataset.mode;
if (activeKey === key) {
activeElapsed = 0;
progress[key] = 0;
} else {
activate(key);
}
});
});
autoButton.addEventListener("click", () => {
if (autoMode) {
autoMode = false;
activeKey = null;
announce("Comparison cycle paused.");
return;
}
resetAll();
autoMode = true;
autoIndex = 0;
activate("dry", true);
announce("Comparison started: drying first. Cooling and fermentation remain unchanged.");
});
resetButton.addEventListener("click", resetAll);
function updateState(delta) {
if (activeKey) {
activeElapsed += delta;
const p = Math.min(activeElapsed / duration, 1);
progress[activeKey] = p;
if (p >= 1) {
const completed = activeKey;
activeKey = null;
if (autoMode) {
autoPause = 0;
announce(`${names[completed]} complete. The shelf is paused before the next method.`);
} else {
announce(`${names[completed]} complete. Choose another method to compare.`);
}
}
} else if (autoMode) {
autoPause += delta;
if (autoPause >= 0.75) {
autoIndex += 1;
if (autoIndex >= sequence.length) {
autoMode = false;
autoIndex = -1;
announce(
"Comparison complete: drying, cooling, and fermentation are all shown at full effect."
);
} else {
activate(sequence[autoIndex], true);
announce(
`${names[sequence[autoIndex]]} is changing now. The other two exhibits remain unchanged.`
);
}
}
}
}
const dryPepperStart = new THREE.Color("#d84f37");
const dryPepperEnd = new THREE.Color("#7f2e22");
const dryFishStart = new THREE.Color("#b7aaa0");
const dryFishEnd = new THREE.Color("#82694a");
const cabbageStart = new THREE.Color("#68763d");
const cabbageEnd = new THREE.Color("#9da84b");
const chiliStart = new THREE.Color("#a94435");
const chiliEnd = new THREE.Color("#d66a38");
function updateVisuals(time) {
const dryP = progress.dry;
dryFoods.scale.set(1 - dryP * 0.16, 1 - dryP * 0.28, 1 - dryP * 0.16);
dryPepperMaterial.color.copy(dryPepperStart).lerp(dryPepperEnd, dryP);
dryFishMaterial.color.copy(dryFishStart).lerp(dryFishEnd, dryP);
dryMoisture.forEach(({ mesh, material, offset }) => {
const cycle = (time * 0.22 + offset) % 1;
mesh.position.y = 1.25 + cycle * 1.55;
mesh.position.x += Math.sin(time * 2 + offset * 10) * 0.0015;
material.opacity = Math.max(0, (1 - dryP) * 0.75);
mesh.scale.setScalar(Math.max(0.001, 1 - dryP * 0.65));
});
const coolP = progress.cool;
const fillScale = 1 - coolP * 0.76;
coolFill.scale.y = fillScale;
coolFill.position.y = 0.22 + (1.18 * fillScale) / 2;
coolFillMaterial.color.set(coolP > 0.55 ? "#4b9cac" : "#d95d4e");
iceGroup.scale.setScalar(0.72 + coolP * 0.28);
frostGroup.scale.setScalar(Math.max(0.001, coolP));
frostGroup.position.y = (1 - coolP) * -0.18;
coolSnow.forEach(({ mesh, material, offset }) => {
const cycle = (time * 0.25 + offset) % 1;
mesh.position.y = 2.65 - cycle * 2.05;
material.opacity = coolP * 0.85;
mesh.scale.setScalar(Math.max(0.001, coolP));
});
const fermentP = progress.ferment;
fermentContent.scale.setScalar(1 + fermentP * 0.055);
cabbageMaterial.color.copy(cabbageStart).lerp(cabbageEnd, fermentP);
chiliMaterial.color.copy(chiliStart).lerp(chiliEnd, fermentP);
bubbles.forEach(({ mesh, offset }, index) => {
const cycle = (time * 0.30 + offset) % 1;
mesh.position.y = 0.28 + cycle * 1.28;
mesh.position.x = -0.30 + (index % 5) * 0.15 + Math.sin(time + index) * 0.025;
const reveal = Math.min(1, Math.max(0, fermentP * 1.45 - index * 0.035));
mesh.scale.setScalar(Math.max(0.001, reveal));
mesh.visible = fermentP > 0.015;
});
}
function updateInterface() {
const dryMoistureValue = Math.round(68 - 56 * progress.dry);
const coolTemperature = Math.round(12 - 14 * progress.cool);
const fermentCO2 = Math.round(90 * progress.ferment);
document.querySelector("#dry-value").textContent = `${dryMoistureValue}%`;
document.querySelector("#cool-value").textContent = `${coolTemperature}°C`;
document.querySelector("#ferment-value").textContent = `${fermentCO2}%`;
modeButtons.forEach((button) => {
button.classList.toggle("active", button.dataset.mode === activeKey);
});
const activeProgress = activeKey ? progress[activeKey] : autoMode ? 1 : 0;
progressFill.style.width = `${activeProgress * 100}%`;
autoButton.textContent = autoMode ? "■ Stop comparison" : "▶ Run comparison";
updateMetricPanel(
dryMetric,
"MOISTURE",
`${dryMoistureValue}%`,
dryMoistureValue < 25 ? "DRIED / LOW WATER" : "REFERENCE / FRESH"
);
updateMetricPanel(
coolMetric,
"TEMPERATURE",
`${coolTemperature}°C`,
coolTemperature < 0 ? "CHILLED / SLOWER GROWTH" : "REFERENCE / AMBIENT"
);
updateMetricPanel(
fermentMetric,
"CO₂ ACTIVITY",
`${fermentCO2}%`,
fermentCO2 > 60 ? "ACTIVE / FERMENTING" : "REFERENCE / RESTING"
);
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
updateState(delta);
updateVisuals(time);
updateInterface();
renderer.render(scene, camera);
}
renderer.compile(scene, camera);
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
});
</script>
</body>
</html>
```