Prompt specification
Build or customize the Three.js 3D scene "Kitchen melting and boiling gallery" 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: Kitchen melting and boiling gallery
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/kitchen-melting-and-boiling-gallery-x1491
Scene Description Prompt:
Compose an ice tray, melting pot, and boiling-water inset; distinguish liquid droplets in visible steam from invisible water vapor and label processes separately. Build this with Three.js from cdnjs as a voxel scene in one self-contained HTML file.
Working Three.js Starter (kitchen-melting-and-boiling-gallery-x1491):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Water Phase Lab — Voxel Diagram</title>
<style>
:root {
--bg: #07111e;
--panel: rgba(9, 22, 38, 0.88);
--line: rgba(171, 214, 238, 0.19);
--text: #eef8ff;
--muted: #9bb2c7;
--ice: #65dcff;
--water: #3aa8ff;
--heat: #ffb454;
--boil: #ff6f61;
--steam: #f2fbff;
--vapor: #c69aff;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 36%, #122b42 0%, #091827 42%, #050c15 100%);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
cursor: grab;
touch-action: none;
outline: none;
}
#scene.dragging {
cursor: grabbing;
}
#leaders {
position: fixed;
inset: 0;
z-index: 3;
width: 100%;
height: 100%;
pointer-events: none;
overflow: visible;
transition: opacity 180ms ease;
}
#leaders path {
fill: none;
stroke-width: 1.25;
stroke-dasharray: 4 4;
opacity: 0.75;
}
#leaders circle {
stroke-width: 1.5;
fill: #091827;
}
header {
position: fixed;
z-index: 8;
top: 0;
left: 0;
right: 0;
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 22px 26px;
pointer-events: none;
background: linear-gradient(
to bottom,
rgba(4, 10, 18, 0.76),
rgba(4, 10, 18, 0)
);
}
.brand {
max-width: 540px;
}
.eyebrow {
display: block;
margin-bottom: 5px;
color: #76c8ea;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(21px, 2.5vw, 35px);
line-height: 1;
letter-spacing: -0.04em;
font-weight: 820;
}
.subtitle {
margin: 9px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.actions {
display: flex;
gap: 8px;
pointer-events: auto;
}
.actions button {
appearance: none;
border: 1px solid rgba(163, 207, 231, 0.2);
border-radius: 9px;
padding: 9px 12px;
color: #dff4ff;
background: rgba(12, 29, 46, 0.82);
backdrop-filter: blur(10px);
cursor: pointer;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.04em;
transition:
border-color 150ms ease,
background 150ms ease,
transform 150ms ease;
}
.actions button:hover {
border-color: rgba(101, 220, 255, 0.55);
background: rgba(19, 48, 70, 0.94);
transform: translateY(-1px);
}
.callout {
position: fixed;
z-index: 5;
width: 222px;
padding: 13px 14px 14px;
border: 1px solid var(--line);
border-top: 2px solid var(--accent);
border-radius: 10px;
background:
linear-gradient(
135deg,
color-mix(in srgb, var(--accent) 7%, transparent),
transparent 48%
),
var(--panel);
box-shadow:
0 14px 40px rgba(0, 0, 0, 0.22),
inset 0 1px rgba(255, 255, 255, 0.035);
backdrop-filter: blur(13px);
pointer-events: none;
transition:
opacity 180ms ease,
transform 180ms ease;
}
.callout::after {
content: "";
position: absolute;
top: 10px;
right: 11px;
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 12px var(--accent);
}
.callout .tag {
display: block;
margin-bottom: 5px;
color: var(--accent);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.callout strong {
display: block;
margin-bottom: 5px;
color: #f4fbff;
font-size: 15px;
letter-spacing: -0.01em;
}
.callout p {
margin: 0;
color: #aac0d1;
font-size: 11px;
line-height: 1.5;
}
.callout .formula {
display: inline-block;
margin-top: 7px;
padding: 3px 6px;
border: 1px solid rgba(255, 255, 255, 0.11);
border-radius: 5px;
color: #e6f4fb;
background: rgba(255, 255, 255, 0.045);
font-size: 10px;
font-weight: 750;
}
#label-ice {
--accent: var(--ice);
left: 2.3%;
top: 23%;
}
#label-melt {
--accent: var(--heat);
left: 5.2%;
top: 61%;
}
#label-boiling {
--accent: var(--boil);
right: 2.3%;
top: 19%;
}
#label-steam {
--accent: var(--steam);
right: 2.3%;
top: 43%;
}
#label-vapor {
--accent: var(--vapor);
right: 2.3%;
top: 67%;
}
.legend {
position: fixed;
z-index: 6;
left: 50%;
bottom: 18px;
display: flex;
align-items: center;
gap: 17px;
max-width: calc(100vw - 28px);
padding: 9px 13px;
border: 1px solid rgba(169, 211, 233, 0.15);
border-radius: 10px;
color: #a9bdcd;
background: rgba(7, 17, 29, 0.78);
backdrop-filter: blur(12px);
transform: translateX(-50%);
pointer-events: none;
font-size: 9px;
font-weight: 760;
letter-spacing: 0.07em;
text-transform: uppercase;
white-space: nowrap;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--swatch);
box-shadow: 0 0 9px color-mix(in srgb, var(--swatch) 60%, transparent);
}
.swatch.path {
height: 2px;
border-radius: 0;
background: repeating-linear-gradient(
90deg,
var(--vapor) 0 4px,
transparent 4px 7px
);
box-shadow: none;
}
.hint {
position: fixed;
z-index: 6;
left: 18px;
bottom: 18px;
padding: 8px 10px;
border-radius: 8px;
color: #7892a8;
background: rgba(5, 13, 23, 0.62);
pointer-events: none;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.hide-labels .callout,
.hide-labels #leaders {
opacity: 0;
}
.hide-labels .callout {
transform: translateY(5px);
}
@media (max-width: 900px) {
header {
padding: 16px;
}
.subtitle {
max-width: 430px;
}
.callout {
width: 185px;
padding: 10px 11px 11px;
}
.callout p {
font-size: 10px;
}
.legend {
gap: 10px;
bottom: 12px;
}
.legend span:nth-child(4) {
display: none;
}
.hint {
display: none;
}
}
@media (max-width: 640px) {
.brand .subtitle {
display: none;
}
.actions {
flex-direction: column;
}
.actions button {
padding: 7px 9px;
font-size: 9px;
}
.callout {
width: 153px;
}
.callout .tag {
font-size: 8px;
}
.callout strong {
font-size: 12px;
}
.callout p {
display: none;
}
.callout .formula {
margin-top: 3px;
font-size: 9px;
}
#label-ice {
left: 2%;
top: 23%;
}
#label-melt {
left: 2%;
top: 66%;
}
#label-boiling {
right: 2%;
top: 24%;
}
#label-steam {
right: 2%;
top: 49%;
}
#label-vapor {
right: 2%;
top: 74%;
}
.legend {
width: calc(100vw - 20px);
justify-content: center;
gap: 12px;
overflow: hidden;
}
.legend span:nth-child(3),
.legend span:nth-child(5) {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel diagram of water phase changes"></canvas>
<svg id="leaders" aria-hidden="true">
<path id="leader-ice"></path>
<circle id="dot-ice" r="4"></circle>
<path id="leader-melt"></path>
<circle id="dot-melt" r="4"></circle>
<path id="leader-boiling"></path>
<circle id="dot-boiling" r="4"></circle>
<path id="leader-steam"></path>
<circle id="dot-steam" r="4"></circle>
<path id="leader-vapor"></path>
<circle id="dot-vapor" r="4"></circle>
</svg>
<header>
<div class="brand">
<span class="eyebrow">Interactive voxel science lab</span>
<h1>THE WATER PHASE LAB</h1>
<p class="subtitle">
Follow water from an ice tray to a melting pot, then examine boiling,
visible steam, and the invisible water vapor behind it.
</p>
</div>
<div class="actions">
<button id="resetView" type="button" title="Reset camera">Reset view</button>
<button id="toggleAnimation" type="button">Pause</button>
<button id="toggleLabels" type="button">Hide labels</button>
</div>
</header>
<aside id="label-ice" class="callout">
<span class="tag">Solid phase</span>
<strong>Ice tray</strong>
<p>Solid H₂O cubes, near 0°C before melting.</p>
</aside>
<aside id="label-melt" class="callout">
<span class="tag">Process 01 · Melting</span>
<strong>Solid → liquid</strong>
<p>Heat enters the ice; the cubes lose their rigid structure.</p>
<span class="formula">ICE + HEAT → LIQUID WATER</span>
</aside>
<aside id="label-boiling" class="callout">
<span class="tag">Process 02 · Boiling</span>
<strong>Liquid → gas</strong>
<p>Vapor forms throughout the liquid as bubbles.</p>
<span class="formula">LIQUID + HEAT → WATER VAPOR</span>
</aside>
<aside id="label-steam" class="callout">
<span class="tag">Process 03 · Condensation</span>
<strong>Visible steam</strong>
<p>The white cloud is tiny condensed liquid droplets, not gas itself.</p>
<span class="formula">VAPOR → LIQUID MICRODROPLETS</span>
</aside>
<aside id="label-vapor" class="callout">
<span class="tag">Gas phase · not rendered</span>
<strong>Invisible water vapor</strong>
<p>Water molecules are a gas. Purple arrows show only a schematic path.</p>
<span class="formula">NO CLOUD = MOLECULAR GAS</span>
</aside>
<div class="legend" aria-label="Diagram legend">
<span><i class="swatch" style="--swatch:#65dcff"></i>Solid ice</span>
<span><i class="swatch" style="--swatch:#3aa8ff"></i>Liquid water</span>
<span><i class="swatch" style="--swatch:#ff8a5c"></i>Heat</span>
<span><i class="swatch" style="--swatch:#f2fbff"></i>Liquid microdroplets</span>
<span><i class="swatch path"></i>Vapor path only</span>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, camera, and lighting
// ------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: 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.13;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x07111e, 18, 34);
const camera = new THREE.OrthographicCamera(
-9,
9,
5.4,
-5.4,
0.1,
100
);
const clock = new THREE.Clock();
const target = new THREE.Vector3(0.35, 2.1, 0);
let azimuth = 0.64;
let polar = 1.03;
let zoom = 1;
let running = true;
let simulationTime = 0;
function updateCamera() {
const radius = 18;
camera.position.set(
target.x + radius * Math.sin(azimuth) * Math.cos(polar),
target.y + radius * Math.sin(polar),
target.z + radius * Math.cos(azimuth) * Math.cos(polar)
);
camera.lookAt(target);
camera.zoom = zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(10.6, 13.8 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
const svg = document.querySelector("#leaders");
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
}
window.addEventListener("resize", resize);
resize();
updateCamera();
const hemisphere = new THREE.HemisphereLight(
0x9bdcff,
0x172132,
2.0
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xdaf4ff, 3.3);
keyLight.position.set(-4, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x6caeff, 1.4);
rimLight.position.set(8, 5, -7);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xff7c4c, 12, 8, 2);
warmLight.position.set(-0.1, 0.8, 1.0);
scene.add(warmLight);
// ------------------------------------------------------------
// Reusable geometry helpers
// ------------------------------------------------------------
const materials = {
floor: new THREE.MeshStandardMaterial({
color: 0x0b1b2a,
roughness: 0.94,
metalness: 0.08
}),
platform: new THREE.MeshStandardMaterial({
color: 0x10283a,
roughness: 0.72,
metalness: 0.24
}),
platformEdge: new THREE.MeshStandardMaterial({
color: 0x1b425c,
roughness: 0.48,
metalness: 0.36
}),
steel: new THREE.MeshStandardMaterial({
color: 0x526678,
roughness: 0.38,
metalness: 0.76
}),
steelDark: new THREE.MeshStandardMaterial({
color: 0x263849,
roughness: 0.42,
metalness: 0.72
}),
steelLight: new THREE.MeshStandardMaterial({
color: 0x7890a0,
roughness: 0.34,
metalness: 0.68
}),
tray: new THREE.MeshStandardMaterial({
color: 0x237fa8,
roughness: 0.44,
metalness: 0.14
}),
trayEdge: new THREE.MeshStandardMaterial({
color: 0x47b9df,
roughness: 0.38,
metalness: 0.18
}),
heat: new THREE.MeshStandardMaterial({
color: 0xff6b3d,
emissive: 0xff3c16,
emissiveIntensity: 1.35,
roughness: 0.5
}),
heatDim: new THREE.MeshStandardMaterial({
color: 0xa73527,
emissive: 0x7d1a10,
emissiveIntensity: 0.8,
roughness: 0.6
}),
panel: new THREE.MeshStandardMaterial({
color: 0x0b1d2d,
roughness: 0.82,
metalness: 0.12,
side: THREE.DoubleSide
}),
purple: new THREE.MeshBasicMaterial({
color: 0xc69aff,
transparent: true,
opacity: 0.82,
depthWrite: false
})
};
function addBox(parent, size, position, material, shadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = shadow;
mesh.receiveShadow = shadow;
parent.add(mesh);
return mesh;
}
function addVoxelBeam(parent, start, end, thickness, material) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const midpoint = a.clone().add(b).multiplyScalar(0.5);
const direction = b.clone().sub(a);
const length = direction.length();
const beam = addBox(
parent,
[thickness, length, thickness],
midpoint.toArray(),
material
);
beam.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return beam;
}
function createIceCube(size = 0.46) {
const group = new THREE.Group();
const shellMaterial = new THREE.MeshStandardMaterial({
color: 0x8ce9ff,
transparent: true,
opacity: 0.78,
roughness: 0.18,
metalness: 0.04
});
const coreMaterial = new THREE.MeshStandardMaterial({
color: 0x4dc5ec,
emissive: 0x0b3d54,
emissiveIntensity: 0.5,
roughness: 0.3
});
const shell = addBox(
group,
[size, size, size],
[0, 0, 0],
shellMaterial
);
addBox(
group,
[size * 0.66, size * 0.66, size * 0.66],
[0, 0, 0],
coreMaterial,
false
);
const edge = new THREE.LineSegments(
new THREE.EdgesGeometry(shell.geometry),
new THREE.LineBasicMaterial({
color: 0xd5f8ff,
transparent: true,
opacity: 0.8
})
);
group.add(edge);
return group;
}
function createChevron(color, size = 1) {
const group = new THREE.Group();
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.8,
depthWrite: false
});
const left = addBox(
group,
[0.28 * size, 0.045 * size, 0.045 * size],
[-0.07 * size, -0.035 * size, 0],
material,
false
);
left.rotation.z = 0.68;
const right = addBox(
group,
[0.28 * size, 0.045 * size, 0.045 * size],
[0.07 * size, -0.035 * size, 0],
material,
false
);
right.rotation.z = -0.68;
addBox(
group,
[0.045 * size, 0.21 * size, 0.045 * size],
[0, -0.18 * size, 0],
material,
false
);
group.userData.materials = [material];
return group;
}
// ------------------------------------------------------------
// Floor and exhibit platforms
// ------------------------------------------------------------
const stage = new THREE.Group();
scene.add(stage);
addBox(
stage,
[19, 0.45, 10.5],
[0, -0.48, 0],
materials.floor
);
const grid = new THREE.GridHelper(24, 32, 0x31546c, 0x183247);
grid.position.y = -0.245;
grid.material.transparent = true;
grid.material.opacity = 0.23;
stage.add(grid);
addBox(
stage,
[5.2, 0.22, 4.2],
[-1.25, -0.12, 0.15],
materials.platform
);
addBox(
stage,
[3.8, 0.10, 0.10],
[-1.25, 0.01, 2.18],
materials.platformEdge
);
addBox(
stage,
[3.8, 0.10, 0.10],
[-1.25, 0.01, -1.88],
materials.platformEdge
);
// A small voxel support makes the tilted tray read as part of the exhibit.
addBox(
stage,
[0.18, 3.9, 0.18],
[-4.3, 1.65, -1.25],
materials.steelDark
);
addVoxelBeam(
stage,
[-4.3, 3.35, -1.25],
[-3.25, 3.35, -0.65],
0.16,
materials.steel
);
// ------------------------------------------------------------
// Tilted ice tray
// ------------------------------------------------------------
const tray = new THREE.Group();
tray.position.set(-2.75, 3.55, -0.55);
tray.rotation.z = -0.23;
tray.rotation.x = 0.035;
scene.add(tray);
addBox(
tray,
[2.8, 0.16, 1.75],
[0, 0, 0],
materials.tray
);
// Outer rim.
addBox(tray, [2.9, 0.27, 0.12], [0, 0.11, -0.88], materials.trayEdge);
addBox(tray, [2.9, 0.27, 0.12], [0, 0.11, 0.88], materials.trayEdge);
addBox(tray, [0.12, 0.27, 1.75], [-1.42, 0.11, 0], materials.trayEdge);
addBox(tray, [0.12, 0.27, 1.75], [1.42, 0.11, 0], materials.trayEdge);
// Compartment dividers.
addBox(tray, [0.075, 0.22, 1.65], [-0.46, 0.09, 0], materials.trayEdge);
addBox(tray, [0.075, 0.22, 1.65], [0.47, 0.09, 0], materials.trayEdge);
addBox(tray, [2.72, 0.20, 0.075], [0, 0.08, 0], materials.trayEdge);
// Pouring lip.
addBox(tray, [0.42, 0.12, 1.45], [1.62, -0.08, 0], materials.trayEdge);
const trayIcePositions = [
[-0.94, 0.27, -0.43],
[-0.94, 0.27, 0.43],
[-0.01, 0.27, -0.43],
[0.51, 0.27, 0.43]
];
for (const position of trayIcePositions) {
const ice = createIceCube(0.43);
ice.position.set(...position);
ice.rotation.y = Math.random() * Math.PI;
tray.add(ice);
}
// ------------------------------------------------------------
// Melting pot and hotplate
// ------------------------------------------------------------
const meltingPot = new THREE.Group();
meltingPot.position.set(-0.15, 0, 0.25);
scene.add(meltingPot);
addBox(
meltingPot,
[3.25, 0.20, 2.85],
[0, 0.05, 0],
materials.steelDark
);
for (let i = -1; i <= 1; i++) {
addBox(
meltingPot,
[0.72, 0.08, 1.85],
[i * 0.9, 0.19, 0],
materials.heatDim
);
}
addBox(
meltingPot,
[2.95, 0.32, 2.45],
[0, 0.39, 0],
materials.steelDark
);
// Tall rear and side walls; low front wall reveals the contents.
addBox(
meltingPot,
[3.0, 1.35, 0.25],
[0, 1.10, 1.12],
materials.steel
);
addBox(
meltingPot,
[0.25, 1.35, 2.45],
[-1.39, 1.10, 0],
materials.steel
);
addBox(
meltingPot,
[0.25, 1.35, 2.45],
[1.39, 1.10, 0],
materials.steel
);
addBox(
meltingPot,
[3.0, 0.73, 0.25],
[0, 0.77, -1.12],
materials.steelLight
);
// Pot rim.
addBox(
meltingPot,
[3.16, 0.13, 0.34],
[0, 1.79, 1.10],
materials.steelLight
);
addBox(
meltingPot,
[3.16, 0.13, 0.34],
[0, 1.35, -1.10],
materials.steelLight
);
addBox(
meltingPot,
[0.34, 0.13, 2.40],
[-1.37, 1.79, 0],
materials.steelLight
);
addBox(
meltingPot,
[0.34, 0.13, 2.40],
[1.37, 1.79, 0],
materials.steelLight
);
// Blocky handle.
addBox(
meltingPot,
[0.70, 0.15, 0.15],
[1.83, 1.58, 0],
materials.steelDark
);
addBox(
meltingPot,
[0.15, 0.72, 0.15],
[2.10, 1.25, 0],
materials.steelDark
);
addBox(
meltingPot,
[0.70, 0.15, 0.15],
[1.83, 0.92, 0],
materials.steelDark
);
const meltingWaterMaterial = new THREE.MeshStandardMaterial({
color: 0x238fd0,
transparent: true,
opacity: 0.68,
roughness: 0.18,
metalness: 0.02,
depthWrite: false
});
const meltingWater = addBox(
meltingPot,
[2.45, 0.72, 1.92],
[0, 0.94, 0],
meltingWaterMaterial,
false
);
const waterSurfaceMaterial = new THREE.MeshStandardMaterial({
color: 0x55c8f5,
transparent: true,
opacity: 0.72,
roughness: 0.16,
depthWrite: false
});
const meltingSurface = addBox(
meltingPot,
[2.38, 0.055, 1.87],
[0, 1.30, 0],
waterSurfaceMaterial,
false
);
// Visible heat entering the melting vessel.
const heatArrows = [];
for (let i = 0; i < 3; i++) {
const arrow = createChevron(0xff9a52, 0.60);
arrow.position.set(-0.75 + i * 0.75, 0.54, -1.30);
meltingPot.add(arrow);
heatArrows.push(arrow);
}
// Ice chunks already inside the pot.
const potChunks = [];
const chunkPositions = [
[-0.58, 1.23, -0.42],
[0.18, 1.20, 0.43],
[0.63, 1.18, -0.28],
[-0.08, 1.14, 0.06]
];
for (const position of chunkPositions) {
const chunk = createIceCube(0.42);
chunk.position.set(...position);
chunk.rotation.set(Math.random(), Math.random(), Math.random());
meltingPot.add(chunk);
potChunks.push({
mesh: chunk,
phase: Math.random() * Math.PI * 2,
baseScale: 0.8 + Math.random() * 0.25
});
}
// ------------------------------------------------------------
// Boiling-water inset: framed cutaway vessel
// ------------------------------------------------------------
const inset = new THREE.Group();
inset.position.set(4.15, 0, 0.05);
scene.add(inset);
addBox(
inset,
[3.45, 0.25, 3.25],
[0, 0.02, 0],
materials.platform
);
// Vertical backing panel creates an explicit inset/frame.
addBox(
inset,
[3.55, 5.25, 0.15],
[0, 2.63, -1.48],
materials.panel
);
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0x28536c,
emissive: 0x102f43,
emissiveIntensity: 0.45,
roughness: 0.46,
metalness: 0.35
});
addBox(inset, [3.62, 0.08, 0.10], [0, 5.27, -1.37], frameMaterial);
addBox(inset, [3.62, 0.08, 0.10], [0, 0.04, -1.37], frameMaterial);
addBox(inset, [0.08, 5.25, 0.10], [-1.78, 2.65, -1.37], frameMaterial);
addBox(inset, [0.08, 5.25, 0.10], [1.78, 2.65, -1.37], frameMaterial);
// Decorative inset header.
addBox(inset, [2.7, 0.08, 0.08], [0, 4.83, -1.35], materials.heat);
addBox(inset, [0.45, 0.08, 0.08], [-1.10, 4.83, -1.35], materials.platformEdge);
// Cutaway boiling pot.
addBox(inset, [2.65, 0.30, 2.15], [0, 0.43, 0.20], materials.steelDark);
addBox(inset, [2.45, 1.55, 0.22], [0, 1.18, 1.05], materials.steel);
addBox(inset, [0.22, 1.55, 2.05], [-1.16, 1.18, 0.20], materials.steel);
addBox(inset, [0.22, 1.55, 2.05], [1.16, 1.18, 0.20], materials.steel);
addBox(inset, [2.45, 0.42, 0.22], [0, 0.75, -0.80], materials.steelLight);
addBox(inset, [2.58, 0.12, 0.30], [0, 1.98, 1.03], materials.steelLight);
addBox(inset, [0.30, 0.12, 2.08], [-1.15, 1.98, 0.20], materials.steelLight);
addBox(inset, [0.30, 0.12, 2.08], [1.15, 1.98, 0.20], materials.steelLight);
const boilingWaterMaterial = new THREE.MeshStandardMaterial({
color: 0x168ec6,
transparent: true,
opacity: 0.60,
roughness: 0.2,
metalness: 0.02,
depthWrite: false
});
const boilingWater = addBox(
inset,
[1.98, 1.20, 1.64],
[0, 1.13, 0.16],
boilingWaterMaterial,
false
);
const boilingSurfaceMaterial = new THREE.MeshStandardMaterial({
color: 0x6fe4ff,
transparent: true,
opacity: 0.75,
roughness: 0.15,
depthWrite: false
});
const boilingSurface = addBox(
inset,
[1.95, 0.055, 1.60],
[0, 1.75, 0.16],
boilingSurfaceMaterial,
false
);
// Orange heat chevrons inside the liquid.
const boilingHeatArrows = [];
for (let i = 0; i < 3; i++) {
const arrow = createChevron(0xff9b55, 0.55);
arrow.position.set(-0.60 + i * 0.60, 0.90, 0.87);
inset.add(arrow);
boilingHeatArrows.push(arrow);
}
// Boiling bubbles: visible gas pockets rising through the liquid.
const bubbles = [];
const bubbleGeometry = new THREE.BoxGeometry(0.13, 0.13, 0.13);
const bubbleMaterial = new THREE.MeshStandardMaterial({
color: 0xb9f3ff,
emissive: 0x4eb5d0,
emissiveIntensity: 0.55,
transparent: true,
opacity: 0.78,
roughness: 0.22
});
for (let i = 0; i < 12; i++) {
const bubble = new THREE.Mesh(bubbleGeometry, bubbleMaterial);
inset.add(bubble);
bubbles.push({
mesh: bubble,
x: (Math.random() - 0.5) * 1.55,
z: 0.16 + (Math.random() - 0.5) * 1.20,
phase: Math.random(),
speed: 0.26 + Math.random() * 0.22,
size: 0.55 + Math.random() * 0.75
});
}
// ------------------------------------------------------------
// Visible steam: tiny condensed liquid droplets
// ------------------------------------------------------------
const steamDroplets = [];
const dropletGeometry = new THREE.BoxGeometry(0.09, 0.09, 0.09);
for (let i = 0; i < 42; i++) {
const material = new THREE.MeshBasicMaterial({
color: i % 4 === 0 ? 0xbcefff : 0xf4fcff,
transparent: true,
opacity: 0.5,
depthWrite: false
});
const droplet = new THREE.Mesh(dropletGeometry, material);
inset.add(droplet);
steamDroplets.push({
mesh: droplet,
phase: Math.random(),
speed: 0.17 + Math.random() * 0.13,
x: -0.57 + (Math.random() - 0.5) * 0.58,
z: 0.13 + (Math.random() - 0.5) * 0.65,
sway: 0.07 + Math.random() * 0.12,
size: 0.45 + Math.random() * 1.10
});
}
// A small neck of condensed droplets directly over the water.
for (let i = 0; i < 8; i++) {
const material = new THREE.MeshBasicMaterial({
color: 0xeafaff,
transparent: true,
opacity: 0.45,
depthWrite: false
});
const droplet = new THREE.Mesh(dropletGeometry, material);
inset.add(droplet);
steamDroplets.push({
mesh: droplet,
phase: Math.random(),
speed: 0.22 + Math.random() * 0.1,
x: -0.20 + (Math.random() - 0.5) * 0.35,
z: 0.12 + (Math.random() - 0.5) * 0.3,
sway: 0.025,
size: 0.35 + Math.random() * 0.45
});
}
// ------------------------------------------------------------
// Invisible water vapor: schematic arrows only
// ------------------------------------------------------------
const vaporArrows = [];
for (let i = 0; i < 4; i++) {
const arrow = createChevron(0xc69aff, 0.72);
arrow.position.set(0.78, 2.48 + i * 0.58, -0.18);
inset.add(arrow);
vaporArrows.push(arrow);
}
// Dashed schematic shaft, deliberately not made of molecular particles.
for (let i = 0; i < 8; i++) {
const dash = addBox(
inset,
[0.04, 0.13, 0.04],
[0.78, 2.18 + i * 0.29, -0.18],
materials.purple,
false
);
dash.userData.vaporDash = true;
}
// ------------------------------------------------------------
// Falling and melting ice cubes
// ------------------------------------------------------------
const fallingIce = [];
let spawnTimer = 0.65;
function spawnIceCube() {
const cube = createIceCube(0.43);
scene.add(cube);
const local = new THREE.Vector3(
0.98 + Math.random() * 0.12,
0.28,
(Math.random() - 0.5) * 0.72
);
tray.updateMatrixWorld(true);
const start = tray.localToWorld(local.clone());
const targetPosition = new THREE.Vector3(
meltingPot.position.x + (Math.random() - 0.5) * 0.82,
1.19,
meltingPot.position.z + (Math.random() - 0.5) * 0.62
);
cube.position.copy(start);
cube.rotation.set(
Math.random() * 0.5,
Math.random() * Math.PI,
Math.random() * 0.5
);
fallingIce.push({
mesh: cube,
phase: "fall",
age: 0,
duration: 1.05 + Math.random() * 0.12,
start,
target: targetPosition,
meltAge: 0,
meltDuration: 4.8 + Math.random() * 1.2
});
}
function updateFallingIce(dt) {
for (let i = fallingIce.length - 1; i >= 0; i--) {
const item = fallingIce[i];
if (item.phase === "fall") {
item.age += dt;
const t = Math.min(item.age / item.duration, 1);
const eased = t * t * (3 - 2 * t);
item.mesh.position.lerpVectors(item.start, item.target, eased);
item.mesh.position.y += Math.sin(Math.PI * t) * 0.42;
item.mesh.rotation.x += dt * 2.8;
item.mesh.rotation.z += dt * 2.1;
if (t >= 1) {
item.phase = "melt";
item.age = 0;
item.mesh.position.copy(item.target);
}
} else {
item.meltAge += dt;
const t = Math.min(item.meltAge / item.meltDuration, 1);
const scale = THREE.MathUtils.lerp(1, 0.13, t * t);
item.mesh.scale.setScalar(scale);
item.mesh.rotation.y += dt * 0.55;
item.mesh.position.y += Math.sin(simulationTime * 2 + i) * dt * 0.012;
if (t >= 1) {
scene.remove(item.mesh);
fallingIce.splice(i, 1);
}
}
}
}
// ------------------------------------------------------------
// Animated scene details
// ------------------------------------------------------------
function updateScene(dt) {
spawnTimer -= dt;
if (spawnTimer <= 0) {
spawnIceCube();
spawnTimer = 1.25 + Math.random() * 0.35;
}
updateFallingIce(dt);
const meltRise = Math.min(
0.24,
fallingIce.filter((item) => item.phase === "melt").length * 0.035
);
const meltHeight = 0.72 + meltRise;
meltingWater.scale.y = meltHeight / 0.72;
meltingWater.position.y = 0.58 + meltHeight / 2;
meltingSurface.position.y = 0.58 + meltHeight + 0.025;
meltingSurface.position.x = Math.sin(simulationTime * 1.8) * 0.025;
for (const chunk of potChunks) {
const pulse = 0.92 + Math.sin(simulationTime * 1.7 + chunk.phase) * 0.08;
chunk.mesh.scale.setScalar(chunk.baseScale * pulse);
}
for (let i = 0; i < heatArrows.length; i++) {
const arrow = heatArrows[i];
const phase = (simulationTime * 0.55 + i * 0.28) % 1;
arrow.position.y = 0.48 + phase * 0.43;
arrow.userData.materials[0].opacity = 0.25 + (1 - phase) * 0.65;
}
// Boiling surface motion.
boilingWater.scale.y = 1 + Math.sin(simulationTime * 3.1) * 0.014;
boilingSurface.position.y =
1.755 + Math.sin(simulationTime * 3.4) * 0.025;
boilingSurface.position.x = Math.sin(simulationTime * 1.9) * 0.018;
for (let i = 0; i < boilingHeatArrows.length; i++) {
const arrow = boilingHeatArrows[i];
const phase = (simulationTime * 0.65 + i * 0.24) % 1;
arrow.position.y = 0.72 + phase * 0.72;
arrow.userData.materials[0].opacity = 0.20 + (1 - phase) * 0.65;
}
// Rising gas pockets.
for (const bubble of bubbles) {
const p = (bubble.phase + simulationTime * bubble.speed) % 1;
bubble.mesh.position.set(
bubble.x + Math.sin(p * 9 + bubble.phase * 8) * 0.035,
0.69 + p * 0.94,
bubble.z
);
const scale = bubble.size * (0.60 + p * 0.65);
bubble.mesh.scale.setScalar(scale);
bubble.mesh.rotation.x = simulationTime * 0.7;
bubble.mesh.rotation.y = simulationTime * 0.9;
}
// Visible steam droplets rise, spread, and fade.
for (const droplet of steamDroplets) {
const p = (droplet.phase + simulationTime * droplet.speed) % 1;
const rise = p * p * 0.28 + p * 2.62;
droplet.mesh.position.set(
droplet.x + Math.sin(p * 7 + droplet.phase * 12) * droplet.sway,
2.00 + rise,
droplet.z + Math.cos(p * 5 + droplet.phase * 9) * 0.035
);
const scale = droplet.size * (0.38 + p * 1.12);
droplet.mesh.scale.setScalar(scale);
droplet.mesh.material.opacity = 0.58 * Math.sin(Math.PI * p);
droplet.mesh.rotation.x = simulationTime * 0.4 + droplet.phase * 4;
droplet.mesh.rotation.y = simulationTime * 0.6 + droplet.phase * 3;
}
// Purple vapor arrows pulse along the invisible gas path.
for (let i = 0; i < vaporArrows.length; i++) {
const arrow = vaporArrows[i];
const phase = (simulationTime * 0.72 + i * 0.24) % 1;
arrow.position.y = 2.42 + phase * 1.76;
arrow.userData.materials[0].opacity = 0.25 + (1 - phase) * 0.70;
}
}
// ------------------------------------------------------------
// HTML labels and projected leader lines
// ------------------------------------------------------------
const anchors = {
ice: new THREE.Vector3(-2.65, 4.25, -0.35),
melt: new THREE.Vector3(-0.15, 1.65, 0.35),
boiling: new THREE.Vector3(4.15, 1.75, 0.25),
steam: new THREE.Vector3(3.58, 3.75, 0.12),
vapor: new THREE.Vector3(4.93, 3.52, -0.13)
};
const labelColors = {
ice: "#65dcff",
melt: "#ffb454",
boiling: "#ff6f61",
steam: "#f2fbff",
vapor: "#c69aff"
};
function updateLeaders() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const [key, worldPoint] of Object.entries(anchors)) {
const projected = worldPoint.clone().project(camera);
const path = document.querySelector(`#leader-${key}`);
const dot = document.querySelector(`#dot-${key}`);
const card = document.querySelector(`#label-${key}`);
if (projected.z < -1 || projected.z > 1) {
path.style.opacity = "0";
dot.style.opacity = "0";
continue;
}
const endX = (projected.x * 0.5 + 0.5) * width;
const endY = (-projected.y * 0.5 + 0.5) * height;
const rect = card.getBoundingClientRect();
let startX;
let startY;
if (endX < rect.left) {
startX = rect.left;
startY = THREE.MathUtils.clamp(
endY,
rect.top + 16,
rect.bottom - 16
);
} else if (endX > rect.right) {
startX = rect.right;
startY = THREE.MathUtils.clamp(
endY,
rect.top + 16,
rect.bottom - 16
);
} else if (endY < rect.top) {
startX = endX;
startY = rect.top;
} else if (endY > rect.bottom) {
startX = endX;
startY = rect.bottom;
} else {
startX = endX < rect.left + rect.width / 2 ? rect.left : rect.right;
startY = endY;
}
const bend = (endX - startX) * 0.42;
path.setAttribute(
"d",
`M ${startX} ${startY} C ${startX + bend} ${startY}, ${endX - bend} ${endY}, ${endX} ${endY}`
);
path.setAttribute("stroke", labelColors[key]);
dot.setAttribute("cx", endX);
dot.setAttribute("cy", endY);
dot.setAttribute("stroke", labelColors[key]);
path.style.opacity = "0.78";
dot.style.opacity = "1";
}
}
// ------------------------------------------------------------
// Custom orbit controls — no external controls addon
// ------------------------------------------------------------
let dragging = false;
let previousX = 0;
let previousY = 0;
function resetView() {
azimuth = 0.64;
polar = 1.03;
zoom = 1;
updateCamera();
}
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.classList.add("dragging");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
azimuth -= dx * 0.006;
polar = THREE.MathUtils.clamp(
polar - dy * 0.005,
0.56,
1.34
);
previousX = event.clientX;
previousY = event.clientY;
updateCamera();
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.65
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") azimuth += 0.08;
if (event.key === "ArrowRight") azimuth -= 0.08;
if (event.key === "ArrowUp") polar = Math.max(0.56, polar - 0.06);
if (event.key === "ArrowDown") polar = Math.min(1.34, polar + 0.06);
if (event.key === "+" || event.key === "=") zoom = Math.min(1.65, zoom + 0.08);
if (event.key === "-") zoom = Math.max(0.72, zoom - 0.08);
updateCamera();
});
document.querySelector("#resetView").addEventListener("click", resetView);
document.querySelector("#toggleAnimation").addEventListener("click", (event) => {
running = !running;
event.currentTarget.textContent = running ? "Pause" : "Resume";
});
document.querySelector("#toggleLabels").addEventListener("click", (event) => {
const hidden = document.body.classList.toggle("hide-labels");
event.currentTarget.textContent = hidden ? "Show labels" : "Hide labels";
});
// ------------------------------------------------------------
// Render loop
// ------------------------------------------------------------
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (running) {
simulationTime += dt;
updateScene(dt);
}
renderer.render(scene, camera);
updateLeaders();
}
animate();
</script>
</body>
</html>
```