Prompt specification
Build or customize the Three.js 3D scene "Evaporation and condensation tabletop" 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: Evaporation and condensation tabletop
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/evaporation-and-condensation-tabletop-x1266
Scene Description Prompt:
Please use Three.js from cdnjs for a stylized scene based on this idea: evaporation and condensation tabletop. Show two shallow trays beneath transparent covers, one with a cooled upper plate; animate conceptual vapor markers and droplets while distinguishing invisible vapor from liquid water. Return one self-contained HTML file.
Working Three.js Starter (evaporation-and-condensation-tabletop-x1266):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Evaporation & Condensation Tabletop</title>
<style>
:root {
color-scheme: light;
--ink: #19313d;
--muted: #5f737d;
--amber: #ee9a3d;
--blue: #278fc3;
--panel: rgba(255, 255, 255, 0.76);
--line: rgba(42, 70, 82, 0.14);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7edef;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.title-block {
position: absolute;
top: 25px;
left: 28px;
max-width: min(460px, calc(100vw - 56px));
padding: 17px 19px 16px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 12px 35px rgba(39, 63, 72, 0.10);
backdrop-filter: blur(15px);
}
.eyebrow {
margin-bottom: 7px;
color: #7b8f97;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 2.7vw, 34px);
line-height: 1.08;
letter-spacing: -0.035em;
font-weight: 750;
}
.subtitle {
margin-top: 8px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.controls {
position: absolute;
top: 25px;
right: 25px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(35, 65, 77, 0.15);
border-radius: 12px;
padding: 10px 13px;
background: rgba(255, 255, 255, 0.82);
color: var(--ink);
font: 700 11px/1 Inter, ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.025em;
cursor: pointer;
box-shadow: 0 7px 20px rgba(38, 64, 75, 0.08);
backdrop-filter: blur(12px);
transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}
button:hover { transform: translateY(-1px); background: #fff; }
button:active { transform: translateY(0); }
button[aria-pressed="false"] { opacity: 0.55; }
.legend {
position: absolute;
left: 50%;
bottom: 25px;
transform: translateX(-50%);
display: flex;
align-items: stretch;
gap: 0;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 12px 35px rgba(39, 63, 72, 0.10);
backdrop-filter: blur(15px);
}
.legend-item {
display: flex;
align-items: center;
gap: 10px;
min-width: 235px;
padding: 12px 15px;
}
.legend-item + .legend-item { border-left: 1px solid var(--line); }
.legend-title {
display: block;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.02em;
}
.legend-note {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
line-height: 1.25;
}
.vapor-swatch {
width: 29px;
height: 29px;
flex: 0 0 auto;
border: 2px dashed var(--amber);
border-radius: 50%;
position: relative;
}
.vapor-swatch::after {
content: "";
position: absolute;
width: 4px;
height: 4px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
background: var(--amber);
}
.liquid-swatch {
width: 18px;
height: 23px;
flex: 0 0 auto;
border-radius: 55% 55% 58% 58% / 38% 38% 72% 72%;
background: linear-gradient(135deg, #66c7ec, #197ba9);
box-shadow: inset 4px 3px 7px rgba(255,255,255,.65),
0 3px 6px rgba(27, 112, 153, .20);
}
.hint {
position: absolute;
right: 27px;
bottom: 27px;
color: rgba(31, 56, 67, 0.60);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.035em;
text-align: right;
line-height: 1.55;
}
.loader {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #e7edef;
color: #617680;
font-size: 11px;
font-weight: 800;
letter-spacing: .14em;
text-transform: uppercase;
transition: opacity 500ms ease, visibility 500ms ease;
}
.loader.hidden {
opacity: 0;
visibility: hidden;
}
@media (max-width: 760px) {
.title-block {
top: 14px;
left: 14px;
right: 14px;
max-width: none;
padding: 13px 15px;
}
.subtitle { display: none; }
.controls { top: 111px; right: 14px; }
.legend { left: 14px; right: 14px; bottom: 14px; transform: none; }
.legend-item { min-width: 0; flex: 1 1 50%; padding: 10px; gap: 8px; }
.legend-note { font-size: 8px; }
.hint { display: none; }
}
@media (max-width: 470px) {
.legend-item { display: block; text-align: center; }
.vapor-swatch, .liquid-swatch { margin: 0 auto 7px; }
}
</style>
</head>
<body>
<div id="loader" class="loader">Preparing tabletop…</div>
<div class="hud">
<section class="title-block">
<div class="eyebrow">Phase-change study · interactive model</div>
<h1>Evaporation &<br>Condensation</h1>
<div class="subtitle">
Two covered water trays compare warm-side evaporation with condensation beneath a cooled upper plate.
</div>
</section>
<nav class="controls" aria-label="Scene controls">
<button id="pause" type="button">Pause</button>
<button id="vaporToggle" type="button" aria-pressed="true">Vapor markers</button>
<button id="reset" type="button">Reset view</button>
</nav>
<section class="legend" aria-label="Visualization legend">
<div class="legend-item">
<span class="vapor-swatch" aria-hidden="true"></span>
<span>
<span class="legend-title">Conceptual vapor marker</span>
<span class="legend-note">Real water vapor is invisible</span>
</span>
</div>
<div class="legend-item">
<span class="liquid-swatch" aria-hidden="true"></span>
<span>
<span class="legend-title">Liquid water</span>
<span class="legend-note">Visible droplets and surface</span>
</span>
</div>
</section>
<div class="hint">DRAG TO ORBIT · SCROLL TO ZOOM<br>DOUBLE-CLICK TO RESET</div>
</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
const loader = document.getElementById('loader');
const pauseButton = document.getElementById('pause');
const vaporButton = document.getElementById('vaporToggle');
const resetButton = document.getElementById('reset');
// ---------------------------------------------------------------------
// Renderer, scene, and camera
// ---------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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;
renderer.domElement.tabIndex = 0;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7edef);
scene.fog = new THREE.Fog(0xe7edef, 19, 42);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraTarget = new THREE.Vector3(0, 1.35, 0);
let azimuth = 0.46;
let polar = 1.17;
let radius = 14.6;
let targetAzimuth = azimuth;
let targetPolar = polar;
let targetRadius = radius;
let userMovedCamera = false;
function updateCamera(dt) {
const damping = 1 - Math.exp(-8 * dt);
azimuth += (targetAzimuth - azimuth) * damping;
polar += (targetPolar - polar) * damping;
radius += (targetRadius - radius) * damping;
const sinPolar = Math.sin(polar);
camera.position.set(
cameraTarget.x + radius * sinPolar * Math.sin(azimuth),
cameraTarget.y + radius * Math.cos(polar),
cameraTarget.z + radius * sinPolar * Math.cos(azimuth)
);
camera.lookAt(cameraTarget);
}
// Direct camera controls implemented without external add-ons.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener('pointerdown', event => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = 'grabbing';
});
renderer.domElement.addEventListener('pointermove', event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
targetAzimuth -= dx * 0.006;
targetPolar = THREE.MathUtils.clamp(targetPolar - dy * 0.005, 0.72, 1.43);
userMovedCamera = true;
});
function endDrag(event) {
dragging = false;
renderer.domElement.style.cursor = 'grab';
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener('pointerup', endDrag);
renderer.domElement.addEventListener('pointercancel', endDrag);
renderer.domElement.addEventListener('pointerleave', () => {
if (!dragging) renderer.domElement.style.cursor = 'grab';
});
renderer.domElement.addEventListener('wheel', event => {
event.preventDefault();
targetRadius = THREE.MathUtils.clamp(
targetRadius * Math.exp(event.deltaY * 0.001),
8.5,
23
);
userMovedCamera = true;
}, { passive: false });
renderer.domElement.style.cursor = 'grab';
function resetView() {
targetAzimuth = 0.46;
targetPolar = 1.17;
targetRadius = window.innerWidth / window.innerHeight < 0.85 ? 20 : 14.6;
userMovedCamera = false;
}
renderer.domElement.addEventListener('dblclick', resetView);
resetButton.addEventListener('click', resetView);
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xe9f7ff, 0x745847, 2.25);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2dc, 3.4);
keyLight.position.set(-5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 28;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0xaedfff, 1.35);
rimLight.position.set(7, 6, -6);
scene.add(rimLight);
// ---------------------------------------------------------------------
// Geometry and material helpers
// ---------------------------------------------------------------------
function roundedBoxGeometry(width, height, depth, radius) {
const r = Math.min(radius, width * 0.49, depth * 0.49);
const x = -width / 2;
const y = -depth / 2;
const shape = new THREE.Shape();
shape.moveTo(x + r, y);
shape.lineTo(x + width - r, y);
shape.quadraticCurveTo(x + width, y, x + width, y + r);
shape.lineTo(x + width, y + depth - r);
shape.quadraticCurveTo(x + width, y + depth, x + width - r, y + depth);
shape.lineTo(x + r, y + depth);
shape.quadraticCurveTo(x, y + depth, x, y + depth - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: height,
bevelEnabled: false,
curveSegments: 8,
steps: 1
});
geometry.rotateX(-Math.PI / 2);
geometry.translate(0, -height / 2, 0);
geometry.computeVertexNormals();
return geometry;
}
function addRounded(parent, size, position, material, shadows = true) {
const mesh = new THREE.Mesh(
roundedBoxGeometry(size[0], size[1], size[2], size[3]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = shadows;
mesh.receiveShadow = shadows;
parent.add(mesh);
return mesh;
}
function canvasRoundRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function canvasTexture(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(4, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function makePlaque(text, accent) {
const canvas = document.createElement('canvas');
canvas.width = 1024;
canvas.height = 192;
const ctx = canvas.getContext('2d');
canvasRoundRect(ctx, 5, 5, 1014, 182, 42);
ctx.fillStyle = 'rgba(25, 42, 51, 0.92)';
ctx.fill();
ctx.lineWidth = 5;
ctx.strokeStyle = accent;
ctx.stroke();
ctx.fillStyle = '#ffffff';
ctx.font = '700 58px Inter, Arial, sans-serif';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(text, 512, 99);
const texture = canvasTexture(canvas);
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(2.75, 0.52), material);
mesh.renderOrder = 9;
return mesh;
}
function makeFloatingLabel(text, accent, width = 2.25) {
const canvas = document.createElement('canvas');
canvas.width = 1024;
canvas.height = 180;
const ctx = canvas.getContext('2d');
canvasRoundRect(ctx, 12, 10, 1000, 160, 70);
ctx.fillStyle = 'rgba(255,255,255,0.78)';
ctx.fill();
ctx.lineWidth = 5;
ctx.strokeStyle = accent;
ctx.stroke();
ctx.fillStyle = accent;
ctx.font = '800 48px Inter, Arial, sans-serif';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(text, 512, 92);
const texture = canvasTexture(canvas);
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, width * 0.176, 1);
sprite.renderOrder = 12;
return sprite;
}
const materials = {
table: new THREE.MeshStandardMaterial({
color: 0xbcae99,
roughness: 0.72,
metalness: 0.03
}),
tableTop: new THREE.MeshStandardMaterial({
color: 0xe8dfd0,
roughness: 0.67,
metalness: 0.02
}),
leg: new THREE.MeshStandardMaterial({
color: 0x6d6258,
roughness: 0.62,
metalness: 0.12
}),
trayWarm: new THREE.MeshStandardMaterial({
color: 0x755343,
roughness: 0.38,
metalness: 0.52
}),
trayCold: new THREE.MeshStandardMaterial({
color: 0x607b88,
roughness: 0.31,
metalness: 0.62
}),
copper: new THREE.MeshStandardMaterial({
color: 0xd98345,
roughness: 0.27,
metalness: 0.78,
emissive: 0x6d2608,
emissiveIntensity: 0.12
}),
coldPlate: new THREE.MeshPhysicalMaterial({
color: 0xb9e5ee,
roughness: 0.26,
metalness: 0.46,
clearcoat: 0.72,
clearcoatRoughness: 0.2
}),
tube: new THREE.MeshStandardMaterial({
color: 0x8ed8ec,
roughness: 0.22,
metalness: 0.72,
emissive: 0x164e61,
emissiveIntensity: 0.18
}),
support: new THREE.MeshStandardMaterial({
color: 0xaab7bd,
roughness: 0.25,
metalness: 0.82
}),
glass: new THREE.MeshPhysicalMaterial({
color: 0xc8edf3,
transparent: true,
opacity: 0.13,
roughness: 0.06,
metalness: 0,
clearcoat: 1,
clearcoatRoughness: 0.05,
side: THREE.DoubleSide,
depthWrite: false
}),
waterWarm: new THREE.MeshPhysicalMaterial({
color: 0x66bdd7,
roughness: 0.17,
metalness: 0.04,
clearcoat: 1,
clearcoatRoughness: 0.08,
transparent: true,
opacity: 0.78,
transmission: 0.08,
thickness: 0.4,
side: THREE.DoubleSide,
depthWrite: false
}),
waterCold: new THREE.MeshPhysicalMaterial({
color: 0x50aeca,
roughness: 0.13,
metalness: 0.03,
clearcoat: 1,
clearcoatRoughness: 0.06,
transparent: true,
opacity: 0.8,
transmission: 0.1,
thickness: 0.4,
side: THREE.DoubleSide,
depthWrite: false
}),
droplet: new THREE.MeshPhysicalMaterial({
color: 0x298fc0,
roughness: 0.07,
metalness: 0,
transmission: 0.22,
thickness: 0.3,
clearcoat: 1,
transparent: true,
opacity: 0.9,
depthWrite: false
}),
amberLED: new THREE.MeshStandardMaterial({
color: 0xffb052,
emissive: 0xff7b21,
emissiveIntensity: 2.2,
roughness: 0.3
}),
blueLED: new THREE.MeshStandardMaterial({
color: 0x79ddff,
emissive: 0x159ed1,
emissiveIntensity: 2.2,
roughness: 0.3
})
};
// ---------------------------------------------------------------------
// Tabletop and studio floor
// ---------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
new THREE.MeshStandardMaterial({
color: 0xd9d8d3,
roughness: 0.94,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -2.12;
ground.receiveShadow = true;
scene.add(ground);
addRounded(scene, [14.5, 0.55, 8.3, 0.48], [0, 0, 0], materials.table);
addRounded(scene, [14.04, 0.075, 7.84, 0.40], [0, 0.305, 0], materials.tableTop);
for (const x of [-5.85, 5.85]) {
for (const z of [-3.05, 3.05]) {
addRounded(scene, [0.5, 1.95, 0.5, 0.11], [x, -1.17, z], materials.leg);
}
}
// ---------------------------------------------------------------------
// Two trays and transparent covers
// ---------------------------------------------------------------------
const WATER_Y = 0.665;
const COLD_TRAY_X = 3;
const PLATE_CENTER_Y = 3.32;
const PLATE_BOTTOM_Y = PLATE_CENTER_Y - 0.09;
function createWater(material) {
const geometry = new THREE.PlaneGeometry(4.16, 2.92, 30, 20);
geometry.rotateX(-Math.PI / 2);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.y = WATER_Y;
mesh.receiveShadow = true;
mesh.renderOrder = 1;
return mesh;
}
function createTray(x, cold) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
const trayMaterial = cold ? materials.trayCold : materials.trayWarm;
for (const footX of [-1.92, 1.92]) {
for (const footZ of [-1.35, 1.35]) {
const foot = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.16, 0.14, 20),
materials.support
);
foot.position.set(footX, 0.37, footZ);
foot.castShadow = true;
group.add(foot);
}
}
addRounded(
group,
[4.58, 0.09, 3.48, 0.24],
[0, 0.405, 0],
cold ? materials.support : materials.copper
);
addRounded(group, [4.78, 0.18, 3.72, 0.28], [0, 0.535, 0], trayMaterial);
const water = createWater(cold ? materials.waterCold : materials.waterWarm);
group.add(water);
addRounded(group, [4.62, 0.43, 0.14, 0.06], [0, 0.735, 1.78], trayMaterial);
addRounded(group, [4.62, 0.43, 0.14, 0.06], [0, 0.735, -1.78], trayMaterial);
addRounded(group, [0.14, 0.43, 3.46, 0.06], [2.29, 0.735, 0], trayMaterial);
addRounded(group, [0.14, 0.43, 3.46, 0.06], [-2.29, 0.735, 0], trayMaterial);
const plaque = makePlaque(
cold ? 'COLD TRAY • 4°C' : 'WARM TRAY • 35°C',
cold ? '#70d9ff' : '#ffb35e'
);
plaque.position.set(0, 0.745, 1.865);
group.add(plaque);
const led = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 18, 12),
cold ? materials.blueLED : materials.amberLED
);
led.position.set(2.39, 0.83, 1.65);
group.add(led);
const localLight = new THREE.PointLight(
cold ? 0x50c9ff : 0xff8b36,
cold ? 5 : 6,
3.8,
2
);
localLight.position.set(0, cold ? 2.65 : 0.95, 0.65);
group.add(localLight);
const coverGeometry = new THREE.BoxGeometry(4.82, 3.56, 3.82);
const cover = new THREE.Mesh(coverGeometry, materials.glass);
cover.position.y = 2.315;
cover.renderOrder = 6;
group.add(cover);
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x80a9b4,
transparent: true,
opacity: 0.42,
depthWrite: false
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(coverGeometry),
edgeMaterial
);
edges.position.copy(cover.position);
edges.renderOrder = 7;
group.add(edges);
// Subtle corner highlights make the transparent enclosures easier to read.
const highlightMaterial = new THREE.MeshBasicMaterial({
color: 0xe6fbff,
transparent: true,
opacity: 0.52,
depthWrite: false
});
for (const xCorner of [-2.34, 2.34]) {
for (const zCorner of [-1.84, 1.84]) {
addRounded(
group,
[0.025, 3.43, 0.025, 0.01],
[xCorner, 2.31, zCorner],
highlightMaterial,
false
);
}
}
if (!cold) {
// A visible copper heating element beneath the warm water.
const path = new THREE.CurvePath();
const coilPoints = [
[-1.72, -1.03], [1.72, -1.03], [1.72, -0.52],
[-1.72, -0.52], [-1.72, 0.02], [1.72, 0.02],
[1.72, 0.53], [-1.72, 0.53], [-1.72, 1.03]
];
for (let i = 0; i < coilPoints.length - 1; i++) {
path.add(new THREE.LineCurve3(
new THREE.Vector3(coilPoints[i][0], 0.59, coilPoints[i][1]),
new THREE.Vector3(coilPoints[i + 1][0], 0.59, coilPoints[i + 1][1])
));
}
const coil = new THREE.Mesh(
new THREE.TubeGeometry(path, 72, 0.026, 8, false),
materials.copper
);
group.add(coil);
const vaporLabel = makeFloatingLabel('CONCEPTUAL VAPOR', '#c87320', 1.85);
vaporLabel.position.set(-0.45, 2.50, 1.63);
group.add(vaporLabel);
}
if (cold) {
// Four supports hold the cooled upper plate inside the cover.
for (const supportX of [-1.84, 1.84]) {
for (const supportZ of [-1.13, 1.13]) {
const rod = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.035, 2.34, 12),
materials.support
);
rod.position.set(supportX, 2.04, supportZ);
rod.castShadow = true;
group.add(rod);
}
}
addRounded(
group,
[4.16, 0.18, 3.05, 0.22],
[0, PLATE_CENTER_Y, 0],
materials.coldPlate
);
// A serpentine coolant line on the upper surface.
const coolantPath = new THREE.CurvePath();
const coolantPoints = [
[-1.72, -1.03], [1.72, -1.03], [1.72, -0.51],
[-1.72, -0.51], [-1.72, 0.01], [1.72, 0.01],
[1.72, 0.53], [-1.72, 0.53], [-1.72, 1.03]
];
for (let i = 0; i < coolantPoints.length - 1; i++) {
coolantPath.add(new THREE.LineCurve3(
new THREE.Vector3(coolantPoints[i][0], 3.445, coolantPoints[i][1]),
new THREE.Vector3(coolantPoints[i + 1][0], 3.445, coolantPoints[i + 1][1])
));
}
const coolant = new THREE.Mesh(
new THREE.TubeGeometry(coolantPath, 72, 0.035, 8, false),
materials.tube
);
group.add(coolant);
const frostGeometry = new THREE.SphereGeometry(1, 10, 7);
for (let i = 0; i < 38; i++) {
const frost = new THREE.Mesh(
frostGeometry,
new THREE.MeshStandardMaterial({
color: 0xf2ffff,
roughness: 0.85,
transparent: true,
opacity: 0.42,
depthWrite: false
})
);
const radius = 0.015 + Math.random() * 0.025;
frost.position.set(
(Math.random() - 0.5) * 3.72,
3.422,
(Math.random() - 0.5) * 2.64
);
frost.scale.set(radius, radius * 0.18, radius);
group.add(frost);
}
const plateLabel = makeFloatingLabel('COOLED PLATE • 4°C', '#2187ad', 2.4);
plateLabel.position.set(0, 3.68, 1.38);
group.add(plateLabel);
const condensationLabel = makeFloatingLabel('CONDENSATION', '#278fc3', 1.85);
condensationLabel.position.set(-0.55, 2.62, 1.61);
group.add(condensationLabel);
}
return { group, water };
}
const warmTray = createTray(-3, false);
const coldTray = createTray(COLD_TRAY_X, true);
// ---------------------------------------------------------------------
// Conceptual vapor markers
//
// These dashed rings are deliberately symbolic: real water vapor is
// invisible. They are not intended to resemble literal steam.
// ---------------------------------------------------------------------
function createVaporTexture() {
const canvas = document.createElement('canvas');
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, 128, 128);
ctx.strokeStyle = '#f09a3f';
ctx.lineWidth = 5;
ctx.setLineDash([10, 8]);
ctx.beginPath();
ctx.arc(64, 64, 43, 0, Math.PI * 2);
ctx.stroke();
ctx.setLineDash([]);
ctx.fillStyle = 'rgba(240,154,63,.88)';
ctx.beginPath();
ctx.arc(64, 64, 4.5, 0, Math.PI * 2);
ctx.fill();
return canvasTexture(canvas);
}
const vaporTexture = createVaporTexture();
const vaporRoot = new THREE.Group();
scene.add(vaporRoot);
const vaporParticles = [];
function createVaporField(x, count, maximumY, cold = false) {
const group = new THREE.Group();
group.position.x = x;
vaporRoot.add(group);
for (let i = 0; i < count; i++) {
const material = new THREE.SpriteMaterial({
map: vaporTexture,
color: 0xffffff,
transparent: true,
opacity: 0,
depthWrite: false,
toneMapped: false
});
const marker = new THREE.Sprite(material);
marker.renderOrder = 2;
group.add(marker);
vaporParticles.push({
marker,
group,
baseX: (Math.random() - 0.5) * 3.35,
baseZ: (Math.random() - 0.5) * 2.45,
phase: Math.random(),
speed: 0.095 + Math.random() * 0.055,
seed: Math.random() * 10,
maximumY,
cold
});
}
}
createVaporField(-3, 13, 3.78, false);
createVaporField(COLD_TRAY_X, 10, 3.13, true);
function updateVapor(time) {
for (const p of vaporParticles) {
const t = (time * p.speed + p.phase) % 1;
const eased = t * t * (3 - 2 * t);
const spread = 0.055 + t * 0.19;
p.marker.position.set(
p.baseX + Math.sin(t * 7.5 + p.seed) * spread,
0.74 + (p.maximumY - 0.74) * eased,
p.baseZ + Math.cos(t * 6.2 + p.seed * 0.7) * spread
);
const size = 0.18 + t * 0.33;
p.marker.scale.set(size, size, 1);
p.marker.material.rotation = time * 0.19 + p.seed;
p.marker.material.opacity =
Math.sin(Math.PI * t) * (p.cold ? 0.68 : 0.78);
}
}
// ---------------------------------------------------------------------
// Condensed liquid droplets
// ---------------------------------------------------------------------
const dropletGeometry = new THREE.SphereGeometry(1, 18, 14);
const rippleGeometry = new THREE.TorusGeometry(0.12, 0.012, 8, 32);
const attachedDroplets = [];
const fallingDroplets = [];
const ripples = [];
for (let i = 0; i < 27; i++) {
const mesh = new THREE.Mesh(dropletGeometry, materials.droplet);
mesh.castShadow = true;
mesh.renderOrder = 4;
const x = (Math.random() - 0.5) * 3.72;
// More beads are placed near the front edge so they remain readable.
const z = i < 15
? 0.95 + Math.random() * 0.47
: (Math.random() - 0.5) * 2.65;
mesh.position.set(x, PLATE_BOTTOM_Y, z);
coldTray.group.add(mesh);
const duration = 4.5 + Math.random() * 5.5;
attachedDroplets.push({
mesh,
x,
z,
duration,
age: Math.random() * duration * 0.82,
released: false
});
}
function createRipple(x, z) {
const material = new THREE.MeshBasicMaterial({
color: 0x4daed0,
transparent: true,
opacity: 0.62,
depthWrite: false,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(rippleGeometry, material);
mesh.rotation.x = Math.PI / 2;
mesh.position.set(x, WATER_Y + 0.018, z);
mesh.renderOrder = 4;
scene.add(mesh);
ripples.push({ mesh, age: 0 });
}
function spawnFallingDroplet(x, z, radius) {
const mesh = new THREE.Mesh(dropletGeometry, materials.droplet);
mesh.position.set(x, PLATE_BOTTOM_Y - radius * 1.5, z);
mesh.scale.set(radius, radius * 1.55, radius);
mesh.renderOrder = 4;
scene.add(mesh);
fallingDroplets.push({
mesh,
radius,
velocityX: (Math.random() - 0.5) * 0.07,
velocityY: -0.08 - Math.random() * 0.1,
velocityZ: (Math.random() - 0.5) * 0.05
});
}
function updateDroplets(dt) {
for (const bead of attachedDroplets) {
if (!bead.released) {
bead.age += dt;
const growth = THREE.MathUtils.clamp(bead.age / bead.duration, 0, 1);
const radius = 0.027 + growth * 0.087;
bead.mesh.scale.set(radius, radius * 1.48, radius);
bead.mesh.position.y = PLATE_BOTTOM_Y - radius * 1.48;
if (growth >= 1) {
bead.released = true;
bead.age = 0;
bead.mesh.visible = false;
spawnFallingDroplet(
COLD_TRAY_X + bead.x,
bead.z,
radius
);
}
} else {
bead.age += dt;
if (bead.age > 0.62) {
bead.released = false;
bead.age = 0;
bead.duration = 4.5 + Math.random() * 5.5;
bead.mesh.visible = true;
}
}
}
for (let i = fallingDroplets.length - 1; i >= 0; i--) {
const drop = fallingDroplets[i];
drop.velocityY -= 4.2 * dt;
drop.mesh.position.x += drop.velocityX * dt;
drop.mesh.position.y += drop.velocityY * dt;
drop.mesh.position.z += drop.velocityZ * dt;
const stretch = 1.35 + Math.min(Math.abs(drop.velocityY) * 0.22, 0.72);
drop.mesh.scale.set(
drop.radius,
drop.radius * stretch,
drop.radius
);
if (drop.mesh.position.y <= WATER_Y + 0.025) {
createRipple(drop.mesh.position.x, drop.mesh.position.z);
scene.remove(drop.mesh);
fallingDroplets.splice(i, 1);
}
}
for (let i = ripples.length - 1; i >= 0; i--) {
const ripple = ripples[i];
ripple.age += dt;
const life = ripple.age / 0.82;
ripple.mesh.scale.setScalar(1 + life * 5.5);
ripple.mesh.material.opacity = Math.max(0, (1 - life) * 0.62);
if (life >= 1) {
scene.remove(ripple.mesh);
ripple.mesh.material.dispose();
ripples.splice(i, 1);
}
}
}
// ---------------------------------------------------------------------
// Water animation
// ---------------------------------------------------------------------
function animateWater(mesh, time, phase) {
const positions = mesh.geometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const x = positions.getX(i);
const z = positions.getZ(i);
const wave =
Math.sin(x * 1.45 + time * 1.35 + phase) * 0.011 +
Math.sin(z * 2.05 - time * 0.92 + phase * 0.7) * 0.007;
positions.setY(i, wave);
}
positions.needsUpdate = true;
mesh.geometry.computeVertexNormals();
}
// ---------------------------------------------------------------------
// UI state and animation loop
// ---------------------------------------------------------------------
let paused = false;
let simulationTime = 0;
const clock = new THREE.Clock();
pauseButton.addEventListener('click', () => {
paused = !paused;
pauseButton.textContent = paused ? 'Resume' : 'Pause';
pauseButton.setAttribute('aria-pressed', String(!paused));
});
vaporButton.addEventListener('click', () => {
vaporRoot.visible = !vaporRoot.visible;
vaporButton.setAttribute('aria-pressed', String(vaporRoot.visible));
});
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused) {
simulationTime += dt;
updateVapor(simulationTime);
updateDroplets(dt);
animateWater(warmTray.water, simulationTime, 0);
animateWater(coldTray.water, simulationTime, 1.7);
}
updateCamera(dt);
renderer.render(scene, camera);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
if (!userMovedCamera) {
targetRadius = width / height < 0.85 ? 20 : 14.6;
}
}
window.addEventListener('resize', resize);
resize();
updateCamera(1);
renderer.render(scene, camera);
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => loader.classList.add('hidden'));
</script>
</body>
</html>
```