Prompt specification
Build or customize the Three.js 3D scene "Warm moist air over a cold plate" 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: Warm moist air over a cold plate
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/warm-moist-air-over-a-cold-plate-x1214
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows condensation and cloud formation. Create a transparent chamber with rising air arrows and a chilled overhead plate; grow schematic droplets on the plate while labeling molecular processes simplified. Stylized solid forms.
Working Three.js Starter (warm-moist-air-over-a-cold-plate-x1214):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Condensation Chamber</title>
<style>
:root {
--ink: #163746;
--muted: #5d7480;
--glass: rgba(248, 253, 255, 0.76);
--border: rgba(44, 102, 125, 0.18);
--cyan: #20b9dc;
--blue: #168fc4;
--coral: #f47758;
--cream: #fff7df;
--green: #35b58a;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background:
radial-gradient(circle at 66% 28%, #ffffff 0%, #eef7fa 35%, #d8e6ec 74%, #c7d8df 100%);
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
#hud {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.glass {
background: var(--glass);
border: 1px solid var(--border);
box-shadow:
0 18px 50px rgba(30, 72, 88, 0.12),
inset 0 1px 0 rgba(255, 255, 255, 0.8);
backdrop-filter: blur(16px) saturate(1.15);
-webkit-backdrop-filter: blur(16px) saturate(1.15);
}
.intro {
position: absolute;
top: 24px;
left: 24px;
width: 326px;
padding: 22px;
border-radius: 22px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: var(--blue);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 0 5px rgba(32, 185, 220, 0.13);
content: "";
}
h1 {
margin: 0;
font-size: clamp(28px, 3vw, 39px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 1.03;
}
.intro p {
margin: 13px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.live-status {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 17px;
padding: 10px 12px;
border: 1px solid rgba(32, 185, 220, 0.18);
border-radius: 12px;
background: rgba(225, 248, 253, 0.64);
}
.live-status small {
display: block;
margin-bottom: 2px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#stage-label {
font-size: 12px;
font-weight: 750;
}
.temperature {
flex: 0 0 auto;
text-align: right;
}
.temperature b {
display: block;
color: var(--blue);
font-size: 17px;
}
.temperature span {
color: var(--muted);
font-size: 10px;
}
.controls {
display: flex;
gap: 8px;
margin-top: 13px;
pointer-events: auto;
}
.controls button {
flex: 1;
padding: 9px 11px;
color: var(--ink);
border: 1px solid rgba(38, 97, 119, 0.18);
border-radius: 10px;
background: rgba(255, 255, 255, 0.72);
cursor: pointer;
font-size: 11px;
font-weight: 750;
transition:
transform 150ms ease,
border-color 150ms ease,
background 150ms ease;
}
.controls button:hover {
transform: translateY(-1px);
border-color: rgba(32, 185, 220, 0.45);
background: white;
}
.controls button:active {
transform: translateY(0);
}
.legend {
position: absolute;
top: 24px;
right: 24px;
width: 190px;
padding: 16px 17px;
border-radius: 17px;
}
.legend-title {
margin-bottom: 11px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
color: var(--muted);
font-size: 11px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 50%;
box-shadow: inset 0 0 0 1px rgba(20, 50, 65, 0.12);
}
.swatch.warm { background: var(--coral); }
.swatch.cool { background: var(--cyan); }
.swatch.vapor { background: #ef725a; }
.swatch.water { background: #30b7df; }
.swatch.cloud { background: #e8f8fb; }
.help {
margin-top: 12px;
padding-top: 11px;
color: #78909a;
border-top: 1px solid var(--border);
font-size: 10px;
line-height: 1.45;
}
.callout {
position: absolute;
min-width: 156px;
padding: 10px 12px;
border-radius: 12px;
background: rgba(250, 254, 255, 0.86);
border: 1px solid rgba(40, 112, 139, 0.18);
box-shadow: 0 9px 24px rgba(36, 76, 91, 0.1);
backdrop-filter: blur(10px);
transform: translate(-50%, -50%);
transition: opacity 160ms ease;
}
.callout::before {
position: absolute;
top: 14px;
left: -5px;
width: 9px;
height: 9px;
border: 2px solid white;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 0 1px rgba(22, 143, 196, 0.35);
content: "";
}
.callout b {
display: block;
margin-bottom: 3px;
color: var(--blue);
font-size: 9px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.callout span {
display: block;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.process-strip {
position: absolute;
bottom: 22px;
left: 50%;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
width: min(930px, calc(100% - 48px));
padding: 8px;
border-radius: 19px;
transform: translateX(-50%);
}
.process-card {
position: relative;
min-height: 74px;
padding: 12px 13px 14px;
overflow: hidden;
border: 1px solid transparent;
border-radius: 13px;
background: rgba(255, 255, 255, 0.45);
transition:
border-color 250ms ease,
background 250ms ease,
transform 250ms ease;
}
.process-card.active {
border-color: rgba(32, 185, 220, 0.36);
background: rgba(236, 250, 254, 0.9);
transform: translateY(-2px);
}
.process-card.done .step-number {
color: white;
background: var(--green);
}
.process-top {
display: flex;
align-items: center;
gap: 8px;
}
.step-number {
display: grid;
flex: 0 0 auto;
width: 23px;
height: 23px;
place-items: center;
color: white;
border-radius: 7px;
background: #8aa7b3;
font-size: 10px;
font-weight: 800;
transition: background 250ms ease;
}
.process-card.active .step-number {
background: var(--cyan);
}
.process-card strong {
font-size: 11px;
letter-spacing: -0.01em;
}
.process-card p {
margin: 7px 0 0 31px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.mini-progress {
position: absolute;
right: 12px;
bottom: 7px;
left: 12px;
height: 2px;
overflow: hidden;
border-radius: 2px;
background: rgba(70, 115, 130, 0.1);
}
.mini-progress span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--cyan);
transition: width 100ms linear;
}
@media (max-width: 900px) {
.legend {
display: none;
}
.intro {
width: 286px;
}
.callout {
transform: translate(-50%, -50%) scale(0.9);
}
}
@media (max-width: 650px) {
.intro {
top: 12px;
left: 12px;
width: calc(100% - 24px);
padding: 15px;
border-radius: 17px;
}
.intro p,
.help,
.temperature {
display: none;
}
.eyebrow {
margin-bottom: 6px;
}
h1 {
font-size: 25px;
}
.live-status {
margin-top: 10px;
padding: 8px 10px;
}
.controls {
margin-top: 8px;
}
.controls button {
padding: 7px 9px;
}
.callout {
display: none;
}
.process-strip {
bottom: 10px;
gap: 4px;
width: calc(100% - 20px);
padding: 5px;
border-radius: 14px;
}
.process-card {
min-height: 58px;
padding: 9px 7px 11px;
}
.process-top {
gap: 5px;
}
.step-number {
width: 19px;
height: 19px;
border-radius: 6px;
font-size: 9px;
}
.process-card strong {
font-size: 9px;
line-height: 1.1;
}
.process-card p {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="hud">
<section class="intro glass">
<div class="eyebrow">Interactive molecular model</div>
<h1>Inside a<br />condensation chamber</h1>
<p>
Warm, moist air rises toward a cold plate. As the water molecules
lose thermal energy, they change from gas into liquid droplets.
</p>
<div class="live-status">
<div>
<small>Current process</small>
<div id="stage-label">Condensation</div>
</div>
<div class="temperature">
<b>4°C</b>
<span>chilled plate</span>
</div>
</div>
<div class="controls">
<button id="pause-button" type="button">Pause</button>
<button id="restart-button" type="button">Restart cycle</button>
<button id="camera-button" type="button">Reset view</button>
</div>
</section>
<aside class="legend glass">
<div class="legend-title">Visual key</div>
<div class="legend-row"><i class="swatch warm"></i>Warm rising air</div>
<div class="legend-row"><i class="swatch cool"></i>Cooled air</div>
<div class="legend-row"><i class="swatch vapor"></i>H₂O oxygen center</div>
<div class="legend-row"><i class="swatch water"></i>Liquid droplets</div>
<div class="legend-row"><i class="swatch cloud"></i>Condensed micro-cloud</div>
<div class="help">
Drag to orbit · Scroll or pinch to zoom<br />
Molecules and droplets are enlarged for clarity.
</div>
</aside>
<div class="callout" id="callout-evaporate">
<b>01 · Evaporation</b>
<span>Liquid water gains energy and enters the air as vapor.</span>
</div>
<div class="callout" id="callout-rise">
<b>02 · Rising air</b>
<span>Warm air carries water molecules upward.</span>
</div>
<div class="callout" id="callout-cool">
<b>03 · Cooling</b>
<span>The chilled plate removes thermal energy from the vapor.</span>
</div>
<div class="callout" id="callout-condense">
<b>04 · Condensation</b>
<span>Vapor becomes liquid and forms growing droplets.</span>
</div>
<section class="process-strip glass">
<article class="process-card" data-step="0">
<div class="process-top">
<span class="step-number">1</span>
<strong>Warm water</strong>
</div>
<p>Liquid → vapor</p>
<div class="mini-progress"><span></span></div>
</article>
<article class="process-card" data-step="1">
<div class="process-top">
<span class="step-number">2</span>
<strong>Rising air</strong>
</div>
<p>Vapor moves upward</p>
<div class="mini-progress"><span></span></div>
</article>
<article class="process-card" data-step="2">
<div class="process-top">
<span class="step-number">3</span>
<strong>Chilled plate</strong>
</div>
<p>Thermal energy decreases</p>
<div class="mini-progress"><span></span></div>
</article>
<article class="process-card" data-step="3">
<div class="process-top">
<span class="step-number">4</span>
<strong>Condensation</strong>
</div>
<p>Vapor → liquid droplets</p>
<div class="mini-progress"><span></span></div>
</article>
</section>
</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 lights
// -------------------------------------------------------------------------
const sceneHost = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
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 scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xdce9ef, 19, 37);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraTarget = new THREE.Vector3(0.5, 4.0, 0);
let cameraYaw = 0.64;
let cameraElevation = 0.18;
let cameraRadius = 15.6;
const hemisphere = new THREE.HemisphereLight(0xeafaff, 0x6d7d85, 2.4);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(8, 13, 10);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 13;
keyLight.shadow.camera.bottom = -4;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.normalBias = 0.035;
scene.add(keyLight);
const coldLight = new THREE.PointLight(0x55d8ff, 24, 13, 2);
coldLight.position.set(-2.7, 7.0, 2.8);
scene.add(coldLight);
const warmLight = new THREE.PointLight(0xff8c61, 18, 10, 2);
warmLight.position.set(2.5, 1.2, 2.2);
scene.add(warmLight);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
const material = {
frame: new THREE.MeshStandardMaterial({
color: 0x7895a2,
roughness: 0.48,
metalness: 0.58
}),
base: new THREE.MeshStandardMaterial({
color: 0x587784,
roughness: 0.56,
metalness: 0.28
}),
heater: new THREE.MeshStandardMaterial({
color: 0xe96f50,
roughness: 0.48,
metalness: 0.08,
emissive: 0x5b1004,
emissiveIntensity: 0.22
}),
water: new THREE.MeshPhysicalMaterial({
color: 0x76d9ea,
roughness: 0.18,
metalness: 0,
transparent: true,
opacity: 0.8,
clearcoat: 0.8,
clearcoatRoughness: 0.2
}),
coldPlate: new THREE.MeshStandardMaterial({
color: 0x2a7ca5,
roughness: 0.3,
metalness: 0.64
}),
coldTop: new THREE.MeshStandardMaterial({
color: 0x83d8ee,
roughness: 0.24,
metalness: 0.36,
emissive: 0x0c6085,
emissiveIntensity: 0.35
}),
coldGlow: new THREE.MeshStandardMaterial({
color: 0xa9f1ff,
roughness: 0.22,
metalness: 0.12,
emissive: 0x25b9e8,
emissiveIntensity: 0.7
}),
acrylic: new THREE.MeshPhysicalMaterial({
color: 0xc2eff8,
roughness: 0.16,
metalness: 0,
transparent: true,
opacity: 0.055,
side: THREE.DoubleSide,
depthWrite: false
}),
oxygen: new THREE.MeshStandardMaterial({
color: 0xef725a,
roughness: 0.5
}),
hydrogen: new THREE.MeshStandardMaterial({
color: 0xfff3d9,
roughness: 0.55
}),
waterDrop: new THREE.MeshPhysicalMaterial({
color: 0x31b9df,
roughness: 0.18,
metalness: 0.05,
clearcoat: 0.9,
clearcoatRoughness: 0.16,
emissive: 0x073c55,
emissiveIntensity: 0.16
})
};
function smoothstep(edge0, edge1, value) {
const t = THREE.MathUtils.clamp(
(value - edge0) / (edge1 - edge0),
0,
1
);
return t * t * (3 - 2 * t);
}
function makeBox(width, height, depth, mat, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeCylinder(
radiusTop,
radiusBottom,
height,
mat,
x,
y,
z,
parent = scene,
segments = 24
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addEdges(mesh, color = 0x3f6979, opacity = 0.45) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry),
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
edges.scale.setScalar(1.002);
mesh.add(edges);
return edges;
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(
x + width,
y + height,
x + width - r,
y + height
);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabelSprite(text, accent = "#62d9f5", width = 3.2) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 112;
const ctx = canvas.getContext("2d");
roundedRect(ctx, 4, 4, 632, 104, 22);
ctx.fillStyle = "rgba(16, 47, 61, 0.90)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 3;
ctx.stroke();
ctx.fillStyle = "#f7feff";
ctx.font = "700 33px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 320, 57);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(width, width * 112 / 640, 1);
sprite.renderOrder = 20;
return sprite;
}
// -------------------------------------------------------------------------
// Ground and chamber
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(42, 42),
new THREE.MeshStandardMaterial({
color: 0xdbe7eb,
roughness: 0.88,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.13;
floor.receiveShadow = true;
scene.add(floor);
for (const radius of [5.2, 6.7, 8.6]) {
const ring = new THREE.Mesh(
new THREE.RingGeometry(radius, radius + 0.025, 120),
new THREE.MeshBasicMaterial({
color: 0x7da4b2,
transparent: true,
opacity: 0.15,
side: THREE.DoubleSide
})
);
ring.rotation.x = -Math.PI / 2;
ring.position.y = -0.115;
scene.add(ring);
}
const chamber = new THREE.Group();
chamber.position.x = 0.75;
scene.add(chamber);
const chamberWidth = 7.2;
const chamberDepth = 4.6;
const chamberBottom = 0.35;
const chamberTop = 8.15;
const chamberHeight = chamberTop - chamberBottom;
const chamberBase = makeBox(
chamberWidth + 0.42,
0.36,
chamberDepth + 0.42,
material.base,
0,
0.18,
0,
chamber
);
addEdges(chamberBase, 0x365c6c, 0.5);
for (const x of [-3.0, 3.0]) {
for (const z of [-1.8, 1.8]) {
makeCylinder(
0.16,
0.2,
0.3,
material.frame,
x,
-0.08,
z,
chamber
);
}
}
const acrylicFront = makeBox(
chamberWidth,
chamberHeight,
0.035,
material.acrylic,
0,
chamberBottom + chamberHeight / 2,
chamberDepth / 2,
chamber
);
acrylicFront.castShadow = false;
acrylicFront.renderOrder = 2;
const acrylicBack = makeBox(
chamberWidth,
chamberHeight,
0.035,
material.acrylic,
0,
chamberBottom + chamberHeight / 2,
-chamberDepth / 2,
chamber
);
acrylicBack.castShadow = false;
acrylicBack.renderOrder = 1;
for (const x of [-chamberWidth / 2, chamberWidth / 2]) {
const side = makeBox(
0.035,
chamberHeight,
chamberDepth,
material.acrylic,
x,
chamberBottom + chamberHeight / 2,
0,
chamber
);
side.castShadow = false;
side.renderOrder = 1;
}
const lid = makeBox(
chamberWidth,
0.04,
chamberDepth,
material.acrylic,
0,
chamberTop,
0,
chamber
);
lid.castShadow = false;
const chamberFrame = new THREE.LineSegments(
new THREE.EdgesGeometry(
new THREE.BoxGeometry(chamberWidth, chamberHeight, chamberDepth)
),
new THREE.LineBasicMaterial({
color: 0x426f80,
transparent: true,
opacity: 0.52
})
);
chamberFrame.position.y = chamberBottom + chamberHeight / 2;
chamber.add(chamberFrame);
// Warm water reservoir and heater
const heater = makeBox(
5.8,
0.48,
3.35,
material.heater,
0,
0.6,
0,
chamber
);
addEdges(heater, 0x8e3f31, 0.35);
const waterSurface = makeBox(
5.42,
0.08,
2.96,
material.water,
0,
0.88,
0,
chamber
);
addEdges(waterSurface, 0x4bbbd3, 0.25);
for (let i = 0; i < 8; i++) {
makeBox(
0.42,
0.09,
0.045,
material.coldGlow,
-2.15 + i * 0.61,
0.63,
1.7,
chamber
);
}
const warmLabel = makeLabelSprite(
"WARM RESERVOIR · 24°C",
"#ff9c72",
3.4
);
warmLabel.position.set(0, 1.28, 2.1);
chamber.add(warmLabel);
// Chilled overhead plate
const coldPlate = makeBox(
6.35,
0.38,
3.72,
material.coldPlate,
0,
7.06,
0,
chamber
);
addEdges(coldPlate, 0x164d6d, 0.6);
const coldTop = makeBox(
6.08,
0.08,
3.46,
material.coldTop,
0,
7.28,
0,
chamber
);
addEdges(coldTop, 0x3ca6c9, 0.32);
const coldUnderside = makeBox(
6.15,
0.08,
3.56,
material.coldGlow,
0,
6.83,
0,
chamber
);
for (let i = 0; i < 7; i++) {
makeBox(
0.075,
0.055,
3.18,
material.coldTop,
-2.25 + i * 0.75,
6.77,
0,
chamber
);
}
for (const x of [-2.83, 2.83]) {
for (const z of [-1.55, 1.55]) {
makeCylinder(
0.075,
0.075,
0.08,
material.frame,
x,
7.34,
z,
chamber,
16
);
}
}
// Rear suspension rods.
for (const x of [-2.7, 2.7]) {
makeCylinder(
0.045,
0.045,
0.85,
material.frame,
x,
7.7,
-1.45,
chamber,
12
);
}
const coldLabel = makeLabelSprite(
"CHILLED PLATE · 4°C",
"#6ce4ff",
3.35
);
coldLabel.position.set(0, 7.72, 1.6);
chamber.add(coldLabel);
// -------------------------------------------------------------------------
// Deterministic pseudo-random placement
// -------------------------------------------------------------------------
let randomSeed = 2187;
function random() {
randomSeed =
(randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
// -------------------------------------------------------------------------
// Rising air arrows
// -------------------------------------------------------------------------
const arrows = [];
for (let i = 0; i < 6; i++) {
const arrowMaterial = new THREE.MeshStandardMaterial({
color: 0xf47758,
roughness: 0.38,
metalness: 0.04,
emissive: 0x441006,
emissiveIntensity: 0.12
});
const arrow = new THREE.Group();
const stem = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.035, 0.64, 12),
arrowMaterial
);
stem.position.y = -0.15;
arrow.add(stem);
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.145, 0.3, 16),
arrowMaterial
);
head.position.y = 0.33;
arrow.add(head);
const x = -2.45 + i * 0.98;
const z = -1.15 + (i % 2) * 1.55;
arrow.position.set(x, 1.2, z);
chamber.add(arrow);
arrows.push({
group: arrow,
material: arrowMaterial,
offset: i * 0.83,
speed: 0.43 + (i % 3) * 0.035
});
}
// -------------------------------------------------------------------------
// Enlarged schematic H₂O molecules
// -------------------------------------------------------------------------
const molecules = [];
const oxygenGeometry = new THREE.SphereGeometry(0.092, 16, 12);
const hydrogenGeometry = new THREE.SphereGeometry(0.055, 14, 10);
for (let i = 0; i < 27; i++) {
const molecule = new THREE.Group();
const oxygen = new THREE.Mesh(oxygenGeometry, material.oxygen);
oxygen.castShadow = true;
molecule.add(oxygen);
const hydrogenA = new THREE.Mesh(
hydrogenGeometry,
material.hydrogen
);
hydrogenA.position.set(-0.13, -0.055, 0.015);
hydrogenA.castShadow = true;
molecule.add(hydrogenA);
const hydrogenB = new THREE.Mesh(
hydrogenGeometry,
material.hydrogen
);
hydrogenB.position.set(0.13, -0.055, 0.015);
hydrogenB.castShadow = true;
molecule.add(hydrogenB);
const baseX = -2.7 + random() * 5.4;
const baseZ = -1.5 + random() * 3.0;
molecule.position.set(baseX, 1, baseZ);
molecule.rotation.set(
random() * Math.PI,
random() * Math.PI,
random() * Math.PI
);
chamber.add(molecule);
molecules.push({
group: molecule,
baseX,
baseZ,
offset: random(),
speed: 0.75 + random() * 0.5,
phase: random() * Math.PI * 2
});
}
// -------------------------------------------------------------------------
// Stylized condensation micro-cloud
// -------------------------------------------------------------------------
const cloudPuffs = [];
const puffGeometry = new THREE.IcosahedronGeometry(1, 1);
const cloudMaterials = [
new THREE.MeshStandardMaterial({
color: 0xeafaff,
roughness: 0.85
}),
new THREE.MeshStandardMaterial({
color: 0xc7eff7,
roughness: 0.88
})
];
for (let i = 0; i < 20; i++) {
const puff = new THREE.Mesh(
puffGeometry,
cloudMaterials[i % cloudMaterials.length]
);
const scaleX = 0.28 + random() * 0.44;
const scaleY = 0.2 + random() * 0.28;
const scaleZ = 0.25 + random() * 0.36;
const baseScale = new THREE.Vector3(
scaleX,
scaleY,
scaleZ
);
puff.position.set(
-2.55 + random() * 5.1,
6.08 + random() * 0.48,
-0.9 + random() * 0.55
);
puff.scale.setScalar(0.001);
puff.castShadow = true;
chamber.add(puff);
cloudPuffs.push({
mesh: puff,
baseScale,
delay: random() * 3.1
});
}
// -------------------------------------------------------------------------
// Hanging droplets that grow on the underside of the cold plate
// -------------------------------------------------------------------------
const hangingDroplets = [];
const dropGeometry = new THREE.SphereGeometry(1, 20, 14);
for (let i = 0; i < 18; i++) {
const group = new THREE.Group();
const radius = 0.105 + random() * 0.065;
const drop = new THREE.Mesh(
dropGeometry,
material.waterDrop
);
drop.scale.set(radius, radius * 1.55, radius);
drop.position.y = -radius * 1.03;
drop.castShadow = true;
group.add(drop);
const neck = new THREE.Mesh(
dropGeometry,
material.waterDrop
);
neck.scale.set(radius * 0.46, radius * 0.65, radius * 0.46);
neck.position.y = -0.035;
group.add(neck);
const x = -2.75 + random() * 5.5;
const z = -0.05 + random() * 1.45;
group.position.set(x, 6.76, z);
group.scale.setScalar(0.001);
chamber.add(group);
hangingDroplets.push({
group,
radius,
delay: (i % 7) * 0.27 + random() * 0.16
});
}
// Detached droplets fall after the condensation stage.
const fallingDroplets = [];
for (let i = 0; i < 5; i++) {
const mat = new THREE.MeshPhysicalMaterial({
color: 0x31b9df,
roughness: 0.18,
metalness: 0.03,
clearcoat: 0.9,
transparent: true,
opacity: 0
});
const mesh = new THREE.Mesh(dropGeometry, mat);
const radius = 0.105 + random() * 0.05;
mesh.scale.set(radius, radius * 1.5, radius);
mesh.visible = false;
chamber.add(mesh);
fallingDroplets.push({
mesh,
material: mat,
radius,
x: -2.4 + random() * 4.8,
z: 0.15 + random() * 1.15,
start: 17.05 + i * 0.18,
phase: random() * Math.PI * 2
});
}
// -------------------------------------------------------------------------
// HUD and projected labels
// -------------------------------------------------------------------------
const stageLabel = document.getElementById("stage-label");
const pauseButton = document.getElementById("pause-button");
const restartButton = document.getElementById("restart-button");
const cameraButton = document.getElementById("camera-button");
const processCards = [
...document.querySelectorAll(".process-card")
];
const progressFills = processCards.map((card) =>
card.querySelector(".mini-progress span")
);
const callouts = [
{
element: document.getElementById("callout-evaporate"),
anchor: new THREE.Vector3(3.3, 1.25, 1.4),
offset: [55, 28]
},
{
element: document.getElementById("callout-rise"),
anchor: new THREE.Vector3(-1.8, 4.15, -0.9),
offset: [-60, -15]
},
{
element: document.getElementById("callout-cool"),
anchor: new THREE.Vector3(3.0, 7.35, 1.3),
offset: [62, -28]
},
{
element: document.getElementById("callout-condense"),
anchor: new THREE.Vector3(-1.9, 6.45, 0.5),
offset: [-58, 30]
}
];
let simulationTime = 14.2;
let paused = false;
function updateHUD(cycle) {
let stage;
let label;
if (cycle < 3) {
stage = 0;
label = "Evaporation";
} else if (cycle < 8) {
stage = 1;
label = "Rising vapor";
} else if (cycle < 12) {
stage = 2;
label = "Cooling at the plate";
} else if (cycle < 18) {
stage = 3;
label = "Condensation";
} else {
stage = 3;
label = "Droplets falling";
}
stageLabel.textContent = label;
processCards.forEach((card, index) => {
card.classList.toggle("active", index === stage);
card.classList.toggle("done", index < stage);
});
const amounts = [
THREE.MathUtils.clamp(cycle / 3, 0, 1),
THREE.MathUtils.clamp((cycle - 3) / 5, 0, 1),
THREE.MathUtils.clamp((cycle - 8) / 4, 0, 1),
THREE.MathUtils.clamp((cycle - 12) / 6, 0, 1)
];
progressFills.forEach((fill, index) => {
fill.style.width = `${amounts[index] * 100}%`;
});
}
function updateCallouts() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const callout of callouts) {
const projected = callout.anchor.clone().project(camera);
if (projected.z < -1 || projected.z > 1) {
callout.element.style.opacity = "0";
continue;
}
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
callout.element.style.left = `${x + callout.offset[0]}px`;
callout.element.style.top = `${y + callout.offset[1]}px`;
callout.element.style.opacity = "1";
}
}
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const warmColor = new THREE.Color(0xf47758);
const coolColor = new THREE.Color(0x3ed8f4);
const temporaryColor = new THREE.Color();
function updateSimulation() {
const cycle = simulationTime % 20;
const endFade = 1 - smoothstep(18.25, 19.85, cycle);
// Rising molecular clusters.
for (const molecule of molecules) {
const travel =
(simulationTime * 0.092 * molecule.speed + molecule.offset) % 1;
const y = 0.96 + travel * 5.93;
molecule.group.position.x =
molecule.baseX +
Math.sin(simulationTime * 0.55 + molecule.phase) * 0.2;
molecule.group.position.z =
molecule.baseZ +
Math.cos(simulationTime * 0.42 + molecule.phase) * 0.13;
molecule.group.position.y = y;
molecule.group.rotation.y += 0.003;
molecule.group.rotation.z =
Math.sin(simulationTime * 0.7 + molecule.phase) * 0.22;
}
// Rising air arrows.
for (const arrow of arrows) {
const travel =
(simulationTime * arrow.speed + arrow.offset) % 5.45;
const y = 1.15 + travel;
arrow.group.position.y = y;
const cooling = THREE.MathUtils.clamp(
(y - 1.2) / 5.3,
0,
1
);
temporaryColor.lerpColors(
warmColor,
coolColor,
cooling
);
arrow.material.color.copy(temporaryColor);
arrow.material.emissive.copy(temporaryColor);
arrow.material.emissiveIntensity = 0.07 + cooling * 0.08;
}
// Condensation micro-cloud.
for (const puff of cloudPuffs) {
const formation = smoothstep(
8.4 + puff.delay,
14.3 + puff.delay,
cycle
);
const amount = Math.max(0.001, formation * endFade);
puff.mesh.scale.copy(puff.baseScale).multiplyScalar(amount);
puff.mesh.visible = amount > 0.003;
}
// Droplets grow beneath the chilled plate.
let visibleDroplets = 0;
for (const droplet of hangingDroplets) {
const growth = smoothstep(
12 + droplet.delay,
16 + droplet.delay,
cycle
);
const amount = Math.max(0.001, growth * endFade);
droplet.group.scale.setScalar(amount);
droplet.group.visible = amount > 0.003;
if (amount > 0.1) {
visibleDroplets++;
}
}
// A few enlarged droplets detach and fall.
for (const droplet of fallingDroplets) {
const age = cycle - droplet.start;
if (age >= 0 && age < 1.85) {
droplet.mesh.visible = true;
droplet.mesh.position.x =
droplet.x + Math.sin(age * 4 + droplet.phase) * 0.08;
droplet.mesh.position.z =
droplet.z + Math.cos(age * 3 + droplet.phase) * 0.05;
droplet.mesh.position.y =
6.72 - (1.55 * age + 1.35 * age * age);
droplet.material.opacity = 1 - age / 1.85;
} else {
droplet.mesh.visible = false;
droplet.material.opacity = 0;
}
}
// Subtle water movement and cold plate glow.
waterSurface.position.y = 0.88 + Math.sin(simulationTime * 1.4) * 0.015;
const condensationAmount = smoothstep(8.5, 15, cycle);
material.coldGlow.emissiveIntensity =
0.55 +
condensationAmount * 0.75 +
Math.sin(simulationTime * 2.1) * 0.08;
coldLight.intensity = 20 + condensationAmount * 12;
updateHUD(cycle);
}
function applyCamera() {
const horizontalRadius =
cameraRadius * Math.cos(cameraElevation);
camera.position.set(
cameraTarget.x +
horizontalRadius * Math.sin(cameraYaw),
cameraTarget.y +
cameraRadius * Math.sin(cameraElevation),
cameraTarget.z +
horizontalRadius * Math.cos(cameraYaw)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraYaw = 0.64;
cameraElevation = 0.18;
cameraRadius =
window.innerWidth < 650 ? 18.5 : 15.6;
applyCamera();
}
// -------------------------------------------------------------------------
// Direct camera controls — no Three.js addons
// -------------------------------------------------------------------------
const pointer = {
active: false,
lastX: 0,
lastY: 0
};
renderer.domElement.addEventListener("pointerdown", (event) => {
pointer.active = true;
pointer.lastX = event.clientX;
pointer.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointer.active) return;
const dx = event.clientX - pointer.lastX;
const dy = event.clientY - pointer.lastY;
cameraYaw -= dx * 0.006;
cameraElevation = THREE.MathUtils.clamp(
cameraElevation + dy * 0.0045,
-0.08,
1.05
);
pointer.lastX = event.clientX;
pointer.lastY = event.clientY;
});
function releasePointer(event) {
pointer.active = false;
if (
renderer.domElement.hasPointerCapture &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius + event.deltaY * 0.012,
10.5,
24
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") cameraYaw += 0.08;
if (event.key === "ArrowRight") cameraYaw -= 0.08;
if (event.key === "ArrowUp") cameraElevation += 0.05;
if (event.key === "ArrowDown") cameraElevation -= 0.05;
if (event.key === "+" || event.key === "=") {
cameraRadius = Math.max(10.5, cameraRadius - 0.7);
}
if (event.key === "-") {
cameraRadius = Math.min(24, cameraRadius + 0.7);
}
});
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
});
restartButton.addEventListener("click", () => {
simulationTime = 0;
});
cameraButton.addEventListener("click", resetCamera);
window.addEventListener("resize", () => {
renderer.setPixelRatio(
Math.min(window.devicePixelRatio, 2)
);
renderer.setSize(
window.innerWidth,
window.innerHeight
);
camera.aspect =
window.innerWidth / window.innerHeight;
camera.fov =
window.innerWidth < 650 ? 48 : 38;
camera.updateProjectionMatrix();
});
// -------------------------------------------------------------------------
// Main loop
// -------------------------------------------------------------------------
let previousTime = performance.now();
function animate(now) {
requestAnimationFrame(animate);
const delta = Math.min(
(now - previousTime) / 1000,
0.05
);
previousTime = now;
if (!paused) {
simulationTime += delta;
}
updateSimulation();
applyCamera();
updateCallouts();
renderer.render(scene, camera);
}
resetCamera();
updateSimulation();
requestAnimationFrame(animate);
</script>
</body>
</html>
```