Prompt specification
Build or customize the Three.js 3D scene "Historical ice delivery to a food cabinet" 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: Historical ice delivery to a food cabinet
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/historical-ice-delivery-to-a-food-cabinet-x2526
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts historical refrigeration and food cold chains. Create a referenced domestic ice-delivery vignette with insulated cabinet and replaceable ice compartment. Show meltwater collection and separate storage temperature from decorative frost effects. Low-poly.
Working Three.js Starter (historical-ice-delivery-to-a-food-cabinet-x2526):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Historical Refrigeration — Domestic Ice-Delivery Vignette</title>
<style>
:root {
--ink: #23332f;
--muted: #5f6f69;
--panel: rgba(249, 247, 237, 0.94);
--line: rgba(35, 51, 47, 0.16);
--wood: #81522f;
--teal: #287b78;
--blue: #397fa8;
--amber: #b8762f;
--frost: #d8edf0;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background: #dce5df;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene,
#scene canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
#scene canvas {
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
header {
position: fixed;
z-index: 5;
top: 18px;
left: 22px;
max-width: 560px;
pointer-events: none;
text-shadow: 0 1px 0 rgba(255,255,255,.65);
}
.eyebrow {
display: inline-block;
margin-bottom: 7px;
padding: 5px 9px;
border: 1px solid rgba(35,51,47,.22);
border-radius: 999px;
background: rgba(249,247,237,.84);
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 3vw, 43px);
font-weight: 500;
line-height: .98;
letter-spacing: -.035em;
}
header p {
max-width: 520px;
margin: 9px 0 0;
color: #445650;
font-size: 13px;
line-height: 1.45;
}
.panel,
details,
#timelinePanel,
#legend {
border: 1px solid var(--line);
border-radius: 13px;
background: var(--panel);
box-shadow: 0 13px 40px rgba(35,51,47,.13);
backdrop-filter: blur(10px);
}
#controls {
position: fixed;
z-index: 6;
top: 18px;
left: 22px;
width: 304px;
max-height: calc(100vh - 36px);
padding: 15px;
overflow: auto;
scrollbar-width: thin;
}
.panel-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 11px;
}
.panel-title h2,
#timelinePanel h2 {
margin: 0;
font-size: 12px;
letter-spacing: .09em;
text-transform: uppercase;
}
.small-button {
padding: 4px 8px;
border: 1px solid var(--line);
border-radius: 7px;
background: rgba(255,255,255,.58);
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: 11px;
}
.small-button:hover {
background: white;
}
.section {
margin-top: 13px;
padding-top: 12px;
border-top: 1px solid var(--line);
}
.section:first-of-type {
border-top: 0;
}
.section-label {
margin-bottom: 9px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .09em;
text-transform: uppercase;
}
.control {
margin: 10px 0;
}
.control-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 5px;
font-size: 12px;
}
.control-row output {
color: var(--teal);
font-weight: 800;
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
margin: 0;
accent-color: var(--teal);
cursor: pointer;
}
.domain {
padding: 10px;
border: 1px solid rgba(55,127,168,.24);
border-radius: 9px;
background: rgba(230,242,247,.55);
}
.domain.storage {
border-color: rgba(40,123,120,.25);
background: rgba(229,242,235,.64);
}
.domain-title {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 12px;
font-weight: 800;
}
.domain small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.button-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
button.action {
min-height: 34px;
padding: 7px 8px;
border: 1px solid rgba(35,51,47,.18);
border-radius: 8px;
background: rgba(255,255,255,.62);
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: 11px;
font-weight: 700;
}
button.action:hover {
background: white;
border-color: rgba(35,51,47,.32);
}
button.action.primary {
border-color: var(--teal);
background: var(--teal);
color: white;
}
button.action.primary:hover {
background: #216d6a;
}
.check {
display: flex;
align-items: flex-start;
gap: 8px;
margin: 8px 0;
font-size: 12px;
line-height: 1.35;
}
.check input {
margin-top: 2px;
accent-color: var(--teal);
}
.note {
padding: 9px 10px;
border-left: 3px solid var(--amber);
border-radius: 4px;
background: rgba(238,221,185,.35);
color: #6c5434;
font-size: 11px;
line-height: 1.45;
}
.stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 9px;
}
.stat {
padding: 8px;
border-radius: 8px;
background: rgba(255,255,255,.56);
border: 1px solid rgba(35,51,47,.10);
}
.stat span {
display: block;
color: var(--muted);
font-size: 9px;
letter-spacing: .07em;
text-transform: uppercase;
}
.stat strong {
display: block;
margin-top: 3px;
font-size: 14px;
font-variant-numeric: tabular-nums;
}
#labels {
position: fixed;
z-index: 4;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
top: 0;
left: 0;
max-width: 190px;
padding: 6px 9px;
border: 1px solid rgba(35,51,47,.18);
border-radius: 8px;
background: rgba(250,248,239,.91);
box-shadow: 0 5px 16px rgba(35,51,47,.12);
color: #31443f;
font-size: 10px;
font-weight: 700;
line-height: 1.3;
text-align: center;
white-space: nowrap;
transform: translate(-50%, -50%);
}
.world-label::after {
content: "";
display: inline-block;
width: 6px;
height: 6px;
margin-right: 6px;
border-radius: 50%;
background: var(--teal);
vertical-align: 1px;
}
.world-label.blue::after {
background: var(--blue);
}
.world-label.white::after {
background: #9ac7d0;
}
#timelinePanel {
position: fixed;
z-index: 5;
left: 346px;
right: 22px;
bottom: 18px;
padding: 12px 14px 13px;
}
#timelinePanel h2 {
margin-bottom: 9px;
}
#eraButtons {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 6px;
}
.era {
position: relative;
min-height: 42px;
padding: 7px 5px;
border: 1px solid rgba(35,51,47,.13);
border-radius: 8px;
background: rgba(255,255,255,.48);
color: var(--muted);
cursor: pointer;
font: inherit;
text-align: center;
}
.era strong,
.era span {
display: block;
}
.era strong {
color: var(--ink);
font-size: 10px;
}
.era span {
margin-top: 2px;
font-size: 9px;
}
.era.active {
border-color: var(--teal);
background: rgba(40,123,120,.11);
box-shadow: inset 0 0 0 1px rgba(40,123,120,.14);
}
#eraCaption {
margin: 9px 2px 0;
color: #50615c;
font-size: 11px;
line-height: 1.4;
}
details {
position: fixed;
z-index: 7;
top: 18px;
right: 22px;
width: 285px;
padding: 11px 13px;
font-size: 11px;
}
details summary {
cursor: pointer;
font-size: 11px;
font-weight: 800;
letter-spacing: .04em;
}
details p {
margin: 10px 0;
color: var(--muted);
line-height: 1.45;
}
details ul {
margin: 8px 0;
padding-left: 17px;
}
details li {
margin: 6px 0;
line-height: 1.4;
}
details a {
color: var(--teal);
}
#legend {
position: fixed;
z-index: 4;
right: 22px;
bottom: 169px;
padding: 9px 11px;
color: #52625d;
font-size: 10px;
line-height: 1.6;
}
.swatch {
display: inline-block;
width: 9px;
height: 9px;
margin-right: 5px;
border-radius: 2px;
vertical-align: -1px;
}
#toast {
position: fixed;
z-index: 20;
top: 22px;
left: 50%;
max-width: min(430px, calc(100vw - 40px));
padding: 10px 14px;
border-radius: 9px;
background: rgba(35,51,47,.93);
color: white;
font-size: 12px;
text-align: center;
pointer-events: none;
opacity: 0;
transform: translate(-50%, -12px);
transition: opacity .2s, transform .2s;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
@media (max-width: 920px) {
header {
max-width: calc(100vw - 340px);
}
header p {
display: none;
}
details {
width: 245px;
}
#timelinePanel {
left: 22px;
}
#legend {
display: none;
}
}
@media (max-width: 700px) {
header {
top: 10px;
left: 12px;
max-width: calc(100vw - 24px);
}
header h1 {
max-width: 250px;
font-size: 26px;
}
#controls {
top: 91px;
left: 12px;
width: 250px;
max-height: 48vh;
padding: 12px;
}
details {
top: 10px;
right: 12px;
width: 38px;
height: 38px;
padding: 10px;
overflow: hidden;
}
details[open] {
width: min(300px, calc(100vw - 24px));
height: auto;
}
details summary {
white-space: nowrap;
}
#timelinePanel {
left: 12px;
right: 12px;
bottom: 10px;
padding: 10px;
}
#eraButtons {
display: flex;
overflow-x: auto;
}
.era {
min-width: 100px;
}
#eraCaption {
max-height: 50px;
overflow: auto;
}
.world-label {
max-width: 135px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive low-poly historical ice-delivery scene"></div>
<header>
<div class="eyebrow">Interpretive reconstruction · c. 1880–1920</div>
<h1>Domestic Ice-Delivery Vignette</h1>
<p>
A removable upper ice compartment cools a separate food chamber below.
Meltwater is collected in a pan; the frost treatment is decorative only.
</p>
</header>
<aside id="controls" class="panel">
<div class="panel-title">
<h2>Explanatory Controls</h2>
<button id="resetView" class="small-button" type="button">Reset view</button>
</div>
<div class="section">
<div class="section-label">Independent thermal domains</div>
<div class="domain">
<div class="domain-title">
<span>Ice-compartment temperature</span>
<output id="iceTempValue">−2 °C</output>
</div>
<input id="iceTemp" type="range" min="-8" max="8" step="0.5" value="-2"
aria-label="Ice compartment temperature">
<small>Upper removable ice bay. Controls the modeled ice-melting rate.</small>
</div>
<div class="domain storage">
<div class="domain-title">
<span>Food-storage temperature</span>
<output id="storageTempValue">6 °C</output>
</div>
<input id="storageTemp" type="range" min="2" max="15" step="0.5" value="6"
aria-label="Food storage temperature">
<small>Lower food compartment. This readout is independent of decorative frost.</small>
</div>
</div>
<div class="section">
<div class="section-label">Ice and meltwater</div>
<div class="control">
<div class="control-row">
<label for="iceCharge">Remaining ice charge</label>
<output id="chargeValue">58%</output>
</div>
<input id="iceCharge" type="range" min="0" max="100" step="1" value="58">
</div>
<div class="stats">
<div class="stat">
<span>Collected meltwater</span>
<strong id="waterValue">0.28 L</strong>
</div>
<div class="stat">
<span>Storage air</span>
<strong id="storageBadge">6.0 °C</strong>
</div>
</div>
<div class="button-grid" style="margin-top:9px">
<button id="toggleTray" class="action" type="button">Remove ice bay</button>
<button id="replaceIce" class="action primary" type="button">Replace with fresh ice</button>
<button id="drainPan" class="action" type="button">Drain collection pan</button>
<button id="toggleDoor" class="action" type="button">Close cabinet</button>
</div>
</div>
<div class="section">
<div class="section-label">Visual treatment</div>
<label class="check">
<input id="frostToggle" type="checkbox" checked>
<span>Show decorative frost crystals</span>
</label>
<label class="check">
<input id="pathToggle" type="checkbox" checked>
<span>Show explanatory cold-chain path</span>
</label>
<label class="check">
<input id="pauseToggle" type="checkbox">
<span>Pause ice-melt demonstration</span>
</label>
<div class="note">
Frost is a surface styling effect. Turning it on or off does not change
either temperature readout, and the meltwater pan is a separate system.
</div>
</div>
</aside>
<div id="labels" aria-hidden="true">
<div id="labelDelivery" class="world-label">Delivered natural ice</div>
<div id="labelIce" class="world-label">Replaceable ice compartment</div>
<div id="labelPan" class="world-label blue">Meltwater collection pan</div>
<div id="labelStorage" class="world-label">Separate food-storage zone</div>
<div id="labelFrost" class="world-label white">Decorative frost — visual only</div>
</div>
<section id="timelinePanel">
<h2>A brief history of mechanical and organized cold</h2>
<div id="eraButtons">
<button class="era" data-era="pre" type="button">
<strong>Before 1830</strong><span>Ice and snow</span>
</button>
<button class="era" data-era="trade" type="button">
<strong>1830–1880</strong><span>Urban ice trade</span>
</button>
<button class="era active" data-era="icebox" type="button">
<strong>1880–1930</strong><span>Domestic icebox</span>
</button>
<button class="era" data-era="electric" type="button">
<strong>1920–1960</strong><span>Electric refrigeration</span>
</button>
<button class="era" data-era="chain" type="button">
<strong>Modern era</strong><span>Cold-chain networks</span>
</button>
</div>
<p id="eraCaption"></p>
</section>
<details id="references">
<summary>References & interpretation</summary>
<p>
This is an educational low-poly reconstruction, not a measured replica.
The cutaway emphasizes the separation of the ice bay, food chamber,
insulation, and meltwater collection found in common domestic iceboxes.
</p>
<ul>
<li>
<a href="https://www.britannica.com/technology/icebox"
target="_blank" rel="noopener">Encyclopaedia Britannica: “Icebox”</a>
</li>
<li>
<a href="https://www.loc.gov/pictures/search/?q=icebox%20domestic"
target="_blank" rel="noopener">Library of Congress: domestic icebox photographs</a>
</li>
<li>
<a href="https://www.loc.gov/pictures/search/?q=ice%20delivery"
target="_blank" rel="noopener">Library of Congress: ice-delivery imagery</a>
</li>
<li>
<a href="https://americanhistory.si.edu/collections/search?edan_q=icebox"
target="_blank" rel="noopener">Smithsonian NMAH collection search: iceboxes</a>
</li>
</ul>
<p>
Temperatures and melt rates in this scene are explanatory assumptions,
not a thermodynamic simulation or artifact-specific measurements.
</p>
</details>
<div id="legend">
<div><span class="swatch" style="background:#dceff2"></span>Decorative frost</div>
<div><span class="swatch" style="background:#62afd0"></span>Collected meltwater</div>
<div><span class="swatch" style="background:#9b663d"></span>Wood / insulated shell</div>
</div>
<div id="toast" role="status" aria-live="polite"></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene and renderer
// -------------------------------------------------------------------------
const sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce5df);
scene.fog = new THREE.Fog(0xdce5df, 13, 27);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
80
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
sceneHost.appendChild(renderer.domElement);
// -------------------------------------------------------------------------
// Direct camera controls — no addons or examples modules
// -------------------------------------------------------------------------
const cameraState = {
theta: 0.48,
phi: 1.12,
radius: 11.7,
target: new THREE.Vector3(0.35, 1.72, 0)
};
const defaultCamera = {
theta: 0.48,
phi: 1.12,
radius: 11.7,
target: new THREE.Vector3(0.35, 1.72, 0)
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
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 dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.48,
1.43
);
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();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
6.4,
17
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
cameraState.radius = defaultCamera.radius;
cameraState.target.copy(defaultCamera.target);
updateCamera();
});
// -------------------------------------------------------------------------
// Lighting and low-poly materials
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xf8f2df, 0x70847c, 2.05);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1d7, 3.2);
sun.position.set(-4, 8, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -8;
sun.shadow.camera.right = 8;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -6;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 25;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.PointLight(0xb7d9e8, 10, 13, 2);
fill.position.set(1, 3, 4);
scene.add(fill);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...options
});
}
const mats = {
floor: material(0xb7c6b9),
rug: material(0x7e8f81),
wall: material(0xe8e2cf),
wood: material(0x875432),
woodLight: material(0xa87548),
woodDark: material(0x593824),
brass: material(0xa7823f, { metalness: 0.58, roughness: 0.43 }),
tin: material(0xd8ded8, { metalness: 0.34, roughness: 0.48 }),
tinDark: material(0x9ba6a0, { metalness: 0.45, roughness: 0.48 }),
wool: material(0xc2a878),
ice: material(0xbce8f0, {
transparent: true,
opacity: 0.82,
roughness: 0.24,
metalness: 0.03,
depthWrite: false
}),
iceSolid: material(0xd5f0f2, {
transparent: true,
opacity: 0.86,
roughness: 0.28
}),
water: material(0x4ba4c6, {
transparent: true,
opacity: 0.72,
roughness: 0.18,
depthWrite: false
}),
frost: material(0xe6f4f4, {
transparent: true,
opacity: 0.82,
roughness: 0.95,
depthWrite: false
}),
milk: material(0xf2eee0),
egg: material(0xeee5ce),
leaf: material(0x557b42),
tomato: material(0xb84f3f),
meat: material(0xa85850),
cloth: material(0x385b61),
apron: material(0x506b69),
skin: material(0xc9986e),
cap: material(0x493f39),
dark: material(0x33433f),
coldPath: new THREE.LineDashedMaterial({
color: 0x3a9eaa,
dashSize: 0.12,
gapSize: 0.08,
transparent: true,
opacity: 0.78
})
};
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
function box(parent, size, position, mat, rotation = [0, 0, 0]) {
const mesh = new THREE.Mesh(cubeGeometry, mat);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, radiusTop, radiusBottom, height, position, mat, segments = 8) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function polySphere(parent, radius, position, mat, detail = 0) {
const mesh = new THREE.Mesh(
new THREE.DodecahedronGeometry(radius, detail),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function rodBetween(parent, a, b, radius, mat) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 6),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Room, floor, window, and furniture
// -------------------------------------------------------------------------
box(scene, [18, 0.12, 14], [0, -0.08, 0], mats.floor);
box(scene, [9.2, 0.025, 3.1], [0.45, 0.005, 0.25], mats.rug);
box(scene, [16, 6.8, 0.16], [0, 3.3, -2.7], mats.wall);
// Window on the back wall.
box(scene, [2.35, 2.55, 0.10], [-3.8, 2.65, -2.58], mats.woodLight);
box(scene, [2.08, 2.28, 0.12], [-3.8, 2.65, -2.49], material(0xa9cbd0));
box(scene, [0.10, 2.30, 0.13], [-3.8, 2.65, -2.40], mats.woodLight);
box(scene, [2.10, 0.10, 0.13], [-3.8, 2.65, -2.40], mats.woodLight);
// A small kitchen table at right.
const table = new THREE.Group();
table.position.set(4.25, 0, -0.65);
scene.add(table);
box(table, [2.05, 0.13, 1.35], [0, 1.55, 0], mats.woodLight);
box(table, [0.15, 1.5, 0.15], [-0.78, 0.76, -0.43], mats.woodDark);
box(table, [0.15, 1.5, 0.15], [0.78, 0.76, -0.43], mats.woodDark);
box(table, [0.15, 1.5, 0.15], [-0.78, 0.76, 0.43], mats.woodDark);
box(table, [0.15, 1.5, 0.15], [0.78, 0.76, 0.43], mats.woodDark);
cylinder(table, 0.33, 0.27, 0.24, [0.25, 1.74, 0], mats.tin, 10);
cylinder(table, 0.22, 0.19, 0.31, [-0.48, 1.78, 0.05], mats.milk, 8);
cylinder(table, 0.23, 0.20, 0.13, [-0.48, 2.00, 0.05], mats.milk, 8);
// -------------------------------------------------------------------------
// Domestic icebox cabinet
// -------------------------------------------------------------------------
const cabinet = new THREE.Group();
cabinet.position.set(1.0, 0, 0);
scene.add(cabinet);
// Feet and base.
for (const x of [-1.22, 1.22]) {
for (const z of [-0.57, 0.57]) {
box(cabinet, [0.20, 0.76, 0.20], [x, 0.39, z], mats.woodDark);
}
}
box(cabinet, [3.16, 0.18, 1.72], [0, 0.78, 0], mats.wood);
box(cabinet, [3.25, 0.18, 1.82], [0, 3.44, 0], mats.woodLight);
box(cabinet, [3.30, 0.10, 1.84], [0, 3.56, 0], mats.woodDark);
// Outer shell, insulation, and inner liner.
box(cabinet, [0.16, 2.62, 1.66], [-1.49, 2.08, 0], mats.wood);
box(cabinet, [0.09, 2.46, 1.50], [-1.38, 2.08, 0], mats.wool);
box(cabinet, [0.05, 2.34, 1.38], [-1.32, 2.08, 0], mats.tin);
box(cabinet, [0.16, 2.62, 1.66], [1.49, 2.08, 0], mats.wood);
box(cabinet, [0.09, 2.46, 1.50], [1.38, 2.08, 0], mats.wool);
box(cabinet, [0.05, 2.34, 1.38], [1.32, 2.08, 0], mats.tin);
box(cabinet, [2.80, 2.62, 0.15], [0, 2.08, -0.78], mats.wood);
box(cabinet, [2.68, 2.46, 0.08], [0, 2.08, -0.69], mats.wool);
box(cabinet, [2.60, 2.34, 0.05], [0, 2.08, -0.635], mats.tin);
// Front frame.
box(cabinet, [0.15, 2.60, 0.12], [-1.39, 2.08, 0.84], mats.woodLight);
box(cabinet, [0.15, 2.60, 0.12], [1.39, 2.08, 0.84], mats.woodLight);
box(cabinet, [2.92, 0.15, 0.12], [0, 3.32, 0.84], mats.woodLight);
box(cabinet, [2.92, 0.15, 0.12], [0, 0.91, 0.84], mats.woodLight);
// Divider and lower food shelf.
box(cabinet, [2.67, 0.10, 1.38], [0, 1.43, 0], mats.tinDark);
box(cabinet, [2.78, 0.10, 1.48], [0, 1.34, 0], mats.wood);
// Small wooden door, initially open toward the rear/right.
const door = new THREE.Group();
door.position.set(1.48, 0.91, 0.88);
cabinet.add(door);
box(door, [2.92, 2.40, 0.12], [-1.46, 1.20, 0], mats.wood);
box(door, [2.48, 1.92, 0.05], [-1.46, 1.20, 0.085], mats.woodLight);
box(door, [2.18, 1.62, 0.035], [-1.46, 1.20, 0.12], mats.wood);
box(door, [0.13, 0.42, 0.12], [-2.70, 1.23, 0.12], mats.brass);
let doorOpen = true;
let doorTarget = 2.03;
// -------------------------------------------------------------------------
// Food-storage zone
// -------------------------------------------------------------------------
const food = new THREE.Group();
food.position.set(0, 1.49, 0);
cabinet.add(food);
// Milk bottle.
cylinder(food, 0.20, 0.24, 0.58, [-0.83, 0.31, 0.05], mats.milk, 10);
cylinder(food, 0.095, 0.16, 0.17, [-0.83, 0.68, 0.05], mats.milk, 8);
cylinder(food, 0.10, 0.10, 0.07, [-0.83, 0.79, 0.05], mats.woodLight, 8);
// Egg cup and eggs.
cylinder(food, 0.31, 0.24, 0.10, [-0.20, 0.06, 0.13], mats.tin, 10);
const eggPositions = [
[-0.30, 0.19, 0.12],
[-0.18, 0.18, 0.18],
[-0.08, 0.19, 0.10]
];
for (const position of eggPositions) {
const egg = polySphere(food, 0.11, position, mats.egg, 1);
egg.scale.set(0.82, 1.16, 0.82);
}
// Produce crate.
box(food, [0.74, 0.08, 0.55], [0.70, 0.08, 0.08], mats.woodLight);
box(food, [0.74, 0.30, 0.07], [0.70, 0.20, 0.33], mats.woodLight);
box(food, [0.74, 0.30, 0.07], [0.70, 0.20, -0.17], mats.woodLight);
box(food, [0.07, 0.30, 0.55], [0.36, 0.20, 0.08], mats.woodLight);
box(food, [0.07, 0.30, 0.55], [1.04, 0.20, 0.08], mats.woodLight);
polySphere(food, 0.16, [0.49, 0.23, 0.08], mats.tomato, 0);
polySphere(food, 0.15, [0.77, 0.22, 0.02], mats.tomato, 0);
polySphere(food, 0.17, [0.98, 0.23, 0.14], mats.leaf, 0);
// Covered dish in the rear of the food zone.
cylinder(food, 0.32, 0.35, 0.12, [0.58, 0.12, -0.42], mats.tin, 10);
const lid = polySphere(food, 0.30, [0.58, 0.22, -0.42], mats.tinDark, 1);
lid.scale.set(1, 0.32, 1);
// -------------------------------------------------------------------------
// Removable upper ice compartment
// -------------------------------------------------------------------------
const tray = new THREE.Group();
tray.position.set(0, 2.38, 0.06);
cabinet.add(tray);
box(tray, [2.52, 0.08, 1.08], [0, 0, 0], mats.tinDark);
box(tray, [2.52, 0.33, 0.06], [0, 0.16, -0.51], mats.tin);
box(tray, [0.06, 0.33, 1.08], [-1.23, 0.16, 0], mats.tin);
box(tray, [0.06, 0.33, 1.08], [1.23, 0.16, 0], mats.tin);
box(tray, [2.52, 0.33, 0.06], [0, 0.16, 0.51], mats.tin);
// Small removable drawer pull.
box(tray, [0.68, 0.10, 0.12], [0, 0.12, 0.64], mats.brass);
box(tray, [0.10, 0.18, 0.10], [-0.27, 0.10, 0.59], mats.brass);
box(tray, [0.10, 0.18, 0.10], [0.27, 0.10, 0.59], mats.brass);
// Drain notch and small spout above the pan.
box(tray, [0.30, 0.05, 0.26], [0.72, -0.055, 0.10], mats.tinDark);
rodBetween(
cabinet,
[0.72, 2.31, 0.10],
[0.72, 2.16, 0.10],
0.035,
mats.tinDark
);
const iceBlocks = [];
const iceLayout = [
[-0.86, 0.24, -0.27, 0.52, 0.38, 0.46],
[-0.34, 0.23, -0.25, 0.57, 0.34, 0.48],
[0.18, 0.24, -0.28, 0.52, 0.40, 0.44],
[0.69, 0.23, -0.25, 0.48, 0.35, 0.46],
[-0.78, 0.23, 0.19, 0.54, 0.36, 0.44],
[-0.23, 0.24, 0.19, 0.50, 0.39, 0.47],
[0.30, 0.23, 0.19, 0.55, 0.35, 0.46],
[0.82, 0.22, 0.18, 0.44, 0.32, 0.43]
];
for (const [x, y, z, w, h, d] of iceLayout) {
const ice = box(
tray,
[w, h, d],
[x, y, z],
mats.ice,
[0.02 * (x + 1), 0.035 * z, -0.018 * x]
);
ice.castShadow = false;
iceBlocks.push(ice);
}
// Smaller chipped ice.
for (let i = 0; i < 6; i++) {
const chip = polySphere(
tray,
0.10 + (i % 3) * 0.018,
[-0.95 + i * 0.36, 0.13, 0.39],
mats.iceSolid,
0
);
chip.scale.set(1.2, 0.58, 0.9);
chip.rotation.set(i * 0.17, i * 0.31, i * 0.11);
iceBlocks.push(chip);
}
let trayRemoved = false;
let trayTargetZ = 0.06;
// -------------------------------------------------------------------------
// Meltwater collection pan
// -------------------------------------------------------------------------
const pan = new THREE.Group();
pan.position.set(0, 2.04, 0.10);
cabinet.add(pan);
box(pan, [2.38, 0.07, 1.04], [0, 0, 0], mats.tinDark);
box(pan, [2.38, 0.22, 0.05], [0, 0.11, -0.50], mats.tin);
box(pan, [2.38, 0.22, 0.05], [0, 0.11, 0.50], mats.tin);
box(pan, [0.05, 0.22, 1.04], [-1.17, 0.11, 0], mats.tin);
box(pan, [0.05, 0.22, 1.04], [1.17, 0.11, 0], mats.tin);
const water = box(
pan,
[2.24, 0.035, 0.91],
[0, 0.07, 0],
mats.water
);
water.castShadow = false;
// Melt droplets are blue and animated downward into the pan.
const droplets = [];
for (let i = 0; i < 7; i++) {
const droplet = polySphere(
cabinet,
0.035,
[0.70, 2.25, 0.10],
mats.water,
0
);
droplet.scale.set(0.65, 1.5, 0.65);
droplet.castShadow = false;
droplets.push(droplet);
}
// -------------------------------------------------------------------------
// Decorative frost — intentionally separate from temperature behavior
// -------------------------------------------------------------------------
const frostGroup = new THREE.Group();
cabinet.add(frostGroup);
const frostPositions = [
[-1.04, 2.79, -0.58, 0.16],
[-0.72, 2.62, -0.58, 0.11],
[-0.45, 2.91, -0.58, 0.13],
[-0.12, 2.70, -0.58, 0.10],
[0.22, 2.84, -0.58, 0.14],
[0.58, 2.64, -0.58, 0.11],
[0.91, 2.91, -0.58, 0.17],
[1.06, 2.53, -0.58, 0.12],
[-0.88, 2.42, -0.58, 0.10],
[0.02, 2.45, -0.58, 0.13]
];
for (const [x, y, z, radius] of frostPositions) {
const crystal = polySphere(frostGroup, radius, [x, y, z], mats.frost, 0);
crystal.scale.set(1.0, 0.62, 0.23);
crystal.rotation.set(0.4, x * 2.2, y * 0.6);
crystal.castShadow = false;
}
// -------------------------------------------------------------------------
// Ice-delivery figure, tongs, and crate
// -------------------------------------------------------------------------
const deliverer = new THREE.Group();
deliverer.position.set(-2.30, 0, 0.20);
deliverer.rotation.y = -0.12;
scene.add(deliverer);
// Legs and boots.
rodBetween(deliverer, [-0.18, 0.14, 0], [-0.15, 0.84, 0], 0.13, mats.dark);
rodBetween(deliverer, [0.18, 0.14, 0], [0.15, 0.84, 0], 0.13, mats.dark);
box(deliverer, [0.34, 0.18, 0.47], [-0.18, 0.10, 0.09], mats.woodDark);
box(deliverer, [0.34, 0.18, 0.47], [0.18, 0.10, 0.09], mats.woodDark);
// Coat and apron.
box(deliverer, [0.78, 0.93, 0.42], [0, 1.30, 0], mats.cloth);
box(deliverer, [0.58, 0.72, 0.055], [0, 1.17, 0.235], mats.apron);
cylinder(deliverer, 0.22, 0.18, 0.23, [0, 1.84, 0], mats.skin, 8);
// Head, cap, and face details.
polySphere(deliverer, 0.25, [0, 2.03, 0], mats.skin, 1);
cylinder(deliverer, 0.27, 0.29, 0.13, [0, 2.20, -0.01], mats.cap, 8);
box(deliverer, [0.38, 0.045, 0.18], [0.11, 2.19, 0.21], mats.cap);
polySphere(deliverer, 0.035, [-0.09, 2.06, 0.225], mats.dark, 0);
polySphere(deliverer, 0.035, [0.09, 2.06, 0.225], mats.dark, 0);
// Arms and tongs.
rodBetween(deliverer, [-0.34, 1.66, 0], [-0.06, 1.42, 0.25], 0.105, mats.cloth);
rodBetween(deliverer, [0.34, 1.66, 0], [0.37, 1.45, 0.28], 0.105, mats.cloth);
rodBetween(deliverer, [0.17, 1.40, 0.30], [0.44, 1.78, 0.34], 0.025, mats.woodDark);
rodBetween(deliverer, [0.53, 1.40, 0.30], [0.45, 1.78, 0.34], 0.025, mats.woodDark);
// Ice block held in the tongs.
const deliveredIce = box(
deliverer,
[0.56, 0.43, 0.48],
[0.46, 1.73, 0.34],
mats.iceSolid,
[0.02, 0.12, -0.04]
);
// Delivery crate and additional blocks.
const deliveryCrate = new THREE.Group();
deliveryCrate.position.set(-3.42, 0, -0.18);
scene.add(deliveryCrate);
box(deliveryCrate, [1.15, 0.10, 0.86], [0, 0.10, 0], mats.woodLight);
box(deliveryCrate, [1.15, 0.55, 0.07], [0, 0.35, -0.40], mats.woodLight);
box(deliveryCrate, [1.15, 0.55, 0.07], [0, 0.35, 0.40], mats.woodLight);
box(deliveryCrate, [0.07, 0.55, 0.86], [-0.54, 0.35, 0], mats.woodLight);
box(deliveryCrate, [0.07, 0.55, 0.86], [0.54, 0.35, 0], mats.woodLight);
box(deliveryCrate, [0.65, 0.35, 0.56], [-0.16, 0.37, 0], mats.iceSolid, [0, 0.08, 0]);
box(deliveryCrate, [0.60, 0.33, 0.52], [0.31, 0.35, 0.04], mats.iceSolid, [0, -0.04, 0.08]);
// -------------------------------------------------------------------------
// Temperature readouts inside the scene
// -------------------------------------------------------------------------
function createReadout(parent, position, width = 1.35) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 240;
const context = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.position.set(...position);
sprite.scale.set(width, width * 240 / 512, 1);
parent.add(sprite);
return { canvas, context, texture, sprite };
}
function temperatureColor(temperature) {
const cold = new THREE.Color(0x4c9dc2);
const mild = new THREE.Color(0x54a886);
const warm = new THREE.Color(0xc38343);
if (temperature <= 6) {
return cold.clone().lerp(mild, THREE.MathUtils.clamp((temperature + 8) / 14, 0, 1));
}
return mild.clone().lerp(warm, THREE.MathUtils.clamp((temperature - 6) / 9, 0, 1));
}
function drawReadout(readout, title, value, accent) {
const ctx = readout.context;
const w = readout.canvas.width;
const h = readout.canvas.height;
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "rgba(31,47,43,0.91)";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 16, h);
ctx.textAlign = "left";
ctx.fillStyle = "#d8e3dc";
ctx.font = "700 29px Arial";
ctx.fillText(title, 38, 68);
ctx.fillStyle = "#ffffff";
ctx.font = "700 82px Arial";
ctx.fillText(value, 37, 158);
ctx.fillStyle = "#aebeb7";
ctx.font = "22px Arial";
ctx.fillText("EXPLANATORY READOUT", 39, 207);
readout.texture.needsUpdate = true;
}
const iceReadout = createReadout(cabinet, [0.82, 2.98, 0.69], 1.38);
const storageReadout = createReadout(cabinet, [0.82, 1.78, 0.70], 1.42);
// -------------------------------------------------------------------------
// Cold-chain path
// -------------------------------------------------------------------------
const coldPathGroup = new THREE.Group();
scene.add(coldPathGroup);
const pathCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.83, 1.80, 0.57),
new THREE.Vector3(-0.72, 2.22, 0.75),
new THREE.Vector3(0.88, 2.60, 0.82),
new THREE.Vector3(1.67, 2.22, 0.80),
new THREE.Vector3(1.73, 1.57, 0.72)
]);
const pathLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(pathCurve.getPoints(80)),
mats.coldPath
);
pathLine.computeLineDistances();
coldPathGroup.add(pathLine);
for (const t of [0.27, 0.58, 0.82]) {
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.075, 0.22, 5),
material(0x3a9eaa, { transparent: true, opacity: 0.9 })
);
arrow.position.copy(pathCurve.getPoint(t));
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
pathCurve.getTangent(t).normalize()
);
coldPathGroup.add(arrow);
}
// -------------------------------------------------------------------------
// World-space explanatory labels
// -------------------------------------------------------------------------
const labelAnchors = [];
function anchorLabel(elementId, parent, position) {
const anchor = new THREE.Object3D();
anchor.position.set(...position);
parent.add(anchor);
labelAnchors.push({
element: document.getElementById(elementId),
anchor
});
}
anchorLabel("labelDelivery", deliverer, [0.46, 2.18, 0.36]);
anchorLabel("labelIce", tray, [0.30, 0.67, 0.20]);
anchorLabel("labelPan", cabinet, [-0.62, 2.10, 0.73]);
anchorLabel("labelStorage", food, [0.82, 0.62, 0.38]);
anchorLabel("labelFrost", cabinet, [-0.85, 3.02, -0.51]);
const projected = new THREE.Vector3();
function updateWorldLabels() {
const width = innerWidth;
const height = innerHeight;
for (const item of labelAnchors) {
item.anchor.getWorldPosition(projected);
projected.project(camera);
const visible = projected.z > -1 && projected.z < 1;
item.element.style.display = visible ? "block" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
item.element.style.left = `${x}px`;
item.element.style.top = `${y}px`;
}
}
// -------------------------------------------------------------------------
// UI state and interactions
// -------------------------------------------------------------------------
const iceTempInput = document.getElementById("iceTemp");
const storageTempInput = document.getElementById("storageTemp");
const iceChargeInput = document.getElementById("iceCharge");
const frostToggle = document.getElementById("frostToggle");
const pathToggle = document.getElementById("pathToggle");
const pauseToggle = document.getElementById("pauseToggle");
let iceTemperature = Number(iceTempInput.value);
let storageTemperature = Number(storageTempInput.value);
let iceCharge = Number(iceChargeInput.value);
let waterLiters = 0.28;
let paused = false;
const toast = document.getElementById("toast");
let toastTimer;
function showToast(message) {
toast.textContent = message;
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 2200);
}
function formatTemperature(value) {
return `${value.toFixed(1)} °C`;
}
function updateReadouts() {
const iceColor = `#${temperatureColor(iceTemperature).getHexString()}`;
const storageColor = `#${temperatureColor(storageTemperature).getHexString()}`;
drawReadout(iceReadout, "ICE BAY", formatTemperature(iceTemperature), iceColor);
drawReadout(storageReadout, "FOOD STORE", formatTemperature(storageTemperature), storageColor);
document.getElementById("iceTempValue").textContent = formatTemperature(iceTemperature);
document.getElementById("storageTempValue").textContent = formatTemperature(storageTemperature);
document.getElementById("storageBadge").textContent = formatTemperature(storageTemperature);
document.getElementById("storageBadge").style.color = storageColor;
}
function updateIceVisibility() {
const visibleCount = Math.ceil((iceCharge / 100) * iceBlocks.length);
iceBlocks.forEach((ice, index) => {
ice.visible = index < visibleCount;
});
}
function updateWater() {
const level = THREE.MathUtils.clamp(waterLiters / 1.25, 0, 1);
water.position.y = 0.065 + level * 0.13;
water.scale.y = 0.7 + level * 0.8;
document.getElementById("waterValue").textContent = `${waterLiters.toFixed(2)} L`;
}
function updateChargeUI() {
document.getElementById("chargeValue").textContent = `${Math.round(iceCharge)}%`;
if (document.activeElement !== iceChargeInput) {
iceChargeInput.value = String(Math.round(iceCharge));
}
updateIceVisibility();
}
iceTempInput.addEventListener("input", () => {
iceTemperature = Number(iceTempInput.value);
updateReadouts();
});
storageTempInput.addEventListener("input", () => {
storageTemperature = Number(storageTempInput.value);
updateReadouts();
showToast("Food-storage temperature changed independently of frost.");
});
iceChargeInput.addEventListener("input", () => {
iceCharge = Number(iceChargeInput.value);
updateChargeUI();
});
frostToggle.addEventListener("change", () => {
frostGroup.visible = frostToggle.checked;
showToast(
frostToggle.checked
? "Decorative frost shown; temperature values are unchanged."
: "Decorative frost hidden; temperature values are unchanged."
);
});
pathToggle.addEventListener("change", () => {
coldPathGroup.visible = pathToggle.checked;
});
pauseToggle.addEventListener("change", () => {
paused = pauseToggle.checked;
});
document.getElementById("toggleTray").addEventListener("click", (event) => {
trayRemoved = !trayRemoved;
trayTargetZ = trayRemoved ? 1.67 : 0.06;
event.currentTarget.textContent = trayRemoved
? "Insert ice bay"
: "Remove ice bay";
showToast(
trayRemoved
? "The replaceable upper ice bay is shown withdrawn from the cabinet."
: "The ice bay is returned to the upper compartment."
);
});
document.getElementById("replaceIce").addEventListener("click", () => {
iceCharge = 100;
waterLiters = 0.04;
trayRemoved = false;
trayTargetZ = 0.06;
document.getElementById("toggleTray").textContent = "Remove ice bay";
updateChargeUI();
updateWater();
showToast("Fresh ice inserted and the collection pan emptied.");
});
document.getElementById("drainPan").addEventListener("click", () => {
waterLiters = 0.02;
updateWater();
showToast("Meltwater collection pan drained.");
});
document.getElementById("toggleDoor").addEventListener("click", (event) => {
doorOpen = !doorOpen;
doorTarget = doorOpen ? 2.03 : 0;
event.currentTarget.textContent = doorOpen
? "Close cabinet"
: "Open cabinet";
});
document.getElementById("resetView").addEventListener("click", () => {
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
cameraState.radius = defaultCamera.radius;
cameraState.target.copy(defaultCamera.target);
updateCamera();
});
// -------------------------------------------------------------------------
// Historical timeline
// -------------------------------------------------------------------------
const eras = {
pre: {
caption:
"Before widespread mechanical refrigeration, households and businesses combined seasonal ice, snow, cellars, ventilated pantries, and evaporative cooling. The “cold chain” was seasonal and depended on a locally stored natural-ice reserve."
},
trade: {
caption:
"During the nineteenth-century urban ice trade, ice was cut from ponds and lakes, packed in sawdust, and delivered to homes and businesses. The cutaway scene focuses on the later domestic icebox, a common part of this expanding urban cold supply."
},
icebox: {
caption:
"Domestic iceboxes commonly placed ice in an upper compartment. Cold air descended into a separate food chamber, while a lower pan received meltwater. Insulation, a tight door, regular ice delivery, and drainage were central to the household cold chain."
},
electric: {
caption:
"As electric motors and compressors spread during the twentieth century, refrigeration removed the need for scheduled ice delivery. The enclosed refrigerator introduced a mechanically controlled cold space, although food storage and temperature monitoring continued to evolve."
},
chain: {
caption:
"Modern cold chains coordinate refrigerated production, transport, warehouses, retail, and homes within specified temperature ranges. Sensors, refrigerated vehicles, and standardized controls extend the domestic idea of a protected cold compartment across an entire supply network."
}
};
document.getElementById("eraButtons").addEventListener("click", (event) => {
const button = event.target.closest("[data-era]");
if (!button) return;
document.querySelectorAll(".era").forEach((eraButton) => {
eraButton.classList.toggle("active", eraButton === button);
eraButton.setAttribute("aria-pressed", String(eraButton === button));
});
document.getElementById("eraCaption").textContent = eras[button.dataset.era].caption;
});
document.getElementById("eraCaption").textContent = eras.icebox.caption;
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let uiAccumulator = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
// Demonstrative melt model: warmer ice relative to ambient melts faster.
// The food-storage temperature is deliberately not coupled to frost.
if (!paused && iceCharge > 0) {
const meltPercentPerSecond = Math.max(
0.04,
(22 - iceTemperature) * 0.035
);
const meltedPercent = Math.min(
iceCharge,
meltPercentPerSecond * delta
);
iceCharge = Math.max(0, iceCharge - meltedPercent);
if (waterLiters < 1.25) {
waterLiters = Math.min(
1.25,
waterLiters + (meltedPercent / 100) * 0.82
);
}
}
// Smooth cabinet and drawer animation.
tray.position.z = THREE.MathUtils.lerp(
tray.position.z,
trayTargetZ,
1 - Math.pow(0.001, delta)
);
door.rotation.y = THREE.MathUtils.lerp(
door.rotation.y,
doorTarget,
1 - Math.pow(0.001, delta)
);
// Blue melt droplets fall only while ice remains and the bay is inserted.
droplets.forEach((droplet, index) => {
const active = iceCharge > 0 && !trayRemoved;
droplet.visible = active;
if (!active) return;
const phase = (elapsed * 0.85 + index * 0.17) % 1;
droplet.position.y = 2.30 - phase * 0.14;
droplet.position.x = 0.72 + Math.sin(index * 2.1) * 0.025;
droplet.scale.set(0.65, 1.5, 0.65);
});
// A subtle visual pulse for the cold-chain arrows.
coldPathGroup.children.forEach((child) => {
if (child.material && "opacity" in child.material) {
child.material.opacity = 0.72 + Math.sin(elapsed * 2.2) * 0.10;
}
});
uiAccumulator += delta;
if (uiAccumulator > 0.08) {
uiAccumulator = 0;
updateChargeUI();
updateWater();
}
updateWorldLabels();
renderer.render(scene, camera);
}
function onResize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
addEventListener("resize", onResize);
updateCamera();
updateReadouts();
updateChargeUI();
updateWater();
animate();
</script>
</body>
</html>
```