Prompt specification
Build or customize the Three.js 3D scene "Food supply chain with cooled transfer points" 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 supply chain with cooled transfer points
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/food-supply-chain-with-cooled-transfer-points-x2527
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts historical refrigeration and food cold chains. Build a compact historical-to-modern exhibit linking cold storage, transport, market, and household cabinet. Show where temperature control must continue between distinct handling stages. Low-poly.
Working Three.js Starter (food-supply-chain-with-cooled-transfer-points-x2527):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Cold Chain — A History of Refrigeration</title>
<style>
:root {
color-scheme: dark;
--bg: #07111c;
--panel: rgba(8, 20, 31, 0.84);
--line: rgba(151, 218, 230, 0.18);
--text: #e8f5f7;
--muted: #89a8b4;
--cold: #67e8f9;
--cold-2: #2bb9d2;
--warm: #fb923c;
--warm-2: #ef5b3f;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 48% 46%, transparent 35%, rgba(0, 0, 0, 0.36) 100%),
linear-gradient(180deg, rgba(3, 9, 15, 0.18), transparent 22%, transparent 76%, rgba(3, 9, 15, 0.38));
z-index: 1;
}
header {
position: fixed;
top: 28px;
left: 30px;
z-index: 3;
width: min(470px, calc(100vw - 60px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 11px;
color: var(--cold);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 25px;
height: 2px;
background: var(--cold);
box-shadow: 0 0 14px var(--cold);
}
h1 {
margin: 0;
color: var(--text);
font-size: clamp(34px, 4.4vw, 66px);
font-weight: 820;
letter-spacing: -0.055em;
line-height: 0.94;
}
h1 span {
color: var(--cold);
}
.subtitle {
max-width: 440px;
margin: 14px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
#chain-status {
position: fixed;
top: 30px;
right: 30px;
z-index: 4;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 13px;
border: 1px solid rgba(103, 232, 249, 0.23);
border-radius: 999px;
background: rgba(5, 16, 25, 0.74);
color: #bdeff4;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
backdrop-filter: blur(12px);
transition: 220ms ease;
}
#chain-status .dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--cold);
box-shadow: 0 0 12px var(--cold);
}
body.breach-active #chain-status {
color: #ffd1ad;
border-color: rgba(251, 146, 60, 0.48);
}
body.breach-active #chain-status .dot {
background: var(--warm);
box-shadow: 0 0 13px var(--warm);
animation: blink 0.8s infinite alternate;
}
@keyframes blink {
to { opacity: 0.35; }
}
.exhibit-panel {
position: fixed;
top: 88px;
right: 30px;
z-index: 3;
width: 316px;
padding: 17px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 22px 60px rgba(0, 0, 0, 0.26);
backdrop-filter: blur(18px);
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
}
.panel-heading strong {
color: #d7edf0;
font-size: 11px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#reset-view {
padding: 5px 8px;
border: 1px solid rgba(151, 218, 230, 0.18);
border-radius: 7px;
background: rgba(255, 255, 255, 0.025);
color: var(--muted);
cursor: pointer;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
transition: 160ms ease;
}
#reset-view:hover {
border-color: rgba(103, 232, 249, 0.5);
color: var(--cold);
}
.timeline {
position: relative;
display: grid;
gap: 6px;
}
.timeline::before {
content: "";
position: absolute;
top: 20px;
bottom: 20px;
left: 16px;
width: 1px;
background: linear-gradient(var(--cold), rgba(103, 232, 249, 0.15));
}
.stage-button {
position: relative;
display: grid;
grid-template-columns: 33px 1fr auto;
align-items: center;
gap: 9px;
width: 100%;
min-height: 52px;
padding: 8px 9px;
border: 1px solid transparent;
border-radius: 11px;
background: transparent;
color: var(--muted);
text-align: left;
cursor: pointer;
transition: 160ms ease;
}
.stage-button:hover {
background: rgba(103, 232, 249, 0.045);
color: #d4edf1;
}
.stage-button.active {
border-color: rgba(103, 232, 249, 0.17);
background: rgba(103, 232, 249, 0.075);
color: var(--text);
}
.stage-number {
position: relative;
z-index: 1;
display: grid;
place-items: center;
width: 19px;
height: 19px;
margin-left: 7px;
border: 1px solid rgba(103, 232, 249, 0.5);
border-radius: 50%;
background: #0b1b28;
color: var(--cold);
font-size: 8px;
font-weight: 900;
}
.stage-button.active .stage-number {
background: var(--cold);
color: #07111c;
box-shadow: 0 0 15px rgba(103, 232, 249, 0.35);
}
.stage-name {
display: block;
color: inherit;
font-size: 12px;
font-weight: 750;
}
.stage-era {
display: block;
margin-top: 3px;
color: #6f909c;
font-size: 9px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.stage-temp {
color: #a9d6de;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
white-space: nowrap;
}
.panel-note {
margin: 14px 2px 2px;
padding-top: 13px;
border-top: 1px solid var(--line);
color: #7898a4;
font-size: 10px;
line-height: 1.55;
}
.panel-note b {
color: #b8d5dc;
font-weight: 700;
}
#breach-button {
width: 100%;
margin-top: 13px;
padding: 10px 12px;
border: 1px solid rgba(251, 146, 60, 0.34);
border-radius: 10px;
background: rgba(251, 146, 60, 0.075);
color: #ffc28f;
cursor: pointer;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
transition: 160ms ease;
}
#breach-button:hover {
background: rgba(251, 146, 60, 0.15);
border-color: rgba(251, 146, 60, 0.65);
}
body.breach-active #breach-button {
border-color: rgba(103, 232, 249, 0.4);
background: rgba(103, 232, 249, 0.08);
color: var(--cold);
}
.story {
position: fixed;
left: 30px;
bottom: 28px;
z-index: 3;
width: min(455px, calc(100vw - 60px));
padding: 18px 20px 19px;
border-left: 2px solid var(--cold);
background: linear-gradient(90deg, rgba(7, 17, 28, 0.9), rgba(7, 17, 28, 0.5));
backdrop-filter: blur(12px);
pointer-events: none;
}
.story-kicker {
margin-bottom: 7px;
color: var(--cold);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.story h2 {
margin: 0 0 8px;
color: var(--text);
font-size: 23px;
letter-spacing: -0.025em;
}
.story p {
margin: 0;
color: #91aeb8;
font-size: 11px;
line-height: 1.6;
}
#breach-alert {
position: fixed;
left: 50%;
bottom: 33px;
z-index: 4;
width: min(420px, calc(100vw - 60px));
padding: 14px 17px;
border: 1px solid rgba(251, 146, 60, 0.46);
border-radius: 12px;
background: rgba(45, 20, 12, 0.91);
color: #ffd3b1;
box-shadow: 0 16px 45px rgba(0, 0, 0, 0.32);
font-size: 11px;
line-height: 1.5;
opacity: 0;
pointer-events: none;
transform: translate(-50%, 15px);
transition: 240ms ease;
}
#breach-alert strong {
display: block;
margin-bottom: 3px;
color: #fff0e4;
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
body.breach-active #breach-alert {
opacity: 1;
transform: translate(-50%, 0);
}
.help {
position: fixed;
right: 30px;
bottom: 30px;
z-index: 3;
color: #688894;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
pointer-events: none;
}
.help span {
color: #a9c9d1;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #07111c;
color: var(--cold);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
#loading.hide {
opacity: 0;
pointer-events: none;
}
@media (max-width: 820px) {
header {
top: 18px;
left: 18px;
}
.subtitle {
display: none;
}
#chain-status {
top: 18px;
right: 18px;
padding: 8px 10px;
font-size: 8px;
}
.exhibit-panel {
top: 78px;
right: 18px;
width: 268px;
padding: 12px;
}
.stage-button {
min-height: 43px;
}
.stage-name {
font-size: 10px;
}
.stage-era,
.panel-note {
display: none;
}
.story {
left: 18px;
bottom: 18px;
width: min(430px, calc(100vw - 36px));
}
.help {
display: none;
}
}
@media (max-width: 520px) {
h1 {
font-size: 34px;
}
.exhibit-panel {
top: auto;
right: 12px;
bottom: 12px;
width: 230px;
}
.story {
display: none;
}
#breach-alert {
bottom: 295px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly history of refrigeration and the food cold chain"></canvas>
<div class="vignette"></div>
<header>
<div class="eyebrow">An exhibit in four stages</div>
<h1>COLD<br /><span>CONTINUOUS</span></h1>
<p class="subtitle">
From winter ice to the household cabinet: a compact history of the
temperature-controlled journey between harvest, transport, market and home.
</p>
</header>
<div id="chain-status">
<span class="dot"></span>
<span id="status-text">Cold chain intact</span>
</div>
<aside class="exhibit-panel" aria-label="Exhibit stages">
<div class="panel-heading">
<strong>1850 → Today</strong>
<button id="reset-view" type="button">Full exhibit</button>
</div>
<div class="timeline">
<button class="stage-button active" data-stage="0" type="button">
<span class="stage-number">01</span>
<span>
<span class="stage-name">Ice house</span>
<span class="stage-era">Cold storage</span>
</span>
<span class="stage-temp">0°C</span>
</button>
<button class="stage-button" data-stage="1" type="button">
<span class="stage-number">02</span>
<span>
<span class="stage-name">Refrigerated transport</span>
<span class="stage-era">Cold distribution</span>
</span>
<span class="stage-temp">4°C</span>
</button>
<button class="stage-button" data-stage="2" type="button">
<span class="stage-number">03</span>
<span>
<span class="stage-name">Public market</span>
<span class="stage-era">Retail handoff</span>
</span>
<span class="stage-temp">4°C</span>
</button>
<button class="stage-button" data-stage="3" type="button">
<span class="stage-number">04</span>
<span>
<span class="stage-name">Household cabinet</span>
<span class="stage-era">Final cold storage</span>
</span>
<span class="stage-temp">4°C</span>
</button>
</div>
<p class="panel-note">
<b>One temperature envelope, four owners.</b>
Each blue handoff must preserve the controlled range established upstream.
Temperatures shown are illustrative for chilled food.
</p>
<button id="breach-button" type="button">
Simulate failed market handoff
</button>
</aside>
<section class="story" aria-live="polite">
<div id="story-kicker" class="story-kicker">1850 / Stage 01</div>
<h2 id="story-title">Harvest meets the ice house</h2>
<p id="story-body">
Before mechanical refrigeration, layered winter ice and insulated chambers
held food near 0°C. The cold chain began where harvest met storage.
</p>
</section>
<div id="breach-alert" role="status">
<strong>Cold-chain interruption at handoff 03</strong>
A twelve-minute market delay leaves food outside its controlled temperature
envelope. The remaining stages can preserve warmth, but cannot erase it.
</div>
<div class="help"><span>Drag</span> to orbit · <span>Scroll</span> to zoom · <span>Click</span> a stage</div>
<div id="loading">Building the cold chain…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, camera and lighting
// -------------------------------------------------------------------------
const canvas = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111c);
scene.fog = new THREE.FogExp2(0x07111c, 0.0145);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
120
);
const hemisphere = new THREE.HemisphereLight(0xc5edff, 0x15202b, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff3dd, 3.2);
keyLight.position.set(-8, 15, 11);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -22;
keyLight.shadow.camera.right = 22;
keyLight.shadow.camera.top = 16;
keyLight.shadow.camera.bottom = -16;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 50;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const coldFill = new THREE.PointLight(0x4ee8ff, 34, 24, 2);
coldFill.position.set(-7, 6, 4);
scene.add(coldFill);
const warmFill = new THREE.PointLight(0xffb46b, 25, 22, 2);
warmFill.position.set(9, 5, 4);
scene.add(warmFill);
// -------------------------------------------------------------------------
// Materials and reusable helpers
// -------------------------------------------------------------------------
function material(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...extra
});
}
const M = {
floor: material(0x08151f, { roughness: 0.96 }),
wall: material(0x0a1b27),
wallTrim: material(0x143341, { emissive: 0x082531, emissiveIntensity: 0.45 }),
platform: material(0x102633, { roughness: 0.9 }),
platformTop: material(0x15313e, { roughness: 0.84 }),
platformEdge: material(0x23596a, {
emissive: 0x0b3644,
emissiveIntensity: 0.7
}),
stone: material(0x89939a),
stoneDark: material(0x65727a),
stoneLight: material(0xa6afb1),
snow: material(0xe1f3f1, { roughness: 0.9 }),
ice: material(0x9cdde4, {
transparent: true,
opacity: 0.86,
roughness: 0.24,
metalness: 0.04,
emissive: 0x173e49,
emissiveIntensity: 0.45
}),
cold: material(0x67e8f9, {
emissive: 0x20cbe3,
emissiveIntensity: 1.65,
roughness: 0.32
}),
coldDark: material(0x236b78, {
emissive: 0x0d4652,
emissiveIntensity: 0.55
}),
truck: material(0x86bec2),
truckLight: material(0xe2e5dc),
glass: material(0x183744, {
roughness: 0.24,
metalness: 0.35
}),
rubber: material(0x11171b, { roughness: 0.96 }),
chrome: material(0x91a8ac, { roughness: 0.35, metalness: 0.55 }),
wood: material(0x8a5e3b),
woodDark: material(0x5b3c29),
cream: material(0xe6d8bc),
red: material(0xc95c45),
green: material(0x4c8f58),
orange: material(0xe89a38),
leaf: material(0x6e9d52),
fridge: material(0xd8ded8),
fridgeInside: material(0x6f9fa3, {
emissive: 0x24555d,
emissiveIntensity: 0.38
}),
warm: material(0xfb923c, {
emissive: 0xe84e18,
emissiveIntensity: 1.3
})
};
function mesh(geometry, mat, parent = scene, position = [0, 0, 0]) {
const object = new THREE.Mesh(geometry, mat);
object.position.set(position[0], position[1], position[2]);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(w, h, d, mat, parent = scene, position = [0, 0, 0]) {
return mesh(new THREE.BoxGeometry(w, h, d), mat, parent, position);
}
function cylinder(rt, rb, h, segments, mat, parent = scene, position = [0, 0, 0]) {
return mesh(
new THREE.CylinderGeometry(rt, rb, h, segments),
mat,
parent,
position
);
}
function ico(radius, detail, mat, parent = scene, position = [0, 0, 0]) {
return mesh(
new THREE.IcosahedronGeometry(radius, detail),
mat,
parent,
position
);
}
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function badge(title, subtitle, accent = "#67e8f9", width = 4.2) {
const c = document.createElement("canvas");
c.width = 768;
c.height = 220;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
roundedRect(ctx, 6, 8, 756, 204, 28);
ctx.fillStyle = "rgba(6, 18, 28, 0.91)";
ctx.fill();
ctx.strokeStyle = "rgba(145, 220, 231, 0.30)";
ctx.lineWidth = 3;
ctx.stroke();
roundedRect(ctx, 14, 16, 11, 188, 5);
ctx.fillStyle = accent;
ctx.fill();
ctx.fillStyle = "#ecf8f9";
ctx.font = "800 43px Arial, sans-serif";
ctx.textBaseline = "middle";
ctx.fillText(title, 52, 83, 675);
ctx.fillStyle = accent;
ctx.font = "700 25px Arial, sans-serif";
ctx.fillText(subtitle, 53, 151, 670);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: false
})
);
sprite.scale.set(width, width * 220 / 768, 1);
sprite.renderOrder = 10;
return sprite;
}
// -------------------------------------------------------------------------
// Museum environment
// -------------------------------------------------------------------------
const floor = mesh(
new THREE.PlaneGeometry(100, 100),
M.floor,
scene,
[0, -0.56, 0]
);
floor.rotation.x = -Math.PI / 2;
floor.castShadow = false;
const grid = new THREE.GridHelper(54, 54, 0x315260, 0x18313d);
grid.position.y = -0.535;
grid.material.transparent = true;
grid.material.opacity = 0.17;
scene.add(grid);
const backWall = box(36, 8, 0.35, M.wall, scene, [0, 3.2, -6.25]);
backWall.castShadow = false;
for (let i = -5; i <= 5; i++) {
const h = 5.1 + Math.abs(i % 3) * 0.55;
box(0.12, h, 0.16, M.wallTrim, scene, [i * 3.25, 2.6, -5.99]);
}
box(32, 0.08, 0.08, M.platformEdge, scene, [0, 5.65, -5.94]);
const mainPlatform = box(30.2, 0.5, 9.8, M.platform, scene, [0, -0.29, 0]);
mainPlatform.castShadow = false;
const platformTop = box(29.7, 0.06, 9.3, M.platformTop, scene, [0, -0.015, 0]);
platformTop.castShadow = false;
box(29.6, 0.05, 0.06, M.platformEdge, scene, [0, 0.035, 4.68]);
box(0.06, 0.05, 9.3, M.platformEdge, scene, [-14.84, 0.035, 0]);
for (let i = 0; i < 19; i++) {
box(0.035, 0.025, 0.26, M.platformEdge, scene, [-13.5 + i * 1.5, 0.04, 4.43]);
}
// -------------------------------------------------------------------------
// The continuous cold-chain route
// -------------------------------------------------------------------------
const coldCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-10.5, 0.22, 0),
new THREE.Vector3(-8.2, 0.22, 0.9),
new THREE.Vector3(-3.8, 0.22, 1.4),
new THREE.Vector3(-0.4, 0.22, 0.3),
new THREE.Vector3(3.3, 0.22, -1.4),
new THREE.Vector3(7.0, 0.22, -0.6),
new THREE.Vector3(10.2, 0.22, 0.2)
]);
const routeBase = mesh(
new THREE.TubeGeometry(coldCurve, 180, 0.18, 8, false),
M.coldDark,
scene
);
routeBase.castShadow = false;
const route = mesh(
new THREE.TubeGeometry(coldCurve, 180, 0.09, 8, false),
M.cold,
scene
);
route.castShadow = false;
const stationGroups = [];
const selectionRings = [];
function createStationBase(parent, radius, color = 0x3d8d9c) {
cylinder(
radius,
radius,
0.12,
8,
M.platform,
parent,
[0, 0.08, 0]
);
const ringMaterial = material(color, {
emissive: color,
emissiveIntensity: 0.65,
transparent: true,
opacity: 0.17,
depthWrite: false
});
const ring = mesh(
new THREE.TorusGeometry(radius - 0.18, 0.025, 5, 48),
ringMaterial,
parent,
[0, 0.16, 0]
);
ring.rotation.x = Math.PI / 2;
ring.castShadow = false;
selectionRings.push(ring);
return ring;
}
function registerStation(group, index) {
group.userData.stage = index;
stationGroups.push(group);
}
// -------------------------------------------------------------------------
// Stage 01: Ice house
// -------------------------------------------------------------------------
const iceHouse = new THREE.Group();
iceHouse.position.set(-10.5, 0, 0);
scene.add(iceHouse);
registerStation(iceHouse, 0);
createStationBase(iceHouse, 2.75);
cylinder(2.35, 2.48, 0.68, 8, M.stoneDark, iceHouse, [0, 0.43, 0]);
cylinder(2.12, 2.25, 0.62, 8, M.stone, iceHouse, [0, 1.05, 0]);
cylinder(1.88, 2.06, 0.65, 8, M.stoneLight, iceHouse, [0, 1.67, 0]);
const iceRoof = mesh(
new THREE.ConeGeometry(2.45, 1.55, 8),
M.snow,
iceHouse,
[0, 2.73, 0]
);
iceRoof.rotation.y = Math.PI / 8;
box(1.05, 1.35, 0.16, M.woodDark, iceHouse, [0, 0.78, 2.26]);
box(0.78, 1.15, 0.17, M.glass, iceHouse, [0, 0.78, 2.36]);
const iceBlockData = [
[-1.35, 0.32, 2.05, 0.55, 0.42, 0.48, 0.2],
[-0.70, 0.30, 2.32, 0.48, 0.36, 0.43, -0.3],
[1.23, 0.32, 2.08, 0.62, 0.45, 0.49, 0.25],
[1.76, 0.29, 1.75, 0.48, 0.38, 0.47, -0.2],
[-1.74, 0.27, 1.65, 0.44, 0.34, 0.43, 0.35]
];
iceBlockData.forEach(([x, y, z, w, h, d, r]) => {
const iceBlock = box(w, h, d, M.ice, iceHouse, [x, y, z]);
iceBlock.rotation.y = r;
});
box(0.38, 0.75, 0.38, M.stoneDark, iceHouse, [0, 3.52, 0]);
const iceLabel = badge(
"1850 / ICE HOUSE",
"COLD STORAGE • LAYERED WINTER ICE • 0°C",
"#b9f1f4",
4.55
);
iceLabel.position.set(0, 4.35, 0);
iceHouse.add(iceLabel);
// -------------------------------------------------------------------------
// Stage 02: Refrigerated transport
// -------------------------------------------------------------------------
const truck = new THREE.Group();
truck.position.set(-3.8, 0, 1.4);
scene.add(truck);
registerStation(truck, 1);
createStationBase(truck, 2.85);
box(3.5, 0.22, 1.48, M.truckLight, truck, [0.1, 0.62, 0]);
box(2.9, 1.8, 1.72, M.truck, truck, [0.55, 1.56, 0]);
box(2.96, 0.17, 1.76, M.coldDark, truck, [0.55, 1.23, 0]);
box(1.35, 1.35, 1.65, M.truckLight, truck, [-1.55, 1.43, 0]);
box(1.34, 0.62, 1.67, M.glass, truck, [-1.56, 1.76, 0]);
box(0.58, 0.56, 1.52, M.truck, truck, [-2.12, 0.98, 0]);
box(0.9, 0.25, 1.2, M.truck, truck, [-1.55, 2.19, 0]);
box(0.68, 0.34, 0.76, M.chrome, truck, [-1.57, 2.39, 0]);
for (let i = 0; i < 4; i++) {
box(0.045, 1.48, 0.045, M.coldDark, truck, [-0.3 + i * 0.57, 1.61, 0.88]);
}
box(0.08, 0.55, 0.55, M.cold, truck, [2.04, 1.63, 0.52]);
const wheelGeometry = new THREE.CylinderGeometry(0.39, 0.39, 0.28, 12);
const hubGeometry = new THREE.CylinderGeometry(0.17, 0.17, 0.30, 10);
[-1.55, 1.08].forEach(x => {
[-0.94, 0.94].forEach(z => {
const wheel = mesh(wheelGeometry, M.rubber, truck, [x, 0.43, z]);
wheel.rotation.x = Math.PI / 2;
const hub = mesh(hubGeometry, M.chrome, truck, [x, 0.43, z]);
hub.rotation.x = Math.PI / 2;
});
});
box(0.12, 0.18, 0.36, M.red, truck, [-2.39, 0.98, 0.48]);
box(0.12, 0.18, 0.36, M.orange, truck, [-2.39, 0.98, -0.48]);
const truckLabel = badge(
"1920 / COLD TRUCK",
"INSULATED TRANSPORT • SEALED CARGO • 4°C",
"#8cecf1",
4.55
);
truckLabel.position.set(0, 3.55, 0);
truck.add(truckLabel);
// -------------------------------------------------------------------------
// Stage 03: Public market
// -------------------------------------------------------------------------
const market = new THREE.Group();
market.position.set(3.3, 0, -1.4);
scene.add(market);
registerStation(market, 2);
createStationBase(market, 2.75);
box(3.7, 0.66, 1.22, M.wood, market, [0, 0.61, 0]);
box(3.85, 0.16, 1.35, M.woodDark, market, [0, 0.98, 0]);
[-1.8, 1.8].forEach(x => {
[-0.78, 0.78].forEach(z => {
box(0.11, 2.65, 0.11, M.woodDark, market, [x, 1.46, z]);
});
});
for (let i = 0; i < 8; i++) {
const x = -1.75 + i * 0.5;
const stripeMat = i % 2 === 0 ? M.cream : M.red;
box(0.5, 0.13, 2.18, stripeMat, market, [x, 2.86, 0]);
box(0.5, 0.29, 0.11, stripeMat, market, [x, 2.66, 1.04]);
}
box(0.08, 0.85, 0.08, M.chrome, market, [0, 2.3, 0]);
box(0.62, 0.12, 0.12, M.chrome, market, [0, 2.04, 0]);
const scalePan = cylinder(0.35, 0.25, 0.08, 12, M.chrome, market, [0, 1.82, 0]);
scalePan.rotation.x = 0;
function createCrate(parent, x, z, color, fruitMat) {
box(0.82, 0.13, 0.68, M.woodDark, parent, [x, 1.12, z]);
box(0.82, 0.38, 0.07, M.wood, parent, [x, 1.29, z + 0.31]);
box(0.82, 0.38, 0.07, M.wood, parent, [x, 1.29, z - 0.31]);
box(0.07, 0.38, 0.68, M.wood, parent, [x + 0.38, 1.29, z]);
box(0.07, 0.38, 0.68, M.wood, parent, [x - 0.38, 1.29, z]);
for (let i = 0; i < 5; i++) {
const fruit = ico(0.12, 0, fruitMat, parent, [
x - 0.25 + (i % 3) * 0.22,
1.48 + (i > 2 ? 0.13 : 0),
z - 0.15 + Math.floor(i / 3) * 0.28
]);
fruit.scale.y = 1.15;
}
}
createCrate(market, -1.05, 0.08, M.orange, M.orange);
createCrate(market, 0.08, -0.10, M.green, M.leaf);
createCrate(market, 1.16, 0.07, M.red, M.red);
box(0.82, 0.48, 0.72, M.chrome, market, [1.08, 1.3, 0]);
box(0.88, 0.12, 0.78, M.cold, market, [1.08, 1.57, 0]);
const marketLabel = badge(
"1950 / PUBLIC MARKET",
"RETAIL HANDOFF • CHILLED DISPLAY • 4°C",
"#8cecf1",
4.65
);
marketLabel.position.set(0, 3.78, 0);
market.add(marketLabel);
// -------------------------------------------------------------------------
// Stage 04: Household cabinet
// -------------------------------------------------------------------------
const cabinet = new THREE.Group();
cabinet.position.set(10.2, 0, 0.2);
scene.add(cabinet);
registerStation(cabinet, 3);
createStationBase(cabinet, 2.65);
box(2.2, 3.25, 0.16, M.fridgeInside, cabinet, [0, 1.77, -0.76]);
box(0.16, 3.25, 1.64, M.fridge, cabinet, [-1.02, 1.77, 0]);
box(0.16, 3.25, 1.64, M.fridge, cabinet, [1.02, 1.77, 0]);
box(2.2, 0.18, 1.64, M.fridge, cabinet, [0, 0.22, 0]);
box(2.2, 0.18, 1.64, M.fridge, cabinet, [0, 3.31, 0]);
[1.12, 1.87, 2.62].forEach((y, index) => {
box(1.85, 0.07, 1.27, index === 2 ? M.cold : M.chrome, cabinet, [0, y, 0.03]);
});
// Milk carton, jar, produce and covered tray.
box(0.28, 0.48, 0.28, M.cream, cabinet, [-0.55, 1.4, 0.03]);
box(0.19, 0.15, 0.19, M.orange, cabinet, [0.1, 2.07, 0.04]);
cylinder(0.18, 0.18, 0.33, 10, M.green, cabinet, [0.55, 2.08, 0.04]);
ico(0.16, 0, M.red, cabinet, [-0.38, 2.84, 0.05]);
ico(0.15, 0, M.leaf, cabinet, [0.05, 2.83, 0.06]);
box(0.62, 0.12, 0.42, M.chrome, cabinet, [0.42, 1.31, 0.08]);
const doorPivot = new THREE.Group();
doorPivot.position.set(1.02, 0, 0.83);
doorPivot.rotation.y = 1.08;
cabinet.add(doorPivot);
box(2.08, 3.05, 0.16, M.fridge, doorPivot, [-1.04, 1.76, 0]);
box(1.82, 2.76, 0.05, M.fridgeInside, doorPivot, [-1.04, 1.76, 0.11]);
box(0.09, 0.75, 0.12, M.chrome, doorPivot, [-1.76, 1.88, 0.16]);
box(0.9, 0.14, 0.48, M.coldDark, cabinet, [0, 3.53, -0.25]);
const cabinetLabel = badge(
"1970+ / HOME CABINET",
"FINAL COLD STORAGE • COMPRESSOR + GASKET • 4°C",
"#8cecf1",
4.75
);
cabinetLabel.position.set(0, 4.35, 0);
cabinet.add(cabinetLabel);
// -------------------------------------------------------------------------
// Handoff checkpoints between stages
// -------------------------------------------------------------------------
const checkpoints = [];
const checkpointTimes = [0.245, 0.51, 0.755];
checkpointTimes.forEach((t, index) => {
const point = coldCurve.getPointAt(t);
const tangent = coldCurve.getTangentAt(t).normalize();
const perpendicular = new THREE.Vector3(-tangent.z, 0, tangent.x).normalize();
const checkpoint = new THREE.Group();
checkpoint.position.copy(point);
scene.add(checkpoint);
[-1, 1].forEach(side => {
const post = cylinder(
0.045,
0.055,
0.7,
8,
M.chrome,
checkpoint,
[
perpendicular.x * 0.42 * side,
0.43,
perpendicular.z * 0.42 * side
]
);
post.castShadow = false;
});
const ring = mesh(
new THREE.TorusGeometry(0.34, 0.035, 6, 24),
M.cold,
checkpoint,
[0, 0.58, 0]
);
ring.quaternion.setFromUnitVectors(new THREE.Vector3(0, 0, 1), tangent);
ring.castShadow = false;
const beacon = ico(0.1, 1, M.cold, checkpoint, [0, 0.93, 0]);
const label = badge(
`HANDOFF 0${index + 1}`,
"SEALED TRANSFER • 0–4°C",
"#67e8f9",
2.75
);
label.position.set(0, 1.35, 0);
checkpoint.add(label);
checkpoints.push({ group: checkpoint, label, beacon, ring });
});
// -------------------------------------------------------------------------
// Moving temperature-controlled parcels
// -------------------------------------------------------------------------
const parcelCount = 10;
const parcelGeometry = new THREE.BoxGeometry(0.31, 0.24, 0.37);
const parcels = new THREE.InstancedMesh(parcelGeometry, M.cold, parcelCount);
parcels.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
parcels.castShadow = true;
scene.add(parcels);
const packetGeometry = new THREE.IcosahedronGeometry(0.075, 0);
const packets = new THREE.InstancedMesh(packetGeometry, M.cold, 8);
packets.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
scene.add(packets);
// -------------------------------------------------------------------------
// Failed market-to-cabinet handoff
// -------------------------------------------------------------------------
const breachCurvePoints = [];
for (let i = 0; i <= 18; i++) {
breachCurvePoints.push(coldCurve.getPointAt(0.71 + (i / 18) * 0.09));
}
const breachCurve = new THREE.CatmullRomCurve3(breachCurvePoints);
const breachTube = mesh(
new THREE.TubeGeometry(breachCurve, 50, 0.13, 8, false),
M.warm,
scene
);
breachTube.castShadow = false;
breachTube.visible = false;
const breachBeacon = ico(0.17, 1, M.warm, checkpoints[2].group, [0, 0.78, 0]);
breachBeacon.visible = false;
const breachLabel = badge(
"HANDOFF 03",
"12 MIN DELAY • TEMPERATURE RISING",
"#fb923c",
3.15
);
breachLabel.position.set(0, 1.35, 0);
breachLabel.visible = false;
checkpoints[2].group.add(breachLabel);
let breachActive = false;
// -------------------------------------------------------------------------
// UI, selection and interaction
// -------------------------------------------------------------------------
const stageMeta = [
{
title: "Harvest meets the ice house",
body: "Before mechanical refrigeration, layered winter ice and insulated chambers held food near 0°C. The cold chain began where harvest met storage.",
target: new THREE.Vector3(-10.5, 1.0, 0)
},
{
title: "A sealed load crosses the city",
body: "Early refrigerated vehicles connected producer, warehouse and market. Insulated panels, cold storage, seals and timers had to work together for every kilometre.",
target: new THREE.Vector3(-3.8, 1.15, 1.4)
},
{
title: "Many hands, one critical handoff",
body: "Sorting, display and selling create repeated door-open moments. Goods must move from the truck to a chilled counter without spending an unrefrigerated interval on the stall.",
target: new THREE.Vector3(3.3, 1.1, -1.4)
},
{
title: "The cold chain ends at home",
body: "The household cabinet extends the chain rather than restarting it. Its compressor, gaskets and internal temperature preserve the work completed at every earlier stage.",
target: new THREE.Vector3(10.2, 1.45, 0.2)
}
];
const storyKicker = document.getElementById("story-kicker");
const storyTitle = document.getElementById("story-title");
const storyBody = document.getElementById("story-body");
const stageButtons = [...document.querySelectorAll(".stage-button")];
const resetButton = document.getElementById("reset-view");
const breachButton = document.getElementById("breach-button");
const statusText = document.getElementById("status-text");
let selectedStage = 0;
const desired = {
target: new THREE.Vector3(-0.7, 1.0, 0),
radius: window.innerWidth < 700 ? 45 : 25.5,
azimuth: 0.53,
polar: 1.04
};
const current = {
target: desired.target.clone(),
radius: desired.radius,
azimuth: desired.azimuth,
polar: desired.polar
};
function selectStage(index) {
selectedStage = index;
const meta = stageMeta[index];
storyKicker.textContent = `${meta === stageMeta[0] ? "1850" : meta === stageMeta[1] ? "1920" : meta === stageMeta[2] ? "1950" : "1970+"} / Stage 0${index + 1}`;
storyTitle.textContent = meta.title;
storyBody.textContent = meta.body;
stageButtons.forEach((button, i) => {
button.classList.toggle("active", i === index);
});
}
function focusStage(index) {
selectStage(index);
desired.target.copy(stageMeta[index].target);
desired.radius = 10.4;
desired.azimuth = 0.48;
desired.polar = 1.08;
}
stageButtons.forEach(button => {
button.addEventListener("click", () => {
focusStage(Number(button.dataset.stage));
});
});
resetButton.addEventListener("click", () => {
desired.target.set(-0.7, 1.0, 0);
desired.radius = window.innerWidth < 700 ? 45 : 25.5;
desired.azimuth = 0.53;
desired.polar = 1.04;
});
breachButton.addEventListener("click", () => {
breachActive = !breachActive;
document.body.classList.toggle("breach-active", breachActive);
breachTube.visible = breachActive;
breachBeacon.visible = breachActive;
breachLabel.visible = breachActive;
checkpoints[2].label.visible = !breachActive;
breachButton.textContent = breachActive
? "Restore the cold chain"
: "Simulate failed market handoff";
statusText.textContent = breachActive
? "Cold chain interrupted"
: "Cold chain intact";
});
// Direct orbit controls — no external controls or examples modules.
let pointerDown = false;
let pointerMoved = false;
let lastPointerX = 0;
let lastPointerY = 0;
canvas.addEventListener("pointerdown", event => {
pointerDown = true;
pointerMoved = false;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!pointerDown) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
if (Math.abs(dx) + Math.abs(dy) > 2) pointerMoved = true;
desired.azimuth -= dx * 0.0055;
desired.polar = THREE.MathUtils.clamp(
desired.polar - dy * 0.0045,
0.48,
1.38
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
});
canvas.addEventListener("pointerup", event => {
pointerDown = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (!pointerMoved) {
const pointer = new THREE.Vector2(
(event.clientX / window.innerWidth) * 2 - 1,
-(event.clientY / window.innerHeight) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(stationGroups, true);
if (hits.length) {
let object = hits[0].object;
while (object && object.userData.stage === undefined) {
object = object.parent;
}
if (object) focusStage(object.userData.stage);
}
}
});
canvas.addEventListener("pointercancel", () => {
pointerDown = false;
});
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
7.2,
55
);
},
{ passive: false }
);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
const dummy = new THREE.Object3D();
const axisX = new THREE.Vector3(1, 0, 0);
const coldColor = new THREE.Color(0x67e8f9);
const warmColor = new THREE.Color(0xfb923c);
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const damping = 0.085;
current.target.lerp(desired.target, damping);
current.radius += (desired.radius - current.radius) * damping;
current.azimuth += (desired.azimuth - current.azimuth) * damping;
current.polar += (desired.polar - current.polar) * damping;
const sinPolar = Math.sin(current.polar);
camera.position.set(
current.target.x + current.radius * sinPolar * Math.sin(current.azimuth),
current.target.y + current.radius * Math.cos(current.polar),
current.target.z + current.radius * sinPolar * Math.cos(current.azimuth)
);
camera.lookAt(current.target);
// Selection rings.
selectionRings.forEach((ring, index) => {
const active = index === selectedStage;
ring.material.opacity = active
? 0.64 + Math.sin(elapsed * 2.8) * 0.16
: 0.14;
ring.scale.setScalar(active ? 1.015 + Math.sin(elapsed * 2.8) * 0.012 : 1);
});
// Animated cold parcels moving through every stage.
for (let i = 0; i < parcelCount; i++) {
const t = (i / parcelCount + (reducedMotion ? 0 : elapsed * 0.026)) % 1;
const point = coldCurve.getPointAt(t);
const tangent = coldCurve.getTangentAt(t).normalize();
point.y += 0.21;
dummy.position.copy(point);
dummy.quaternion.setFromUnitVectors(axisX, tangent);
dummy.scale.setScalar(i === 0 ? 1.3 : 1);
dummy.updateMatrix();
parcels.setMatrixAt(i, dummy.matrix);
const color = breachActive && t > 0.69 ? warmColor : coldColor;
parcels.setColorAt(i, color);
}
parcels.instanceMatrix.needsUpdate = true;
if (parcels.instanceColor) parcels.instanceColor.needsUpdate = true;
// Smaller bright packets emphasize direction of travel.
for (let i = 0; i < 8; i++) {
const t = (i / 8 + (reducedMotion ? 0 : elapsed * 0.038) + 0.04) % 1;
const point = coldCurve.getPointAt(t);
const tangent = coldCurve.getTangentAt(t).normalize();
point.y += 0.38;
dummy.position.copy(point);
dummy.quaternion.setFromUnitVectors(axisX, tangent);
dummy.scale.setScalar(0.8 + Math.sin(elapsed * 3 + i) * 0.12);
dummy.updateMatrix();
packets.setMatrixAt(i, dummy.matrix);
packets.setColorAt(i, breachActive && t > 0.69 ? warmColor : coldColor);
}
packets.instanceMatrix.needsUpdate = true;
if (packets.instanceColor) packets.instanceColor.needsUpdate = true;
// Checkpoint pulses.
checkpoints.forEach((checkpoint, index) => {
const pulse = 1 + Math.sin(elapsed * 3.1 + index * 1.4) * 0.16;
checkpoint.beacon.scale.setScalar(pulse);
checkpoint.ring.material.emissiveIntensity = 0.7 + pulse * 0.4;
});
if (breachActive) {
const pulse = 1 + Math.sin(elapsed * 6) * 0.22;
breachBeacon.scale.setScalar(pulse);
breachTube.material.emissiveIntensity = 1.15 + pulse * 0.65;
}
renderer.render(scene, camera);
}
selectStage(0);
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hide");
});
</script>
</body>
</html>
```