Prompt specification
Build or customize the Three.js 3D scene "Outdoor clothing material 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: Outdoor clothing material exhibit
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/outdoor-clothing-material-exhibit-x0612
Scene Description Prompt:
A low-poly layered-rainwear exhibit with rain and airflow controls revealing qualitative moisture pathways. Build one HTML file using Three.js from cdnjs.
Working Three.js Starter (outdoor-clothing-material-exhibit-x0612):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rainwear Unpacked — Moisture Pathway Exhibit</title>
<style>
:root {
color-scheme: dark;
--bg: #071218;
--panel: rgba(11, 25, 32, 0.82);
--line: rgba(188, 225, 235, 0.15);
--text: #edf7f8;
--muted: #93aeb7;
--cyan: #72ddff;
--violet: #bda1ff;
--amber: #ffc466;
--orange: #f47a43;
--teal: #32c8b0;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 47% 35%, #17313b 0%, #09161d 43%, #050d12 100%);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-block {
position: absolute;
top: 30px;
left: 34px;
max-width: 430px;
text-shadow: 0 2px 22px rgba(0, 0, 0, 0.45);
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
color: var(--cyan);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 28px;
height: 1px;
background: currentColor;
}
h1 {
margin: 0;
font-size: clamp(30px, 4vw, 54px);
font-weight: 620;
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
max-width: 360px;
margin: 14px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.panel {
position: absolute;
top: 24px;
right: 24px;
width: 318px;
padding: 20px;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow:
0 24px 70px rgba(0, 0, 0, 0.36),
inset 0 1px 0 rgba(255, 255, 255, 0.05);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
pointer-events: auto;
}
.panel::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 2px;
background: linear-gradient(transparent, var(--cyan), transparent);
opacity: 0.7;
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 22px;
}
.panel-heading h2 {
margin: 0;
font-size: 12px;
font-weight: 760;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.live-badge {
display: flex;
align-items: center;
gap: 7px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.live-badge::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: #55e2ad;
box-shadow: 0 0 12px #55e2ad;
animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
50% { opacity: 0.45; }
}
.control {
margin-bottom: 22px;
}
.control-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
}
.control label {
color: #d7e7ea;
font-size: 11px;
font-weight: 760;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.value {
color: var(--cyan);
font-size: 12px;
font-variant-numeric: tabular-nums;
font-weight: 720;
}
.range-note {
display: flex;
justify-content: space-between;
margin-top: 7px;
color: #718b94;
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 5px 0 0;
border-radius: 10px;
outline: none;
appearance: none;
-webkit-appearance: none;
background: linear-gradient(
to right,
var(--cyan) 0%,
var(--cyan) var(--fill, 50%),
rgba(255, 255, 255, 0.12) var(--fill, 50%),
rgba(255, 255, 255, 0.12) 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 16px;
height: 16px;
border: 3px solid #dff8ff;
border-radius: 50%;
appearance: none;
-webkit-appearance: none;
background: #14323e;
box-shadow: 0 0 0 4px rgba(114, 221, 255, 0.1);
}
input[type="range"]::-moz-range-thumb {
width: 12px;
height: 12px;
border: 3px solid #dff8ff;
border-radius: 50%;
background: #14323e;
box-shadow: 0 0 0 4px rgba(114, 221, 255, 0.1);
}
.divider {
height: 1px;
margin: 19px 0;
background: var(--line);
}
.section-label {
margin-bottom: 10px;
color: #829da5;
font-size: 9px;
font-weight: 740;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.layer-grid {
display: grid;
gap: 7px;
}
.layer-button {
display: grid;
grid-template-columns: 10px 1fr auto;
align-items: center;
gap: 10px;
width: 100%;
padding: 10px 11px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 10px;
background: rgba(255, 255, 255, 0.035);
color: inherit;
text-align: left;
cursor: pointer;
transition: 160ms ease;
}
.layer-button:hover,
.layer-button.active {
border-color: rgba(114, 221, 255, 0.34);
background: rgba(114, 221, 255, 0.08);
}
.swatch {
width: 8px;
height: 8px;
border-radius: 50%;
box-shadow: 0 0 12px currentColor;
}
.layer-name {
font-size: 11px;
font-weight: 700;
}
.layer-state {
color: #78929a;
font-size: 9px;
text-align: right;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
margin: 16px 0;
color: #c4d7dc;
font-size: 11px;
font-weight: 650;
}
.toggle {
position: relative;
width: 39px;
height: 22px;
padding: 0;
border: 0;
border-radius: 20px;
background: #31454d;
cursor: pointer;
transition: 180ms ease;
}
.toggle::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 16px;
height: 16px;
border-radius: 50%;
background: #d4e1e4;
transition: 180ms ease;
}
.toggle[aria-checked="true"] {
background: #2b8499;
}
.toggle[aria-checked="true"]::after {
left: 20px;
background: #e7fbff;
}
.presets {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
}
.preset {
padding: 8px 4px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
background: rgba(255, 255, 255, 0.035);
color: #9eb5bb;
font: inherit;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
transition: 150ms ease;
}
.preset:hover {
border-color: rgba(114, 221, 255, 0.4);
color: var(--cyan);
background: rgba(114, 221, 255, 0.07);
}
.legend {
position: absolute;
left: 34px;
bottom: 31px;
display: grid;
gap: 9px;
padding: 13px 15px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(8, 19, 25, 0.62);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.legend-item {
display: flex;
align-items: center;
gap: 9px;
color: #a9c0c6;
font-size: 10px;
letter-spacing: 0.025em;
}
.legend-line {
width: 18px;
height: 2px;
border-radius: 2px;
box-shadow: 0 0 9px currentColor;
}
.status-card {
position: absolute;
left: 50%;
bottom: 30px;
width: min(470px, calc(100vw - 40px));
padding: 13px 18px;
transform: translateX(-50%);
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(8, 19, 25, 0.74);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.status-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
}
.status-label {
color: var(--cyan);
font-size: 9px;
font-weight: 780;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.status-state {
color: #728b93;
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.status-text {
margin-top: 5px;
color: #e1eef0;
font-size: 12px;
line-height: 1.4;
}
.hint {
position: absolute;
right: 31px;
bottom: 31px;
color: #607981;
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 820px) {
.title-block {
top: 18px;
left: 20px;
}
.subtitle {
display: none;
}
.panel {
top: auto;
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
max-height: 47vh;
overflow-y: auto;
padding: 15px;
}
.panel-heading {
margin-bottom: 14px;
}
.control {
margin-bottom: 15px;
}
.legend {
top: 105px;
bottom: auto;
left: 20px;
padding: 10px 12px;
}
.status-card,
.hint {
display: none;
}
}
@media (max-height: 700px) and (min-width: 821px) {
.panel {
top: 12px;
right: 12px;
max-height: calc(100vh - 24px);
overflow-y: auto;
}
.legend {
bottom: 18px;
}
.status-card {
bottom: 18px;
}
}
</style>
</head>
<body>
<div class="hud">
<header class="title-block">
<div class="eyebrow">Material Lab / Exhibit 03</div>
<h1>Rainwear,<br />unpacked.</h1>
<p class="subtitle">
An interactive study of liquid, vapor, and condensation moving through
three protective layers.
</p>
</header>
<section class="panel" aria-label="Exhibit controls">
<div class="panel-heading">
<h2>Environment</h2>
<div class="live-badge">Simulation live</div>
</div>
<div class="control">
<div class="control-row">
<label for="rain">Rainfall</label>
<output id="rainValue" class="value">68%</output>
</div>
<input id="rain" type="range" min="0" max="100" value="68" />
<div class="range-note"><span>Dry</span><span>Steady</span><span>Heavy</span></div>
</div>
<div class="control">
<div class="control-row">
<label for="air">Airflow</label>
<output id="airValue" class="value">42%</output>
</div>
<input id="air" type="range" min="0" max="100" value="42" />
<div class="range-note"><span>Still</span><span>Cross-draft</span><span>Strong</span></div>
</div>
<div class="control">
<div class="control-row">
<label for="split">Layer separation</label>
<output id="splitValue" class="value">0%</output>
</div>
<input id="split" type="range" min="0" max="100" value="0" />
<div class="range-note"><span>Worn</span><span>Exploded</span></div>
</div>
<div class="divider"></div>
<div class="section-label">Inspect a layer</div>
<div class="layer-grid">
<button class="layer-button" data-layer="outer" type="button">
<span class="swatch" style="color:#f47a43;background:#f47a43"></span>
<span class="layer-name">01 / Outer shell</span>
<span id="outerState" class="layer-state">Beading</span>
</button>
<button class="layer-button" data-layer="middle" type="button">
<span class="swatch" style="color:#32c8b0;background:#32c8b0"></span>
<span class="layer-name">02 / Mid-layer</span>
<span id="middleState" class="layer-state">Transport</span>
</button>
<button class="layer-button" data-layer="base" type="button">
<span class="swatch" style="color:#d8e7ed;background:#d8e7ed"></span>
<span class="layer-name">03 / Base layer</span>
<span id="baseState" class="layer-state">Dry</span>
</button>
</div>
<div class="toggle-row">
<span>Moisture pathways</span>
<button
id="pathToggle"
class="toggle"
type="button"
role="switch"
aria-checked="true"
aria-label="Toggle moisture pathways"
></button>
</div>
<div class="section-label">Test presets</div>
<div class="presets">
<button class="preset" data-preset="dry" type="button">Dry</button>
<button class="preset" data-preset="steady" type="button">Commute</button>
<button class="preset" data-preset="storm" type="button">Storm</button>
</div>
</section>
<aside class="legend" aria-label="Moisture pathway legend">
<div class="legend-item">
<span class="legend-line" style="color:#72ddff;background:#72ddff"></span>
Liquid beading and runoff
</div>
<div class="legend-item">
<span class="legend-line" style="color:#bda1ff;background:#bda1ff"></span>
Vapor transport
</div>
<div class="legend-item">
<span class="legend-line" style="color:#ffc466;background:#ffc466"></span>
Condensation at base layer
</div>
</aside>
<div class="status-card" aria-live="polite">
<div class="status-top">
<span class="status-label">Observed pathway</span>
<span class="status-state">Qualitative model</span>
</div>
<div id="statusText" class="status-text">
Liquid beads on the shell, then moves inward as vapor.
</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (id) => document.getElementById(id);
const state = {
rain: 0.68,
air: 0.42,
split: 0,
paths: true,
focus: "all"
};
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071218);
scene.fog = new THREE.Fog(0x071218, 10, 22);
const camera = new THREE.PerspectiveCamera(
34,
innerWidth / innerHeight,
0.1,
50
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional layered rainwear exhibit"
);
document.body.prepend(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xbceeff, 0x18232a, 1.8);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.2);
keyLight.position.set(4.5, 7.5, 5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -2;
keyLight.shadow.bias = -0.0003;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x58cfff, 2.2);
rimLight.position.set(-4, 4, -3);
scene.add(rimLight);
const warmFill = new THREE.PointLight(0xff9d62, 16, 9, 2);
warmFill.position.set(3, 2.6, 3);
scene.add(warmFill);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x071116,
roughness: 0.95,
metalness: 0.02
});
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.1;
floor.receiveShadow = true;
scene.add(floor);
const platformMaterial = new THREE.MeshStandardMaterial({
color: 0x12232a,
roughness: 0.72,
metalness: 0.2,
flatShading: true
});
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(2.55, 2.72, 0.16, 48),
platformMaterial
);
platform.position.y = 0;
platform.receiveShadow = true;
scene.add(platform);
const grid = new THREE.GridHelper(5.2, 26, 0x5db1c6, 0x193740);
grid.position.y = 0.087;
grid.material.transparent = true;
grid.material.opacity = 0.3;
scene.add(grid);
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0x4aaec4,
transparent: true,
opacity: 0.16
});
for (const radius of [1.9, 2.28]) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(radius, 0.008, 4, 96),
ringMaterial
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.095;
scene.add(ring);
}
const outerMaterial = new THREE.MeshStandardMaterial({
color: 0xf16d38,
roughness: 0.62,
metalness: 0.02,
flatShading: true
});
const middleMaterial = new THREE.MeshStandardMaterial({
color: 0x24b9a6,
roughness: 0.92,
metalness: 0,
flatShading: true
});
const baseMaterial = new THREE.MeshStandardMaterial({
color: 0xcbdce4,
roughness: 0.95,
metalness: 0,
flatShading: true
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x15242b,
roughness: 0.82,
metalness: 0.12,
flatShading: true
});
const mannequinMaterial = new THREE.MeshStandardMaterial({
color: 0x81939a,
roughness: 0.9,
metalness: 0,
flatShading: true
});
const headMaterial = new THREE.MeshStandardMaterial({
color: 0xc6d1d1,
roughness: 0.88,
flatShading: true
});
function addMesh(parent, geometry, material, position = [0, 0, 0]) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addSleeve(parent, material, start, end, radius) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const length = direction.length();
const sleeve = addMesh(
parent,
new THREE.CylinderGeometry(
radius * 0.9,
radius,
length,
8,
1,
false
),
material
);
sleeve.position.copy(a).add(b).multiplyScalar(0.5);
sleeve.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return sleeve;
}
// Central abstract mannequin.
const mannequin = new THREE.Group();
scene.add(mannequin);
addMesh(
mannequin,
new THREE.CylinderGeometry(0.36, 0.43, 0.42, 8),
mannequinMaterial,
[0, 1.2, 0]
);
addSleeve(
mannequin,
mannequinMaterial,
[-0.19, 1.08, 0],
[-0.25, 0.3, 0.02],
0.14
);
addSleeve(
mannequin,
mannequinMaterial,
[0.19, 1.08, 0],
[0.25, 0.3, 0.02],
0.14
);
for (const side of [-1, 1]) {
addMesh(
mannequin,
new THREE.BoxGeometry(0.32, 0.18, 0.48),
darkMaterial,
[side * 0.25, 0.19, 0.1]
);
}
addMesh(
mannequin,
new THREE.CylinderGeometry(0.13, 0.15, 0.35, 8),
mannequinMaterial,
[0, 3.08, 0]
);
addMesh(
mannequin,
new THREE.IcosahedronGeometry(0.275, 1),
headMaterial,
[0, 3.48, 0.08]
);
// Three independently movable garment layers.
const outerLayer = new THREE.Group();
const middleLayer = new THREE.Group();
const baseLayer = new THREE.Group();
scene.add(outerLayer, middleLayer, baseLayer);
const outerTorso = addMesh(
outerLayer,
new THREE.CylinderGeometry(0.61, 0.72, 1.43, 10),
outerMaterial,
[0, 2.18, 0]
);
outerTorso.scale.z = 0.67;
addSleeve(
outerLayer,
outerMaterial,
[-0.56, 2.73, 0],
[-0.93, 1.55, 0.08],
0.18
);
addSleeve(
outerLayer,
outerMaterial,
[0.56, 2.73, 0],
[0.93, 1.55, 0.08],
0.18
);
const collar = addMesh(
outerLayer,
new THREE.TorusGeometry(0.27, 0.085, 6, 12),
outerMaterial,
[0, 2.96, 0]
);
collar.rotation.x = Math.PI / 2;
const hood = addMesh(
outerLayer,
new THREE.SphereGeometry(0.5, 10, 7),
outerMaterial,
[0, 3.48, -0.22]
);
hood.scale.set(0.92, 1.05, 0.7);
const hoodInside = addMesh(
outerLayer,
new THREE.IcosahedronGeometry(0.34, 1),
darkMaterial,
[0, 3.46, -0.08]
);
hoodInside.scale.set(0.9, 1, 0.48);
addMesh(
outerLayer,
new THREE.BoxGeometry(0.028, 1.25, 0.035),
darkMaterial,
[0, 2.19, 0.485]
);
addMesh(
outerLayer,
new THREE.BoxGeometry(0.025, 0.28, 0.025),
darkMaterial,
[-0.35, 2.03, 0.45]
).rotation.z = -0.25;
addMesh(
outerLayer,
new THREE.BoxGeometry(0.025, 0.28, 0.025),
darkMaterial,
[0.35, 2.03, 0.45]
).rotation.z = 0.25;
const hem = addMesh(
outerLayer,
new THREE.CylinderGeometry(0.725, 0.725, 0.1, 10, 1, true),
darkMaterial,
[0, 1.48, 0]
);
hem.scale.z = 0.67;
const reflectiveMaterial = new THREE.MeshStandardMaterial({
color: 0xd8f5f3,
emissive: 0x477a78,
emissiveIntensity: 0.22,
roughness: 0.5,
flatShading: true
});
addMesh(
outerLayer,
new THREE.BoxGeometry(0.52, 0.035, 0.025),
reflectiveMaterial,
[0, 2.52, 0.474]
);
const middleTorso = addMesh(
middleLayer,
new THREE.CylinderGeometry(0.54, 0.64, 1.34, 9),
middleMaterial,
[0, 2.13, 0]
);
middleTorso.scale.z = 0.68;
addSleeve(
middleLayer,
middleMaterial,
[-0.51, 2.7, -0.01],
[-0.78, 1.87, 0.04],
0.15
);
addSleeve(
middleLayer,
middleMaterial,
[0.51, 2.7, -0.01],
[0.78, 1.87, 0.04],
0.15
);
const quiltMaterial = new THREE.MeshStandardMaterial({
color: 0x138b7f,
roughness: 0.95,
flatShading: true
});
for (const y of [1.72, 2.12, 2.52]) {
const seam = addMesh(
middleLayer,
new THREE.TorusGeometry(0.58, 0.013, 4, 18),
quiltMaterial,
[0, y, 0]
);
seam.rotation.x = Math.PI / 2;
seam.scale.z = 0.68;
}
const baseTorso = addMesh(
baseLayer,
new THREE.CylinderGeometry(0.49, 0.59, 1.25, 8),
baseMaterial,
[0, 2.06, 0]
);
baseTorso.scale.z = 0.7;
addSleeve(
baseLayer,
baseMaterial,
[-0.47, 2.61, 0],
[-0.68, 2.08, 0.03],
0.135
);
addSleeve(
baseLayer,
baseMaterial,
[0.47, 2.61, 0],
[0.68, 2.08, 0.03],
0.135
);
const baseCollar = addMesh(
baseLayer,
new THREE.TorusGeometry(0.23, 0.055, 5, 12),
baseMaterial,
[0, 2.75, 0]
);
baseCollar.rotation.x = Math.PI / 2;
// Liquid beading and runoff on the outer shell.
const beadMaterial = new THREE.MeshStandardMaterial({
color: 0x7fe6ff,
emissive: 0x0a7892,
emissiveIntensity: 0.65,
roughness: 0.15,
metalness: 0.05,
transparent: true,
opacity: 0.8
});
const beadData = [];
const beadMesh = new THREE.InstancedMesh(
new THREE.IcosahedronGeometry(0.024, 0),
beadMaterial,
36
);
beadMesh.frustumCulled = false;
outerLayer.add(beadMesh);
for (let i = 0; i < 36; i++) {
const y = 1.58 + Math.random() * 1.19;
const theta = -1.13 + Math.random() * 2.26;
const radius = THREE.MathUtils.lerp(0.72, 0.61, (y - 1.45) / 1.45);
beadData.push({
x: Math.cos(theta) * radius,
y,
z: Math.sin(theta) * radius * 0.68,
phase: Math.random() * Math.PI * 2
});
}
const runoffMaterial = new THREE.LineBasicMaterial({
color: 0x72ddff,
transparent: true,
opacity: 0.45,
depthWrite: false
});
for (let j = 0; j < 9; j++) {
const theta = -0.95 + j * 0.235;
const points = [];
for (let i = 0; i < 18; i++) {
const y = THREE.MathUtils.lerp(2.83, 1.52, i / 17);
const radius = THREE.MathUtils.lerp(0.72, 0.61, (y - 1.45) / 1.45);
const drift = Math.sin(i * 0.65 + j) * 0.035;
points.push(
new THREE.Vector3(
Math.cos(theta + drift) * radius,
y,
Math.sin(theta + drift) * radius * 0.68
)
);
}
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
runoffMaterial
);
outerLayer.add(line);
}
// Vapor transport through the middle layer.
const vaporMaterial = new THREE.PointsMaterial({
color: 0xbda1ff,
size: 0.047,
transparent: true,
opacity: 0.75,
depthWrite: false,
blending: THREE.AdditiveBlending
});
const vaporCount = 76;
const vaporPositions = new Float32Array(vaporCount * 3);
const vaporPhases = [];
for (let i = 0; i < vaporCount; i++) {
vaporPhases.push(Math.random());
}
const vaporGeometry = new THREE.BufferGeometry();
vaporGeometry.setAttribute(
"position",
new THREE.BufferAttribute(vaporPositions, 3)
);
const vaporPoints = new THREE.Points(vaporGeometry, vaporMaterial);
middleLayer.add(vaporPoints);
const vaporLineMaterial = new THREE.LineBasicMaterial({
color: 0x9c83e8,
transparent: true,
opacity: 0.15,
depthWrite: false
});
for (let j = 0; j < 3; j++) {
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.48, 1.52 + j * 0.12, 0.43),
new THREE.Vector3(-0.16, 1.95 + j * 0.1, 0.49),
new THREE.Vector3(0.12, 2.38 + j * 0.08, 0.46),
new THREE.Vector3(0.46, 2.8, 0.4)
]);
middleLayer.add(
new THREE.Line(
new THREE.BufferGeometry().setFromPoints(curve.getPoints(45)),
vaporLineMaterial
)
);
}
// Condensation collecting near the base layer's neck and chest.
const condensationMaterial = new THREE.PointsMaterial({
color: 0xffc466,
size: 0.048,
transparent: true,
opacity: 0,
depthWrite: false,
blending: THREE.AdditiveBlending
});
const condensationCount = 42;
const condensationPositions = new Float32Array(condensationCount * 3);
for (let i = 0; i < condensationCount; i++) {
const theta = -1.18 + Math.random() * 2.36;
const radius = 0.49 - Math.random() * 0.06;
const y = 2.35 + Math.random() * 0.42;
condensationPositions[i * 3] = Math.cos(theta) * radius;
condensationPositions[i * 3 + 1] = y;
condensationPositions[i * 3 + 2] = Math.sin(theta) * radius * 0.7;
}
const condensationGeometry = new THREE.BufferGeometry();
condensationGeometry.setAttribute(
"position",
new THREE.BufferAttribute(condensationPositions, 3)
);
const condensationPoints = new THREE.Points(
condensationGeometry,
condensationMaterial
);
baseLayer.add(condensationPoints);
// Rain represented by animated line segments.
const maxDrops = 420;
const rainPositions = new Float32Array(maxDrops * 6);
const rainData = [];
for (let i = 0; i < maxDrops; i++) {
rainData.push({
x: (Math.random() - 0.5) * 4.2,
y: Math.random() * 6.5,
z: (Math.random() - 0.5) * 3.4,
speed: 4.8 + Math.random() * 3.4,
length: 0.13 + Math.random() * 0.2
});
}
const rainGeometry = new THREE.BufferGeometry();
rainGeometry.setAttribute(
"position",
new THREE.BufferAttribute(rainPositions, 3)
);
const rainMaterial = new THREE.LineBasicMaterial({
color: 0x9ce6ff,
transparent: true,
opacity: 0.55,
depthWrite: false
});
const rainLines = new THREE.LineSegments(rainGeometry, rainMaterial);
rainLines.frustumCulled = false;
scene.add(rainLines);
// Airflow streamlines and traveling arrowheads.
const airflowCurves = [];
const airflowGroup = new THREE.Group();
scene.add(airflowGroup);
for (let i = 0; i < 7; i++) {
const y = 1.65 + i * 0.23;
const z = -0.8 + (i % 3) * 0.68;
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-3.4, y, z),
new THREE.Vector3(-2.1, y + 0.1, z * 0.75),
new THREE.Vector3(-0.9, y + 0.05, z * 0.55),
new THREE.Vector3(0.65, y - 0.05, z * 0.6),
new THREE.Vector3(2.1, y + 0.03, z * 0.8),
new THREE.Vector3(3.3, y, z)
]);
airflowCurves.push(curve);
const material = new THREE.LineBasicMaterial({
color: 0x73d9ee,
transparent: true,
opacity: 0.12,
depthWrite: false
});
airflowGroup.add(
new THREE.Line(
new THREE.BufferGeometry().setFromPoints(curve.getPoints(90)),
material
)
);
}
const arrowMaterial = new THREE.MeshBasicMaterial({
color: 0x9beaf7,
transparent: true,
opacity: 0.8
});
const arrowGeometry = new THREE.ConeGeometry(0.035, 0.14, 5);
const arrows = [];
for (let i = 0; i < 18; i++) {
const arrow = new THREE.Mesh(arrowGeometry, arrowMaterial);
arrow.userData.curve = airflowCurves[i % airflowCurves.length];
arrow.userData.phase = Math.random();
airflowGroup.add(arrow);
arrows.push(arrow);
}
// Custom orbit controls, implemented without external addons.
const orbit = {
azimuth: 0.53,
elevation: 0.18,
radius: 6.3,
targetRadius: 6.3,
targetX: 0,
dragging: false,
pointerX: 0,
pointerY: 0
};
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
orbit.dragging = true;
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!orbit.dragging) return;
const dx = event.clientX - orbit.pointerX;
const dy = event.clientY - orbit.pointerY;
orbit.azimuth -= dx * 0.005;
orbit.elevation = THREE.MathUtils.clamp(
orbit.elevation + dy * 0.0035,
-0.08,
0.62
);
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
});
function endDrag(event) {
orbit.dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.targetRadius = THREE.MathUtils.clamp(
orbit.targetRadius + event.deltaY * 0.005,
4.2,
9.2
);
},
{ passive: false }
);
function resetCamera() {
orbit.azimuth = 0.53;
orbit.elevation = 0.18;
orbit.targetRadius = 6.3;
orbit.targetX = 0;
state.focus = "all";
updateFocus();
}
canvas.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") orbit.azimuth -= 0.1;
if (event.key === "ArrowRight") orbit.azimuth += 0.1;
if (event.key === "ArrowUp") orbit.elevation += 0.05;
if (event.key === "ArrowDown") orbit.elevation -= 0.05;
if (event.key === "Escape") resetCamera();
});
function updateSliderFill(input) {
const percent =
((input.value - input.min) / (input.max - input.min)) * 100;
input.style.setProperty("--fill", `${percent}%`);
}
function updateFocus() {
outerMaterial.emissive.setHex(0x000000);
middleMaterial.emissive.setHex(0x000000);
baseMaterial.emissive.setHex(0x000000);
outerMaterial.emissiveIntensity = 0;
middleMaterial.emissiveIntensity = 0;
baseMaterial.emissiveIntensity = 0;
if (state.focus === "outer") {
outerMaterial.emissive.setHex(0x7a2c0c);
outerMaterial.emissiveIntensity = 0.45;
}
if (state.focus === "middle") {
middleMaterial.emissive.setHex(0x075f54);
middleMaterial.emissiveIntensity = 0.5;
}
if (state.focus === "base") {
baseMaterial.emissive.setHex(0x355767);
baseMaterial.emissiveIntensity = 0.38;
}
document.querySelectorAll(".layer-button").forEach((button) => {
button.classList.toggle(
"active",
button.dataset.layer === state.focus
);
});
}
function updateStatus() {
const condensation = THREE.MathUtils.clamp(
state.rain * (1 - state.air * 0.6),
0,
1
);
$("outerState").textContent =
state.rain < 0.05 ? "Dry" :
state.rain > 0.7 ? "Heavy beading" : "Beading";
$("middleState").textContent =
state.rain < 0.12 ? "Mostly dry" :
state.air > 0.65 ? "Fast transport" : "Moisture wicking";
$("baseState").textContent =
condensation > 0.55 ? "Condensation" : "Comfortably dry";
if (state.rain < 0.08) {
$("statusText").textContent =
"The shell remains dry; no meaningful moisture transport is visible.";
} else if (state.air > 0.72) {
$("statusText").textContent =
"Strong cross-flow moves vapor away from the body and limits base-layer condensation.";
} else if (condensation > 0.55) {
$("statusText").textContent =
"Moisture reaches the base layer and collects near the neckline as condensation.";
} else {
$("statusText").textContent =
"Liquid beads and runs on the shell, then moves inward as vapor through the mid-layer.";
}
}
function syncControls() {
$("rain").value = Math.round(state.rain * 100);
$("air").value = Math.round(state.air * 100);
$("split").value = Math.round(state.split * 100);
$("rainValue").textContent = `${Math.round(state.rain * 100)}%`;
$("airValue").textContent = `${Math.round(state.air * 100)}%`;
$("splitValue").textContent = `${Math.round(state.split * 100)}%`;
updateSliderFill($("rain"));
updateSliderFill($("air"));
updateSliderFill($("split"));
updateStatus();
}
$("rain").addEventListener("input", (event) => {
state.rain = Number(event.target.value) / 100;
syncControls();
});
$("air").addEventListener("input", (event) => {
state.air = Number(event.target.value) / 100;
syncControls();
});
$("split").addEventListener("input", (event) => {
state.split = Number(event.target.value) / 100;
state.focus = "all";
orbit.targetX = 0;
updateFocus();
syncControls();
});
$("pathToggle").addEventListener("click", () => {
state.paths = !state.paths;
$("pathToggle").setAttribute("aria-checked", String(state.paths));
});
document.querySelectorAll(".layer-button").forEach((button) => {
button.addEventListener("click", () => {
const layer = button.dataset.layer;
state.split = 0.78;
state.focus = layer;
orbit.targetX =
layer === "outer" ? -0.56 :
layer === "base" ? 0.56 : 0;
orbit.targetRadius = layer === "middle" ? 5.7 : 6.3;
updateFocus();
syncControls();
});
});
document.querySelectorAll(".preset").forEach((button) => {
button.addEventListener("click", () => {
const preset = button.dataset.preset;
if (preset === "dry") {
state.rain = 0;
state.air = 0.15;
state.split = 0;
} else if (preset === "steady") {
state.rain = 0.55;
state.air = 0.35;
state.split = 0.28;
} else {
state.rain = 0.92;
state.air = 0.72;
state.split = 0.72;
}
state.focus = "all";
orbit.targetX = 0;
updateFocus();
syncControls();
});
});
const dummy = new THREE.Object3D();
const clock = new THREE.Clock();
let elapsed = 0;
function updateCamera(dt) {
const smoothing = 1 - Math.exp(-dt * 8);
orbit.azimuth += (orbit.azimuth - orbit.azimuth) * smoothing;
orbit.elevation += (orbit.elevation - orbit.elevation) * smoothing;
orbit.radius += (orbit.targetRadius - orbit.radius) * smoothing;
const target = new THREE.Vector3(orbit.targetX, 2.08, 0);
const horizontal = Math.cos(orbit.elevation) * orbit.radius;
const desiredPosition = new THREE.Vector3(
target.x + Math.sin(orbit.azimuth) * horizontal,
target.y + Math.sin(orbit.elevation) * orbit.radius,
target.z + Math.cos(orbit.azimuth) * horizontal
);
camera.position.lerp(desiredPosition, smoothing);
camera.lookAt(target);
}
function updateRain(dt) {
const visibleCount = Math.floor(maxDrops * state.rain);
const centerX = outerLayer.position.x;
rainLines.visible = visibleCount > 0;
rainMaterial.opacity = 0.12 + state.rain * 0.56;
for (let i = 0; i < visibleCount; i++) {
const drop = rainData[i];
drop.y -= drop.speed * dt * (0.7 + state.rain * 0.55);
drop.x += state.air * 0.22 * dt;
const hitsOuter =
drop.y < 2.98 &&
drop.y > 1.43 &&
Math.abs(drop.x - centerX) < 0.67 &&
Math.abs(drop.z) < 0.49;
if (drop.y < 0.15 || hitsOuter || drop.x > centerX + 2.2) {
drop.y = 5.6 + Math.random() * 1.1;
drop.x = centerX + (Math.random() - 0.5) * 4;
drop.z = (Math.random() - 0.5) * 3.2;
}
const offset = i * 6;
rainPositions[offset] = drop.x;
rainPositions[offset + 1] = drop.y;
rainPositions[offset + 2] = drop.z;
rainPositions[offset + 3] = drop.x;
rainPositions[offset + 4] = drop.y - drop.length;
rainPositions[offset + 5] = drop.z;
}
rainGeometry.attributes.position.needsUpdate = true;
rainGeometry.setDrawRange(0, visibleCount * 2);
}
function updateAirflow(dt) {
const visibleArrows = Math.floor(arrows.length * state.air);
airflowGroup.visible = state.air > 0.01;
airflowGroup.children.forEach((line) => {
line.material.opacity = 0.035 + state.air * 0.16;
});
for (let i = 0; i < arrows.length; i++) {
const arrow = arrows[i];
arrow.visible = i < visibleArrows;
if (!arrow.visible) continue;
const speed = 0.07 + state.air * 0.15;
const t = (elapsed * speed + arrow.userData.phase) % 1;
const curve = arrow.userData.curve;
const point = curve.getPointAt(t);
const tangent = curve.getTangentAt(t).normalize();
arrow.position.copy(point);
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
tangent
);
arrow.scale.setScalar(0.75 + state.air * 0.45);
}
arrowMaterial.opacity = 0.35 + state.air * 0.55;
}
function updateMoisture() {
const pathVisibility = state.paths ? 1 : 0;
const beadScale = Math.pow(state.rain, 1.35);
beadMesh.visible = state.paths && state.rain > 0.01;
beadMaterial.opacity = 0.78 * pathVisibility;
beadData.forEach((bead, index) => {
const pulse = 0.8 + Math.sin(elapsed * 2.1 + bead.phase) * 0.2;
const scale = Math.max(0.001, beadScale * pulse);
dummy.position.set(bead.x, bead.y, bead.z);
dummy.scale.setScalar(scale);
dummy.updateMatrix();
beadMesh.setMatrixAt(index, dummy.matrix);
});
beadMesh.instanceMatrix.needsUpdate = true;
runoffMaterial.opacity = state.rain * 0.48 * pathVisibility;
vaporLineMaterial.opacity = state.rain * 0.2 * pathVisibility;
const vaporStrength = state.rain * (0.38 + state.air * 0.62);
vaporMaterial.opacity =
vaporStrength * 0.8 * pathVisibility;
vaporPoints.visible = state.paths && state.rain > 0.02;
for (let i = 0; i < vaporCount; i++) {
const t = (elapsed * (0.055 + state.air * 0.095) + vaporPhases[i]) % 1;
const lateral = Math.sin(t * Math.PI) * (0.08 + state.air * 0.12);
const offset = i * 3;
vaporPositions[offset] =
-0.49 + t * 0.98 + lateral;
vaporPositions[offset + 1] =
1.51 + t * 1.28 + Math.sin(t * Math.PI * 2 + vaporPhases[i]) * 0.035;
vaporPositions[offset + 2] =
0.45 + Math.sin(t * Math.PI) * 0.08;
}
vaporGeometry.attributes.position.needsUpdate = true;
const condensation = THREE.MathUtils.clamp(
state.rain * (1 - state.air * 0.6),
0,
1
);
condensationMaterial.opacity =
condensation * 0.82 * pathVisibility;
condensationMaterial.size =
0.035 + condensation * 0.022;
condensationPoints.visible = state.paths && condensation > 0.03;
}
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
const layerSmoothing = 1 - Math.exp(-dt * 7);
outerLayer.position.x = THREE.MathUtils.lerp(
outerLayer.position.x,
-0.72 * state.split,
layerSmoothing
);
middleLayer.position.x = THREE.MathUtils.lerp(
middleLayer.position.x,
0,
layerSmoothing
);
baseLayer.position.x = THREE.MathUtils.lerp(
baseLayer.position.x,
0.72 * state.split,
layerSmoothing
);
outerLayer.position.y = THREE.MathUtils.lerp(
outerLayer.position.y,
0.1 * state.split,
layerSmoothing
);
middleLayer.position.y = THREE.MathUtils.lerp(
middleLayer.position.y,
0,
layerSmoothing
);
baseLayer.position.y = THREE.MathUtils.lerp(
baseLayer.position.y,
-0.08 * state.split,
layerSmoothing
);
updateCamera(dt);
updateRain(dt);
updateAirflow(dt);
updateMoisture();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
});
syncControls();
updateFocus();
animate();
</script>
</body>
</html>
```