Prompt specification
Build or customize the Three.js 3D scene "Energy pathway kitchen classroom" 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: Energy pathway kitchen classroom
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/energy-pathway-kitchen-classroom-x0156
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts convection in a soup pot. Build a diagrammatic kitchen linking heater, pot, liquid, and room air; controls reveal conduction, convection, and radiation as separately colored qualitative pathways with clear legends. Voxel style.
Working Three.js Starter (energy-pathway-kitchen-classroom-x0156):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Convection in the Soup Pot — Voxel Thermal Kitchen</title>
<style>
:root {
--ink: #24323a;
--muted: #66747a;
--panel: rgba(255, 255, 255, 0.88);
--line: rgba(36, 50, 58, 0.13);
--conduction: #ff5a36;
--convection: #00a6a6;
--radiation: #a855f7;
--air: #84b9ca;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e5d9;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#app,
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
#scene canvas.dragging {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
background:
radial-gradient(
circle at 47% 43%,
transparent 0%,
transparent 48%,
rgba(44, 51, 53, 0.07) 100%
);
}
.intro {
position: fixed;
top: 28px;
left: 30px;
z-index: 5;
width: min(390px, calc(100vw - 60px));
pointer-events: none;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: #627178;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 3px;
content: "";
background: var(--convection);
box-shadow: 7px 0 0 var(--conduction), 14px 0 0 var(--radiation);
}
h1 {
margin: 0;
color: #25343b;
font-size: clamp(32px, 4.1vw, 58px);
font-weight: 850;
letter-spacing: -0.055em;
line-height: 0.93;
}
h1 span {
color: #607078;
font-weight: 650;
}
.intro p {
max-width: 350px;
margin: 15px 0 0;
color: #59676e;
font-size: 13px;
line-height: 1.55;
}
.panel {
position: fixed;
top: 24px;
right: 24px;
z-index: 6;
width: 302px;
padding: 18px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 18px;
background: var(--panel);
box-shadow:
0 18px 50px rgba(47, 57, 59, 0.13),
inset 0 0 0 1px rgba(36, 50, 58, 0.05);
backdrop-filter: blur(16px);
}
.panel-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 14px;
}
.panel h2 {
margin: 0;
font-size: 15px;
letter-spacing: -0.02em;
}
.panel-sub {
margin: 4px 0 0;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.bulk-buttons {
display: flex;
gap: 6px;
}
.mini-button {
min-width: 44px;
padding: 6px 8px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255, 255, 255, 0.7);
cursor: pointer;
font-size: 10px;
font-weight: 750;
transition: background 150ms ease, transform 150ms ease;
}
.mini-button:hover {
background: #fff;
transform: translateY(-1px);
}
.layer {
display: grid;
grid-template-columns: 35px 1fr auto;
align-items: center;
gap: 10px;
min-height: 58px;
padding: 9px 0;
border-top: 1px solid var(--line);
cursor: pointer;
}
.layer input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.toggle {
position: relative;
width: 34px;
height: 20px;
border-radius: 999px;
background: #cbd2d3;
transition: background 180ms ease;
}
.toggle::after {
position: absolute;
top: 3px;
left: 3px;
width: 14px;
height: 14px;
content: "";
border-radius: 50%;
background: white;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
transition: transform 180ms ease;
}
.layer input:checked + .toggle {
background: var(--route-color);
}
.layer input:checked + .toggle::after {
transform: translateX(14px);
}
.layer-copy {
display: flex;
min-width: 0;
flex-direction: column;
gap: 2px;
}
.layer-copy strong {
font-size: 12px;
}
.layer-copy small {
overflow: hidden;
color: var(--muted);
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
.route-mark {
display: grid;
width: 25px;
height: 25px;
place-items: center;
border-radius: 7px;
color: var(--route-color);
background: color-mix(in srgb, var(--route-color) 12%, white);
font-size: 15px;
font-weight: 900;
}
.panel-note {
margin: 12px 0 0;
padding: 10px 11px;
border-radius: 10px;
color: #5d6a70;
background: rgba(39, 55, 62, 0.055);
font-size: 10px;
line-height: 1.5;
}
.panel-actions {
display: flex;
gap: 8px;
margin-top: 13px;
}
.action-button {
flex: 1;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.8);
cursor: pointer;
font-size: 10px;
font-weight: 800;
transition: transform 150ms ease, background 150ms ease;
}
.action-button:hover {
background: white;
transform: translateY(-1px);
}
.legend {
position: fixed;
bottom: 22px;
left: 50%;
z-index: 6;
display: flex;
align-items: stretch;
gap: 8px;
width: max-content;
max-width: calc(100vw - 32px);
padding: 9px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 16px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 14px 40px rgba(43, 55, 58, 0.12);
backdrop-filter: blur(14px);
transform: translateX(-50%);
}
.legend-title {
display: flex;
min-width: 112px;
padding: 7px 11px;
flex-direction: column;
justify-content: center;
border-right: 1px solid var(--line);
}
.legend-title strong {
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend-title small {
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
.legend-item {
display: grid;
grid-template-columns: 31px auto;
align-items: center;
gap: 8px;
min-width: 164px;
padding: 5px 10px;
}
.legend-line {
position: relative;
width: 31px;
height: 4px;
border-radius: 3px;
background: var(--route-color);
}
.legend-line.dashed {
background: repeating-linear-gradient(
90deg,
var(--route-color) 0 7px,
transparent 7px 11px
);
}
.legend-line.loop {
height: 13px;
border: 3px solid var(--route-color);
border-right-color: transparent;
border-radius: 50%;
background: transparent;
}
.legend-copy {
display: flex;
flex-direction: column;
gap: 2px;
}
.legend-copy strong {
font-size: 11px;
}
.legend-copy small {
color: var(--muted);
font-size: 9px;
}
#world-labels {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
.world-label {
position: absolute;
width: 0;
height: 0;
}
.label-dot {
position: absolute;
width: 7px;
height: 7px;
border: 2px solid white;
border-radius: 50%;
background: var(--label-color, #33454d);
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
transform: translate(-50%, -50%);
}
.label-card {
position: absolute;
top: -17px;
left: 15px;
min-width: 90px;
padding: 7px 9px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 9px;
background: rgba(255, 255, 255, 0.84);
box-shadow: 0 5px 16px rgba(40, 53, 58, 0.12);
backdrop-filter: blur(8px);
}
.label-card::before {
position: absolute;
top: 21px;
left: -16px;
width: 16px;
height: 1px;
content: "";
background: rgba(61, 78, 85, 0.5);
}
.world-label.left .label-card {
right: 15px;
left: auto;
}
.world-label.left .label-card::before {
right: -16px;
left: auto;
}
.label-card strong {
display: block;
color: #34464d;
font-size: 10px;
letter-spacing: 0.02em;
}
.label-card small {
display: block;
margin-top: 2px;
color: #758187;
font-size: 8px;
}
.interaction-hint {
position: fixed;
bottom: 24px;
left: 26px;
z-index: 5;
padding: 8px 10px;
border-radius: 9px;
color: #68767b;
background: rgba(255, 255, 255, 0.65);
font-size: 9px;
letter-spacing: 0.03em;
pointer-events: none;
backdrop-filter: blur(8px);
}
@media (max-width: 760px) {
.intro {
top: 16px;
left: 16px;
width: 220px;
}
h1 {
font-size: 31px;
}
.intro p {
display: none;
}
.panel {
top: 12px;
right: 12px;
width: 226px;
padding: 13px;
}
.panel-note {
display: none;
}
.layer {
min-height: 49px;
}
.legend {
bottom: 10px;
gap: 3px;
width: calc(100vw - 20px);
overflow-x: auto;
padding: 6px;
}
.legend-title {
min-width: 90px;
}
.legend-item {
min-width: 142px;
}
.interaction-hint {
display: none;
}
.world-label.optional {
display: none !important;
}
}
@media (max-width: 500px) {
.intro {
width: 180px;
}
.intro .eyebrow {
font-size: 8px;
}
h1 {
font-size: 26px;
}
.panel {
top: auto;
bottom: 88px;
width: 210px;
}
.panel-head {
margin-bottom: 7px;
}
.panel-sub,
.route-mark {
display: none;
}
.layer {
grid-template-columns: 35px 1fr;
}
.panel-actions {
margin-top: 7px;
}
.legend-title,
.legend-copy small {
display: none;
}
.legend-item {
min-width: 100px;
grid-template-columns: 26px auto;
}
}
</style>
</head>
<body>
<main id="app">
<div id="scene" aria-label="Interactive voxel kitchen showing heat transfer"></div>
<div class="vignette"></div>
<header class="intro">
<div class="eyebrow">Interactive thermal kitchen</div>
<h1>Convection<br /><span>in the soup pot</span></h1>
<p>
Reveal how heat travels by conduction, convection, and radiation.
Arrows indicate direction; paths and particles are qualitative.
</p>
</header>
<aside class="panel" aria-label="Thermal pathway controls">
<div class="panel-head">
<div>
<h2>Pathway layers</h2>
<p class="panel-sub">Choose what to reveal</p>
</div>
<div class="bulk-buttons">
<button class="mini-button" id="show-all" type="button">All</button>
<button class="mini-button" id="show-none" type="button">None</button>
</div>
</div>
<label class="layer" style="--route-color: var(--conduction)">
<input type="checkbox" data-route="conduction" checked />
<span class="toggle" aria-hidden="true"></span>
<span class="layer-copy">
<strong>Conduction</strong>
<small>Heater → metal pot base</small>
</span>
<span class="route-mark" aria-hidden="true">↑</span>
</label>
<label class="layer" style="--route-color: var(--convection)">
<input type="checkbox" data-route="convection" checked />
<span class="toggle" aria-hidden="true"></span>
<span class="layer-copy">
<strong>Convection</strong>
<small>Warm rises · cooler liquid sinks</small>
</span>
<span class="route-mark" aria-hidden="true">↻</span>
</label>
<label class="layer" style="--route-color: var(--radiation)">
<input type="checkbox" data-route="radiation" checked />
<span class="toggle" aria-hidden="true"></span>
<span class="layer-copy">
<strong>Radiation</strong>
<small>Infrared toward pot and room</small>
</span>
<span class="route-mark" aria-hidden="true">⇢</span>
</label>
<p class="panel-note">
The pot is cut away so the circulation cells inside the soup remain visible.
Radiation is drawn as a discontinuous path because it does not require matter.
</p>
<div class="panel-actions">
<button class="action-button" id="pause" type="button">Pause motion</button>
<button class="action-button" id="reset-view" type="button">Reset view</button>
</div>
</aside>
<div id="world-labels" aria-hidden="true">
<div class="world-label" id="label-heater" style="--label-color: #ff5a36">
<span class="label-dot"></span>
<div class="label-card">
<strong>Heater</strong>
<small>energy input</small>
</div>
</div>
<div class="world-label left" id="label-soup" style="--label-color: #f59e0b">
<span class="label-dot"></span>
<div class="label-card">
<strong>Hot soup</strong>
<small>circulating liquid</small>
</div>
</div>
<div class="world-label" id="label-pot" style="--label-color: #52606d">
<span class="label-dot"></span>
<div class="label-card">
<strong>Cutaway pot</strong>
<small>metal heat conductor</small>
</div>
</div>
<div class="world-label" id="label-air" style="--label-color: #84b9ca">
<span class="label-dot"></span>
<div class="label-card">
<strong>Room air</strong>
<small>absorbs infrared energy</small>
</div>
</div>
<div class="world-label left optional" id="label-stove" style="--label-color: #607078">
<span class="label-dot"></span>
<div class="label-card">
<strong>Stovetop</strong>
<small>supporting the pot</small>
</div>
</div>
</div>
<footer class="legend" aria-label="Pathway legend">
<div class="legend-title">
<strong>Pathway legend</strong>
<small>Direction, not scale</small>
</div>
<div class="legend-item" style="--route-color: var(--conduction)">
<span class="legend-line"></span>
<span class="legend-copy">
<strong>Conduction</strong>
<small>through solid contact</small>
</span>
</div>
<div class="legend-item" style="--route-color: var(--convection)">
<span class="legend-line loop"></span>
<span class="legend-copy">
<strong>Convection</strong>
<small>bulk motion of soup</small>
</span>
</div>
<div class="legend-item" style="--route-color: var(--radiation)">
<span class="legend-line dashed"></span>
<span class="legend-copy">
<strong>Radiation</strong>
<small>infrared through space</small>
</span>
</div>
</footer>
<div class="interaction-hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color("#e9e5d9");
scene.fog = new THREE.Fog("#e9e5d9", 14, 27);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
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.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneHost.appendChild(renderer.domElement);
const world = new THREE.Group();
scene.add(world);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
}
function addBox(
parent,
size,
position,
material,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight("#f7fbff", "#8b7962", 2.15));
const keyLight = new THREE.DirectionalLight("#fff8e8", 3.1);
keyLight.position.set(-4.5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight("#b9dbe8", 1.1);
fillLight.position.set(7, 4, 4);
scene.add(fillLight);
const heaterLight = new THREE.PointLight("#ff5a36", 11, 4.2, 2);
heaterLight.position.set(0, 0.85, 0.2);
scene.add(heaterLight);
// ---------------------------------------------------------------------
// Voxel kitchen
// ---------------------------------------------------------------------
const floorMat = standardMaterial("#cfc9bb");
const floorLineMat = standardMaterial("#b8b1a2");
const wallMat = standardMaterial("#e3dfd4");
const tileMats = [
standardMaterial("#ece8dc"),
standardMaterial("#e6e3d7"),
standardMaterial("#f0eadc"),
standardMaterial("#dfe5dc")
];
const cabinetMat = standardMaterial("#668b86");
const cabinetDarkMat = standardMaterial("#486c69");
const counterMat = standardMaterial("#d3c3a5");
const stoveMat = standardMaterial("#3b464c", { metalness: 0.5, roughness: 0.48 });
const grateMat = standardMaterial("#242d31", { metalness: 0.45, roughness: 0.55 });
const shelfMat = standardMaterial("#9c7758");
const frameMat = standardMaterial("#60777a");
addBox(world, [13, 0.18, 9], [0, -2.15, -0.4], floorMat, false, true);
for (let x = -6; x <= 6; x++) {
addBox(world, [0.025, 0.012, 8.6], [x, -2.048, -0.4], floorLineMat, false, false);
}
for (let z = -4; z <= 3; z += 1) {
addBox(world, [12.5, 0.012, 0.025], [0, -2.047, z], floorLineMat, false, false);
}
addBox(world, [13, 7, 0.18], [0, 1.15, -3.65], wallMat, false, true);
addBox(world, [0.18, 7, 7.6], [-6.45, 1.15, -0.3], wallMat, false, true);
// Pixel-style backsplash tiles.
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 12; col++) {
const material = tileMats[(row * 3 + col * 5) % tileMats.length];
addBox(
world,
[0.96, 0.96, 0.08],
[-5.5 + col, 0.18 + row, -3.515],
material,
false,
true
);
}
}
// Cabinet and countertop.
addBox(world, [9.9, 1.78, 4.35], [0, -1.0, -0.38], cabinetMat);
addBox(world, [10.3, 0.22, 4.75], [0, 0.0, -0.35], counterMat);
for (const x of [-3.25, 0, 3.25]) {
addBox(world, [2.95, 1.38, 0.12], [x, -1.02, 1.84], cabinetDarkMat);
addBox(world, [0.65, 0.07, 0.08], [x, -0.55, 1.94], counterMat);
}
// Stovetop.
addBox(world, [4.35, 0.13, 3.82], [0, 0.18, 0.05], stoveMat);
addBox(world, [4.35, 0.31, 0.25], [0, -0.08, 1.93], stoveMat);
addBox(world, [0.56, 0.06, 0.07], [-1.2, 0.07, 2.08], counterMat);
addBox(world, [0.56, 0.06, 0.07], [1.2, 0.07, 2.08], counterMat);
addBox(world, [0.05, 0.05, 0.09], [-1.36, 0.1, 2.08], cabinetDarkMat);
addBox(world, [0.05, 0.05, 0.09], [-1.08, 0.1, 2.08], cabinetDarkMat);
addBox(world, [0.05, 0.05, 0.09], [1.08, 0.1, 2.08], cabinetDarkMat);
addBox(world, [0.05, 0.05, 0.09], [1.36, 0.1, 2.08], cabinetDarkMat);
// Shelf and jars.
addBox(world, [3.1, 0.18, 0.66], [-4.05, 3.15, -3.12], shelfMat);
addBox(world, [0.62, 0.75, 0.52], [-4.85, 3.61, -3.08], standardMaterial("#d9a45d"));
addBox(world, [0.65, 0.92, 0.53], [-3.95, 3.7, -3.08], standardMaterial("#b8c8a7"));
addBox(world, [0.52, 0.68, 0.48], [-3.05, 3.58, -3.08], standardMaterial("#d4c5a4"));
addBox(world, [0.72, 0.12, 0.61], [-4.85, 4.04, -3.08], standardMaterial("#8f6d50"));
addBox(world, [0.75, 0.12, 0.62], [-3.95, 4.22, -3.08], standardMaterial("#8f6d50"));
// Window.
const skyMat = standardMaterial("#acd7e5", {
emissive: "#8fc4d4",
emissiveIntensity: 0.13,
roughness: 1
});
addBox(world, [2.25, 1.65, 0.08], [3.85, 3.17, -3.43], skyMat, false, false);
addBox(world, [2.42, 0.13, 0.16], [3.85, 4.03, -3.35], frameMat);
addBox(world, [2.42, 0.13, 0.16], [3.85, 2.31, -3.35], frameMat);
addBox(world, [0.13, 1.83, 0.16], [2.69, 3.17, -3.35], frameMat);
addBox(world, [0.13, 1.83, 0.16], [5.01, 3.17, -3.35], frameMat);
addBox(world, [0.10, 1.65, 0.14], [3.85, 3.17, -3.34], frameMat);
addBox(world, [0.36, 0.36, 0.08], [4.38, 3.62, -3.34], standardMaterial("#f6cf65"), false, false);
// Hanging utensils.
addBox(world, [2.4, 0.09, 0.14], [0.45, 2.46, -3.30], frameMat);
addBox(world, [0.12, 0.82, 0.12], [-0.35, 2.08, -3.25], frameMat);
addBox(world, [0.42, 0.12, 0.12], [-0.35, 1.67, -3.25], frameMat);
addBox(world, [0.12, 0.67, 0.12], [0.45, 2.14, -3.25], frameMat);
addBox(world, [0.38, 0.38, 0.10], [0.45, 1.70, -3.25], frameMat);
addBox(world, [0.12, 0.72, 0.12], [1.25, 2.11, -3.25], frameMat);
addBox(world, [0.12, 0.44, 0.12], [1.25, 1.55, -3.25], frameMat);
// ---------------------------------------------------------------------
// Heater and cutaway pot
// ---------------------------------------------------------------------
const heaterMat = standardMaterial("#d93b24", {
emissive: "#ff3d18",
emissiveIntensity: 1.15,
roughness: 0.46
});
for (const x of [-1.12, 1.12]) {
addBox(world, [0.18, 0.39, 2.65], [x, 0.41, 0], grateMat);
addBox(world, [0.13, 0.13, 2.8], [x, 0.62, 0], grateMat);
}
addBox(world, [2.42, 0.11, 0.26], [0, 0.53, 0.63], heaterMat);
addBox(world, [2.42, 0.11, 0.26], [0, 0.53, -0.63], heaterMat);
addBox(world, [0.25, 0.11, 1.2], [-0.95, 0.53, 0], heaterMat);
addBox(world, [0.25, 0.11, 1.2], [0.95, 0.53, 0], heaterMat);
const potMat = standardMaterial("#53636e", {
metalness: 0.48,
roughness: 0.4
});
const potDarkMat = standardMaterial("#394750", {
metalness: 0.55,
roughness: 0.38
});
const potBaseMat = standardMaterial("#4a5963", {
metalness: 0.55,
roughness: 0.4,
emissive: "#ff4e28",
emissiveIntensity: 0
});
addBox(world, [3.48, 0.22, 2.88], [0, 0.78, 0], potBaseMat);
addBox(world, [0.18, 1.50, 2.72], [-1.64, 1.52, 0], potMat);
addBox(world, [0.18, 1.50, 2.72], [1.64, 1.52, 0], potMat);
addBox(world, [3.40, 1.50, 0.18], [0, 1.52, -1.30], potDarkMat);
// Low front lip leaves the liquid visible.
addBox(world, [3.45, 0.33, 0.18], [0, 0.94, 1.30], potMat);
// Pot rim.
addBox(world, [3.58, 0.13, 0.16], [0, 2.31, -1.34], potMat);
addBox(world, [3.58, 0.13, 0.16], [0, 2.31, 1.34], potMat);
addBox(world, [0.16, 0.13, 2.80], [-1.72, 2.31, 0], potMat);
addBox(world, [0.16, 0.13, 2.80], [1.72, 2.31, 0], potMat);
// Handles.
addBox(world, [0.75, 0.18, 0.22], [-2.06, 1.95, 0], potDarkMat);
addBox(world, [0.75, 0.18, 0.22], [2.06, 1.95, 0], potDarkMat);
addBox(world, [0.18, 0.18, 0.22], [-2.35, 1.95, 0], potDarkMat);
addBox(world, [0.18, 0.18, 0.22], [2.35, 1.95, 0], potDarkMat);
const soupMat = standardMaterial("#f59e0b", {
transparent: true,
opacity: 0.73,
roughness: 0.62,
depthWrite: false,
emissive: "#d75c00",
emissiveIntensity: 0.08
});
const soupTopMat = standardMaterial("#fbbf24", {
transparent: true,
opacity: 0.82,
roughness: 0.58,
depthWrite: false,
emissive: "#f97316",
emissiveIntensity: 0.12
});
const soupBody = addBox(world, [2.96, 1.25, 2.35], [0, 1.55, 0.04], soupMat, false, false);
const soupTop = addBox(world, [2.96, 0.12, 2.35], [0, 2.205, 0.04], soupTopMat, false, false);
soupBody.renderOrder = 1;
soupTop.renderOrder = 2;
// Small soup cubes near the surface.
const soupCubeMats = [
standardMaterial("#ffd45b", { emissive: "#f59e0b", emissiveIntensity: 0.16 }),
standardMaterial("#f8b733"),
standardMaterial("#ffdf76")
];
for (const [x, z, s] of [
[-0.75, 0.55, 0.12],
[-0.15, -0.38, 0.10],
[0.62, 0.34, 0.13],
[0.88, -0.66, 0.09],
[-0.88, -0.82, 0.10]
]) {
addBox(world, [s, s, s], [x, 2.28, z], soupCubeMats[0], false, false);
}
// ---------------------------------------------------------------------
// Voxel room-air particles
// ---------------------------------------------------------------------
const airCount = 42;
const airGeometry = unitBox;
const airMaterial = new THREE.MeshBasicMaterial({
color: "#84b9ca",
transparent: true,
opacity: 0.46,
depthWrite: false
});
const airMesh = new THREE.InstancedMesh(airGeometry, airMaterial, airCount);
airMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
airMesh.frustumCulled = false;
scene.add(airMesh);
const airParticles = [];
const airDummy = new THREE.Object3D();
for (let i = 0; i < airCount; i++) {
const seed = i * 12.9898;
const randX = (Math.sin(seed) * 43758.5453) % 1;
const randY = (Math.sin(seed + 1.7) * 24634.6345) % 1;
const randZ = (Math.sin(seed + 3.1) * 19349.1234) % 1;
const positive = (n) => Math.abs(n);
const particle = {
x: -3.7 + positive(randX) * 7.5,
y: 2.3 + positive(randY) * 3.1,
z: -2.3 + positive(randZ) * 4.0,
size: 0.07 + positive(randZ) * 0.09,
phase: positive(randX) * Math.PI * 2,
speed: 0.25 + positive(randY) * 0.3
};
airParticles.push(particle);
airDummy.position.set(particle.x, particle.y, particle.z);
airDummy.scale.setScalar(particle.size);
airDummy.updateMatrix();
airMesh.setMatrixAt(i, airDummy.matrix);
}
airMesh.instanceMatrix.needsUpdate = true;
// ---------------------------------------------------------------------
// Qualitative pathway rendering
// ---------------------------------------------------------------------
const routeGroups = {
conduction: new THREE.Group(),
convection: new THREE.Group(),
radiation: new THREE.Group()
};
Object.values(routeGroups).forEach((group) => scene.add(group));
const routeDefinitions = [];
function polylineLength(points) {
let length = 0;
for (let i = 0; i < points.length - 1; i++) {
length += points[i].distanceTo(points[i + 1]);
}
return length;
}
function samplePolyline(points, t, outPosition, outTangent) {
const total = polylineLength(points);
let remaining = ((t % 1) + 1) % 1 * total;
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
const segmentLength = a.distanceTo(b);
if (remaining <= segmentLength || i === points.length - 2) {
const amount = segmentLength === 0 ? 0 : remaining / segmentLength;
outPosition.lerpVectors(a, b, amount);
outTangent.subVectors(b, a).normalize();
return;
}
remaining -= segmentLength;
}
}
function createVoxelArrow(color) {
const arrow = new THREE.Group();
const material = new THREE.MeshBasicMaterial({ color });
addBox(arrow, [0.065, 0.18, 0.065], [0, -0.06, 0], material, false, false);
addBox(arrow, [0.075, 0.075, 0.075], [0, 0.075, 0], material, false, false);
addBox(arrow, [0.060, 0.060, 0.060], [-0.052, 0.035, 0], material, false, false);
addBox(arrow, [0.060, 0.060, 0.060], [0.052, 0.035, 0], material, false, false);
return arrow;
}
function createRoute({
group,
points,
color,
speed,
packetCount,
dotSpacing,
dotSize,
opacity,
scale = 1
}) {
const routePoints = points.map((point) => new THREE.Vector3(...point));
const totalLength = polylineLength(routePoints);
const dotMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity,
depthWrite: false
});
const dotCount = Math.max(2, Math.floor(totalLength / dotSpacing));
for (let i = 0; i <= dotCount; i++) {
const position = new THREE.Vector3();
const tangent = new THREE.Vector3();
samplePolyline(routePoints, i / dotCount, position, tangent);
const dot = new THREE.Mesh(unitBox, dotMaterial);
dot.scale.setScalar(dotSize);
dot.position.copy(position);
group.add(dot);
}
const packets = [];
for (let i = 0; i < packetCount; i++) {
const arrow = createVoxelArrow(color);
arrow.scale.setScalar(scale);
group.add(arrow);
packets.push({
arrow,
offset: i / packetCount
});
}
routeDefinitions.push({
points: routePoints,
speed,
packets
});
}
// Conduction: heater to the solid metal base.
createRoute({
group: routeGroups.conduction,
points: [
[0, 0.52, 1.52],
[0, 0.79, 1.52]
],
color: "#ff5a36",
speed: 0.38,
packetCount: 3,
dotSpacing: 0.12,
dotSize: 0.085,
opacity: 0.72,
scale: 0.82
});
// Convection: two counter-rotating circulation cells.
createRoute({
group: routeGroups.convection,
points: [
[0, 1.10, 1.29],
[0, 2.10, 1.29],
[-1.08, 2.10, 1.29],
[-1.08, 1.10, 1.29],
[0, 1.10, 1.29]
],
color: "#00a6a6",
speed: 0.12,
packetCount: 4,
dotSpacing: 0.16,
dotSize: 0.075,
opacity: 0.52,
scale: 0.76
});
createRoute({
group: routeGroups.convection,
points: [
[0, 1.10, 1.31],
[0, 2.10, 1.31],
[1.08, 2.10, 1.31],
[1.08, 1.10, 1.31],
[0, 1.10, 1.31]
],
color: "#00a6a6",
speed: 0.12,
packetCount: 4,
dotSpacing: 0.16,
dotSize: 0.075,
opacity: 0.52,
scale: 0.76
});
// Radiation: discontinuous infrared paths toward the pot and room air.
createRoute({
group: routeGroups.radiation,
points: [
[0, 0.56, 1.58],
[-1.77, 1.42, 1.02]
],
color: "#a855f7",
speed: 0.18,
packetCount: 2,
dotSpacing: 0.22,
dotSize: 0.075,
opacity: 0.7,
scale: 0.73
});
createRoute({
group: routeGroups.radiation,
points: [
[0, 0.56, 1.58],
[2.15, 1.72, 1.78],
[3.72, 4.32, 1.04]
],
color: "#a855f7",
speed: 0.13,
packetCount: 3,
dotSpacing: 0.25,
dotSize: 0.075,
opacity: 0.62,
scale: 0.73
});
// Warm soup voxels reinforce the rising portion of the convection cells.
const hotVoxels = [];
const hotMaterial = new THREE.MeshBasicMaterial({
color: "#ff8a1f",
transparent: true,
opacity: 0.88,
depthWrite: false
});
for (let i = 0; i < 8; i++) {
const mesh = new THREE.Mesh(unitBox, hotMaterial);
const scale = 0.10 + (i % 3) * 0.025;
mesh.scale.setScalar(scale);
routeGroups.convection.add(mesh);
hotVoxels.push({
mesh,
x: (i % 4 - 1.5) * 0.32,
z: 0.35 + Math.floor(i / 4) * 0.42,
phase: i * 0.137,
speed: 0.17 + (i % 3) * 0.025
});
}
// ---------------------------------------------------------------------
// Direct camera controls: no addons or example modules
// ---------------------------------------------------------------------
const orbit = {
theta: 0.64,
phi: 1.10,
radius: 11.0,
target: new THREE.Vector3(-0.15, 1.12, -0.12)
};
function updateCamera() {
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 resetView() {
orbit.theta = 0.64;
orbit.phi = 1.10;
orbit.radius = 11.0;
orbit.target.set(-0.15, 1.12, -0.12);
updateCamera();
}
let dragging = false;
let previousPointerX = 0;
let previousPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousPointerX;
const dy = event.clientY - previousPointerY;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
orbit.theta -= dx * 0.007;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - dy * 0.006, 0.53, 1.42);
updateCamera();
});
function stopDragging(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.008,
7.2,
15.2
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
updateCamera();
// ---------------------------------------------------------------------
// UI controls
// ---------------------------------------------------------------------
const routeInputs = [...document.querySelectorAll("[data-route]")];
function applyRouteVisibility() {
routeInputs.forEach((input) => {
routeGroups[input.dataset.route].visible = input.checked;
});
}
routeInputs.forEach((input) => {
input.addEventListener("change", applyRouteVisibility);
});
document.getElementById("show-all").addEventListener("click", () => {
routeInputs.forEach((input) => {
input.checked = true;
});
applyRouteVisibility();
});
document.getElementById("show-none").addEventListener("click", () => {
routeInputs.forEach((input) => {
input.checked = false;
});
applyRouteVisibility();
});
let paused = false;
const pauseButton = document.getElementById("pause");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume motion" : "Pause motion";
pauseButton.setAttribute("aria-pressed", String(paused));
});
document.getElementById("reset-view").addEventListener("click", resetView);
applyRouteVisibility();
// ---------------------------------------------------------------------
// Projected HTML labels
// ---------------------------------------------------------------------
const labelDefinitions = [
{
element: document.getElementById("label-heater"),
anchor: new THREE.Vector3(0, 0.57, 1.64)
},
{
element: document.getElementById("label-soup"),
anchor: new THREE.Vector3(-0.62, 1.85, 1.25)
},
{
element: document.getElementById("label-pot"),
anchor: new THREE.Vector3(1.72, 1.88, 0.05)
},
{
element: document.getElementById("label-air"),
anchor: new THREE.Vector3(3.55, 4.20, 0.88)
},
{
element: document.getElementById("label-stove"),
anchor: new THREE.Vector3(-3.2, 0.30, 1.0)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
labelDefinitions.forEach(({ element, anchor }) => {
projected.copy(anchor).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.08 &&
projected.x < 1.08 &&
projected.y > -1.08 &&
projected.y < 1.08;
element.style.display = visible ? "block" : "none";
if (visible) {
element.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
}
});
}
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const up = new THREE.Vector3(0, 1, 0);
const packetPosition = new THREE.Vector3();
const packetTangent = new THREE.Vector3();
let elapsed = 0;
let previousTime = performance.now();
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (!paused) {
elapsed += delta;
}
// Heater pulse.
heaterMat.emissiveIntensity = 1.0 + Math.sin(elapsed * 5.2) * 0.22;
heaterLight.intensity = 10 + Math.sin(elapsed * 5.2) * 2.2;
// Pot base responds visually to the conduction layer.
potBaseMat.emissiveIntensity = routeGroups.conduction.visible
? 0.13 + Math.sin(elapsed * 4.2) * 0.035
: 0;
// Gently bob the soup surface.
soupTop.position.y = 2.205 + Math.sin(elapsed * 1.8) * 0.012;
// Animated route packets.
routeDefinitions.forEach((route) => {
route.packets.forEach((packet) => {
const t = (elapsed * route.speed + packet.offset) % 1;
samplePolyline(route.points, t, packetPosition, packetTangent);
packet.arrow.position.copy(packetPosition);
packet.arrow.quaternion.setFromUnitVectors(up, packetTangent);
});
});
// Rising hot-soup voxels.
hotVoxels.forEach((voxel) => {
const phase = (elapsed * voxel.speed + voxel.phase) % 1;
voxel.mesh.position.set(
voxel.x + Math.sin(elapsed * 1.8 + voxel.phase * 8) * 0.08,
1.04 + phase * 1.08,
voxel.z
);
voxel.mesh.rotation.y = elapsed * 0.7 + voxel.phase;
});
// Air voxel drift.
airParticles.forEach((particle, index) => {
const drift = elapsed * particle.speed;
airDummy.position.set(
particle.x + Math.sin(drift + particle.phase) * 0.18,
particle.y + Math.sin(drift * 0.73 + particle.phase) * 0.20,
particle.z + Math.cos(drift * 0.62 + particle.phase) * 0.12
);
airDummy.scale.setScalar(particle.size);
airDummy.updateMatrix();
airMesh.setMatrixAt(index, airDummy.matrix);
});
airMesh.instanceMatrix.needsUpdate = true;
updateLabels();
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
```