Prompt specification
Build or customize the Three.js 3D scene "Evaporation and skin blood-flow 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: Evaporation and skin blood-flow comparison
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/evaporation-and-skin-blood-flow-comparison-x1022
Scene Description Prompt:
Make a cutaway Three.js scene in a self-contained HTML file using cdnjs: evaporation and skin blood-flow comparison. Place two educational skin panels highlighting sweat evaporation and vessel-diameter changes separately; show qualitative heat-transfer arrows without predicting actual body temperature.
Working Three.js Starter (evaporation-and-skin-blood-flow-comparison-x1022):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Skin Heat Transfer — Evaporation vs. Blood Flow</title>
<style>
:root {
color-scheme: dark;
--cyan: #65ddff;
--amber: #ffc66d;
--coral: #ff667e;
--ink: #f3f8fc;
--muted: #a7bac9;
--glass: rgba(8, 22, 34, 0.78);
--line: rgba(188, 224, 245, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 30%, rgba(23, 70, 94, 0.22), transparent 38%),
radial-gradient(circle at 12% 90%, rgba(0, 163, 211, 0.08), transparent 32%),
linear-gradient(150deg, #06111b 0%, #091723 48%, #050d15 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
canvas {
-webkit-tap-highlight-color: transparent;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.header {
position: fixed;
top: 24px;
left: 28px;
z-index: 10;
width: min(630px, calc(100vw - 390px));
pointer-events: none;
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 1px;
content: "";
background: currentColor;
box-shadow: 0 0 10px currentColor;
}
h1 {
max-width: 620px;
margin: 0;
font-size: clamp(25px, 3.2vw, 46px);
font-weight: 660;
line-height: 1.04;
letter-spacing: -0.045em;
text-wrap: balance;
}
.subtitle {
max-width: 580px;
margin: 13px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.subtitle strong {
color: #e8f3fa;
font-weight: 650;
}
.controls {
position: fixed;
top: 24px;
right: 26px;
z-index: 20;
display: flex;
align-items: center;
gap: 8px;
}
.control-button {
min-height: 38px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(10, 27, 40, 0.76);
color: #dceaf3;
font: inherit;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.03em;
cursor: pointer;
backdrop-filter: blur(14px);
transition:
border-color 160ms ease,
background 160ms ease,
color 160ms ease,
transform 160ms ease;
}
.control-button:hover {
border-color: rgba(101, 221, 255, 0.46);
background: rgba(16, 42, 58, 0.9);
color: white;
transform: translateY(-1px);
}
.control-button:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 3px;
}
.control-button[aria-pressed="false"] {
color: #8ca3b3;
}
.hint {
position: fixed;
top: 72px;
right: 28px;
z-index: 9;
color: rgba(190, 210, 223, 0.7);
font-size: 10px;
letter-spacing: 0.05em;
pointer-events: none;
}
#labels {
position: fixed;
inset: 0;
z-index: 7;
opacity: 1;
pointer-events: none;
transition: opacity 180ms ease;
}
body.labels-off #labels {
opacity: 0;
}
.callout {
position: absolute;
width: max-content;
max-width: 220px;
padding: 9px 11px 10px;
border: 1px solid rgba(170, 213, 235, 0.18);
border-radius: 10px;
background: rgba(7, 20, 31, 0.82);
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
color: #edf8ff;
font-size: 10px;
font-weight: 800;
line-height: 1.25;
letter-spacing: 0.09em;
text-transform: uppercase;
transform: translate(-50%, calc(-100% - 14px));
backdrop-filter: blur(12px);
transition: opacity 120ms linear;
white-space: nowrap;
}
.callout::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 13px;
content: "";
background: linear-gradient(currentColor, transparent);
opacity: 0.65;
}
.callout .detail {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
font-weight: 500;
letter-spacing: 0.025em;
text-transform: none;
white-space: normal;
}
.callout.cyan {
color: var(--cyan);
}
.callout.amber {
color: var(--amber);
}
.callout.coral {
color: var(--coral);
}
.legend {
position: fixed;
right: 26px;
bottom: 24px;
z-index: 10;
display: grid;
gap: 8px;
min-width: 218px;
padding: 13px 15px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(7, 19, 30, 0.68);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
backdrop-filter: blur(14px);
pointer-events: none;
}
.legend-title {
margin-bottom: 1px;
color: #7f98a9;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.legend-item {
display: flex;
align-items: center;
gap: 9px;
color: #c9d9e4;
font-size: 10px;
line-height: 1.3;
}
.swatch {
width: 23px;
height: 2px;
flex: 0 0 auto;
border-radius: 2px;
box-shadow: 0 0 8px currentColor;
}
.swatch.cyan {
color: var(--cyan);
background: var(--cyan);
}
.swatch.amber {
color: var(--amber);
background: var(--amber);
}
.swatch.coral {
width: 11px;
height: 11px;
border: 2px solid var(--coral);
border-radius: 50%;
background: rgba(255, 102, 126, 0.13);
}
.note {
position: fixed;
left: 28px;
bottom: 25px;
z-index: 10;
max-width: 510px;
color: #9bb0be;
font-size: 10px;
line-height: 1.55;
pointer-events: none;
}
.note strong {
color: #dceaf2;
font-weight: 700;
}
.conceptual {
display: inline-block;
margin-right: 7px;
padding: 3px 6px;
border: 1px solid rgba(101, 221, 255, 0.25);
border-radius: 4px;
color: var(--cyan);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
vertical-align: 1px;
}
#fallback {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
padding: 30px;
background: #08131d;
color: white;
text-align: center;
}
#fallback[hidden] {
display: none;
}
@media (max-width: 820px) {
.header {
top: 18px;
left: 18px;
width: calc(100vw - 36px);
}
h1 {
max-width: 500px;
font-size: 29px;
}
.subtitle {
max-width: 470px;
font-size: 12px;
}
.controls {
top: auto;
right: 16px;
bottom: 82px;
}
.control-button {
min-height: 34px;
padding: 0 10px;
font-size: 9px;
}
.hint {
display: none;
}
.legend {
right: 16px;
bottom: 16px;
min-width: 188px;
padding: 10px 12px;
}
.note {
left: 18px;
bottom: 16px;
max-width: calc(100vw - 230px);
font-size: 9px;
}
.callout {
max-width: 170px;
padding: 7px 9px;
font-size: 8px;
}
.callout .detail {
display: none;
}
}
@media (max-width: 560px) {
.eyebrow {
margin-bottom: 7px;
font-size: 9px;
}
h1 {
font-size: 25px;
}
.subtitle {
display: none;
}
.callout {
display: none;
}
.legend {
min-width: 170px;
}
.note {
max-width: calc(100vw - 210px);
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive Three.js cutaway comparison of heat transfer through skin"></main>
<header class="header">
<div class="eyebrow">Thermal exchange · visual guide</div>
<h1>Two ways skin exchanges heat</h1>
<p class="subtitle">
<strong>Left:</strong> sweat evaporation carries latent heat away.
<strong>Right:</strong> vessel diameter changes how much blood-delivered
heat reaches the skin surface.
</p>
</header>
<nav class="controls" aria-label="Scene controls">
<button class="control-button" id="motionButton" type="button" aria-pressed="true">
Pause motion
</button>
<button class="control-button" id="labelsButton" type="button" aria-pressed="true">
Labels
</button>
<button class="control-button" id="resetButton" type="button">
Reset view
</button>
</nav>
<div class="hint">DRAG TO ORBIT · SCROLL TO ZOOM · ARROW KEYS TO ROTATE</div>
<div id="labels" aria-hidden="true">
<div class="callout cyan" id="sweatLabel">
Sweat film
<span class="detail">Liquid water reaches the surface</span>
</div>
<div class="callout cyan" id="vaporLabel">
Vapor + latent heat
<span class="detail">Evaporation carries heat away</span>
</div>
<div class="callout coral" id="narrowLabel">
Narrower vessel
<span class="detail">A smaller internal passage</span>
</div>
<div class="callout coral" id="wideLabel">
Wider vessel
<span class="detail">Greater cross-sectional area</span>
</div>
<div class="callout amber" id="heatLabel">
Heat toward surface
<span class="detail">Carried by blood flow</span>
</div>
</div>
<aside class="legend" aria-label="Diagram legend">
<div class="legend-title">Qualitative key</div>
<div class="legend-item">
<span class="swatch cyan"></span>
<span>Evaporative heat carried away</span>
</div>
<div class="legend-item">
<span class="swatch amber"></span>
<span>Blood-delivered heat direction</span>
</div>
<div class="legend-item">
<span class="swatch coral"></span>
<span>Relative vessel diameter</span>
</div>
</aside>
<div class="note">
<span class="conceptual">Conceptual only</span>
<strong>No body temperature is predicted.</strong>
Arrow direction and relative widths show mechanisms, not measured
heat-transfer rates.
</div>
<div id="fallback" hidden>
This scene requires WebGL and access to the Three.js CDN module.
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const host = document.getElementById("scene");
const fallback = document.getElementById("fallback");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
} catch (error) {
fallback.hidden = false;
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Three-dimensional skin cutaway with evaporation and blood-flow panels"
);
renderer.domElement.tabIndex = 0;
host.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x07131d, 0.022);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
const palette = {
cyan: 0x65ddff,
amber: 0xffc66d,
coral: 0xff667e,
epidermis: 0xf3c7a0,
dermis: 0xe88880,
fat: 0xe8bd68,
plinth: 0x102a3a,
dark: 0x071723
};
const hemisphere = new THREE.HemisphereLight(0xc8e8ff, 0x1a1720, 1.8);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4df, 3.4);
keyLight.position.set(5, 10, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x78caff, 1.15);
fillLight.position.set(-7, 5, -5);
scene.add(fillLight);
const cyanLight = new THREE.PointLight(palette.cyan, 42, 8, 2);
cyanLight.position.set(-3.2, 3.4, 4.5);
scene.add(cyanLight);
const coralLight = new THREE.PointLight(palette.coral, 34, 8, 2);
coralLight.position.set(3.2, 3.1, 4.5);
scene.add(coralLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 30),
new THREE.ShadowMaterial({
color: 0x000000,
opacity: 0.32
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.54;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(32, 32, 0x315267, 0x18313f);
grid.position.y = -0.525;
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
const world = new THREE.Group();
scene.add(world);
const labels = [];
const animatedDroplets = [];
const evaporationArrows = [];
const flowArrows = [];
const vaporSeeds = [];
const up = new THREE.Vector3(0, 1, 0);
const forward = new THREE.Vector3(0, 0, 1);
function makeStandard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.68,
metalness: 0.02,
...options
});
}
function addEdges(mesh, color = 0xd8eef5, opacity = 0.22) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry, 22),
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
mesh.add(edges);
return edges;
}
function addBox(parent, size, position, material, edgeColor, edgeOpacity = 0.2) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size.x, size.y, size.z),
material
);
mesh.position.copy(position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (edgeColor !== undefined) {
addEdges(mesh, edgeColor, edgeOpacity);
}
return mesh;
}
function roundedRectPath(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 createPlaque(parent, title, subtitle, accentCss) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
const gradient = ctx.createLinearGradient(0, 0, 1024, 256);
gradient.addColorStop(0, "rgba(7, 22, 34, 0.98)");
gradient.addColorStop(1, "rgba(13, 37, 50, 0.96)");
roundedRectPath(ctx, 8, 8, 1008, 240, 32);
ctx.fillStyle = gradient;
ctx.fill();
ctx.strokeStyle = accentCss;
ctx.globalAlpha = 0.36;
ctx.lineWidth = 3;
ctx.stroke();
ctx.globalAlpha = 1;
ctx.fillStyle = accentCss;
ctx.fillRect(44, 49, 8, 158);
ctx.fillStyle = "#f3f8fc";
ctx.font = "700 64px system-ui, sans-serif";
ctx.fillText(title, 78, 108);
ctx.fillStyle = "#9db2c1";
ctx.font = "500 31px system-ui, sans-serif";
ctx.fillText(subtitle, 80, 169);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
renderer.capabilities.getMaxAnisotropy(),
8
);
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(3.45, 0.86),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
})
);
plaque.position.set(0, -0.38, 1.397);
plaque.renderOrder = 8;
parent.add(plaque);
}
function createSkinPanel(x, accentColor, accentCss) {
const group = new THREE.Group();
group.position.x = x;
world.add(group);
const plinthMaterial = makeStandard(palette.plinth, {
roughness: 0.42,
metalness: 0.28
});
const accentMaterial = makeStandard(accentColor, {
emissive: accentColor,
emissiveIntensity: 0.34,
roughness: 0.35
});
addBox(
group,
new THREE.Vector3(4.32, 0.24, 2.76),
new THREE.Vector3(0, -0.38, 0),
plinthMaterial,
0x8ac6df,
0.18
);
addBox(
group,
new THREE.Vector3(4.16, 0.035, 2.78),
new THREE.Vector3(0, -0.245, 0),
accentMaterial
);
const fat = addBox(
group,
new THREE.Vector3(3.8, 0.8, 2.3),
new THREE.Vector3(0, 0.14, 0),
makeStandard(palette.fat, {
roughness: 0.88,
emissive: 0x3b2405,
emissiveIntensity: 0.04
}),
0xffe6a5,
0.2
);
const dermis = addBox(
group,
new THREE.Vector3(3.8, 0.74, 2.3),
new THREE.Vector3(0, 0.91, 0),
makeStandard(palette.dermis, {
roughness: 0.5,
transparent: true,
opacity: 0.57,
depthWrite: false,
side: THREE.DoubleSide
}),
0xffc0b7,
0.34
);
dermis.castShadow = false;
dermis.renderOrder = 3;
const epidermis = addBox(
group,
new THREE.Vector3(3.8, 0.38, 2.3),
new THREE.Vector3(0, 1.47, 0),
makeStandard(palette.epidermis, {
roughness: 0.76,
emissive: 0x4a2811,
emissiveIntensity: 0.035
}),
0xffead4,
0.28
);
// A fine outline emphasizes the exposed front section.
const windowGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-1.77, 0.58, 1.157),
new THREE.Vector3(1.77, 0.58, 1.157),
new THREE.Vector3(1.77, 1.24, 1.157),
new THREE.Vector3(-1.77, 1.24, 1.157)
]);
const windowLine = new THREE.LineLoop(
windowGeometry,
new THREE.LineDashedMaterial({
color: accentColor,
transparent: true,
opacity: 0.42,
dashSize: 0.08,
gapSize: 0.06
})
);
windowLine.computeLineDistances();
windowLine.renderOrder = 5;
group.add(windowLine);
return {
group,
fat,
dermis,
epidermis,
accentMaterial
};
}
const evaporationPanel = createSkinPanel(
-2.35,
palette.cyan,
"rgba(101, 221, 255, 0.95)"
);
evaporationPanel.group.position.z = 0.1;
const bloodPanel = createSkinPanel(
2.35,
palette.coral,
"rgba(255, 102, 126, 0.95)"
);
bloodPanel.group.position.z = -0.08;
createPlaque(
evaporationPanel.group,
"01 EVAPORATION",
"Liquid sweat → water vapor",
"rgba(101, 221, 255, 0.95)"
);
createPlaque(
bloodPanel.group,
"02 VESSEL DIAMETER",
"Relative width → skin blood flow",
"rgba(255, 102, 126, 0.95)"
);
function createAnchor(parent, x, y, z) {
const object = new THREE.Object3D();
object.position.set(x, y, z);
parent.add(object);
return object;
}
function registerLabel(id, object, offsetX = 0, offsetY = 0) {
labels.push({
element: document.getElementById(id),
object,
offsetX,
offsetY
});
}
function createCurvedArrow(parent, points, color, speed = 0.25) {
const curve = new THREE.CatmullRomCurve3(
points.map((point) => new THREE.Vector3(...point)),
false,
"catmullrom",
0.45
);
const arrowMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.76,
depthWrite: false,
toneMapped: false
});
const shaft = new THREE.Mesh(
new THREE.TubeGeometry(curve, 42, 0.017, 8, false),
arrowMaterial
);
shaft.renderOrder = 6;
parent.add(shaft);
const end = curve.getPointAt(1);
const tangent = curve.getTangentAt(1).normalize();
const headLength = 0.23;
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.088, headLength, 14),
arrowMaterial
);
head.position.copy(end).addScaledVector(tangent, -headLength * 0.48);
head.quaternion.setFromUnitVectors(up, tangent);
head.renderOrder = 6;
parent.add(head);
const dash = new THREE.Mesh(
new THREE.SphereGeometry(0.045, 12, 8),
new THREE.MeshBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.78,
depthWrite: false,
toneMapped: false
})
);
dash.renderOrder = 7;
parent.add(dash);
return { curve, dash, speed };
}
// ---- Left panel: sweat gland, duct, droplets, evaporation ----------------
const sweatGroup = evaporationPanel.group;
const glandCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.68, 0.65, 0.69),
new THREE.Vector3(-0.94, 0.73, 0.70),
new THREE.Vector3(-0.96, 0.90, 0.70),
new THREE.Vector3(-0.65, 0.96, 0.70),
new THREE.Vector3(-0.56, 1.10, 0.70),
new THREE.Vector3(-0.76, 1.17, 0.70),
new THREE.Vector3(-0.62, 1.25, 0.70)
]);
const gland = new THREE.Mesh(
new THREE.TubeGeometry(glandCurve, 64, 0.046, 10, false),
makeStandard(0x43c5d8, {
emissive: 0x0a6070,
emissiveIntensity: 0.58,
roughness: 0.34
})
);
gland.castShadow = true;
sweatGroup.add(gland);
const ductCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.62, 1.24, 0.70),
new THREE.Vector3(-0.54, 1.45, 0.70),
new THREE.Vector3(-0.55, 1.67, 0.64)
]);
const duct = new THREE.Mesh(
new THREE.TubeGeometry(ductCurve, 28, 0.025, 9, false),
makeStandard(0x78e6f4, {
emissive: 0x0b7284,
emissiveIntensity: 0.55,
roughness: 0.3
})
);
sweatGroup.add(duct);
const pore = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.065, 0.018, 18),
makeStandard(0x6d4636, {
roughness: 0.95
})
);
pore.position.set(-0.55, 1.67, 0.64);
sweatGroup.add(pore);
const dropletProfile = [
new THREE.Vector2(0.0, -0.12),
new THREE.Vector2(0.055, -0.10),
new THREE.Vector2(0.095, -0.035),
new THREE.Vector2(0.102, 0.04),
new THREE.Vector2(0.075, 0.105),
new THREE.Vector2(0.032, 0.15),
new THREE.Vector2(0.0, 0.175)
];
const dropletGeometry = new THREE.LatheGeometry(dropletProfile, 20);
for (let i = 0; i < 5; i += 1) {
const material = makeStandard(0x8cecff, {
emissive: 0x1386a0,
emissiveIntensity: 0.78,
roughness: 0.18,
transparent: true,
opacity: 0.95,
depthWrite: false
});
const droplet = new THREE.Mesh(dropletGeometry, material);
droplet.position.set(-0.55, 1.78 + i * 0.11, 0.64);
droplet.renderOrder = 7;
droplet.userData.seed = i;
sweatGroup.add(droplet);
animatedDroplets.push(droplet);
}
const evaporationArrowData = [
{
points: [
[-0.15, 1.69, 0.36],
[-0.08, 2.18, 0.23],
[0.02, 2.91, 0.13]
]
},
{
points: [
[0.54, 1.69, 0.35],
[0.66, 2.25, 0.22],
[0.76, 2.95, 0.12]
]
},
{
points: [
[1.20, 1.69, 0.34],
[1.30, 2.16, 0.21],
[1.36, 2.70, 0.10]
]
}
];
evaporationArrowData.forEach((data, index) => {
evaporationArrows.push(
createCurvedArrow(
sweatGroup,
data.points,
palette.cyan,
0.22 + index * 0.025
)
);
});
const vaporCount = 42;
const vaporPositions = new Float32Array(vaporCount * 3);
const vaporGeometry = new THREE.BufferGeometry();
vaporGeometry.setAttribute(
"position",
new THREE.BufferAttribute(vaporPositions, 3)
);
for (let i = 0; i < vaporCount; i += 1) {
vaporSeeds.push({
phase: Math.random(),
x: Math.random(),
z: Math.random()
});
}
const vapor = new THREE.Points(
vaporGeometry,
new THREE.PointsMaterial({
color: 0xa7f2ff,
size: 0.055,
transparent: true,
opacity: 0.7,
depthWrite: false,
blending: THREE.AdditiveBlending,
toneMapped: false
})
);
vapor.frustumCulled = false;
sweatGroup.add(vapor);
const sweatAnchor = createAnchor(sweatGroup, -0.55, 1.69, 1.18);
const vaporAnchor = createAnchor(sweatGroup, 0.74, 2.75, 0.2);
registerLabel("sweatLabel", sweatAnchor, -32, 2);
registerLabel("vaporLabel", vaporAnchor, 34, -6);
// ---- Right panel: tapered vessel and qualitative heat transfer -----------
const bloodGroup = bloodPanel.group;
const vesselCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.22, 0.08, 0.75),
new THREE.Vector3(-0.34, 0.50, 0.76),
new THREE.Vector3(-0.27, 0.91, 0.77),
new THREE.Vector3(0.00, 1.28, 0.77),
new THREE.Vector3(0.14, 1.64, 0.73)
]);
function createTaperedTubeGeometry(
curve,
radiusStart,
radiusEnd,
tubularSegments = 72,
radialSegments = 16
) {
const frames = curve.computeFrenetFrames(
tubularSegments,
false
);
const vertices = [];
const normals = [];
const uvs = [];
const indices = [];
const center = new THREE.Vector3();
const radial = new THREE.Vector3();
for (let i = 0; i <= tubularSegments; i += 1) {
const t = i / tubularSegments;
const radius = THREE.MathUtils.lerp(
radiusStart,
radiusEnd,
t
);
curve.getPointAt(t, center);
for (let j = 0; j <= radialSegments; j += 1) {
const angle = (j / radialSegments) * Math.PI * 2;
const cosine = Math.cos(angle);
const sine = Math.sin(angle);
radial
.copy(frames.normals[i])
.multiplyScalar(cosine)
.addScaledVector(frames.binormals[i], sine)
.normalize();
vertices.push(
center.x + radial.x * radius,
center.y + radial.y * radius,
center.z + radial.z * radius
);
normals.push(radial.x, radial.y, radial.z);
uvs.push(j / radialSegments, t);
}
}
for (let i = 0; i < tubularSegments; i += 1) {
for (let j = 0; j < radialSegments; j += 1) {
const a = (radialSegments + 1) * i + j;
const b = (radialSegments + 1) * (i + 1) + j;
const c = (radialSegments + 1) * (i + 1) + j + 1;
const d = (radialSegments + 1) * i + j + 1;
indices.push(a, d, b, b, d, c);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices, 3)
);
geometry.setAttribute(
"normal",
new THREE.Float32BufferAttribute(normals, 3)
);
geometry.setAttribute(
"uv",
new THREE.Float32BufferAttribute(uvs, 2)
);
geometry.setIndex(indices);
geometry.computeBoundingSphere();
return geometry;
}
const vesselWall = new THREE.Mesh(
createTaperedTubeGeometry(vesselCurve, 0.075, 0.235),
makeStandard(0xcf3156, {
emissive: 0x4b0718,
emissiveIntensity: 0.42,
roughness: 0.36
})
);
vesselWall.castShadow = true;
bloodGroup.add(vesselWall);
const vesselCore = new THREE.Mesh(
createTaperedTubeGeometry(vesselCurve, 0.042, 0.132),
makeStandard(0xff6178, {
emissive: 0x8a102d,
emissiveIntensity: 0.74,
roughness: 0.3
})
);
bloodGroup.add(vesselCore);
function addVesselRing(t, color) {
const point = vesselCurve.getPointAt(t);
const tangent = vesselCurve.getTangentAt(t).normalize();
const radius = THREE.MathUtils.lerp(0.075, 0.235, t);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(radius + 0.013, 0.012, 8, 36),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.72,
toneMapped: false
})
);
ring.position.copy(point);
ring.quaternion.setFromUnitVectors(forward, tangent);
bloodGroup.add(ring);
}
addVesselRing(0.2, 0xff9aae);
addVesselRing(0.84, 0xff9aae);
// A dashed depth guide visually compares the two relative diameters.
const guideGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-0.91, 0.47, 0.98),
new THREE.Vector3(-0.61, 1.43, 0.98)
]);
const guide = new THREE.Line(
guideGeometry,
new THREE.LineDashedMaterial({
color: 0xffa2b3,
transparent: true,
opacity: 0.42,
dashSize: 0.06,
gapSize: 0.05
})
);
guide.computeLineDistances();
bloodGroup.add(guide);
const flowMaterial = new THREE.MeshBasicMaterial({
color: palette.amber,
transparent: true,
opacity: 0.94,
depthTest: false,
depthWrite: false,
toneMapped: false
});
for (let i = 0; i < 5; i += 1) {
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.068, 0.18, 12),
flowMaterial
);
arrow.renderOrder = 12;
arrow.userData.offset = i / 5;
bloodGroup.add(arrow);
flowArrows.push(arrow);
}
const heatArrow = createCurvedArrow(
bloodGroup,
[
[0.02, 1.08, 0.92],
[0.10, 1.53, 0.80],
[0.34, 2.30, 0.58]
],
palette.amber,
0.28
);
const narrowAnchor = createAnchor(bloodGroup, -0.29, 0.52, 1.03);
const wideAnchor = createAnchor(bloodGroup, 0.02, 1.40, 1.03);
const heatAnchor = createAnchor(bloodGroup, 0.33, 2.19, 0.65);
registerLabel("narrowLabel", narrowAnchor, -48, 6);
registerLabel("wideLabel", wideAnchor, 52, 0);
registerLabel("heatLabel", heatAnchor, 42, -4);
// ---- Direct camera controls --------------------------------------------
const controls = {
target: new THREE.Vector3(0, 1.12, 0),
yaw: 0.18,
pitch: 0.48,
zoom: 1,
desiredYaw: 0.18,
desiredPitch: 0.48,
desiredZoom: 1,
responsiveRadius: 12.2
};
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
camera.aspect = aspect;
camera.updateProjectionMatrix();
// Maintain both panels in view on narrow displays.
controls.responsiveRadius = Math.max(
12.2,
13.5 / Math.max(aspect, 0.42)
);
}
window.addEventListener("resize", resize);
resize();
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.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
controls.desiredYaw -= dx * 0.006;
controls.desiredPitch = THREE.MathUtils.clamp(
controls.desiredPitch + dy * 0.0045,
0.18,
1.05
);
});
function endDrag(event) {
dragging = false;
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(
"wheel",
(event) => {
event.preventDefault();
controls.desiredZoom = THREE.MathUtils.clamp(
controls.desiredZoom * Math.exp(event.deltaY * 0.001),
0.65,
1.65
);
},
{ passive: false }
);
function resetView() {
controls.desiredYaw = 0.18;
controls.desiredPitch = 0.48;
controls.desiredZoom = 1;
}
document.getElementById("resetButton").addEventListener(
"click",
resetView
);
renderer.domElement.addEventListener("dblclick", resetView);
window.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "r") {
resetView();
} else if (event.key === "ArrowLeft") {
controls.desiredYaw += 0.08;
} else if (event.key === "ArrowRight") {
controls.desiredYaw -= 0.08;
} else if (event.key === "ArrowUp") {
controls.desiredPitch = THREE.MathUtils.clamp(
controls.desiredPitch + 0.05,
0.18,
1.05
);
} else if (event.key === "ArrowDown") {
controls.desiredPitch = THREE.MathUtils.clamp(
controls.desiredPitch - 0.05,
0.18,
1.05
);
} else if (key === "+" || key === "=") {
controls.desiredZoom = Math.max(
0.65,
controls.desiredZoom * 0.9
);
} else if (key === "-") {
controls.desiredZoom = Math.min(
1.65,
controls.desiredZoom * 1.1
);
}
});
const motionButton = document.getElementById("motionButton");
const labelsButton = document.getElementById("labelsButton");
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
let motionEnabled = !reducedMotion;
let motionTime = 0;
function updateMotionButton() {
motionButton.textContent = motionEnabled
? "Pause motion"
: "Resume motion";
motionButton.setAttribute(
"aria-pressed",
String(motionEnabled)
);
}
motionButton.addEventListener("click", () => {
motionEnabled = !motionEnabled;
updateMotionButton();
});
updateMotionButton();
labelsButton.addEventListener("click", () => {
const enabled = !document.body.classList.contains("labels-off");
document.body.classList.toggle("labels-off", enabled);
labelsButton.setAttribute("aria-pressed", String(!enabled));
});
// ---- Animation ----------------------------------------------------------
const clock = new THREE.Clock();
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
label.object.getWorldPosition(projected);
projected.project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
label.element.style.opacity = visible ? "1" : "0";
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.element.style.left = `${x + label.offsetX}px`;
label.element.style.top = `${y + label.offsetY}px`;
}
}
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (motionEnabled) {
motionTime += delta;
}
const damping = 1 - Math.exp(-8 * delta);
controls.yaw = THREE.MathUtils.lerp(
controls.yaw,
controls.desiredYaw,
damping
);
controls.pitch = THREE.MathUtils.lerp(
controls.pitch,
controls.desiredPitch,
damping
);
controls.zoom = THREE.MathUtils.lerp(
controls.zoom,
controls.desiredZoom,
damping
);
const radius = controls.responsiveRadius * controls.zoom;
const horizontal = Math.cos(controls.pitch) * radius;
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * horizontal,
controls.target.y + Math.sin(controls.pitch) * radius,
controls.target.z + Math.cos(controls.yaw) * horizontal
);
camera.lookAt(controls.target);
// Droplets rise from the pore and fade as they become vapor.
animatedDroplets.forEach((droplet, index) => {
const progress =
(motionTime * 0.19 + index * 0.18) % 1;
droplet.position.y = 1.72 + progress * 0.9;
droplet.position.x =
-0.55 + Math.sin(index * 2.1) * 0.075;
droplet.scale.setScalar(
0.92 - progress * 0.18
);
droplet.material.opacity =
progress > 0.62
? Math.max(0, 1 - (progress - 0.62) / 0.38)
: 0.96;
});
// Moving highlights communicate qualitative direction only.
evaporationArrows.forEach((arrow, index) => {
const t =
(motionTime * arrow.speed + index * 0.21) % 1;
arrow.dash.position.copy(arrow.curve.getPointAt(t));
});
// Vapor particles drift upward and spread.
const positionAttribute = vaporGeometry.getAttribute("position");
vaporSeeds.forEach((seed, index) => {
const progress = (motionTime * 0.17 + seed.phase) % 1;
const spread = 0.15 + progress * 0.8;
positionAttribute.setXYZ(
index,
-0.55 + (seed.x - 0.5) * spread,
1.77 + progress * 1.48,
0.64 + (seed.z - 0.5) * 0.35
);
});
positionAttribute.needsUpdate = true;
// Flow chevrons travel from the deeper vessel toward the surface.
flowArrows.forEach((arrow) => {
const t =
(motionTime * 0.13 + arrow.userData.offset) % 1;
const point = vesselCurve.getPointAt(t);
const tangent = vesselCurve.getTangentAt(t).normalize();
arrow.position.copy(point);
arrow.quaternion.setFromUnitVectors(up, tangent);
});
const heatProgress = (motionTime * heatArrow.speed) % 1;
heatArrow.dash.position.copy(
heatArrow.curve.getPointAt(heatProgress)
);
scene.updateMatrixWorld(true);
updateLabels();
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```