Prompt specification
Build or customize the Three.js 3D scene "Radiation through empty space comparison" 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: Radiation through empty space comparison
Category: Science & Physics · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/radiation-through-empty-space-comparison-x1510
Scene Description Prompt:
Make a stylized Three.js scene in a self-contained HTML file using cdnjs: radiation through empty space comparison. Place two warm objects separated by a transparent vacuum-labeled region; distinguish radiative transfer from conduction or convection requiring material contact or fluid.
Working Three.js Starter (radiation-through-empty-space-comparison-x1510):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Radiation Through Vacuum</title>
<style>
:root {
color-scheme: dark;
--bg: #050a12;
--panel: rgba(8, 17, 29, 0.78);
--border: rgba(159, 211, 255, 0.16);
--text: #edf7ff;
--muted: #91a6ba;
--cyan: #68e7ff;
--amber: #ffc45c;
--orange: #ff7549;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 35%, #11263b 0%, #07111e 45%, #03070d 100%);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--border);
border-radius: 18px;
background: var(--panel);
box-shadow:
0 18px 60px rgba(0, 0, 0, 0.3),
inset 0 1px rgba(255, 255, 255, 0.04);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
#intro {
top: 22px;
left: 22px;
width: min(380px, calc(100vw - 44px));
padding: 20px 22px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 20px;
height: 1px;
content: "";
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
h1 {
max-width: 330px;
margin: 0;
font-size: clamp(28px, 3.1vw, 44px);
font-weight: 720;
line-height: 1.02;
letter-spacing: -0.045em;
}
#intro p {
margin: 13px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.toolbar {
display: flex;
gap: 8px;
margin-top: 16px;
}
button {
border: 0;
color: var(--text);
font: inherit;
cursor: pointer;
}
.tool-button {
padding: 9px 12px;
border: 1px solid rgba(159, 211, 255, 0.16);
border-radius: 10px;
background: rgba(255, 255, 255, 0.045);
font-size: 11px;
font-weight: 700;
transition: background 160ms ease, border-color 160ms ease;
}
.tool-button:hover {
border-color: rgba(159, 211, 255, 0.35);
background: rgba(255, 255, 255, 0.09);
}
#legend {
top: 22px;
right: 22px;
width: 304px;
padding: 13px;
}
.legend-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 3px 10px;
}
.legend-heading strong {
font-size: 11px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.all-button {
padding: 5px 9px;
border-radius: 8px;
background: rgba(104, 231, 255, 0.1);
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.all-button.active {
background: var(--cyan);
color: #041019;
}
.mode {
display: grid;
grid-template-columns: 36px 1fr auto;
align-items: center;
width: 100%;
margin-top: 7px;
padding: 11px;
border: 1px solid transparent;
border-radius: 12px;
background: rgba(255, 255, 255, 0.035);
text-align: left;
transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.mode:hover {
transform: translateX(-2px);
background: rgba(255, 255, 255, 0.07);
}
.mode.active {
border-color: rgba(159, 211, 255, 0.24);
background: rgba(159, 211, 255, 0.09);
}
.mode-icon {
display: grid;
width: 27px;
height: 27px;
place-items: center;
border-radius: 50%;
font-size: 14px;
font-weight: 900;
}
.mode.radiation .mode-icon {
background: rgba(255, 196, 92, 0.13);
color: var(--amber);
}
.mode.conduction .mode-icon {
background: rgba(255, 117, 73, 0.13);
color: var(--orange);
}
.mode.convection .mode-icon {
background: rgba(104, 231, 255, 0.13);
color: var(--cyan);
}
.mode-copy strong,
.mode-copy small {
display: block;
}
.mode-copy strong {
font-size: 12px;
}
.mode-copy small {
margin-top: 3px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.status {
color: #6f879d;
font-size: 15px;
}
#focusText {
min-height: 31px;
margin: 11px 4px 1px;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
#hint {
position: fixed;
z-index: 8;
bottom: 18px;
left: 50%;
padding: 8px 13px;
border: 1px solid rgba(159, 211, 255, 0.12);
border-radius: 999px;
background: rgba(5, 12, 21, 0.68);
color: #8ea5b8;
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
transform: translateX(-50%);
white-space: nowrap;
}
@media (max-width: 760px) {
#intro {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 17px;
}
h1 {
max-width: 270px;
font-size: 27px;
}
#intro p {
display: none;
}
.toolbar {
margin-top: 12px;
}
#legend {
top: auto;
right: 12px;
bottom: 48px;
left: 12px;
width: auto;
padding: 9px;
}
.legend-heading,
#focusText {
display: none;
}
#legend .modes {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
}
.mode {
grid-template-columns: 1fr;
justify-items: center;
gap: 5px;
margin: 0;
padding: 8px 5px;
text-align: center;
}
.mode-copy small,
.status {
display: none;
}
.mode-copy strong {
font-size: 9px;
}
.all-button {
padding: 8px 4px;
}
#hint {
bottom: 10px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive Three.js comparison of thermal energy transfer"></div>
<section id="intro" class="panel">
<div class="eyebrow">Thermal transfer comparison</div>
<h1>Heat does not need matter.</h1>
<p>
Radiation crosses the empty chamber as electromagnetic waves.
Conduction and convection need a solid or fluid carrier along the same path.
</p>
<div class="toolbar">
<button id="pauseButton" class="tool-button" type="button">Pause motion</button>
<button id="resetButton" class="tool-button" type="button">Reset view</button>
</div>
</section>
<aside id="legend" class="panel" aria-label="Transfer mechanism comparison">
<div class="legend-heading">
<strong>Compare mechanisms</strong>
<button class="all-button active" data-mode="all" type="button">All</button>
</div>
<div class="modes">
<button class="mode radiation active" data-mode="radiation" type="button">
<span class="mode-icon">≈</span>
<span class="mode-copy">
<strong>Radiation</strong>
<small>Electromagnetic waves cross empty space</small>
</span>
<span class="status">✓</span>
</button>
<button class="mode conduction" data-mode="conduction" type="button">
<span class="mode-icon">▰</span>
<span class="mode-copy">
<strong>Conduction</strong>
<small>Needs continuous solid contact</small>
</span>
<span class="status">×</span>
</button>
<button class="mode convection" data-mode="convection" type="button">
<span class="mode-icon">◌</span>
<span class="mode-copy">
<strong>Convection</strong>
<small>Needs moving liquid or gas</small>
</span>
<span class="status">×</span>
</button>
</div>
<p id="focusText"></p>
</aside>
<div id="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";
const stage = document.querySelector("#stage");
const pauseButton = document.querySelector("#pauseButton");
const resetButton = document.querySelector("#resetButton");
const focusText = document.querySelector("#focusText");
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x07111e, 13, 27);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.setClearColor(0x050a12, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0x9bd8ff, 0x10131b, 1.7));
const keyLight = new THREE.DirectionalLight(0xd8efff, 2.6);
keyLight.position.set(4, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x397dff, 1.3);
rimLight.position.set(-7, 3, -8);
scene.add(rimLight);
// ------------------------------------------------------------
// Floor, grid, and pedestals
// ------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: 0x07111d,
roughness: 0.82,
metalness: 0.12
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -1.58;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(30, 30, 0x2d8dae, 0x17334a);
grid.position.y = -1.565;
grid.material.transparent = true;
grid.material.opacity = 0.18;
scene.add(grid);
function addPedestal(x, radius, glowColor) {
const base = new THREE.Mesh(
new THREE.CylinderGeometry(radius * 1.18, radius * 1.32, 0.18, 64),
new THREE.MeshStandardMaterial({
color: 0x15202d,
roughness: 0.46,
metalness: 0.72
})
);
base.position.set(x, -1.43, 0);
base.castShadow = true;
base.receiveShadow = true;
scene.add(base);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(radius * 1.02, 0.025, 8, 96),
new THREE.MeshBasicMaterial({
color: glowColor,
transparent: true,
opacity: 0.8
})
);
rim.rotation.x = Math.PI / 2;
rim.position.set(x, -1.325, 0);
scene.add(rim);
}
addPedestal(-4.2, 1.22, 0xff6c35);
addPedestal(4.2, 1.08, 0xffb34f);
// ------------------------------------------------------------
// Warm source and receiver
// ------------------------------------------------------------
function makeWarmObject(x, radius, color, emissive, lightIntensity) {
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.34,
metalness: 0.06,
emissive,
emissiveIntensity: 0.48
});
const body = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, 5),
material
);
body.position.set(x, 0, 0);
body.castShadow = true;
body.receiveShadow = true;
scene.add(body);
const haloMaterial = new THREE.MeshBasicMaterial({
color: emissive,
transparent: true,
opacity: 0.07,
side: THREE.BackSide,
depthWrite: false,
blending: THREE.AdditiveBlending
});
const halo = new THREE.Mesh(
new THREE.SphereGeometry(radius * 1.13, 48, 32),
haloMaterial
);
halo.position.copy(body.position);
scene.add(halo);
const outerHalo = new THREE.Mesh(
new THREE.SphereGeometry(radius * 1.28, 40, 24),
new THREE.MeshBasicMaterial({
color: emissive,
transparent: true,
opacity: 0.025,
side: THREE.BackSide,
depthWrite: false,
blending: THREE.AdditiveBlending
})
);
outerHalo.position.copy(body.position);
scene.add(outerHalo);
const light = new THREE.PointLight(emissive, lightIntensity, 9, 2);
light.position.set(x, 0.25, 0.6);
scene.add(light);
const orbit = new THREE.Mesh(
new THREE.TorusGeometry(radius * 1.07, 0.026, 8, 100),
new THREE.MeshBasicMaterial({
color: emissive,
transparent: true,
opacity: 0.62
})
);
orbit.rotation.x = Math.PI / 2;
orbit.position.set(x, -0.12, 0);
scene.add(orbit);
return { body, material, halo, outerHalo, orbit };
}
const source = makeWarmObject(
-4.2,
1.22,
0xe85b2d,
0xff3d0c,
75
);
const receiver = makeWarmObject(
4.2,
1.08,
0xf49a42,
0xff8d21,
43
);
// ------------------------------------------------------------
// Canvas-generated labels, with no external font or addon
// ------------------------------------------------------------
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.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 makeLabel(
title,
subtitle,
accent = "#68e7ff",
worldWidth = 3.2,
options = {}
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
roundedRect(ctx, 8, 8, 1008, 240, 38);
ctx.fillStyle = options.background || "rgba(5, 13, 23, 0.90)";
ctx.fill();
ctx.lineWidth = 4;
ctx.strokeStyle = options.border || "rgba(151, 207, 240, 0.26)";
ctx.stroke();
ctx.fillStyle = accent;
roundedRect(ctx, 42, 38, 12, 180, 6);
ctx.fill();
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#f3fbff";
ctx.font = "700 58px system-ui, sans-serif";
ctx.fillText(title, 525, 103);
ctx.fillStyle = options.subtitleColor || "#9db1c3";
ctx.font = "500 29px system-ui, sans-serif";
ctx.fillText(subtitle, 525, 171);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(worldWidth, worldWidth / 4, 1);
sprite.renderOrder = 30;
return sprite;
}
const sourceLabel = makeLabel(
"HOT SOURCE",
"thermal energy emitter",
"#ff7549",
3.15
);
sourceLabel.position.set(-4.2, 1.68, 0);
scene.add(sourceLabel);
const receiverLabel = makeLabel(
"WARM RECEIVER",
"absorbs incoming radiation",
"#ffc45c",
3.15
);
receiverLabel.position.set(4.2, 1.58, 0);
scene.add(receiverLabel);
// ------------------------------------------------------------
// Transparent vacuum chamber
// ------------------------------------------------------------
const vacuumGroup = new THREE.Group();
scene.add(vacuumGroup);
const chamberGeometry = new THREE.BoxGeometry(5.4, 3.2, 2.6);
const chamber = new THREE.Mesh(
chamberGeometry,
new THREE.MeshBasicMaterial({
color: 0x55d9ff,
transparent: true,
opacity: 0.045,
side: THREE.DoubleSide,
depthWrite: false
})
);
chamber.position.y = 0.23;
vacuumGroup.add(chamber);
const chamberEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(chamberGeometry),
new THREE.LineBasicMaterial({
color: 0x68e7ff,
transparent: true,
opacity: 0.5
})
);
chamberEdges.position.copy(chamber.position);
vacuumGroup.add(chamberEdges);
const vacuumLabel = makeLabel(
"VACUUM",
"empty space • no matter • no contact",
"#68e7ff",
4.75
);
vacuumLabel.position.set(0, 2.25, 0);
vacuumGroup.add(vacuumLabel);
// ------------------------------------------------------------
// Radiation: transverse electromagnetic waves + moving photons
// ------------------------------------------------------------
const radiationGroup = new THREE.Group();
scene.add(radiationGroup);
class RadiationCurve extends THREE.Curve {
constructor(z, phase, amplitude) {
super();
this.z = z;
this.phase = phase;
this.amplitude = amplitude;
}
getPoint(t, target = new THREE.Vector3()) {
const x = THREE.MathUtils.lerp(-2.98, 2.98, t);
const y =
0.43 +
Math.sin(t * Math.PI * 6 + this.phase) * this.amplitude;
return target.set(x, y, this.z);
}
}
const radiationCurves = [];
const radiationMaterials = [];
const photonMeshes = [];
const waveSettings = [
{ z: -0.52, phase: -0.9, amplitude: 0.12 },
{ z: 0, phase: 0, amplitude: 0.15 },
{ z: 0.52, phase: 0.9, amplitude: 0.12 }
];
for (let i = 0; i < waveSettings.length; i++) {
const setting = waveSettings[i];
const curve = new RadiationCurve(
setting.z,
setting.phase,
setting.amplitude
);
radiationCurves.push(curve);
const material = new THREE.MeshBasicMaterial({
color: i === 1 ? 0xffd475 : 0xffb94e,
transparent: true,
opacity: i === 1 ? 0.76 : 0.47,
blending: THREE.AdditiveBlending,
depthWrite: false
});
radiationMaterials.push(material);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 100, i === 1 ? 0.022 : 0.015, 6, false),
material
);
radiationGroup.add(tube);
}
const photonGeometry = new THREE.SphereGeometry(0.075, 12, 8);
const photonMaterial = new THREE.MeshBasicMaterial({
color: 0xfff0ae,
blending: THREE.AdditiveBlending,
depthWrite: false
});
for (let i = 0; i < 18; i++) {
const photon = new THREE.Mesh(photonGeometry, photonMaterial);
photon.userData.curveIndex = i % radiationCurves.length;
photon.userData.offset = (i * 0.173) % 1;
photon.userData.baseScale = 0.75 + (i % 4) * 0.12;
photon.scale.setScalar(photon.userData.baseScale);
radiationGroup.add(photon);
photonMeshes.push(photon);
}
const radiationArrows = [];
for (const setting of waveSettings) {
const arrowMaterial = new THREE.MeshBasicMaterial({
color: 0xffd77b,
transparent: true,
opacity: 0.8
});
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.115, 0.28, 14),
arrowMaterial
);
arrow.position.set(2.91, 0.43, setting.z);
arrow.rotation.z = -Math.PI / 2;
radiationGroup.add(arrow);
radiationArrows.push(arrow);
}
const radiationLabel = makeLabel(
"RADIATION",
"energy crosses the empty gap",
"#ffc45c",
3.8
);
radiationLabel.position.set(0, 1.03, 0.02);
radiationGroup.add(radiationLabel);
// ------------------------------------------------------------
// Conduction diagram: a broken solid chain, not touching across
// ------------------------------------------------------------
const conductionGroup = new THREE.Group();
scene.add(conductionGroup);
const metalMaterial = new THREE.MeshStandardMaterial({
color: 0x9babb6,
roughness: 0.32,
metalness: 0.82,
emissive: 0x401207,
emissiveIntensity: 0.22
});
const blockGeometry = new THREE.BoxGeometry(0.47, 0.17, 0.48);
for (let i = 0; i < 6; i++) {
const block = new THREE.Mesh(blockGeometry, metalMaterial);
block.position.set(-2.98 + i * 0.5, -0.73, 1.52);
block.castShadow = true;
conductionGroup.add(block);
}
const stopMaterial = new THREE.MeshStandardMaterial({
color: 0xff6845,
emissive: 0xff2d0d,
emissiveIntensity: 0.65,
roughness: 0.4
});
const stopBarGeometry = new THREE.BoxGeometry(0.58, 0.09, 0.12);
for (const angle of [-Math.PI / 4, Math.PI / 4]) {
const bar = new THREE.Mesh(stopBarGeometry, stopMaterial);
bar.position.set(-0.48, -0.73, 1.58);
bar.rotation.z = angle;
conductionGroup.add(bar);
}
const conductionDots = [];
const conductionDotGeometry = new THREE.SphereGeometry(0.055, 10, 8);
const conductionDotMaterial = new THREE.MeshBasicMaterial({
color: 0xff8a48
});
for (let i = 0; i < 6; i++) {
const dot = new THREE.Mesh(conductionDotGeometry, conductionDotMaterial);
dot.userData.offset = i / 6;
conductionGroup.add(dot);
conductionDots.push(dot);
}
const conductionLabel = makeLabel(
"CONDUCTION",
"needs solid contact • path is broken",
"#ff7549",
3.65
);
conductionLabel.position.set(-1.78, -1.2, 1.72);
conductionGroup.add(conductionLabel);
// ------------------------------------------------------------
// Convection diagram: a fluid current that cannot cross vacuum
// ------------------------------------------------------------
const convectionGroup = new THREE.Group();
scene.add(convectionGroup);
const convectionCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(2.98, -0.73, 1.73),
new THREE.Vector3(2.57, -0.91, 1.75),
new THREE.Vector3(2.05, -0.93, 1.77),
new THREE.Vector3(1.53, -0.79, 1.78),
new THREE.Vector3(1.02, -0.63, 1.77),
new THREE.Vector3(0.5, -0.72, 1.75)
]);
const convectionMaterial = new THREE.MeshBasicMaterial({
color: 0x68e7ff,
transparent: true,
opacity: 0.78,
blending: THREE.AdditiveBlending,
depthWrite: false
});
const convectionTube = new THREE.Mesh(
new THREE.TubeGeometry(convectionCurve, 80, 0.045, 8, false),
convectionMaterial
);
convectionGroup.add(convectionTube);
const fluidBeads = [];
const fluidGeometry = new THREE.SphereGeometry(0.09, 14, 10);
const fluidMaterial = new THREE.MeshBasicMaterial({
color: 0x8defff,
transparent: true,
opacity: 0.85
});
for (let i = 0; i < 7; i++) {
const bead = new THREE.Mesh(fluidGeometry, fluidMaterial);
bead.userData.offset = i / 7;
convectionGroup.add(bead);
fluidBeads.push(bead);
}
const fluidArrow = new THREE.Mesh(
new THREE.ConeGeometry(0.13, 0.3, 14),
new THREE.MeshBasicMaterial({
color: 0x8defff,
transparent: true,
opacity: 0.9
})
);
fluidArrow.position.copy(convectionCurve.getPointAt(0.18));
const fluidTangent = convectionCurve.getTangentAt(0.18);
fluidArrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
fluidTangent
);
convectionGroup.add(fluidArrow);
const convectionLabel = makeLabel(
"CONVECTION",
"needs moving fluid • path is broken",
"#68e7ff",
3.65
);
convectionLabel.position.set(1.78, -1.2, 1.72);
convectionGroup.add(convectionLabel);
// ------------------------------------------------------------
// Direct camera controls: orbit, zoom, damping, and reset
// ------------------------------------------------------------
const orbit = {
theta: 0,
phi: 1.08,
radius: innerWidth < 760 ? 15.4 : 12.7,
targetTheta: 0,
targetPhi: 1.08,
targetRadius: innerWidth < 760 ? 15.4 : 12.7,
target: new THREE.Vector3(0, 0.08, 0),
dragging: false,
pointerX: 0,
pointerY: 0
};
function resetCamera() {
orbit.targetTheta = 0;
orbit.targetPhi = 1.08;
orbit.targetRadius = innerWidth < 760 ? 15.4 : 12.7;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
orbit.dragging = true;
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!orbit.dragging) return;
const dx = event.clientX - orbit.pointerX;
const dy = event.clientY - orbit.pointerY;
orbit.targetTheta -= dx * 0.006;
orbit.targetPhi = THREE.MathUtils.clamp(
orbit.targetPhi - dy * 0.005,
0.62,
1.47
);
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
});
function endDrag(event) {
orbit.dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.targetRadius = THREE.MathUtils.clamp(
orbit.targetRadius + event.deltaY * 0.008,
8.5,
20
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
resetButton.addEventListener("click", resetCamera);
// ------------------------------------------------------------
// Focus controls
// ------------------------------------------------------------
const focusCopy = {
all:
"Radiation is the only mechanism shown crossing the chamber without matter.",
radiation:
"Electromagnetic waves travel through the vacuum and heat the receiver.",
conduction:
"Heat would need continuous solid contact; the solid chain is visibly broken.",
convection:
"Heat would need bulk fluid motion; no fluid can carry it across the vacuum."
};
document.querySelectorAll("[data-mode]").forEach((button) => {
button.addEventListener("click", () => {
const mode = button.dataset.mode;
document.querySelectorAll("[data-mode]").forEach((item) => {
item.classList.toggle("active", item === button);
});
radiationGroup.visible = mode === "all" || mode === "radiation";
conductionGroup.visible = mode === "all" || mode === "conduction";
convectionGroup.visible = mode === "all" || mode === "convection";
focusText.textContent = focusCopy[mode];
});
});
focusText.textContent = focusCopy.all;
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
let paused = false;
let elapsed = 0;
const clock = new THREE.Clock();
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume motion" : "Pause motion";
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space" && event.target === document.body) {
event.preventDefault();
pauseButton.click();
}
if (event.key.toLowerCase() === "r") {
resetCamera();
}
});
function updateCamera() {
orbit.theta += (orbit.targetTheta - orbit.theta) * 0.09;
orbit.phi += (orbit.targetPhi - orbit.phi) * 0.09;
orbit.radius += (orbit.targetRadius - orbit.radius) * 0.09;
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused) elapsed += dt;
updateCamera();
const heatPulse = 0.5 + 0.5 * Math.sin(elapsed * 2.1);
const fastPulse = 0.5 + 0.5 * Math.sin(elapsed * 5.3);
source.material.emissiveIntensity = 0.46 + heatPulse * 0.16;
source.halo.material.opacity = 0.055 + heatPulse * 0.025;
source.outerHalo.material.opacity = 0.018 + heatPulse * 0.015;
source.orbit.rotation.z = elapsed * 0.12;
receiver.material.emissiveIntensity = 0.36 + heatPulse * 0.22;
receiver.halo.material.opacity = 0.045 + heatPulse * 0.035;
receiver.outerHalo.material.opacity = 0.015 + heatPulse * 0.02;
receiver.orbit.rotation.z = -elapsed * 0.16;
for (const photon of photonMeshes) {
const curve = radiationCurves[photon.userData.curveIndex];
const t = (elapsed * 0.19 + photon.userData.offset) % 1;
const position = curve.getPointAt(t);
photon.position.copy(position);
photon.scale.setScalar(
photon.userData.baseScale * (0.86 + fastPulse * 0.28)
);
}
radiationMaterials[0].opacity = 0.38 + heatPulse * 0.16;
radiationMaterials[1].opacity = 0.62 + heatPulse * 0.18;
radiationMaterials[2].opacity = 0.38 + heatPulse * 0.16;
radiationArrows.forEach((arrow, index) => {
arrow.material.opacity = 0.48 + heatPulse * 0.42;
arrow.position.y = 0.43 + Math.sin(elapsed * 2.4 + index) * 0.035;
});
conductionDots.forEach((dot) => {
const t = (elapsed * 0.22 + dot.userData.offset) % 1;
dot.position.set(
-2.86 + t * 2.18,
-0.62,
1.63 + Math.sin(t * Math.PI) * 0.08
);
dot.scale.setScalar(0.8 + Math.sin(t * Math.PI) * 0.45);
});
fluidBeads.forEach((bead) => {
const t = (elapsed * 0.18 + bead.userData.offset) % 1;
bead.position.copy(convectionCurve.getPointAt(t));
bead.scale.setScalar(0.72 + Math.sin(t * Math.PI) * 0.5);
});
fluidArrow.position.copy(convectionCurve.getPointAt(0.18));
fluidArrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
convectionCurve.getTangentAt(0.18)
);
renderer.render(scene, camera);
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
window.addEventListener("resize", resize);
animate();
</script>
</body>
</html>
```