Prompt specification
Build or customize the Three.js 3D scene "Transfer between cooled spaces" 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: Transfer between cooled spaces
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/transfer-between-cooled-spaces-x1042
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts cold-chain continuity. Animate a crate moving from storage to vehicle to shop cabinet; a fictional temperature indicator responds to exposed intervals under clearly stated toy heat-transfer rules. Low-poly.
Working Three.js Starter (transfer-between-cooled-spaces-x1042):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Cold-Chain Continuity</title>
<style>
:root {
--ink: #effffc;
--muted: #a8c4c1;
--panel: rgba(8, 31, 36, 0.88);
--line: rgba(185, 235, 225, 0.18);
--cold: #63ead6;
--warm: #ffc26f;
--hot: #ff7468;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe7e4;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.panel {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 18px;
box-shadow: 0 18px 50px rgba(7, 31, 34, 0.18);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
header {
position: absolute;
top: 26px;
left: 30px;
max-width: 560px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: #315f5b;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 26px;
height: 3px;
content: "";
border-radius: 4px;
background: #318f83;
}
h1 {
margin: 0;
color: #143b3d;
font-size: clamp(28px, 3.6vw, 52px);
font-weight: 780;
letter-spacing: -0.045em;
line-height: 0.98;
}
.subtitle {
margin: 10px 0 0;
color: #456966;
font-size: 14px;
line-height: 1.5;
}
.chain-pill {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 14px;
padding: 8px 12px;
border: 1px solid rgba(32, 96, 88, 0.16);
border-radius: 999px;
background: rgba(255, 255, 255, 0.54);
color: #204e4b;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.chain-pill i {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--cold);
box-shadow: 0 0 0 4px rgba(99, 234, 214, 0.18);
}
#rules {
position: absolute;
bottom: 28px;
left: 28px;
width: 350px;
padding: 18px 19px 16px;
pointer-events: auto;
}
.panel-kicker {
margin-bottom: 9px;
color: var(--cold);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#rules h2,
#temperature-card h2 {
margin: 0 0 9px;
font-size: 15px;
letter-spacing: -0.01em;
}
#rules p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.formula {
display: block;
margin: 10px 0;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(0, 0, 0, 0.12);
color: #eafffb;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
line-height: 1.5;
}
.rule-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 10px;
}
.rule-chip {
padding: 8px;
border-radius: 9px;
background: rgba(255, 255, 255, 0.055);
color: #c9dfdc;
font-size: 10px;
line-height: 1.4;
}
.rule-chip strong {
display: block;
color: white;
font-size: 11px;
}
.disclaimer {
margin-top: 10px !important;
color: #7f9e9b !important;
font-size: 10px !important;
}
#temperature-card {
position: absolute;
top: 26px;
right: 26px;
width: 310px;
padding: 18px;
pointer-events: auto;
}
.temp-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.temp-reading {
margin-top: 2px;
color: var(--cold);
font-size: 46px;
font-weight: 760;
letter-spacing: -0.06em;
line-height: 1;
transition: color 180ms ease;
}
.temp-unit {
margin-left: 3px;
font-size: 20px;
letter-spacing: -0.02em;
}
.gauge {
position: relative;
width: 7px;
height: 60px;
overflow: hidden;
flex: 0 0 7px;
border-radius: 99px;
background: rgba(255, 255, 255, 0.09);
}
.gauge-fill {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 16%;
border-radius: 99px;
background: var(--cold);
transition: height 120ms linear, background 180ms ease;
}
.gauge-threshold {
position: absolute;
right: -3px;
bottom: 33.333%;
width: 13px;
height: 1px;
background: var(--warm);
}
#temp-status {
min-height: 18px;
margin-top: 8px;
color: var(--cold);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.035em;
transition: color 180ms ease;
}
#phase-label {
margin-top: 5px;
color: var(--muted);
font-size: 11px;
}
.chart-wrap {
position: relative;
margin-top: 14px;
padding-top: 8px;
border-top: 1px solid var(--line);
}
.chart-title {
position: absolute;
top: 12px;
left: 0;
color: #86a8a4;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#chart {
display: block;
width: 100%;
height: 82px;
overflow: visible;
}
.chart-key {
display: flex;
justify-content: space-between;
color: #86a8a4;
font-size: 9px;
letter-spacing: 0.05em;
}
.world-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
padding: 6px 9px 6px 6px;
border: 1px solid rgba(255, 255, 255, 0.58);
border-radius: 999px;
background: rgba(11, 42, 46, 0.76);
box-shadow: 0 8px 20px rgba(17, 54, 56, 0.12);
color: white;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
white-space: nowrap;
transform: translate(-50%, -50%);
transition: opacity 120ms linear;
}
.world-label span {
display: grid;
width: 20px;
height: 20px;
place-items: center;
border-radius: 50%;
background: rgba(99, 234, 214, 0.18);
color: var(--cold);
font-size: 9px;
}
#label-van span {
background: rgba(255, 194, 111, 0.18);
color: var(--warm);
}
.transport {
position: absolute;
bottom: 25px;
left: 50%;
width: min(760px, calc(100% - 48px));
padding: 13px 15px 12px;
pointer-events: auto;
transform: translateX(-50%);
}
.transport-main {
display: flex;
align-items: center;
gap: 12px;
}
button {
border: 0;
color: #103b39;
font: inherit;
font-size: 11px;
font-weight: 800;
cursor: pointer;
}
#play {
min-width: 72px;
height: 36px;
padding: 0 14px;
border-radius: 10px;
background: var(--cold);
transition: transform 120ms ease, background 180ms ease;
}
#play:hover {
transform: translateY(-1px);
}
#reset {
width: 36px;
height: 36px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.06);
color: white;
font-size: 18px;
}
.timeline-area {
min-width: 0;
flex: 1;
}
.timeline-meta {
display: flex;
justify-content: space-between;
margin-bottom: 5px;
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#timeline {
width: 100%;
height: 15px;
margin: 0;
appearance: none;
background: transparent;
cursor: pointer;
}
#timeline::-webkit-slider-runnable-track {
height: 6px;
border-radius: 99px;
background:
linear-gradient(
90deg,
rgba(99, 234, 214, 0.65) 0 9.26%,
rgba(255, 194, 111, 0.72) 9.26% 27.78%,
rgba(99, 234, 214, 0.65) 27.78% 50%,
rgba(255, 194, 111, 0.72) 50% 70.37%,
rgba(99, 234, 214, 0.65) 70.37% 100%
);
}
#timeline::-moz-range-track {
height: 6px;
border-radius: 99px;
background:
linear-gradient(
90deg,
rgba(99, 234, 214, 0.65) 0 9.26%,
rgba(255, 194, 111, 0.72) 9.26% 27.78%,
rgba(99, 234, 214, 0.65) 27.78% 50%,
rgba(255, 194, 111, 0.72) 50% 70.37%,
rgba(99, 234, 214, 0.65) 70.37% 100%
);
}
#timeline::-webkit-slider-thumb {
width: 15px;
height: 15px;
margin-top: -4.5px;
appearance: none;
border: 3px solid #0b3337;
border-radius: 50%;
background: white;
box-shadow: 0 0 0 2px var(--cold);
}
#timeline::-moz-range-thumb {
width: 10px;
height: 10px;
border: 3px solid #0b3337;
border-radius: 50%;
background: white;
box-shadow: 0 0 0 2px var(--cold);
}
.phase-strip {
display: grid;
grid-template-columns: 5fr 10fr 12fr 11fr 16fr;
gap: 3px;
margin-top: 6px;
color: #789d99;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.04em;
text-align: center;
text-transform: uppercase;
}
.camera-hint {
position: absolute;
right: 29px;
bottom: 29px;
color: rgba(27, 72, 69, 0.62);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
@media (max-width: 1120px) {
#rules {
display: none;
}
.camera-hint {
display: none;
}
}
@media (max-width: 700px) {
header {
top: 18px;
left: 18px;
max-width: calc(100% - 36px);
}
h1 {
font-size: 31px;
}
.subtitle {
display: none;
}
#temperature-card {
top: 108px;
right: 12px;
width: 235px;
padding: 13px;
}
.temp-reading {
font-size: 36px;
}
.chart-wrap {
display: none;
}
.transport {
bottom: 12px;
width: calc(100% - 24px);
}
.phase-strip {
font-size: 6px;
}
.world-label {
display: none;
}
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive low-poly cold-chain scene"></div>
<div class="hud">
<header>
<div class="eyebrow">Continuity Lab / Digital Twin</div>
<h1>Cold-chain,<br />uninterrupted.</h1>
<p class="subtitle">
Follow one temperature-sensitive crate from sealed storage,
through a refrigerated van, and into a shop cabinet.
</p>
<div class="chain-pill">
<i id="chain-dot"></i>
<span id="chain-status">Cold storage online</span>
</div>
</header>
<aside id="rules" class="panel">
<div class="panel-kicker">Toy heat-transfer rules</div>
<h2>Explicit model, not a forecast</h2>
<p>
One real second equals one modeled minute. Cold enclosures target
<strong>4°C</strong>; exposed loading and shop handoffs use
<strong>22°C</strong>.
</p>
<code class="formula">
T′ = T + (Ttarget − T) × (1 − e<sup>−Δt/τ</sup>)
</code>
<div class="rule-grid">
<div class="rule-chip">
<strong>Δt = 1 minute</strong>
Discrete model tick
</div>
<div class="rule-chip">
<strong>τ = 12 minutes</strong>
Refrigerated enclosure
</div>
<div class="rule-chip">
<strong>τ = 10 minutes</strong>
Exposed handoff
</div>
<div class="rule-chip">
<strong>8°C red line</strong>
Illustrative threshold
</div>
</div>
<p class="disclaimer">
The 8°C line is a fictional teaching threshold, not a regulatory,
medical, or commercial cold-chain limit.
</p>
</aside>
<aside id="temperature-card" class="panel">
<div class="panel-kicker">Cargo core indicator</div>
<div class="temp-top">
<div>
<div class="temp-reading">
<span id="temp-value">4.0</span><span class="temp-unit">°C</span>
</div>
<div id="temp-status">Within continuity limit</div>
<div id="phase-label">Cold storage · target 4°C</div>
</div>
<div class="gauge">
<div class="gauge-fill" id="gauge-fill"></div>
<div class="gauge-threshold"></div>
</div>
</div>
<div class="chart-wrap">
<div class="chart-title">54-minute model trace</div>
<svg id="chart" viewBox="0 0 264 82" aria-label="Temperature history"></svg>
<div class="chart-key">
<span>0 MIN</span>
<span>8°C THRESHOLD</span>
<span>54 MIN</span>
</div>
</div>
</aside>
<div id="label-storage" class="world-label">
<span>01</span> COLD STORAGE
</div>
<div id="label-van" class="world-label">
<span>02</span> REEFER VAN
</div>
<div id="label-shop" class="world-label">
<span>03</span> SHOP CABINET
</div>
<footer class="transport panel">
<div class="transport-main">
<button id="play" type="button" aria-label="Pause animation">Pause</button>
<button id="reset" type="button" aria-label="Restart animation">↺</button>
<div class="timeline-area">
<div class="timeline-meta">
<span id="current-phase">Cold storage</span>
<span id="time-readout">T + 00 / 54 MIN</span>
</div>
<input
id="timeline"
type="range"
min="0"
max="54"
step="0.05"
value="0"
aria-label="Model timeline"
/>
<div class="phase-strip">
<span>Storage</span>
<span>Exposed loading</span>
<span>Refrigerated transit</span>
<span>Exposed handoff</span>
<span>Cabinet recovery</span>
</div>
</div>
</div>
</footer>
<div class="camera-hint">Drag to orbit · scroll to zoom · double-click to reset</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
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.15;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe7e4);
scene.fog = new THREE.Fog(0xdbe7e4, 31, 58);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
100
);
// Custom orbit controls: no addon modules are used.
const orbit = {
target: new THREE.Vector3(0, 1.05, 0),
radius: 29,
theta: 0.48,
phi: 1.02,
dragging: false,
lastX: 0,
lastY: 0
};
function applyCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
function resetCamera() {
orbit.radius = 29;
orbit.theta = 0.48;
orbit.phi = 1.02;
orbit.target.set(0, 1.05, 0);
applyCamera();
}
applyCamera();
renderer.domElement.addEventListener("pointerdown", (event) => {
orbit.dragging = true;
orbit.lastX = event.clientX;
orbit.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!orbit.dragging) return;
const dx = event.clientX - orbit.lastX;
const dy = event.clientY - orbit.lastY;
orbit.lastX = event.clientX;
orbit.lastY = event.clientY;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - dy * 0.005, 0.46, 1.35);
applyCamera();
});
function endDrag(event) {
orbit.dragging = false;
if (event.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {}
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.018,
18,
43
);
applyCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") {
orbit.theta -= 0.08;
applyCamera();
}
if (event.key === "ArrowRight") {
orbit.theta += 0.08;
applyCamera();
}
});
// Lighting.
scene.add(new THREE.HemisphereLight(0xf7fffb, 0x56726d, 2.1));
const sun = new THREE.DirectionalLight(0xfff6df, 3.2);
sun.position.set(-9, 18, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 17;
sun.shadow.camera.bottom = -17;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xa9e4e4, 1.2);
fill.position.set(13, 9, -10);
scene.add(fill);
const palette = {
ground: 0xcbd8d2,
road: 0x445b60,
cream: 0xf1eee2,
teal: 0x287d78,
tealDark: 0x164f51,
cyan: 0x63ead6,
cyanGlow: 0x8ffff0,
orange: 0xffb45e,
orangeDark: 0xc76f36,
wood: 0xb67b45,
woodDark: 0x70482c,
tire: 0x1d2d31,
glass: 0x8fe6e0,
dark: 0x173b3e,
white: 0xffffff
};
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.04,
flatShading: true,
...options
});
const mat = {
ground: material(palette.ground),
road: material(palette.road),
cream: material(palette.cream),
teal: material(palette.teal),
tealDark: material(palette.tealDark),
wood: material(palette.wood),
woodDark: material(palette.woodDark),
tire: material(palette.tire),
dark: material(palette.dark),
white: material(palette.white),
orange: material(palette.orange, {
emissive: palette.orange,
emissiveIntensity: 0.18
}),
cold: material(palette.cyan, {
emissive: palette.cyan,
emissiveIntensity: 0.75
})
};
function box(parent, w, h, d, x, y, z, m) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), m);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, rTop, rBottom, h, segments, x, y, z, m) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rTop, rBottom, h, segments),
m
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeSign(title, subtitle, accent = "#63ead6") {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#12383b";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = "rgba(255,255,255,0.18)";
ctx.lineWidth = 5;
ctx.strokeRect(7, 7, canvas.width - 14, canvas.height - 14);
ctx.fillStyle = accent;
ctx.fillRect(35, 34, 12, 124);
ctx.fillStyle = "#f5fffc";
ctx.font = "800 52px system-ui, sans-serif";
ctx.fillText(title, 70, 91);
ctx.fillStyle = accent;
ctx.font = "700 25px system-ui, sans-serif";
ctx.fillText(subtitle, 72, 141);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false
});
}
function makeSnowflake(parent, x, y, z, scale, m) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
for (const angle of [0, Math.PI / 3, -Math.PI / 3]) {
const arm = box(group, 0.78, 0.065, 0.065, 0, 0, 0, m);
arm.rotation.z = angle;
}
parent.add(group);
return group;
}
// Ground and street.
box(scene, 38, 0.25, 16, 0, -0.18, 0, mat.ground);
box(scene, 17, 0.08, 5.6, 0, 0.02, 0, mat.road);
for (let x = -7.5; x < 8; x += 1.65) {
box(scene, 0.82, 0.025, 0.09, x, 0.075, 0, mat.orange);
}
// Low-poly trees and roadside details.
const treeTrunk = material(0x79583b);
const treeLeaf = material(0x3e8971);
function addTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
cylinder(tree, 0.14, 0.19, 1.4, 7, 0, 0.7, 0, treeTrunk);
const lower = new THREE.Mesh(
new THREE.ConeGeometry(0.9, 1.8, 7),
treeLeaf
);
lower.position.y = 1.65;
lower.castShadow = true;
tree.add(lower);
const upper = new THREE.Mesh(
new THREE.ConeGeometry(0.65, 1.45, 7),
material(0x56a181)
);
upper.position.y = 2.35;
upper.castShadow = true;
tree.add(upper);
scene.add(tree);
}
addTree(-15.4, -4.5, 1.0);
addTree(-15.1, 3.4, 0.78);
addTree(15.7, -4.6, 0.95);
addTree(15.8, 3.8, 0.74);
// Cold storage room.
const storage = new THREE.Group();
scene.add(storage);
box(storage, 7.0, 0.32, 6.2, -10.5, 0.12, 0, mat.cream);
box(storage, 7.0, 3.8, 0.24, -10.5, 2.14, -2.92, mat.cream);
box(storage, 0.24, 3.8, 6.1, -13.95, 2.14, 0, mat.cream);
for (const x of [-13.85, -7.15]) {
for (const z of [-2.78, 2.78]) {
box(storage, 0.18, 3.9, 0.18, x, 2.16, z, mat.tealDark);
}
box(storage, 0.18, 0.18, 5.7, x, 4.05, 0, mat.tealDark);
}
box(storage, 6.85, 0.18, 0.18, -10.5, 4.05, -2.78, mat.tealDark);
box(storage, 6.85, 0.18, 0.18, -10.5, 4.05, 2.78, mat.tealDark);
const storageSign = new THREE.Mesh(
new THREE.PlaneGeometry(4.4, 1.1),
makeSign("COLD STORAGE", "SEALED ENCLOSURE • 4°C")
);
storageSign.position.set(-10.3, 3.35, -2.76);
storage.add(storageSign);
makeSnowflake(storage, -13.25, 2.3, -2.74, 1.05, mat.cold);
box(storage, 4.7, 0.06, 0.09, -10.5, 3.75, -2.72, mat.cold);
// Storage shelves.
function addShelf(x) {
for (const dx of [-0.9, 0.9]) {
box(storage, 0.09, 2.25, 0.09, x + dx, 1.4, -2.15, mat.tealDark);
}
for (const y of [0.72, 1.48, 2.24]) {
box(storage, 2.0, 0.09, 0.72, x, y, -2.18, mat.tealDark);
}
box(storage, 0.64, 0.52, 0.56, x - 0.47, 1.0, -2.16, mat.wood);
box(storage, 0.55, 0.48, 0.52, x + 0.4, 1.76, -2.16, mat.woodDark);
}
addShelf(-12.0);
addShelf(-9.15);
const storageRing = new THREE.Mesh(
new THREE.RingGeometry(0.9, 1.02, 32),
mat.cold
);
storageRing.rotation.x = -Math.PI / 2;
storageRing.position.set(-10, 0.31, 0.05);
storage.add(storageRing);
// Refrigerated van, built as a cutaway so the cargo remains visible.
const van = new THREE.Group();
van.position.x = -5;
scene.add(van);
box(van, 3.85, 0.18, 2.5, -1.05, 0.74, 0, mat.cream);
box(van, 3.85, 2.22, 0.13, -1.05, 1.92, -1.24, mat.white);
box(van, 3.85, 0.62, 0.13, -1.05, 1.13, 1.24, mat.teal);
box(van, 0.14, 2.22, 2.5, 0.86, 1.92, 0, mat.cream);
for (const z of [-1.23, 1.23]) {
box(van, 3.9, 0.13, 0.13, -1.05, 3.04, z, mat.teal);
}
for (const x of [-2.95, 0.86]) {
box(van, 0.13, 0.13, 2.5, x, 3.04, 0, mat.teal);
}
box(van, 3.15, 0.055, 0.09, -1.05, 2.93, 0, mat.cold);
const vanSign = new THREE.Mesh(
new THREE.PlaneGeometry(2.9, 0.73),
makeSign("REEFER • 4°C", "CONTROLLED TRANSIT", "#63ead6")
);
vanSign.position.set(-1.05, 2.42, 1.31);
van.add(vanSign);
// Cab.
box(van, 2.05, 1.28, 2.3, 1.72, 1.31, 0, mat.teal);
box(van, 1.65, 1.02, 2.16, 1.42, 2.19, 0, mat.teal);
box(van, 0.95, 0.59, 0.055, 1.73, 2.24, 1.105, mat.dark);
box(van, 0.95, 0.59, 0.055, 1.73, 2.24, -1.105, mat.dark);
box(van, 0.08, 0.67, 1.65, 2.255, 2.18, 0, mat.dark);
box(van, 0.72, 0.42, 2.08, 2.7, 1.04, 0, mat.teal);
box(van, 0.12, 0.18, 1.9, 3.08, 0.87, 0, mat.tealDark);
const headlightMaterial = material(0xfff2b0, {
emissive: 0xffe89c,
emissiveIntensity: 1.2
});
for (const z of [-0.78, 0.78]) {
box(van, 0.09, 0.22, 0.34, 3.09, 1.28, z, headlightMaterial);
}
const wheelPivots = [];
function addWheel(x, z) {
const pivot = new THREE.Group();
pivot.position.set(x, 0.48, z);
const wheel = cylinder(
pivot,
0.43,
0.43,
0.29,
10,
0,
0,
0,
mat.tire
);
wheel.rotation.x = Math.PI / 2;
const hub = cylinder(
pivot,
0.19,
0.19,
0.31,
8,
0,
0,
0,
mat.cream
);
hub.rotation.x = Math.PI / 2;
van.add(pivot);
wheelPivots.push(pivot);
}
addWheel(1.95, 1.27);
addWheel(1.95, -1.27);
addWheel(-1.85, 1.27);
addWheel(-1.85, -1.27);
// Rear cargo door opens around its lower hinge.
const rearDoor = new THREE.Group();
rearDoor.position.set(-2.96, 0.82, 0);
box(rearDoor, 0.12, 2.08, 2.32, 0, 1.04, 0, mat.white);
box(rearDoor, 0.15, 0.08, 2.36, -0.04, 1.84, 0, mat.teal);
van.add(rearDoor);
// Shop and chilled cabinet.
const shop = new THREE.Group();
scene.add(shop);
box(shop, 6.4, 0.32, 6.5, 11.05, 0.12, 0, mat.cream);
box(shop, 6.4, 4.4, 0.22, 11.05, 2.4, -3.05, mat.cream);
box(shop, 6.9, 0.18, 0.18, 11.05, 4.55, -2.88, mat.tealDark);
for (const x of [7.9, 14.2]) {
box(shop, 0.16, 4.45, 0.16, x, 2.4, -2.88, mat.tealDark);
}
box(shop, 6.5, 0.14, 2.2, 11.05, 3.85, -1.25, mat.teal);
for (let x = 8; x < 14.5; x += 0.75) {
const stripe = box(
shop,
0.34,
0.16,
2.22,
x,
3.85,
-1.25,
mat.white
);
stripe.rotation.y = 0.03;
}
const shopSign = new THREE.Mesh(
new THREE.PlaneGeometry(4.7, 1.18),
makeSign("SHOP CABINET", "CHILLED DISPLAY • 4°C")
);
shopSign.position.set(11.05, 4.02, 0.03);
shop.add(shopSign);
// Cabinet structure.
box(shop, 3.15, 0.36, 2.45, 11.05, 0.48, 0, mat.tealDark);
box(shop, 3.0, 2.95, 0.12, 11.05, 1.98, -1.08, mat.cream);
box(shop, 0.13, 2.95, 2.25, 9.55, 1.98, 0, mat.cream);
box(shop, 0.13, 2.95, 2.25, 12.55, 1.98, 0, mat.cream);
box(shop, 3.13, 0.16, 2.35, 11.05, 3.5, 0, mat.teal);
box(shop, 2.78, 0.10, 2.02, 11.05, 0.80, 0, mat.tealDark);
box(shop, 2.78, 0.10, 2.02, 11.05, 2.28, 0, mat.tealDark);
box(shop, 2.55, 0.055, 0.08, 11.05, 3.39, 0.28, mat.cold);
const glassMaterial = material(palette.glass, {
transparent: true,
opacity: 0.18,
roughness: 0.18,
metalness: 0.05,
depthWrite: false
});
const glassLeft = box(
shop,
1.32,
2.55,
0.045,
10.34,
2.04,
1.16,
glassMaterial
);
const glassRight = box(
shop,
1.32,
2.55,
0.045,
11.76,
2.04,
1.16,
glassMaterial
);
box(shop, 0.055, 2.55, 0.07, 11.05, 2.04, 1.19, mat.tealDark);
makeSnowflake(shop, 11.05, 3.1, 1.22, 0.52, mat.cold);
const cabinetLight = new THREE.PointLight(palette.cyanGlow, 7, 5, 2);
cabinetLight.position.set(11.05, 2.8, 0.4);
shop.add(cabinetLight);
// Exposed-route floor dots.
const routeDots = [];
function addRouteDot(x, z) {
const dot = cylinder(
scene,
0.09,
0.09,
0.035,
8,
x,
0.33,
z,
mat.orange
);
routeDots.push(dot);
}
[-9.6, -8.7, -7.8].forEach((x) => addRouteDot(x, 0));
[4.8, 5.8, 6.8].forEach((x) => addRouteDot(x, 1.65));
addRouteDot(8.0, 1.9);
addRouteDot(9.0, 1.25);
// The temperature-sensitive crate.
const crate = new THREE.Group();
scene.add(crate);
box(crate, 1.48, 1.16, 1.28, 0, 0, 0, mat.wood);
for (const z of [-0.66, 0.66]) {
for (const y of [-0.38, 0.38]) {
box(crate, 1.5, 0.13, 0.08, 0, y, z, mat.woodDark);
}
for (const x of [-0.55, 0.55]) {
box(crate, 0.12, 1.18, 0.09, x, 0, z, mat.woodDark);
}
}
for (const x of [-0.5, 0.5]) {
box(crate, 0.12, 0.08, 1.3, x, 0.62, 0, mat.woodDark);
}
box(crate, 1.55, 0.08, 0.09, 0, 0, -0.67, mat.woodDark);
// Sensor housing and indicator.
const sensorHousing = box(
crate,
0.44,
0.26,
0.10,
0.16,
0.17,
0.72,
mat.dark
);
const sensorMaterial = material(palette.cyan, {
emissive: palette.cyan,
emissiveIntensity: 1.7
});
const sensorLed = new THREE.Mesh(
new THREE.SphereGeometry(0.085, 10, 8),
sensorMaterial
);
sensorLed.position.set(0.28, 0.17, 0.80);
crate.add(sensorLed);
const crateLight = new THREE.PointLight(palette.cyanGlow, 1.4, 2.3, 2);
crateLight.position.set(0.25, 0.2, 0.9);
crate.add(crateLight);
// A few decorative products inside the shop.
for (let i = 0; i < 4; i++) {
const product = box(
shop,
0.35,
0.48,
0.34,
9.9 + i * 0.68,
2.55,
-0.42,
i % 2 ? mat.teal : mat.orange
);
product.rotation.y = (i - 1.5) * 0.08;
}
// -------------------------------------------------
// Toy heat-transfer model.
// -------------------------------------------------
const TOTAL_MINUTES = 54;
const temperatures = new Array(TOTAL_MINUTES + 1);
temperatures[0] = 4;
function phaseAt(t) {
if (t < 5) {
return {
target: 4,
tau: 12,
name: "Cold storage",
short: "Storage",
subtitle: "Cold storage · target 4°C",
exposed: false
};
}
if (t < 15) {
return {
target: 22,
tau: 10,
name: "Exposed loading",
short: "Exposed loading",
subtitle: "Loading bay · exposed at 22°C",
exposed: true
};
}
if (t < 27) {
return {
target: 4,
tau: 12,
name: "Refrigerated transit",
short: "Reefer transit",
subtitle: "Closed refrigerated van · target 4°C",
exposed: false
};
}
if (t < 38) {
return {
target: 22,
tau: 10,
name: "Exposed shop handoff",
short: "Exposed handoff",
subtitle: "Shop floor · exposed at 22°C",
exposed: true
};
}
return {
target: 4,
tau: 12,
name: "Cabinet recovery",
short: "Cabinet recovery",
subtitle: "Shop cabinet · target 4°C",
exposed: false
};
}
for (let minute = 1; minute <= TOTAL_MINUTES; minute++) {
const phase = phaseAt(minute - 1);
const previous = temperatures[minute - 1];
temperatures[minute] =
previous +
(phase.target - previous) * (1 - Math.exp(-1 / phase.tau));
}
function temperatureAt(t) {
const clamped = THREE.MathUtils.clamp(t, 0, TOTAL_MINUTES);
const lower = Math.floor(clamped);
if (lower >= TOTAL_MINUTES) return temperatures[TOTAL_MINUTES];
const fraction = clamped - lower;
return THREE.MathUtils.lerp(
temperatures[lower],
temperatures[lower + 1],
fraction
);
}
function smooth01(value) {
const x = THREE.MathUtils.clamp(value, 0, 1);
return x * x * (3 - 2 * x);
}
function windowPulse(t, start, end, ramp = 1) {
const opening = smooth01((t - start) / ramp);
const closing = 1 - smooth01((t - (end - ramp)) / ramp);
return Math.min(opening, closing);
}
function vanXAt(t) {
if (t <= 15) return -5;
if (t >= 27) return 5;
return THREE.MathUtils.lerp(-5, 5, smooth01((t - 15) / 12));
}
function cratePositionAt(t, out) {
if (t <= 5) {
out.set(-10, 0.94, 0);
} else if (t <= 15) {
const u = smooth01((t - 5) / 10);
const lift = smooth01((t - 8.2) / 4.0);
out.set(
THREE.MathUtils.lerp(-10, -6.05, u),
THREE.MathUtils.lerp(0.94, 1.46, lift),
0
);
} else if (t <= 27) {
out.set(vanXAt(t) - 1.05, 1.46, 0);
} else if (t <= 38) {
const u = THREE.MathUtils.clamp((t - 27) / 11, 0, 1);
if (u < 0.58) {
const v = smooth01(u / 0.58);
out.set(
THREE.MathUtils.lerp(3.95, 7.3, v),
THREE.MathUtils.lerp(1.46, 1.37, v),
THREE.MathUtils.lerp(0, 2.35, v)
);
} else {
const v = smooth01((u - 0.58) / 0.42);
out.set(
THREE.MathUtils.lerp(7.3, 11.05, v),
THREE.MathUtils.lerp(1.37, 1.46, v),
THREE.MathUtils.lerp(2.35, 0, v)
);
}
} else {
out.set(11.05, 1.46, 0);
}
return out;
}
// Draw the temperature chart.
const chart = document.getElementById("chart");
const chartWidth = 264;
const chartHeight = 82;
const chartPad = 7;
const chartY = (temperature) =>
chartHeight -
chartPad -
(temperature / 24) * (chartHeight - chartPad * 2);
const chartPoints = temperatures.map((temperature, minute) => {
const x =
chartPad +
(minute / TOTAL_MINUTES) * (chartWidth - chartPad * 2);
return [x, chartY(temperature)];
});
const linePath = chartPoints
.map(([x, y], index) => `${index === 0 ? "M" : "L"}${x.toFixed(2)},${y.toFixed(2)}`)
.join(" ");
const areaPath =
`M${chartPoints[0][0]},${chartHeight - chartPad} ` +
chartPoints
.map(([x, y]) => `L${x.toFixed(2)},${y.toFixed(2)}`)
.join(" ") +
` L${chartPoints[chartPoints.length - 1][0]},${chartHeight - chartPad} Z`;
const thresholdY = chartY(8);
chart.innerHTML = `
<defs>
<linearGradient id="chart-fill" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#63ead6" stop-opacity="0.28"/>
<stop offset="100%" stop-color="#63ead6" stop-opacity="0"/>
</linearGradient>
</defs>
<line
x1="${chartPad}" y1="${thresholdY}"
x2="${chartWidth - chartPad}" y2="${thresholdY}"
stroke="#ffc26f" stroke-width="1" stroke-dasharray="4 4" opacity="0.8"
/>
<path d="${areaPath}" fill="url(#chart-fill)"/>
<path
d="${linePath}" fill="none" stroke="#63ead6"
stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"
/>
<circle id="chart-dot" r="4" fill="#ffffff" stroke="#63ead6" stroke-width="2"/>
`;
const chartDot = document.getElementById("chart-dot");
// UI state.
const tempValue = document.getElementById("temp-value");
const tempStatus = document.getElementById("temp-status");
const phaseLabel = document.getElementById("phase-label");
const currentPhase = document.getElementById("current-phase");
const timeReadout = document.getElementById("time-readout");
const chainStatus = document.getElementById("chain-status");
const chainDot = document.getElementById("chain-dot");
const gaugeFill = document.getElementById("gauge-fill");
const timeline = document.getElementById("timeline");
const playButton = document.getElementById("play");
const resetButton = document.getElementById("reset");
let modelTime = 0;
let playing = true;
const coldColor = new THREE.Color(0x63ead6);
const warmColor = new THREE.Color(0xffc26f);
const hotColor = new THREE.Color(0xff7468);
function temperatureColor(temperature) {
if (temperature <= 8) return coldColor;
if (temperature <= 12) return warmColor;
return hotColor;
}
function updateUI() {
const temperature = temperatureAt(modelTime);
const phase = phaseAt(modelTime);
const color = temperatureColor(temperature);
const colorCSS = `#${color.getHexString()}`;
tempValue.textContent = temperature.toFixed(1);
tempValue.style.color = colorCSS;
tempStatus.style.color = colorCSS;
gaugeFill.style.height = `${THREE.MathUtils.clamp((temperature / 24) * 100, 0, 100)}%`;
gaugeFill.style.background = colorCSS;
if (modelTime >= TOTAL_MINUTES) {
tempStatus.textContent = "Chain closed · within limit";
chainStatus.textContent = "Continuity closed";
chainDot.style.background = colorCSS;
chainDot.style.boxShadow = `0 0 0 4px ${colorCSS}28`;
} else if (temperature > 8 && phase.exposed) {
tempStatus.textContent = "Exposure above 8°C";
chainStatus.textContent = "Exposure detected";
chainDot.style.background = colorCSS;
chainDot.style.boxShadow = `0 0 0 4px ${colorCSS}28`;
} else if (temperature > 8) {
tempStatus.textContent = "Recovering inside cold zone";
chainStatus.textContent = "Recovery in progress";
chainDot.style.background = colorCSS;
chainDot.style.boxShadow = `0 0 0 4px ${colorCSS}28`;
} else {
tempStatus.textContent = "Within continuity limit";
chainStatus.textContent =
modelTime < 5
? "Cold storage online"
: modelTime < 27
? "Refrigerated control active"
: "Continuity restored";
chainDot.style.background = colorCSS;
chainDot.style.boxShadow = `0 0 0 4px ${colorCSS}28`;
}
phaseLabel.textContent = phase.subtitle;
currentPhase.textContent = phase.name;
const minute = Math.floor(modelTime);
timeReadout.textContent =
`T + ${String(minute).padStart(2, "0")} / ${TOTAL_MINUTES} MIN`;
timeline.value = modelTime.toFixed(2);
const chartX =
chartPad +
(modelTime / TOTAL_MINUTES) * (chartWidth - chartPad * 2);
chartDot.setAttribute("cx", chartX.toFixed(2));
chartDot.setAttribute("cy", chartY(temperature).toFixed(2));
chartDot.setAttribute("stroke", colorCSS);
}
function updatePlayButton() {
playButton.textContent = playing ? "Pause" : "Play";
playButton.setAttribute(
"aria-label",
playing ? "Pause animation" : "Play animation"
);
}
playButton.addEventListener("click", () => {
if (modelTime >= TOTAL_MINUTES) modelTime = 0;
playing = !playing;
updatePlayButton();
});
resetButton.addEventListener("click", () => {
modelTime = 0;
playing = true;
updatePlayButton();
});
timeline.addEventListener("input", () => {
modelTime = Number(timeline.value);
playing = false;
updatePlayButton();
});
// World animation.
const tempPosition = new THREE.Vector3();
function updateWorld(t, elapsed) {
const vanX = vanXAt(t);
van.position.x = vanX;
cratePositionAt(t, tempPosition);
crate.position.copy(tempPosition);
// A subtle sensor bob, only while moving.
const speed =
Math.abs(cratePositionAt(Math.min(t + 0.05, TOTAL_MINUTES), new THREE.Vector3()).x -
cratePositionAt(Math.max(t - 0.05, 0), new THREE.Vector3()).x) /
0.1;
sensorLed.position.y = 0.17 + Math.sin(elapsed * 6) * 0.012 * Math.min(speed, 1);
for (const pivot of wheelPivots) {
pivot.rotation.z = -vanX / 0.43;
}
const loadingOpen = windowPulse(t, 4.6, 15.5, 1.1);
const handoffOpen = windowPulse(t, 26.6, 38.5, 1.1);
rearDoor.rotation.z =
Math.max(loadingOpen, handoffOpen) * Math.PI * 0.49;
const cabinetOpen = windowPulse(t, 32.2, 39.0, 1.0);
glassLeft.position.x = 10.34 - cabinetOpen * 0.73;
glassRight.position.x = 11.76 + cabinetOpen * 0.73;
const temperature = temperatureAt(t);
const color = temperatureColor(temperature);
sensorMaterial.color.copy(color);
sensorMaterial.emissive.copy(color);
crateLight.color.copy(color);
crateLight.intensity = 1.1 + (temperature > 8 ? 0.55 : 0.2);
const pulse = 0.76 + Math.sin(elapsed * 2.2) * 0.12;
mat.cold.emissiveIntensity = pulse;
cabinetLight.intensity = 6.4 + Math.sin(elapsed * 1.8) * 0.7;
mat.orange.emissiveIntensity =
0.16 + Math.sin(elapsed * 3.5) * 0.06;
routeDots.forEach((dot, index) => {
dot.scale.y = 1 + Math.sin(elapsed * 3 + index * 0.55) * 0.2;
});
}
// Projected HTML labels.
const labels = [
{
element: document.getElementById("label-storage"),
position: new THREE.Vector3(-10.5, 4.5, 0)
},
{
element: document.getElementById("label-van"),
position: new THREE.Vector3()
},
{
element: document.getElementById("label-shop"),
position: new THREE.Vector3(11.05, 4.35, 0)
}
];
function updateLabels() {
labels[1].position.set(van.position.x + 0.4, 3.65, 0);
for (const label of labels) {
const projected = label.position.clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
label.element.style.left =
`${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
label.element.style.top =
`${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
label.element.style.opacity = visible ? "1" : "0";
}
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
let previous = performance.now();
function animate(now) {
const delta = Math.min((now - previous) / 1000, 0.05);
previous = now;
if (playing) {
modelTime = Math.min(TOTAL_MINUTES, modelTime + delta);
if (modelTime >= TOTAL_MINUTES) {
playing = false;
updatePlayButton();
}
}
updateWorld(modelTime, now / 1000);
updateUI();
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updatePlayButton();
updateUI();
requestAnimationFrame(animate);
</script>
</body>
</html>
```