Prompt specification
Build or customize the Three.js 3D scene "Insulated box with a visible cold source" 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: Insulated box with a visible cold source
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/insulated-box-with-a-visible-cold-source-x2525
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a voxel cutaway of an insulated storage box. Remove one side wall to reveal a food container, a separate cold block, and a simple thermometer inside the cavity. Build the wall as visibly distinct inner lining, insulation layer, and outer shell, with a lid that can be lifted. Use arrows sparingly to distinguish slowed heat transfer through insulation from heat absorbed by the cold block. Keep this a schematic historical-technology exhibit rather than a recipe for storing food safely. The open view should make it impossible to mistake the insulation itself for a source that produces cooling.
Working Three.js Starter (insulated-box-with-a-visible-cold-source-x2525):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Passive Cool Chest — Historical Technology Exhibit</title>
<style>
:root {
--ink: #263a38;
--paper: #f2ead9;
--panel: rgba(246, 240, 225, 0.94);
--line: rgba(38, 58, 56, 0.18);
--shell: #607772;
--insulation: #c7a66b;
--lining: #dce8e2;
--cold: #4d9fc6;
--warm-arrow: #d58a36;
--absorbed-arrow: #d85b48;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8dfcc;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
cursor: grab;
}
#viewport canvas:active {
cursor: grabbing;
}
.exhibit-header {
position: fixed;
top: 26px;
left: 30px;
z-index: 5;
width: min(470px, calc(100vw - 60px));
pointer-events: none;
text-shadow: 0 1px 12px rgba(242, 234, 217, 0.9);
}
.kicker {
margin-bottom: 7px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
color: #526965;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 52px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 410px;
margin: 12px 0 0;
font-size: 14px;
line-height: 1.5;
color: #405450;
}
.legend {
position: fixed;
top: 132px;
right: 28px;
z-index: 5;
width: 294px;
padding: 18px 18px 16px;
border: 1px solid rgba(45, 64, 60, 0.2);
border-radius: 4px;
background: var(--panel);
box-shadow: 0 12px 35px rgba(49, 45, 34, 0.13);
backdrop-filter: blur(8px);
}
.legend-heading {
margin: 0 0 13px;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
color: #6b756d;
}
.material-row,
.thermal-row {
display: grid;
grid-template-columns: 24px 1fr;
gap: 10px;
align-items: start;
margin: 10px 0;
font-size: 12px;
line-height: 1.35;
}
.swatch {
width: 22px;
height: 14px;
margin-top: 2px;
border: 1px solid rgba(25, 38, 35, 0.18);
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.25),
0 2px 0 rgba(38, 58, 56, 0.08);
}
.swatch.shell {
background: var(--shell);
}
.swatch.insulation {
background:
radial-gradient(circle at 3px 3px, #977544 0 1px, transparent 1.5px),
radial-gradient(circle at 11px 8px, #ead4a5 0 1px, transparent 1.5px),
var(--insulation);
background-size: 15px 12px;
}
.swatch.lining {
background: var(--lining);
}
.swatch.cold {
background: var(--cold);
}
.material-row strong,
.thermal-row strong {
display: block;
font-size: 12px;
}
.material-row span,
.thermal-row span {
color: #58635d;
}
.legend-rule {
height: 1px;
margin: 15px 0 13px;
background: var(--line);
}
.arrow-key {
display: inline-block;
width: 25px;
margin-top: 5px;
border-top: 3px solid var(--warm-arrow);
}
.arrow-key.dashed {
border-top-style: dashed;
}
.arrow-key.absorbed {
border-top-color: var(--absorbed-arrow);
}
.clarifier {
margin: 15px 0 0;
padding: 12px 13px;
border-left: 4px solid var(--cold);
background: rgba(77, 159, 198, 0.1);
font-size: 12px;
line-height: 1.48;
}
.clarifier strong {
color: #244f5d;
}
#leaders,
#callouts {
position: fixed;
inset: 0;
z-index: 4;
width: 100%;
height: 100%;
pointer-events: none;
}
#leaders line {
stroke: rgba(45, 63, 59, 0.56);
stroke-width: 1.15;
}
#leaders circle {
fill: #f7f0df;
stroke: #435b56;
stroke-width: 1.5;
}
.callout {
position: absolute;
min-width: 118px;
max-width: 210px;
padding: 7px 10px;
transform: translate(-50%, -50%);
border: 1px solid rgba(44, 61, 57, 0.2);
border-radius: 3px;
background: rgba(247, 241, 226, 0.94);
box-shadow: 0 4px 13px rgba(45, 48, 37, 0.1);
font-size: 11px;
line-height: 1.25;
white-space: nowrap;
}
.callout strong {
display: block;
font-size: 11px;
letter-spacing: 0.01em;
}
.callout small {
display: block;
margin-top: 2px;
color: #65716b;
font-size: 9px;
white-space: normal;
}
.callout.thermal {
border-left-width: 4px;
}
.callout.thermal.warm {
border-left-color: var(--warm-arrow);
}
.callout.thermal.absorbed {
border-left-color: var(--absorbed-arrow);
}
.callout.cold-label {
border-left: 4px solid var(--cold);
}
.controls {
position: fixed;
left: 30px;
bottom: 54px;
z-index: 8;
display: flex;
gap: 8px;
align-items: center;
}
button {
appearance: none;
border: 1px solid rgba(38, 58, 56, 0.26);
border-radius: 3px;
padding: 10px 14px;
background: rgba(246, 240, 225, 0.95);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.035em;
cursor: pointer;
box-shadow: 0 4px 12px rgba(44, 48, 37, 0.09);
transition:
background 120ms ease,
transform 120ms ease;
}
button:hover {
background: #fffaf0;
transform: translateY(-1px);
}
button:focus-visible {
outline: 3px solid rgba(77, 159, 198, 0.45);
outline-offset: 2px;
}
#interaction-hint {
position: fixed;
left: 30px;
bottom: 27px;
z-index: 6;
color: #53635e;
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
}
.disclaimer {
position: fixed;
right: 28px;
bottom: 20px;
z-index: 6;
max-width: 440px;
padding: 9px 12px;
border: 1px solid rgba(68, 75, 60, 0.18);
background: rgba(246, 240, 225, 0.9);
color: #58625b;
font-size: 10px;
line-height: 1.35;
text-align: right;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #e8dfcc;
color: #435b56;
font-size: 12px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
.exhibit-header {
top: 18px;
left: 18px;
width: min(430px, calc(100vw - 36px));
}
.subtitle {
max-width: 350px;
font-size: 12px;
}
.legend {
top: auto;
right: 14px;
bottom: 54px;
width: 265px;
padding: 13px;
}
.legend .thermal-row {
margin: 7px 0;
}
.clarifier {
margin-top: 11px;
padding: 9px 10px;
}
.controls {
top: 114px;
right: 14px;
left: auto;
bottom: auto;
flex-direction: column;
align-items: stretch;
}
#interaction-hint {
display: none;
}
.disclaimer {
right: 14px;
bottom: 10px;
left: 14px;
max-width: none;
text-align: center;
}
}
@media (max-width: 640px) {
h1 {
font-size: 31px;
}
.subtitle {
max-width: 285px;
}
.legend {
right: 10px;
bottom: 48px;
left: 10px;
width: auto;
}
.legend .material-row,
.legend .thermal-row {
font-size: 10px;
}
.legend .material-row strong,
.legend .thermal-row strong {
font-size: 10px;
}
.clarifier {
font-size: 10px;
}
#callouts,
#leaders {
display: none;
}
.disclaimer {
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<header class="exhibit-header">
<div class="kicker">Museum of Everyday Inventions · Gallery 03</div>
<h1>The Passive<br>Cool Chest</h1>
<p class="subtitle">
A voxel reconstruction inspired by early twentieth-century portable
cold boxes. One side is removed to reveal the separate cold block and
the cavity contents.
</p>
</header>
<aside class="legend" aria-label="Exhibit legend">
<h2 class="legend-heading">Read the cutaway</h2>
<div class="material-row">
<span class="swatch shell"></span>
<div>
<strong>Outer shell</strong>
<span>Protective structural layer.</span>
</div>
</div>
<div class="material-row">
<span class="swatch insulation"></span>
<div>
<strong>Insulation</strong>
<span>Slows heat transfer; creates no cold.</span>
</div>
</div>
<div class="material-row">
<span class="swatch lining"></span>
<div>
<strong>Inner lining</strong>
<span>Separates the cavity from the wall layers.</span>
</div>
</div>
<div class="material-row">
<span class="swatch cold"></span>
<div>
<strong>Separate cold block</strong>
<span>The exhibit's finite cold store.</span>
</div>
</div>
<div class="legend-rule"></div>
<div class="thermal-row">
<span class="arrow-key dashed"></span>
<div>
<strong>Slower heat transfer</strong>
<span>Heat still crosses the insulating layer.</span>
</div>
</div>
<div class="thermal-row">
<span class="arrow-key absorbed"></span>
<div>
<strong>Heat absorbed by cold block</strong>
<span>Heat moves into the separate blue block.</span>
</div>
</div>
<p class="clarifier">
<strong>Insulation is not a cooling source.</strong>
The blue block represents the cold supply. The wall layers only slow
incoming heat; they do not manufacture cold.
</p>
</aside>
<svg id="leaders" aria-hidden="true"></svg>
<div id="callouts" aria-hidden="true"></div>
<nav class="controls" aria-label="Exhibit controls">
<button id="lid-button" type="button" aria-pressed="true">Lower lid</button>
<button id="reset-button" type="button">Reset view</button>
</nav>
<div id="interaction-hint">
Drag to orbit · Wheel to zoom · Click the lid to lift or lower it
</div>
<footer class="disclaimer">
Historical schematic only. This exhibit explains a passive mechanism and
does not provide food-storage times, temperatures, preparation, or safety guidance.
</footer>
<div id="loading">Loading the exhibit…</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 viewport = document.getElementById("viewport");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8dfcc);
scene.fog = new THREE.Fog(0xe8dfcc, 16, 29);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
60
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.06;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel cutaway of a historical passive cool chest"
);
viewport.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xfff4dc, 0x728b8d, 2.35);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff0cf, 3.5);
keyLight.position.set(6, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 28;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb9d9e6, 1.15);
fillLight.position.set(-7, 5, -4);
scene.add(fillLight);
const warmRim = new THREE.DirectionalLight(0xe8aa68, 0.85);
warmRim.position.set(-4, 3, 7);
scene.add(warmRim);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
function makeInsulationTexture() {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#c8aa73";
ctx.fillRect(0, 0, 128, 128);
let seed = 8147;
const random = () => {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
};
for (let i = 0; i < 460; i++) {
const x = random() * 128;
const y = random() * 128;
const length = 2 + random() * 5;
ctx.strokeStyle = random() > 0.5
? "rgba(109, 79, 43, 0.28)"
: "rgba(245, 222, 172, 0.32)";
ctx.lineWidth = 0.6 + random() * 1.1;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + length, y + (random() - 0.5) * 2.5);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(2, 2);
return texture;
}
const insulationTexture = makeInsulationTexture();
const shellMaterials = [
new THREE.MeshStandardMaterial({
color: 0x5f7470,
roughness: 0.7,
metalness: 0.18
}),
new THREE.MeshStandardMaterial({
color: 0x687c77,
roughness: 0.67,
metalness: 0.16
}),
new THREE.MeshStandardMaterial({
color: 0x566d68,
roughness: 0.74,
metalness: 0.2
})
];
const insulationMaterials = [
new THREE.MeshStandardMaterial({
color: 0xf1d49b,
map: insulationTexture,
roughness: 1
}),
new THREE.MeshStandardMaterial({
color: 0xe2bd7d,
map: insulationTexture,
roughness: 1
}),
new THREE.MeshStandardMaterial({
color: 0xf4ddb0,
map: insulationTexture,
roughness: 1
})
];
const liningMaterials = [
new THREE.MeshStandardMaterial({
color: 0xdce8e2,
roughness: 0.5,
metalness: 0.05
}),
new THREE.MeshStandardMaterial({
color: 0xcbdad5,
roughness: 0.55,
metalness: 0.04
}),
new THREE.MeshStandardMaterial({
color: 0xe9f0eb,
roughness: 0.48,
metalness: 0.04
})
];
const pedestalMaterial = new THREE.MeshStandardMaterial({
color: 0x6f6859,
roughness: 0.9
});
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xe4dac5,
roughness: 1
});
const ceramicMaterial = new THREE.MeshStandardMaterial({
color: 0xeee1c4,
roughness: 0.62
});
const ceramicShadowMaterial = new THREE.MeshStandardMaterial({
color: 0xcbb894,
roughness: 0.7
});
const redMaterial = new THREE.MeshStandardMaterial({
color: 0xa9513d,
roughness: 0.55,
metalness: 0.08
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x3e504b,
roughness: 0.68
});
const coldMaterials = [
new THREE.MeshStandardMaterial({
color: 0x4b9fc8,
roughness: 0.56,
metalness: 0.03
}),
new THREE.MeshStandardMaterial({
color: 0x69b4d5,
roughness: 0.52,
metalness: 0.02
}),
new THREE.MeshStandardMaterial({
color: 0x398db8,
roughness: 0.6,
metalness: 0.03
}),
new THREE.MeshStandardMaterial({
color: 0x91c9df,
roughness: 0.48,
metalness: 0.02
})
];
const mercuryMaterial = new THREE.MeshStandardMaterial({
color: 0xc54e39,
roughness: 0.35
});
const scaleMaterial = new THREE.MeshStandardMaterial({
color: 0xf4edda,
roughness: 0.6
});
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function addBox(
parent,
width,
height,
depth,
material,
x = 0,
y = 0,
z = 0,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addTiles(
parent,
width,
depth,
thickness,
centerY,
materials,
countX,
countZ,
gap = 0.035
) {
const stepX = width / countX;
const stepZ = depth / countZ;
for (let ix = 0; ix < countX; ix++) {
for (let iz = 0; iz < countZ; iz++) {
const material =
materials[(ix * 5 + iz * 3 + ix * iz) % materials.length];
addBox(
parent,
Math.max(0.02, stepX - gap),
thickness,
Math.max(0.02, stepZ - gap),
material,
-width / 2 + (ix + 0.5) * stepX,
centerY,
-depth / 2 + (iz + 0.5) * stepZ
);
}
}
}
function addWallLayer(
axis,
span,
fixed,
thickness,
bottom,
height,
materials,
countAlong,
countHigh,
gap = 0.035
) {
const stepAlong = span / countAlong;
const stepHigh = height / countHigh;
for (let i = 0; i < countAlong; i++) {
for (let j = 0; j < countHigh; j++) {
const material =
materials[(i * 7 + j * 3) % materials.length];
if (axis === "x") {
addBox(
scene,
Math.max(0.02, stepAlong - gap),
Math.max(0.02, stepHigh - gap),
thickness,
material,
-span / 2 + (i + 0.5) * stepAlong,
bottom + (j + 0.5) * stepHigh,
fixed
);
} else {
addBox(
scene,
thickness,
Math.max(0.02, stepHigh - gap),
Math.max(0.02, stepAlong - gap),
material,
fixed,
bottom + (j + 0.5) * stepHigh,
-span / 2 + (i + 0.5) * stepAlong
);
}
}
}
}
function makeTextPlate(text, foreground = "#4d3930", background = "#efe1bf") {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 96;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, 256, 96);
ctx.strokeStyle = "rgba(76, 54, 40, .4)";
ctx.lineWidth = 5;
ctx.strokeRect(5, 5, 246, 86);
ctx.fillStyle = foreground;
ctx.font = "700 42px Georgia";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 128, 50);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return new THREE.MeshBasicMaterial({ map: texture });
}
// ------------------------------------------------------------
// Exhibit base and layered box
//
// Layer order from the cavity outward:
// lining 0.14, insulation 0.45, shell 0.16.
// The +X side wall is intentionally absent.
// ------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(34, 34),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = 0.025;
ground.receiveShadow = true;
scene.add(ground);
addBox(
scene,
7.45,
0.32,
5.25,
pedestalMaterial,
0,
0.22,
0
);
const OUTER_WIDTH = 6.6;
const OUTER_DEPTH = 4.4;
const WALL_HEIGHT = 2.4;
const FLOOR_BOTTOM = 0.4;
const LINING_THICKNESS = 0.14;
const INSULATION_THICKNESS = 0.45;
const SHELL_THICKNESS = 0.16;
const CAVITY_FLOOR = 1.15;
const WALL_TOP = CAVITY_FLOOR + WALL_HEIGHT;
// Floor: three complete layers, producing a clear cut face at +X.
addTiles(
scene,
OUTER_WIDTH,
OUTER_DEPTH,
SHELL_THICKNESS,
FLOOR_BOTTOM + SHELL_THICKNESS / 2,
shellMaterials,
10,
7
);
addTiles(
scene,
OUTER_WIDTH,
OUTER_DEPTH,
INSULATION_THICKNESS,
FLOOR_BOTTOM + SHELL_THICKNESS + INSULATION_THICKNESS / 2,
insulationMaterials,
10,
7,
0.045
);
addTiles(
scene,
OUTER_WIDTH,
OUTER_DEPTH,
LINING_THICKNESS,
FLOOR_BOTTOM + SHELL_THICKNESS + INSULATION_THICKNESS +
LINING_THICKNESS / 2,
liningMaterials,
10,
7,
0.028
);
const frontZ = {
lining: 1.52,
insulation: 1.815,
shell: 2.12
};
const backZ = {
lining: -1.52,
insulation: -1.815,
shell: -2.12
};
const leftX = {
lining: -2.62,
insulation: -2.915,
shell: -3.22
};
// Back wall.
addWallLayer(
"x", OUTER_WIDTH, backZ.lining, LINING_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, liningMaterials, 12, 6
);
addWallLayer(
"x", OUTER_WIDTH, backZ.insulation, INSULATION_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, insulationMaterials, 12, 6, 0.045
);
addWallLayer(
"x", OUTER_WIDTH, backZ.shell, SHELL_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, shellMaterials, 12, 6
);
// Front wall.
addWallLayer(
"x", OUTER_WIDTH, frontZ.lining, LINING_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, liningMaterials, 12, 6
);
addWallLayer(
"x", OUTER_WIDTH, frontZ.insulation, INSULATION_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, insulationMaterials, 12, 6, 0.045
);
addWallLayer(
"x", OUTER_WIDTH, frontZ.shell, SHELL_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, shellMaterials, 12, 6
);
// Left wall.
addWallLayer(
"z", OUTER_DEPTH, leftX.lining, LINING_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, liningMaterials, 8, 6
);
addWallLayer(
"z", OUTER_DEPTH, leftX.insulation, INSULATION_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, insulationMaterials, 8, 6, 0.045
);
addWallLayer(
"z", OUTER_DEPTH, leftX.shell, SHELL_THICKNESS,
CAVITY_FLOOR, WALL_HEIGHT, shellMaterials, 8, 6
);
// The +X wall is deliberately not built.
// ------------------------------------------------------------
// Hinged lid
// ------------------------------------------------------------
const lidPivot = new THREE.Group();
lidPivot.position.set(0, WALL_TOP, -OUTER_DEPTH / 2);
scene.add(lidPivot);
const lidWidth = 6.76;
const lidDepth = 4.56;
addTiles(
lidPivot,
lidWidth,
lidDepth,
LINING_THICKNESS,
0.07,
liningMaterials,
12,
8,
0.028
);
addTiles(
lidPivot,
lidWidth,
lidDepth,
INSULATION_THICKNESS,
0.365,
insulationMaterials,
12,
8,
0.045
);
addTiles(
lidPivot,
lidWidth,
lidDepth,
SHELL_THICKNESS,
0.67,
shellMaterials,
12,
8,
0.03
);
// Raised outer ribs.
for (const x of [-2.25, 0, 2.25]) {
addBox(
lidPivot,
0.13,
0.12,
4.02,
shellMaterials[1],
x,
0.81,
lidDepth / 2
);
}
// Voxel handle.
addBox(lidPivot, 0.17, 0.28, 0.22, darkMaterial, -0.58, 0.89, 3.92);
addBox(lidPivot, 0.17, 0.28, 0.22, darkMaterial, 0.58, 0.89, 3.92);
addBox(lidPivot, 1.33, 0.18, 0.25, darkMaterial, 0, 1.02, 3.92);
// Hinge barrels remain with the box.
for (const x of [-2.25, 2.25]) {
const hinge = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.14, 0.62, 12),
darkMaterial
);
hinge.rotation.z = Math.PI / 2;
hinge.position.set(x, WALL_TOP, -OUTER_DEPTH / 2);
hinge.castShadow = true;
scene.add(hinge);
}
let lidOpen = true;
let lidAngle = -1.12;
let lidTargetAngle = -1.12;
// ------------------------------------------------------------
// Cavity contents
// ------------------------------------------------------------
// Food container.
const foodContainer = new THREE.Group();
foodContainer.position.set(-0.95, CAVITY_FLOOR, 0.18);
scene.add(foodContainer);
addBox(
foodContainer, 1.58, 0.14, 1.47,
ceramicShadowMaterial, 0, 0.07, 0
);
addBox(
foodContainer, 1.42, 0.52, 1.35,
ceramicMaterial, 0, 0.40, 0
);
addBox(
foodContainer, 1.31, 0.56, 1.25,
ceramicMaterial, 0, 0.94, 0
);
addBox(
foodContainer, 1.60, 0.20, 1.49,
redMaterial, 0, 1.32, 0
);
addBox(
foodContainer, 0.48, 0.17, 0.22,
redMaterial, 0, 1.50, 0
);
const foodLabel = new THREE.Mesh(
new THREE.PlaneGeometry(0.76, 0.285),
makeTextPlate("FOOD")
);
foodLabel.position.set(0, 0.71, 0.686);
foodContainer.add(foodLabel);
// Separate cold block: a deliberately voxelized 3 × 3 × 3 assembly.
const coldBlock = new THREE.Group();
coldBlock.position.set(1.48, CAVITY_FLOOR, -0.04);
scene.add(coldBlock);
const coldCubeSize = 0.39;
const coldGap = 0.025;
const coldPitch = 0.415;
for (let x = 0; x < 3; x++) {
for (let y = 0; y < 3; y++) {
for (let z = 0; z < 3; z++) {
let materialIndex = (x + y * 2 + z * 3) % coldMaterials.length;
if (y === 2 && (x + z) % 2 === 0) {
materialIndex = 3;
}
addBox(
coldBlock,
coldCubeSize,
coldCubeSize,
coldCubeSize,
coldMaterials[materialIndex],
(x - 1) * coldPitch,
0.205 + y * coldPitch,
(z - 1) * coldPitch
);
}
}
}
// Simple thermometer, mounted near the back of the cavity.
const thermometer = new THREE.Group();
thermometer.position.set(0.20, CAVITY_FLOOR, -1.06);
scene.add(thermometer);
addBox(
thermometer, 0.29, 1.58, 0.075,
scaleMaterial, 0, 0.96, -0.12
);
const outerTube = new THREE.Mesh(
new THREE.CylinderGeometry(0.044, 0.044, 1.25, 10),
scaleMaterial
);
outerTube.position.set(0, 0.75, 0);
outerTube.castShadow = true;
thermometer.add(outerTube);
const redColumn = new THREE.Mesh(
new THREE.CylinderGeometry(0.020, 0.020, 0.93, 8),
mercuryMaterial
);
redColumn.position.set(0, 0.57, 0.048);
thermometer.add(redColumn);
const bulb = new THREE.Mesh(
new THREE.SphereGeometry(0.125, 14, 10),
mercuryMaterial
);
bulb.position.set(0, 0.075, 0.035);
bulb.castShadow = true;
thermometer.add(bulb);
for (let i = 0; i < 6; i++) {
addBox(
thermometer,
i % 2 === 0 ? 0.13 : 0.085,
0.018,
0.018,
mercuryMaterial,
0.07,
0.43 + i * 0.18,
-0.067,
false
);
}
// ------------------------------------------------------------
// Arrows: exactly two semantic arrows
// ------------------------------------------------------------
const warmArrowColor = 0xd58a36;
const absorbedArrowColor = 0xd85b48;
function addDashedArrow(start, end, color) {
const group = new THREE.Group();
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
direction.normalize();
const lineGeometry = new THREE.BufferGeometry().setFromPoints([
start,
end
]);
const lineMaterial = new THREE.LineDashedMaterial({
color,
dashSize: 0.16,
gapSize: 0.10,
transparent: true,
opacity: 0.95,
depthTest: false
});
const line = new THREE.Line(lineGeometry, lineMaterial);
line.computeLineDistances();
line.renderOrder = 8;
group.add(line);
const headLength = 0.28;
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.105, headLength, 12),
new THREE.MeshBasicMaterial({
color,
depthTest: false
})
);
head.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction
);
head.position.copy(end).addScaledVector(direction, -headLength / 2);
head.renderOrder = 8;
group.add(head);
scene.add(group);
return group;
}
function addSolidArrow(start, end, color) {
const group = new THREE.Group();
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
direction.normalize();
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([start, end]),
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.98,
depthTest: false
})
);
line.renderOrder = 9;
group.add(line);
const headLength = Math.min(0.30, length * 0.38);
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.115, headLength, 12),
new THREE.MeshBasicMaterial({
color,
depthTest: false
})
);
head.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction
);
head.position.copy(end).addScaledVector(direction, -headLength / 2);
head.renderOrder = 9;
group.add(head);
scene.add(group);
return group;
}
// Amber dashed arrow crosses the exposed insulation section of the
// front wall. It points inward but is visibly interrupted/dashed.
const slowHeatStart = new THREE.Vector3(3.43, 2.78, 2.92);
const slowHeatEnd = new THREE.Vector3(3.43, 2.78, 1.22);
addDashedArrow(slowHeatStart, slowHeatEnd, warmArrowColor);
// Coral arrow shows heat entering the separate cold block.
const absorbedHeatStart = new THREE.Vector3(0.20, 2.45, 0.56);
const absorbedHeatEnd = new THREE.Vector3(0.84, 2.05, 0.12);
addSolidArrow(
absorbedHeatStart,
absorbedHeatEnd,
absorbedArrowColor
);
// ------------------------------------------------------------
// Projected exhibit labels
// ------------------------------------------------------------
const svgNS = "http://www.w3.org/2000/svg";
const leaderLayer = document.getElementById("leaders");
const calloutLayer = document.getElementById("callouts");
const callouts = [];
function addCallout({
title,
detail = "",
anchor,
offset,
className = ""
}) {
const label = document.createElement("div");
label.className = `callout ${className}`;
label.innerHTML = `<strong>${title}</strong>${
detail ? `<small>${detail}</small>` : ""
}`;
calloutLayer.appendChild(label);
const line = document.createElementNS(svgNS, "line");
const dot = document.createElementNS(svgNS, "circle");
dot.setAttribute("r", "3.5");
leaderLayer.appendChild(line);
leaderLayer.appendChild(dot);
callouts.push({
label,
line,
dot,
anchor: new THREE.Vector3(...anchor),
offset
});
}
addCallout({
title: "Food container",
detail: "Separate cavity item",
anchor: [-0.95, 2.25, 0.18],
offset: [-100, -62]
});
addCallout({
title: "Cold block",
detail: "The separate cold supply",
anchor: [1.48, 2.36, -0.04],
offset: [92, -55],
className: "cold-label"
});
addCallout({
title: "Thermometer",
detail: "Simple temperature indicator",
anchor: [0.20, 2.60, -1.02],
offset: [-35, -105]
});
addCallout({
title: "Slower heat transfer",
detail: "Passes through the insulating layer",
anchor: [3.43, 2.78, 2.02],
offset: [108, -93],
className: "thermal warm"
});
addCallout({
title: "Heat absorbed",
detail: "Moves into the cold block",
anchor: [0.50, 2.24, 0.34],
offset: [-45, -114],
className: "thermal absorbed"
});
const projected = new THREE.Vector3();
function updateCallouts() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const item of callouts) {
projected.copy(item.anchor).project(camera);
const visible = projected.z > -1 && projected.z < 1;
item.label.style.display = visible ? "block" : "none";
item.line.style.display = visible ? "block" : "none";
item.dot.style.display = visible ? "block" : "none";
if (!visible) continue;
const anchorX = (projected.x * 0.5 + 0.5) * width;
const anchorY = (-projected.y * 0.5 + 0.5) * height;
const labelX = THREE.MathUtils.clamp(
anchorX + item.offset[0],
90,
width - 90
);
const labelY = THREE.MathUtils.clamp(
anchorY + item.offset[1],
72,
height - 80
);
item.label.style.left = `${labelX}px`;
item.label.style.top = `${labelY}px`;
item.line.setAttribute("x1", anchorX);
item.line.setAttribute("y1", anchorY);
item.line.setAttribute("x2", labelX);
item.line.setAttribute("y2", labelY);
item.dot.setAttribute("cx", anchorX);
item.dot.setAttribute("cy", anchorY);
}
}
// ------------------------------------------------------------
// Direct camera controls: no addons or example modules
// ------------------------------------------------------------
const cameraTarget = new THREE.Vector3(-0.2, 1.62, 0);
const initialCamera = {
radius: 11.8,
theta: 1.27,
phi: 1.02
};
const desiredCamera = { ...initialCamera };
const currentCamera = { ...initialCamera };
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let pointerStartX = 0;
let pointerStartY = 0;
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
renderer.domElement.addEventListener("pointerdown", event => {
if (event.button !== 0) return;
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
pointerStartX = event.clientX;
pointerStartY = 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;
desiredCamera.theta -= dx * 0.006;
desiredCamera.phi = THREE.MathUtils.clamp(
desiredCamera.phi + dy * 0.005,
0.48,
1.38
);
pointerX = event.clientX;
pointerY = event.clientY;
});
renderer.domElement.addEventListener("pointerup", event => {
dragging = false;
const travel = Math.hypot(
event.clientX - pointerStartX,
event.clientY - pointerStartY
);
if (travel < 5) {
const rect = renderer.domElement.getBoundingClientRect();
pointerNDC.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointerNDC.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
const hits = raycaster.intersectObjects(lidPivot.children, true);
if (hits.length > 0) {
toggleLid();
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * Math.exp(event.deltaY * 0.001),
7.2,
16.5
);
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", event => {
event.preventDefault();
});
renderer.domElement.addEventListener("keydown", event => {
const step = 0.09;
if (event.key === "ArrowLeft") desiredCamera.theta += step;
if (event.key === "ArrowRight") desiredCamera.theta -= step;
if (event.key === "ArrowUp") {
desiredCamera.phi = Math.max(0.48, desiredCamera.phi - step);
}
if (event.key === "ArrowDown") {
desiredCamera.phi = Math.min(1.38, desiredCamera.phi + step);
}
if (event.key.toLowerCase() === "l") toggleLid();
});
function updateCamera() {
currentCamera.radius +=
(desiredCamera.radius - currentCamera.radius) * 0.085;
currentCamera.theta +=
(desiredCamera.theta - currentCamera.theta) * 0.085;
currentCamera.phi +=
(desiredCamera.phi - currentCamera.phi) * 0.085;
const sinPhi = Math.sin(currentCamera.phi);
const cosPhi = Math.cos(currentCamera.phi);
camera.position.set(
cameraTarget.x +
currentCamera.radius * sinPhi * Math.sin(currentCamera.theta),
cameraTarget.y + currentCamera.radius * cosPhi,
cameraTarget.z +
currentCamera.radius * sinPhi * Math.cos(currentCamera.theta)
);
camera.lookAt(cameraTarget);
}
// ------------------------------------------------------------
// Lid and reset controls
// ------------------------------------------------------------
const lidButton = document.getElementById("lid-button");
const resetButton = document.getElementById("reset-button");
function toggleLid() {
lidOpen = !lidOpen;
lidTargetAngle = lidOpen ? -1.12 : 0;
lidButton.textContent = lidOpen ? "Lower lid" : "Lift lid";
lidButton.setAttribute("aria-pressed", String(lidOpen));
}
lidButton.addEventListener("click", toggleLid);
resetButton.addEventListener("click", () => {
desiredCamera.radius = initialCamera.radius;
desiredCamera.theta = initialCamera.theta;
desiredCamera.phi = initialCamera.phi;
if (!lidOpen) toggleLid();
});
// ------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
function animate() {
requestAnimationFrame(animate);
updateCamera();
lidAngle += (lidTargetAngle - lidAngle) * 0.075;
lidPivot.rotation.x = lidAngle;
renderer.render(scene, camera);
updateCallouts();
if (!loading.classList.contains("hidden")) {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
}
}
animate();
</script>
</body>
</html>
```