Prompt specification
Build or customize the Three.js 3D scene "Warm-day human heat-exchange exhibit" 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-day human heat-exchange exhibit
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/warm-day-human-heat-exchange-exhibit-x1023
Scene Description Prompt:
Show a voxel person exchanging heat through separate radiation, convection, and evaporation insets. Make one HTML file using Three.js from cdnjs.
Working Three.js Starter (warm-day-human-heat-exchange-exhibit-x1023):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Heat Exchange</title>
<style>
:root {
color-scheme: dark;
--bg: #050b11;
--panel: rgba(11, 23, 32, 0.78);
--panel-strong: rgba(12, 25, 35, 0.94);
--line: rgba(151, 199, 220, 0.14);
--text: #edf8fc;
--muted: #819ba8;
--cyan: #68d8eb;
--red: #ff5f79;
--orange: #ffad5c;
--blue: #67bfff;
--green: #70e1b1;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
min-height: 100%;
margin: 0;
background:
radial-gradient(circle at 15% 5%, rgba(36, 91, 115, 0.15), transparent 28%),
radial-gradient(circle at 85% 80%, rgba(87, 45, 76, 0.12), transparent 30%),
var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button {
font: inherit;
}
.app {
width: 100vw;
height: 100vh;
display: grid;
grid-template-rows: auto minmax(0, 1fr);
}
.topbar {
min-height: 92px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 28px;
padding: 17px 24px;
border-bottom: 1px solid var(--line);
background: rgba(5, 12, 18, 0.78);
backdrop-filter: blur(18px);
z-index: 5;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
width: 43px;
height: 43px;
position: relative;
flex: 0 0 auto;
transform: rotate(30deg);
}
.brand-mark i {
position: absolute;
width: 22px;
height: 22px;
border: 1px solid rgba(104, 216, 235, 0.8);
background: rgba(104, 216, 235, 0.06);
}
.brand-mark i:nth-child(1) {
left: 1px;
top: 10px;
}
.brand-mark i:nth-child(2) {
left: 17px;
top: 2px;
}
.brand-mark i:nth-child(3) {
left: 17px;
top: 19px;
}
.eyebrow {
margin: 0 0 3px;
color: var(--cyan);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(20px, 2vw, 30px);
line-height: 1.1;
font-weight: 620;
letter-spacing: -0.035em;
}
h1 span {
color: var(--muted);
font-weight: 430;
}
.environment {
display: flex;
align-items: stretch;
gap: 8px;
}
.env-item {
min-width: 104px;
padding: 9px 13px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(13, 28, 38, 0.55);
}
.env-item span {
display: block;
margin-bottom: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.14em;
}
.env-item strong {
font-family: "SFMono-Regular", Consolas, monospace;
font-size: 15px;
font-weight: 620;
}
.env-item strong small {
color: var(--muted);
font-size: 10px;
font-weight: 500;
}
.layout {
min-height: 0;
display: grid;
grid-template-columns: minmax(0, 1fr) 365px;
gap: 14px;
padding: 14px;
}
.stage {
min-width: 0;
min-height: 0;
position: relative;
overflow: hidden;
isolation: isolate;
border: 1px solid var(--line);
border-radius: 16px;
background: #071019;
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}
#main-canvas {
width: 100%;
height: 100%;
display: block;
cursor: grab;
touch-action: none;
}
#main-canvas:active {
cursor: grabbing;
}
.stage::after {
content: "";
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
background:
linear-gradient(180deg, rgba(2, 8, 13, 0.42), transparent 21%, transparent 74%, rgba(2, 8, 13, 0.58)),
radial-gradient(circle at center, transparent 45%, rgba(2, 8, 13, 0.28));
}
.stage-header {
position: absolute;
z-index: 4;
top: 17px;
left: 18px;
right: 18px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.stage-id {
display: flex;
align-items: center;
gap: 9px;
color: #c8dce5;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 14px rgba(112, 225, 177, 0.8);
animation: livePulse 1.9s ease-in-out infinite;
}
@keyframes livePulse {
50% {
opacity: 0.45;
transform: scale(0.75);
}
}
.stage-subtitle {
margin-top: 6px;
color: var(--muted);
font-size: 11px;
}
.controls {
display: flex;
align-items: center;
gap: 7px;
pointer-events: auto;
}
.control-btn {
min-height: 32px;
padding: 7px 11px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(8, 18, 26, 0.72);
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(12px);
transition: 160ms ease;
}
.control-btn:hover,
.control-btn.active {
color: var(--text);
border-color: rgba(104, 216, 235, 0.35);
background: rgba(36, 73, 88, 0.45);
}
.channel-toolbar {
position: absolute;
z-index: 4;
top: 72px;
left: 18px;
display: flex;
gap: 6px;
pointer-events: auto;
}
.channel-toggle {
display: flex;
align-items: center;
gap: 7px;
padding: 7px 10px;
border: 1px solid var(--line);
border-radius: 999px;
color: var(--muted);
background: rgba(8, 18, 26, 0.72);
font-size: 10px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(12px);
transition: 160ms ease;
}
.channel-toggle::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: currentColor;
opacity: 0.35;
}
.channel-toggle[data-toggle="radiation"].active {
color: var(--red);
border-color: rgba(255, 95, 121, 0.42);
}
.channel-toggle[data-toggle="convection"].active {
color: var(--orange);
border-color: rgba(255, 173, 92, 0.42);
}
.channel-toggle[data-toggle="evaporation"].active {
color: var(--blue);
border-color: rgba(103, 191, 255, 0.42);
}
.channel-toggle.active::before {
opacity: 1;
box-shadow: 0 0 10px currentColor;
}
.world-label {
position: absolute;
z-index: 3;
min-width: 132px;
padding: 9px 11px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(7, 17, 25, 0.78);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(10px);
transform: translate(-50%, -50%);
pointer-events: none;
transition: opacity 180ms ease;
}
.world-label::before {
content: "";
position: absolute;
left: -18px;
top: 50%;
width: 17px;
height: 1px;
background: currentColor;
opacity: 0.42;
}
.world-label strong {
display: block;
color: currentColor;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
}
.world-label span {
display: block;
margin-top: 3px;
color: #a8bec8;
font-size: 10px;
}
.world-label.radiation {
color: var(--red);
}
.world-label.convection {
color: var(--orange);
}
.world-label.evaporation {
color: var(--blue);
}
.stage-bottom {
position: absolute;
z-index: 4;
left: 18px;
right: 18px;
bottom: 16px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.legend {
width: min(290px, 48%);
}
.legend-title {
display: flex;
justify-content: space-between;
margin-bottom: 7px;
color: #a9bec8;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.legend-bar {
height: 5px;
border-radius: 99px;
background: linear-gradient(90deg, #378db4, #70c7c5, #ffc073, #ff6d57);
box-shadow: 0 0 18px rgba(104, 216, 235, 0.11);
}
.scene-footer {
display: flex;
align-items: flex-end;
gap: 18px;
}
.surface-readout {
min-width: 112px;
text-align: right;
}
.surface-readout span {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.surface-readout strong {
font-family: "SFMono-Regular", Consolas, monospace;
font-size: 13px;
font-weight: 600;
}
.heat-total {
padding-left: 18px;
border-left: 1px solid var(--line);
text-align: right;
}
.heat-total span {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.heat-total strong {
font-family: "SFMono-Regular", Consolas, monospace;
font-size: 23px;
font-weight: 620;
}
.heat-total small {
color: var(--muted);
font-size: 10px;
}
.insets {
min-width: 0;
min-height: 0;
display: grid;
grid-template-rows: repeat(3, minmax(0, 1fr));
gap: 12px;
}
.inset-card {
--accent: var(--red);
min-height: 0;
position: relative;
display: grid;
grid-template-rows: auto minmax(0, 1fr) auto;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 14px;
background:
linear-gradient(145deg, rgba(17, 34, 45, 0.9), rgba(8, 19, 27, 0.84));
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
cursor: pointer;
transition: border-color 180ms ease, opacity 180ms ease, transform 180ms ease;
}
.inset-card::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 2px;
background: var(--accent);
box-shadow: 0 0 18px var(--accent);
opacity: 0.85;
}
.inset-card[data-card="radiation"] {
--accent: var(--red);
}
.inset-card[data-card="convection"] {
--accent: var(--orange);
}
.inset-card[data-card="evaporation"] {
--accent: var(--blue);
}
.inset-card:hover {
transform: translateY(-2px);
border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.inset-card.inactive {
opacity: 0.48;
}
.inset-header {
display: flex;
align-items: center;
gap: 10px;
padding: 13px 14px 7px;
}
.inset-icon {
width: 31px;
height: 31px;
display: grid;
place-items: center;
flex: 0 0 auto;
border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
border-radius: 8px;
color: var(--accent);
background: color-mix(in srgb, var(--accent) 9%, transparent);
font-family: "SFMono-Regular", Consolas, monospace;
font-size: 10px;
font-weight: 800;
}
.inset-heading {
min-width: 0;
flex: 1;
}
.inset-heading h2 {
margin: 0;
font-size: 13px;
font-weight: 680;
letter-spacing: -0.01em;
}
.inset-heading p {
margin: 2px 0 0;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.05em;
}
.inset-value {
text-align: right;
}
.inset-value strong {
display: block;
font-family: "SFMono-Regular", Consolas, monospace;
font-size: 18px;
font-weight: 620;
}
.inset-value span {
color: var(--muted);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.12em;
}
.canvas-wrap {
min-height: 76px;
position: relative;
margin: 0 10px;
overflow: hidden;
border-top: 1px solid rgba(151, 199, 220, 0.07);
border-bottom: 1px solid rgba(151, 199, 220, 0.07);
background:
radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 62%),
linear-gradient(rgba(105, 160, 180, 0.035) 1px, transparent 1px),
linear-gradient(90deg, rgba(105, 160, 180, 0.035) 1px, transparent 1px);
background-size: auto, 24px 24px, 24px 24px;
}
.canvas-wrap canvas {
width: 100%;
height: 100%;
display: block;
}
.inset-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 9px 14px 11px;
}
.formula {
color: #8ba5b1;
font-family: Georgia, "Times New Roman", serif;
font-size: 11px;
font-style: italic;
}
.mechanism {
color: var(--accent);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
@media (max-width: 1050px) {
.layout {
grid-template-columns: minmax(0, 1fr) 330px;
}
.environment .env-item:nth-child(3) {
display: none;
}
.stage-subtitle {
display: none;
}
}
@media (max-width: 820px) {
body {
overflow: auto;
}
.app {
width: 100%;
height: auto;
min-height: 100vh;
}
.topbar {
align-items: flex-start;
padding: 15px;
}
.environment {
display: none;
}
.layout {
grid-template-columns: 1fr;
padding: 10px;
}
.stage {
height: 650px;
}
.insets {
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-rows: none;
}
.inset-card {
min-height: 285px;
}
}
@media (max-width: 650px) {
.insets {
grid-template-columns: 1fr;
}
.inset-card {
min-height: 300px;
}
.stage {
height: 590px;
}
.stage-header {
left: 13px;
right: 13px;
}
.stage-subtitle,
#auto-orbit {
display: none;
}
.controls {
gap: 4px;
}
.control-btn {
padding: 7px 8px;
font-size: 8px;
}
.channel-toolbar {
left: 13px;
right: 13px;
overflow-x: auto;
}
.channel-toggle {
flex: 0 0 auto;
font-size: 8px;
}
.stage-bottom {
left: 13px;
right: 13px;
}
.legend {
width: 45%;
}
.surface-readout {
display: none;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"><i></i><i></i><i></i></div>
<div>
<p class="eyebrow">Biophysics Lab / Visualization 01</p>
<h1>Heat, in three channels <span>— voxel model</span></h1>
</div>
</div>
<div class="environment" aria-label="Environmental conditions">
<div class="env-item">
<span>Core</span>
<strong>37.0<small> °C</small></strong>
</div>
<div class="env-item">
<span>Ambient</span>
<strong>22.0<small> °C</small></strong>
</div>
<div class="env-item">
<span>Humidity</span>
<strong>45<small> %</small></strong>
</div>
</div>
</header>
<main class="layout">
<section class="stage" id="stage">
<canvas id="main-canvas" aria-label="Interactive 3D voxel person showing heat exchange"></canvas>
<div class="stage-header">
<div>
<div class="stage-id">
<span class="live-dot"></span>
Live thermal field
</div>
<div class="stage-subtitle">Drag to orbit · Scroll to zoom · Hover a voxel</div>
</div>
<div class="controls">
<button class="control-btn" id="auto-orbit" type="button" aria-pressed="true">
Auto orbit on
</button>
<button class="control-btn" id="reset-view" type="button">Reset</button>
</div>
</div>
<div class="channel-toolbar" aria-label="Heat exchange channels">
<button class="channel-toggle active" data-toggle="radiation" type="button" aria-pressed="true">
Radiation
</button>
<button class="channel-toggle active" data-toggle="convection" type="button" aria-pressed="true">
Convection
</button>
<button class="channel-toggle active" data-toggle="evaporation" type="button" aria-pressed="true">
Evaporation
</button>
<button class="channel-toggle active" data-toggle="all" id="all-channels" type="button" aria-pressed="true">
All
</button>
</div>
<div class="world-label radiation" data-label="radiation">
<strong>Radiation</strong>
<span>42 W · infrared photons</span>
</div>
<div class="world-label convection" data-label="convection">
<strong>Convection</strong>
<span>18 W · rising air</span>
</div>
<div class="world-label evaporation" data-label="evaporation">
<strong>Evaporation</strong>
<span>9 W · water vapor</span>
</div>
<div class="stage-bottom">
<div class="legend">
<div class="legend-title">
<span>Surface temperature</span>
<span>22 — 37 °C</span>
</div>
<div class="legend-bar"></div>
</div>
<div class="scene-footer">
<div class="surface-readout">
<span>Surface sample</span>
<strong id="surface-value">Hover a voxel</strong>
</div>
<div class="heat-total">
<span>Total heat loss</span>
<strong>69 <small>W</small></strong>
</div>
</div>
</div>
</section>
<aside class="insets" aria-label="Heat transfer mechanism insets">
<article
class="inset-card"
data-card="radiation"
tabindex="0"
aria-label="Radiation inset"
>
<header class="inset-header">
<div class="inset-icon">IR</div>
<div class="inset-heading">
<h2>Radiation</h2>
<p>Electromagnetic waves</p>
</div>
<div class="inset-value">
<strong>42 W</strong>
<span>61% LOSS</span>
</div>
</header>
<div class="canvas-wrap">
<canvas id="radiation-canvas" aria-label="Radiation inset animation"></canvas>
</div>
<footer class="inset-footer">
<span class="formula">εσA(Tₛ⁴ − Tₛᵤᵣ⁴)</span>
<span class="mechanism">Surface → environment</span>
</footer>
</article>
<article
class="inset-card"
data-card="convection"
tabindex="0"
aria-label="Convection inset"
>
<header class="inset-header">
<div class="inset-icon">ΔT</div>
<div class="inset-heading">
<h2>Convection</h2>
<p>Fluid motion and transfer</p>
</div>
<div class="inset-value">
<strong>18 W</strong>
<span>26% LOSS</span>
</div>
</header>
<div class="canvas-wrap">
<canvas id="convection-canvas" aria-label="Convection inset animation"></canvas>
</div>
<footer class="inset-footer">
<span class="formula">hA(Tₛ − Tₐᵢᵣ)</span>
<span class="mechanism">Skin → moving air</span>
</footer>
</article>
<article
class="inset-card"
data-card="evaporation"
tabindex="0"
aria-label="Evaporation inset"
>
<header class="inset-header">
<div class="inset-icon">H₂O</div>
<div class="inset-heading">
<h2>Evaporation</h2>
<p>Phase change at the surface</p>
</div>
<div class="inset-value">
<strong>9 W</strong>
<span>13% LOSS</span>
</div>
</header>
<div class="canvas-wrap">
<canvas id="evaporation-canvas" aria-label="Evaporation inset animation"></canvas>
</div>
<footer class="inset-footer">
<span class="formula">ṁLᵥ</span>
<span class="mechanism">Liquid → vapor</span>
</footer>
</article>
</aside>
</main>
</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.getElementById("stage");
const mainCanvas = document.getElementById("main-canvas");
const state = {
radiation: true,
convection: true,
evaporation: true,
autoOrbit: true
};
// -------------------------------------------------------------------------
// Main scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071019);
scene.fog = new THREE.Fog(0x071019, 11, 24);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 60);
const renderer = new THREE.WebGLRenderer({
canvas: mainCanvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const hemisphere = new THREE.HemisphereLight(0x8cc9e7, 0x10202b, 2.0);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xccefff, 3.1);
keyLight.position.set(4, 8, 5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -2;
scene.add(keyLight);
const warmLight = new THREE.PointLight(0xff6f4a, 11, 8, 2);
warmLight.position.set(0, 3.5, 2.1);
scene.add(warmLight);
const blueLight = new THREE.PointLight(0x3dbde8, 8, 8, 2);
blueLight.position.set(-3, 2.4, -2);
scene.add(blueLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0x07131c,
roughness: 0.96,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.12;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(24, 24, 0x245166, 0x15313d);
grid.position.y = -0.105;
grid.material.transparent = true;
grid.material.opacity = 0.36;
scene.add(grid);
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(1.63, 1.78, 0.18, 64),
new THREE.MeshStandardMaterial({
color: 0x102530,
emissive: 0x07141b,
roughness: 0.66,
metalness: 0.26
})
);
pedestal.position.y = 0;
pedestal.receiveShadow = true;
scene.add(pedestal);
const pedestalRing = new THREE.Mesh(
new THREE.RingGeometry(1.79, 1.81, 96),
new THREE.MeshBasicMaterial({
color: 0x4ccce2,
transparent: true,
opacity: 0.25,
side: THREE.DoubleSide
})
);
pedestalRing.rotation.x = -Math.PI / 2;
pedestalRing.position.y = 0.095;
scene.add(pedestalRing);
const starGeometry = new THREE.BufferGeometry();
const starPositions = [];
for (let i = 0; i < 100; i++) {
starPositions.push(
(Math.random() - 0.5) * 18,
Math.random() * 10 - 0.2,
(Math.random() - 0.5) * 16 - 2
);
}
starGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(starPositions, 3)
);
const stars = new THREE.Points(
starGeometry,
new THREE.PointsMaterial({
color: 0x5b93a8,
size: 0.022,
transparent: true,
opacity: 0.38
})
);
scene.add(stars);
// -------------------------------------------------------------------------
// Voxel body
// -------------------------------------------------------------------------
const personGroup = new THREE.Group();
personGroup.position.y = 0.06;
scene.add(personGroup);
const blocks = [];
const temperatures = [];
const coldColor = new THREE.Color("#378db4");
const middleColor = new THREE.Color("#8bc7b5");
const hotColor = new THREE.Color("#ff6d55");
function colorForTemperature(temperature) {
if (temperature < 31) {
return coldColor.clone().lerp(middleColor, (temperature - 24) / 7);
}
return middleColor.clone().lerp(hotColor, (temperature - 31) / 7);
}
function addBlock(x, y, z, temperature) {
blocks.push({ x, y, z });
temperatures.push(temperature);
}
// Torso: 7 × 7 × 3 voxels.
for (let row = 0; row < 7; row++) {
for (let col = 0; col < 7; col++) {
for (let depth = 0; depth < 3; depth++) {
const distance = Math.abs(col - 3) / 3;
const temperature = 36.7 - distance * 1.2 + (depth === 1 ? 0.2 : 0);
addBlock(
(col - 3) * 0.42,
1.0 + row * 0.42,
(depth - 1) * 0.42,
temperature
);
}
}
}
// Neck.
for (let col = -1; col <= 1; col++) {
for (let depth = -1; depth <= 1; depth++) {
addBlock(col * 0.42, 3.73, depth * 0.42, 36.4);
}
}
// Head: 5 × 5 × 3 voxels.
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 5; col++) {
for (let depth = 0; depth < 3; depth++) {
const edge = col === 0 || col === 4 || row === 0 || row === 4;
addBlock(
(col - 2) * 0.42,
4.06 + row * 0.42,
(depth - 1) * 0.42,
edge ? 34.6 : 36.1
);
}
}
}
// Arms and hands.
for (const side of [-1, 1]) {
for (let col = 0; col < 2; col++) {
for (let row = 0; row < 6; row++) {
for (let depth = 0; depth < 2; depth++) {
const hand = row === 0;
addBlock(
side * (1.47 + col * 0.42),
1.42 + row * 0.42,
(depth - 0.5) * 0.42,
hand ? 31.8 : 34.7
);
}
}
}
}
// Legs and feet.
for (const legSide of [-1, 1]) {
for (let col = 0; col < 2; col++) {
for (let row = 0; row < 4; row++) {
for (let depth = 0; depth < 2; depth++) {
addBlock(
legSide * (0.21 + col * 0.42),
0.42 + row * 0.42,
(depth - 0.5) * 0.42,
27.2 + row * 1.55
);
}
}
}
}
const voxelGeometry = new THREE.BoxGeometry(0.39, 0.39, 0.39);
const voxelMaterial = new THREE.MeshStandardMaterial({
roughness: 0.55,
metalness: 0.08
});
const voxelBody = new THREE.InstancedMesh(
voxelGeometry,
voxelMaterial,
blocks.length
);
const dummy = new THREE.Object3D();
blocks.forEach((block, index) => {
dummy.position.set(block.x, block.y, block.z);
dummy.updateMatrix();
voxelBody.setMatrixAt(index, dummy.matrix);
voxelBody.setColorAt(index, colorForTemperature(temperatures[index]));
});
voxelBody.instanceMatrix.needsUpdate = true;
voxelBody.instanceColor.needsUpdate = true;
voxelBody.castShadow = true;
voxelBody.receiveShadow = true;
personGroup.add(voxelBody);
// Simple face details.
const eyeMaterial = new THREE.MeshBasicMaterial({ color: 0x12222b });
const eyeGeometry = new THREE.BoxGeometry(0.1, 0.1, 0.045);
for (const x of [-0.2, 0.2]) {
const eye = new THREE.Mesh(eyeGeometry, eyeMaterial);
eye.position.set(x, 4.93, 0.635);
personGroup.add(eye);
}
const mouth = new THREE.Mesh(
new THREE.BoxGeometry(0.28, 0.055, 0.04),
eyeMaterial
);
mouth.position.set(0, 4.55, 0.635);
personGroup.add(mouth);
// -------------------------------------------------------------------------
// Main exchange-channel visuals
// -------------------------------------------------------------------------
const channelGroups = {
radiation: new THREE.Group(),
convection: new THREE.Group(),
evaporation: new THREE.Group()
};
Object.values(channelGroups).forEach(group => scene.add(group));
const radiationParticles = [];
const convectionParticles = [];
const evaporationParticles = [];
const radiationMaterial = new THREE.MeshBasicMaterial({
color: 0xff5e78
});
const radiationLineMaterial = new THREE.MeshBasicMaterial({
color: 0xff5e78,
transparent: true,
opacity: 0.58
});
const radiationStarts = [
[-0.72, 4.92, 0.45],
[0.72, 4.96, 0.45],
[-0.42, 5.52, 0.22],
[0.42, 5.55, 0.22],
[-0.76, 3.76, 0.48],
[0.76, 3.82, 0.48]
];
radiationStarts.forEach((start, index) => {
const side = Math.sign(start[0]);
const end = new THREE.Vector3(
side * (2.45 + (index % 3) * 0.22),
start[1] + 0.38 + (index % 2) * 0.35,
start[2] - 0.18
);
const points = [];
for (let i = 0; i <= 32; i++) {
const t = i / 32;
const p = new THREE.Vector3().lerpVectors(
new THREE.Vector3(...start),
end,
t
);
p.y += Math.sin(t * Math.PI * 7) * 0.105 * Math.sin(t * Math.PI);
p.z += Math.sin(t * Math.PI * 6) * 0.06 * Math.sin(t * Math.PI);
points.push(p);
}
const curve = new THREE.CatmullRomCurve3(points);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 48, 0.014, 5, false),
radiationLineMaterial
);
channelGroups.radiation.add(tube);
for (let j = 0; j < 2; j++) {
const photon = new THREE.Mesh(
new THREE.OctahedronGeometry(0.06, 0),
radiationMaterial
);
channelGroups.radiation.add(photon);
radiationParticles.push({
mesh: photon,
curve,
speed: 0.15 + index * 0.006,
offset: j * 0.48 + index * 0.071
});
}
});
const convectionMaterial = new THREE.MeshBasicMaterial({
color: 0xffae5e,
transparent: true,
opacity: 0.38
});
const convectionParticleMaterial = new THREE.MeshBasicMaterial({
color: 0xffbf79
});
[-1.82, -2.08, 1.82, 2.08].forEach((x, index) => {
const z = index % 2 === 0 ? -0.35 : 0.18;
const points = [];
for (let i = 0; i <= 30; i++) {
const t = i / 30;
points.push(
new THREE.Vector3(
x + Math.sin(t * Math.PI * 2 + index) * 0.11,
0.12 + t * 3.82,
z + Math.cos(t * Math.PI * 2) * 0.08
)
);
}
const curve = new THREE.CatmullRomCurve3(points);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 40, 0.013, 5, false),
convectionMaterial
);
channelGroups.convection.add(tube);
const particle = new THREE.Mesh(
new THREE.OctahedronGeometry(0.065, 0),
convectionParticleMaterial
);
channelGroups.convection.add(particle);
convectionParticles.push({
mesh: particle,
curve,
speed: 0.15 + index * 0.012,
offset: index * 0.19
});
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.23, 8),
convectionParticleMaterial
);
arrow.position.set(x, 4.05, z);
channelGroups.convection.add(arrow);
});
const evaporationMaterial = new THREE.MeshBasicMaterial({
color: 0x65c4ff,
transparent: true,
opacity: 0.42
});
const evaporationParticleMaterial = new THREE.MeshBasicMaterial({
color: 0x9bdfff
});
const evaporationStarts = [
[-0.54, 5.48, 0.36],
[0.48, 5.52, 0.34],
[-1.72, 3.28, 0.36],
[1.72, 3.24, 0.36],
[-0.25, 4.96, 0.56]
];
evaporationStarts.forEach((start, index) => {
const end = new THREE.Vector3(
start[0] * (index > 1 ? 1.16 : 1.08),
start[1] + 1.12 + index * 0.08,
start[2] + 0.16
);
const points = [];
for (let i = 0; i <= 30; i++) {
const t = i / 30;
const p = new THREE.Vector3().lerpVectors(
new THREE.Vector3(...start),
end,
t
);
p.x += Math.sin(t * Math.PI * 5 + index) * 0.11 * Math.sin(t * Math.PI);
p.z += Math.sin(t * Math.PI * 4) * 0.09;
points.push(p);
}
const curve = new THREE.CatmullRomCurve3(points);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 40, 0.013, 5, false),
evaporationMaterial
);
channelGroups.evaporation.add(tube);
for (let j = 0; j < 3; j++) {
const molecule = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.038, 0),
evaporationParticleMaterial
);
channelGroups.evaporation.add(molecule);
evaporationParticles.push({
mesh: molecule,
curve,
speed: 0.13 + index * 0.008,
offset: j / 3 + index * 0.087
});
}
});
// -------------------------------------------------------------------------
// Custom camera controls
// -------------------------------------------------------------------------
const orbit = {
radius: 10.2,
theta: 0.32,
phi: 1.30,
target: new THREE.Vector3(0, 2.9, 0)
};
const defaultOrbit = { ...orbit };
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
updateCamera();
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
mainCanvas.addEventListener("pointerdown", event => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
mainCanvas.setPointerCapture(event.pointerId);
});
mainCanvas.addEventListener("pointermove", event => {
const rect = mainCanvas.getBoundingClientRect();
const mouse = new THREE.Vector2(
((event.clientX - rect.left) / rect.width) * 2 - 1,
-((event.clientY - rect.top) / rect.height) * 2 + 1
);
if (dragging) {
const deltaX = event.clientX - lastPointerX;
const deltaY = event.clientY - lastPointerY;
orbit.theta -= deltaX * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - deltaY * 0.005,
0.82,
1.58
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
} else {
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, camera);
const hit = raycaster.intersectObject(voxelBody)[0];
const readout = document.getElementById("surface-value");
if (hit && typeof hit.instanceId === "number") {
const temperature = temperatures[hit.instanceId];
readout.textContent = `${temperature.toFixed(1)} °C`;
mainCanvas.style.cursor = "crosshair";
} else {
readout.textContent = "Hover a voxel";
mainCanvas.style.cursor = "grab";
}
}
});
mainCanvas.addEventListener("pointerup", event => {
dragging = false;
if (mainCanvas.hasPointerCapture(event.pointerId)) {
mainCanvas.releasePointerCapture(event.pointerId);
}
});
mainCanvas.addEventListener("pointercancel", () => {
dragging = false;
});
mainCanvas.addEventListener("pointerleave", () => {
if (!dragging) {
document.getElementById("surface-value").textContent = "Hover a voxel";
}
});
mainCanvas.addEventListener(
"wheel",
event => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.008,
7.2,
14.5
);
},
{ passive: false }
);
document.getElementById("reset-view").addEventListener("click", () => {
orbit.radius = defaultOrbit.radius;
orbit.theta = defaultOrbit.theta;
orbit.phi = defaultOrbit.phi;
});
const autoOrbitButton = document.getElementById("auto-orbit");
autoOrbitButton.addEventListener("click", () => {
state.autoOrbit = !state.autoOrbit;
autoOrbitButton.classList.toggle("active", state.autoOrbit);
autoOrbitButton.setAttribute("aria-pressed", String(state.autoOrbit));
autoOrbitButton.textContent = state.autoOrbit
? "Auto orbit on"
: "Auto orbit off";
});
// -------------------------------------------------------------------------
// Channel toggles
// -------------------------------------------------------------------------
const allButton = document.getElementById("all-channels");
const toggleButtons = [...document.querySelectorAll("[data-toggle]")].filter(
button => button.dataset.toggle !== "all"
);
const cards = [...document.querySelectorAll("[data-card]")];
const labels = [...document.querySelectorAll("[data-label]")];
function syncChannelUI() {
Object.keys(channelGroups).forEach(name => {
channelGroups[name].visible = state[name];
});
toggleButtons.forEach(button => {
const active = state[button.dataset.toggle];
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
cards.forEach(card => {
card.classList.toggle("inactive", !state[card.dataset.card]);
});
labels.forEach(label => {
label.style.opacity = state[label.dataset.label] ? "1" : "0";
});
const allActive = Object.keys(channelGroups).every(name => state[name]);
allButton.classList.toggle("active", allActive);
allButton.setAttribute("aria-pressed", String(allActive));
}
function toggleChannel(name) {
state[name] = !state[name];
syncChannelUI();
}
toggleButtons.forEach(button => {
button.addEventListener("click", () => {
toggleChannel(button.dataset.toggle);
});
});
allButton.addEventListener("click", () => {
Object.keys(channelGroups).forEach(name => {
state[name] = true;
});
syncChannelUI();
});
cards.forEach(card => {
const toggleCard = () => toggleChannel(card.dataset.card);
card.addEventListener("click", toggleCard);
card.addEventListener("keydown", event => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
toggleCard();
}
});
});
syncChannelUI();
// -------------------------------------------------------------------------
// Separate Three.js inset scenes
// -------------------------------------------------------------------------
const insetViews = [];
const miniGeometry = new THREE.BoxGeometry(0.34, 0.34, 0.34);
const miniBodyMaterial = new THREE.MeshStandardMaterial({
color: 0x3b6071,
roughness: 0.74,
metalness: 0.06
});
const miniSkinMaterial = new THREE.MeshStandardMaterial({
color: 0xe59a7f,
roughness: 0.66
});
function addMiniBox(parent, x, y, z, material = miniBodyMaterial) {
const mesh = new THREE.Mesh(miniGeometry, material);
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
function makeMiniBust(parent, xOffset = 0) {
const bust = new THREE.Group();
bust.position.x = xOffset;
for (let row = 0; row < 4; row++) {
for (let col = 0; col < 4; col++) {
addMiniBox(bust, (col - 1.5) * 0.34, 0.18 + row * 0.34, 0);
}
}
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 3; col++) {
addMiniBox(
bust,
(col - 1) * 0.34,
1.52 + row * 0.34,
0,
miniSkinMaterial
);
}
}
parent.add(bust);
return bust;
}
function createInset(kind, canvas) {
const insetScene = new THREE.Scene();
const insetCamera = new THREE.OrthographicCamera(-4, 4, 1.9, -1.9, 0.1, 50);
insetCamera.position.set(0, 1.25, 8);
insetCamera.lookAt(0, 1.25, 0);
const insetRenderer = new THREE.WebGLRenderer({
canvas,
alpha: true,
antialias: true,
powerPreference: "high-performance"
});
insetRenderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
insetRenderer.outputColorSpace = THREE.SRGBColorSpace;
insetRenderer.toneMapping = THREE.ACESFilmicToneMapping;
insetRenderer.toneMappingExposure = 1.15;
insetRenderer.setClearColor(0x000000, 0);
insetScene.add(new THREE.HemisphereLight(0xb9e4f3, 0x152532, 2.7));
const light = new THREE.DirectionalLight(0xd7f3ff, 2.2);
light.position.set(3, 5, 5);
insetScene.add(light);
const particles = [];
if (kind === "radiation") {
makeMiniBust(insetScene, -1.18);
const material = new THREE.MeshBasicMaterial({
color: 0xff6078,
transparent: true,
opacity: 0.67
});
for (let i = 0; i < 5; i++) {
const startX = -0.9;
const startY = 1.36 + i * 0.19;
const points = [];
for (let j = 0; j <= 28; j++) {
const t = j / 28;
points.push(
new THREE.Vector3(
THREE.MathUtils.lerp(startX, 2.75, t),
startY + Math.sin(t * Math.PI * 7) * 0.085 * Math.sin(t * Math.PI),
0.1 + Math.sin(t * Math.PI * 5) * 0.035
)
);
}
const curve = new THREE.CatmullRomCurve3(points);
const line = new THREE.Mesh(
new THREE.TubeGeometry(curve, 36, 0.014, 5, false),
material
);
insetScene.add(line);
const photon = new THREE.Mesh(
new THREE.OctahedronGeometry(0.055, 0),
new THREE.MeshBasicMaterial({ color: 0xff6078 })
);
insetScene.add(photon);
particles.push({
mesh: photon,
curve,
speed: 0.18 + i * 0.013,
offset: i * 0.14
});
}
}
if (kind === "convection") {
makeMiniBust(insetScene, 0);
const material = new THREE.MeshBasicMaterial({
color: 0xffad5b,
transparent: true,
opacity: 0.52
});
for (const side of [-1, 1]) {
for (let layer = 0; layer < 2; layer++) {
const x = side * (0.74 + layer * 0.2);
const z = layer === 0 ? -0.15 : 0.16;
const points = [];
for (let i = 0; i <= 24; i++) {
const t = i / 24;
points.push(
new THREE.Vector3(
x + Math.sin(t * Math.PI * 3 + layer) * 0.055,
-0.12 + t * 3.08,
z
)
);
}
const curve = new THREE.CatmullRomCurve3(points);
const line = new THREE.Mesh(
new THREE.TubeGeometry(curve, 32, 0.012, 5, false),
material
);
insetScene.add(line);
const particle = new THREE.Mesh(
new THREE.OctahedronGeometry(0.055, 0),
new THREE.MeshBasicMaterial({ color: 0xffc17e })
);
insetScene.add(particle);
particles.push({
mesh: particle,
curve,
speed: 0.18 + layer * 0.025,
offset: side > 0 ? 0.38 : 0
});
}
}
}
if (kind === "evaporation") {
makeMiniBust(insetScene, 0);
const material = new THREE.MeshBasicMaterial({
color: 0x62c1ff,
transparent: true,
opacity: 0.48
});
const starts = [
[-0.36, 2.37, 0.12],
[0.28, 2.42, 0.12],
[-0.05, 2.57, 0.12],
[-0.68, 1.18, 0.12],
[0.66, 1.14, 0.12]
];
starts.forEach((start, index) => {
const points = [];
for (let i = 0; i <= 24; i++) {
const t = i / 24;
points.push(
new THREE.Vector3(
start[0] + Math.sin(t * Math.PI * 4 + index) * 0.13,
start[1] + t * 0.64,
start[2] + Math.sin(t * Math.PI * 3) * 0.08
)
);
}
const curve = new THREE.CatmullRomCurve3(points);
const line = new THREE.Mesh(
new THREE.TubeGeometry(curve, 32, 0.011, 5, false),
material
);
insetScene.add(line);
for (let j = 0; j < 2; j++) {
const molecule = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.038, 0),
new THREE.MeshBasicMaterial({ color: 0x9bdfff })
);
insetScene.add(molecule);
particles.push({
mesh: molecule,
curve,
speed: 0.13 + index * 0.008,
offset: j * 0.5 + index * 0.11
});
}
});
}
const view = {
renderer: insetRenderer,
scene: insetScene,
camera: insetCamera,
particles,
kind,
resize() {
const rect = canvas.getBoundingClientRect();
const width = Math.max(1, rect.width);
const height = Math.max(1, rect.height);
const aspect = width / height;
const viewHeight = 3.65;
insetCamera.left = (-viewHeight * aspect) / 2;
insetCamera.right = (viewHeight * aspect) / 2;
insetCamera.top = viewHeight / 2;
insetCamera.bottom = -viewHeight / 2;
insetCamera.updateProjectionMatrix();
insetRenderer.setSize(width, height, false);
},
update(time) {
particles.forEach(particle => {
const t = (time * particle.speed + particle.offset) % 1;
particle.mesh.position.copy(particle.curve.getPointAt(t));
particle.mesh.rotation.y = time * 1.7;
particle.mesh.rotation.x = time * 0.9;
});
}
};
view.resize();
insetViews.push(view);
return view;
}
createInset("radiation", document.getElementById("radiation-canvas"));
createInset("convection", document.getElementById("convection-canvas"));
createInset("evaporation", document.getElementById("evaporation-canvas"));
// -------------------------------------------------------------------------
// Resizing and projected HTML labels
// -------------------------------------------------------------------------
function resizeMain() {
const rect = stage.getBoundingClientRect();
const width = Math.max(1, rect.width);
const height = Math.max(1, rect.height);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(() => {
resizeMain();
insetViews.forEach(view => view.resize());
});
resizeObserver.observe(stage);
document.querySelectorAll(".canvas-wrap").forEach(wrapper => {
resizeObserver.observe(wrapper);
});
resizeMain();
const labelPositions = {
radiation: new THREE.Vector3(-2.68, 5.35, 0.1),
convection: new THREE.Vector3(-2.18, 2.15, 0.1),
evaporation: new THREE.Vector3(2.15, 1.22, 0.25)
};
const projected = new THREE.Vector3();
function updateLabelPositions() {
const width = stage.clientWidth;
const height = stage.clientHeight;
labels.forEach(label => {
projected.copy(labelPositions[label.dataset.label]).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
label.style.visibility = visible ? "visible" : "hidden";
label.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
label.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
});
}
// -------------------------------------------------------------------------
// Animation loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
if (state.autoOrbit && !dragging) {
orbit.theta += dt * 0.075;
}
updateCamera();
personGroup.position.y = 0.06 + Math.sin(time * 1.55) * 0.018;
warmLight.intensity = 10.5 + Math.sin(time * 1.55) * 0.65;
const pulse = 1 + Math.sin(time * 1.35) * 0.025;
pedestalRing.scale.set(pulse, pulse, pulse);
pedestalRing.material.opacity = 0.19 + (Math.sin(time * 1.35) + 1) * 0.035;
stars.rotation.y = time * 0.006;
radiationParticles.forEach(particle => {
const t = (time * particle.speed + particle.offset) % 1;
particle.mesh.position.copy(particle.curve.getPointAt(t));
particle.mesh.rotation.x = time * 1.5;
particle.mesh.rotation.y = time * 2.0;
});
convectionParticles.forEach(particle => {
const t = (time * particle.speed + particle.offset) % 1;
particle.mesh.position.copy(particle.curve.getPointAt(t));
particle.mesh.rotation.y = time * 2.1;
});
evaporationParticles.forEach(particle => {
const t = (time * particle.speed + particle.offset) % 1;
particle.mesh.position.copy(particle.curve.getPointAt(t));
particle.mesh.rotation.y = time * 1.3;
particle.mesh.rotation.z = time * 0.8;
});
updateLabelPositions();
renderer.render(scene, camera);
insetViews.forEach(view => {
view.update(time);
view.renderer.render(view.scene, view.camera);
});
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```