Prompt specification
Build or customize the Three.js 3D scene "Humidity-variable comparison explorer" 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: Humidity-variable comparison explorer
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/humidity-variable-comparison-explorer-x1244
Scene Description Prompt:
A low-poly humidity explorer with temperature and vapor controls, a stated simplified saturation relation, and flagged invalid inputs. Three.js from cdnjs, one HTML file.
Working Three.js Starter (humidity-variable-comparison-explorer-x1244):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#08191f" />
<title>HYMID — Low-Poly Humidity Explorer</title>
<style>
:root {
--bg: #071419;
--panel: rgba(10, 30, 36, 0.82);
--panel-solid: #0b2228;
--line: rgba(175, 231, 224, 0.15);
--line-strong: rgba(175, 231, 224, 0.28);
--text: #edf8f5;
--muted: #91aaa9;
--accent: #6ce6c7;
--accent-soft: rgba(108, 230, 199, 0.12);
--warm: #ffb56f;
--danger: #ff7f77;
--danger-soft: rgba(255, 127, 119, 0.11);
--radius: 18px;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
cursor: grab;
touch-action: none;
}
#scene.dragging { cursor: grabbing; }
.topbar {
position: fixed;
z-index: 10;
top: 0;
left: 0;
right: 0;
height: 78px;
padding: 18px 24px;
display: flex;
align-items: center;
justify-content: space-between;
pointer-events: none;
background: linear-gradient(to bottom, rgba(5, 15, 19, 0.88), transparent);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
position: relative;
width: 39px;
height: 39px;
border: 1px solid rgba(108, 230, 199, 0.52);
border-radius: 11px;
transform: rotate(45deg);
background: rgba(108, 230, 199, 0.07);
box-shadow: inset 0 0 20px rgba(108, 230, 199, 0.08);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
background: var(--accent);
border-radius: 50%;
}
.brand-mark::before {
width: 8px;
height: 8px;
left: 9px;
top: 9px;
}
.brand-mark::after {
width: 5px;
height: 5px;
right: 8px;
bottom: 9px;
opacity: 0.6;
}
.brand-copy {
transform: rotate(-45deg);
transform-origin: center;
width: 160px;
}
.eyebrow {
margin: 0 0 4px;
color: var(--accent);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: 19px;
font-weight: 680;
letter-spacing: 0.08em;
}
.top-actions {
display: flex;
align-items: center;
gap: 10px;
pointer-events: auto;
}
.model-tag {
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 999px;
color: #b9cecb;
background: rgba(7, 24, 29, 0.68);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.12em;
}
.icon-button {
width: 36px;
height: 36px;
display: grid;
place-items: center;
border: 1px solid var(--line);
border-radius: 10px;
color: var(--text);
background: rgba(7, 24, 29, 0.72);
cursor: pointer;
transition: 160ms ease;
}
.icon-button:hover {
border-color: var(--line-strong);
background: rgba(17, 47, 53, 0.9);
transform: translateY(-1px);
}
.panel {
position: fixed;
z-index: 8;
top: 92px;
width: 348px;
max-height: calc(100vh - 116px);
overflow: auto;
scrollbar-width: thin;
scrollbar-color: rgba(108, 230, 199, 0.25) transparent;
padding: 19px;
border: 1px solid var(--line);
border-radius: var(--radius);
background:
linear-gradient(145deg, rgba(20, 49, 55, 0.23), transparent 42%),
var(--panel);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
}
.controls-panel { left: 24px; }
.readout-panel {
top: 92px;
right: 24px;
width: 292px;
}
.panel-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 19px;
}
.panel-title {
margin: 0;
font-size: 12px;
font-weight: 760;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.panel-subtitle {
margin: 6px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.index {
color: rgba(108, 230, 199, 0.65);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
}
.control {
margin-top: 18px;
}
.control-label {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
color: #dceae7;
font-size: 11px;
font-weight: 680;
letter-spacing: 0.055em;
text-transform: uppercase;
}
.control-label span:last-child {
color: var(--muted);
font-size: 9px;
font-weight: 650;
}
.control-row {
display: grid;
grid-template-columns: 1fr 104px;
align-items: center;
gap: 13px;
}
input[type="range"] {
--pct: 50%;
width: 100%;
height: 4px;
margin: 0;
appearance: none;
-webkit-appearance: none;
border-radius: 99px;
background: linear-gradient(
to right,
var(--accent) 0,
var(--accent) var(--pct),
rgba(180, 218, 212, 0.14) var(--pct),
rgba(180, 218, 212, 0.14) 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 16px;
height: 16px;
appearance: none;
-webkit-appearance: none;
border: 3px solid #d9fff6;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 5px rgba(108, 230, 199, 0.12);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 3px solid #d9fff6;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 5px rgba(108, 230, 199, 0.12);
}
.number-wrap {
height: 39px;
display: flex;
align-items: center;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(4, 18, 23, 0.48);
transition: 150ms ease;
}
.number-wrap:focus-within {
border-color: rgba(108, 230, 199, 0.68);
box-shadow: 0 0 0 3px rgba(108, 230, 199, 0.08);
}
.number-wrap.invalid {
border-color: rgba(255, 127, 119, 0.85);
box-shadow: 0 0 0 3px var(--danger-soft);
}
.number-wrap input {
width: 100%;
min-width: 0;
height: 100%;
padding: 0 2px 0 10px;
border: 0;
outline: 0;
color: var(--text);
background: transparent;
font: 650 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.number-wrap input::-webkit-inner-spin-button { opacity: 0.35; }
.unit {
padding-right: 9px;
color: var(--muted);
font-size: 10px;
white-space: nowrap;
}
.presets {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
margin-top: 16px;
}
.preset {
min-height: 33px;
padding: 6px 3px;
border: 1px solid var(--line);
border-radius: 9px;
color: #abc0bd;
background: rgba(255, 255, 255, 0.025);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.055em;
text-transform: uppercase;
cursor: pointer;
transition: 150ms ease;
}
.preset:hover {
color: var(--text);
border-color: var(--line-strong);
background: var(--accent-soft);
}
.divider {
height: 1px;
margin: 19px 0;
background: var(--line);
}
.formula-label {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 10px;
color: var(--accent);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.formula-label::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 10px var(--accent);
}
.formula {
padding: 12px;
border: 1px solid rgba(108, 230, 199, 0.13);
border-radius: 11px;
color: #d9eeea;
background: rgba(3, 16, 20, 0.42);
font: 500 11px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.formula strong { color: var(--accent); }
.formula-note {
margin: 9px 2px 0;
color: #7f9b99;
font-size: 9px;
line-height: 1.55;
}
.status-pill {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 7px 9px;
border: 1px solid rgba(108, 230, 199, 0.22);
border-radius: 999px;
color: var(--accent);
background: rgba(108, 230, 199, 0.075);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.status-pill::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
box-shadow: 0 0 9px currentColor;
}
.status-pill.warning {
color: var(--warm);
border-color: rgba(255, 181, 111, 0.28);
background: rgba(255, 181, 111, 0.08);
}
.status-pill.error {
color: var(--danger);
border-color: rgba(255, 127, 119, 0.3);
background: var(--danger-soft);
}
.rh-wrap {
display: flex;
align-items: flex-end;
justify-content: space-between;
margin-top: 18px;
}
.rh-value {
display: flex;
align-items: flex-start;
line-height: 0.9;
font-variant-numeric: tabular-nums;
}
#rhValue {
font-size: 69px;
font-weight: 580;
letter-spacing: -0.07em;
}
.rh-percent {
margin: 5px 0 0 5px;
color: var(--accent);
font-size: 23px;
font-weight: 580;
}
.condition {
padding-bottom: 5px;
color: #c9dad7;
font-size: 11px;
font-weight: 650;
text-align: right;
}
.rh-track {
height: 6px;
margin-top: 18px;
overflow: hidden;
border-radius: 99px;
background: rgba(180, 218, 212, 0.11);
}
.rh-fill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #4abfae, #7ce9cf);
box-shadow: 0 0 15px rgba(108, 230, 199, 0.32);
transition: width 260ms ease, background 200ms ease;
}
.rh-scale {
display: flex;
justify-content: space-between;
margin-top: 6px;
color: #657f7d;
font: 600 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 18px;
}
.metric {
min-height: 68px;
padding: 11px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(3, 16, 20, 0.3);
}
.metric-label {
color: #7f9997;
font-size: 8px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.metric-value {
margin-top: 8px;
color: #e7f3f0;
font: 600 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.metric-value small {
margin-left: 3px;
color: #78918f;
font-size: 9px;
}
.flags {
min-height: 49px;
margin-top: 10px;
padding: 11px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(3, 16, 20, 0.3);
}
.flags.valid {
border-color: rgba(108, 230, 199, 0.2);
}
.flags.warning {
border-color: rgba(255, 181, 111, 0.3);
background: rgba(255, 181, 111, 0.055);
}
.flags.error {
border-color: rgba(255, 127, 119, 0.34);
background: var(--danger-soft);
}
.flag-title {
display: flex;
align-items: center;
gap: 7px;
color: var(--accent);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.flags.warning .flag-title { color: var(--warm); }
.flags.error .flag-title { color: var(--danger); }
.flag-copy {
margin: 7px 0 0;
color: #92aaa8;
font-size: 9px;
line-height: 1.55;
}
.flag-copy + .flag-copy { margin-top: 4px; }
.view-hint {
position: fixed;
z-index: 7;
left: 50%;
bottom: 23px;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 9px;
padding: 8px 12px;
border: 1px solid rgba(175, 231, 224, 0.1);
border-radius: 999px;
color: rgba(200, 224, 220, 0.6);
background: rgba(5, 19, 23, 0.55);
backdrop-filter: blur(8px);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.07em;
text-transform: uppercase;
pointer-events: none;
white-space: nowrap;
}
.view-hint .dot {
width: 4px;
height: 4px;
border-radius: 50%;
background: var(--accent);
}
.scene-caption {
position: fixed;
z-index: 5;
right: 28px;
bottom: 24px;
color: rgba(193, 220, 216, 0.48);
font: 600 9px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
text-align: right;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 980px) {
.controls-panel { width: 320px; }
.readout-panel { width: 260px; }
.scene-caption { display: none; }
}
@media (max-width: 760px) {
html, body { overflow: auto; }
#scene { position: fixed; height: 100svh; }
.topbar {
position: fixed;
height: 67px;
padding: 13px 14px;
}
.brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.brand-mark::before { left: 6px; top: 6px; }
.brand-mark::after { right: 6px; bottom: 6px; }
.brand-copy { width: 140px; }
.brand h1 { font-size: 15px; }
.brand .eyebrow { font-size: 8px; }
.model-tag { display: none; }
.panel {
position: relative;
top: auto;
left: auto;
right: auto;
width: auto;
max-height: none;
margin: 78px 12px 12px;
}
.controls-panel { margin-bottom: 12px; }
.readout-panel { margin-top: 0; margin-bottom: 72px; }
.view-hint { bottom: 15px; }
#rhValue { font-size: 58px; }
}
@media (prefers-reduced-motion: reduce) {
* { scroll-behavior: auto !important; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly atmospheric humidity visualization"></canvas>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div class="brand-copy">
<p class="eyebrow">Atmospheric systems lab</p>
<h1>HYMID / 01</h1>
</div>
</div>
<div class="top-actions">
<div class="model-tag">SIMPLIFIED MODEL · hPa</div>
<button class="icon-button" id="resetCamera" type="button" title="Reset camera" aria-label="Reset camera">
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M4 8V4m0 0h4M4 4l4.2 4.2A7 7 0 1 1 5 12" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
</header>
<section class="panel controls-panel" aria-labelledby="inputTitle">
<div class="panel-header">
<div>
<h2 class="panel-title" id="inputTitle">Environment inputs</h2>
<p class="panel-subtitle">Adjust the thermal and vapor state.</p>
</div>
<span class="index">01 / INPUT</span>
</div>
<div class="control">
<div class="control-label">
<span>Temperature</span>
<span>−60 to 60 °C</span>
</div>
<div class="control-row">
<input id="tempRange" type="range" min="-60" max="60" step="0.1" value="20" aria-label="Temperature slider" />
<label class="number-wrap" id="tempWrap">
<input id="tempInput" type="number" step="0.1" value="20" aria-label="Temperature in degrees Celsius" />
<span class="unit">°C</span>
</label>
</div>
</div>
<div class="control">
<div class="control-label">
<span>Actual vapor pressure</span>
<span>0 to 60 hPa</span>
</div>
<div class="control-row">
<input id="vaporRange" type="range" min="0" max="60" step="0.1" value="11.3" aria-label="Actual vapor pressure slider" />
<label class="number-wrap" id="vaporWrap">
<input id="vaporInput" type="number" min="0" max="60" step="0.1" value="11.3" aria-label="Actual vapor pressure in hectopascals" />
<span class="unit">hPa</span>
</label>
</div>
</div>
<div class="presets" aria-label="Preset environmental conditions">
<button class="preset" type="button" data-temp="12" data-vapor="5.4">Dry</button>
<button class="preset" type="button" data-temp="20" data-vapor="11.3">Comfort</button>
<button class="preset" type="button" data-temp="25" data-vapor="23.5">Humid</button>
<button class="preset" type="button" data-temp="25" data-vapor="31.7">Satur.</button>
</div>
<div class="divider"></div>
<div class="formula-label">Stated simplified relation</div>
<div class="formula">
e<sub>s</sub>(T) = <strong>6.112</strong> · exp(<strong>17.67T</strong> / (T + 243.5))<br />
RH = <strong>100</strong> · e / e<sub>s</sub>
</div>
<p class="formula-note">
T in °C; saturation pressure e<sub>s</sub> and actual vapor pressure e in hPa.
Liquid-water approximation over the stated −60 to 60 °C range.
</p>
</section>
<section class="panel readout-panel" aria-labelledby="outputTitle">
<div class="panel-header">
<div>
<h2 class="panel-title" id="outputTitle">Model readout</h2>
<p class="panel-subtitle">Calculated atmospheric state.</p>
</div>
<span class="index">02 / STATE</span>
</div>
<div id="statusPill" class="status-pill" aria-live="polite">Valid state</div>
<div class="rh-wrap">
<div class="rh-value" aria-label="Relative humidity">
<span id="rhValue">48</span>
<span class="rh-percent">%</span>
</div>
<div id="condition" class="condition">Balanced vapor</div>
</div>
<div class="rh-track" aria-hidden="true">
<div id="rhFill" class="rh-fill"></div>
</div>
<div class="rh-scale">
<span>0%</span>
<span>50%</span>
<span>100%</span>
</div>
<div class="metric-grid">
<div class="metric">
<div class="metric-label">Saturation e<sub>s</sub></div>
<div class="metric-value"><span id="satValue">23.4</span><small>hPa</small></div>
</div>
<div class="metric">
<div class="metric-label">Actual e</div>
<div class="metric-value"><span id="actualValue">11.3</span><small>hPa</small></div>
</div>
<div class="metric">
<div class="metric-label">Temperature</div>
<div class="metric-value"><span id="tempValue">20.0</span><small>°C</small></div>
</div>
<div class="metric">
<div class="metric-label">Saturation margin</div>
<div class="metric-value"><span id="marginValue">12.1</span><small>hPa</small></div>
</div>
</div>
<div id="flags" class="flags valid" aria-live="polite">
<div class="flag-title">✓ Inputs valid</div>
<p class="flag-copy">No condensation predicted in the simplified unsaturated-vapor model.</p>
</div>
</section>
<div class="view-hint"><span class="dot"></span> Drag to orbit · Scroll to zoom</div>
<div class="scene-caption">Procedural low-poly field<br />Three.js core / no external models</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x08191f);
scene.fog = new THREE.Fog(0x08191f, 18, 38);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xc9f6ff, 0x193126, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe1b5, 3.1);
sun.position.set(8, 13, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(1024, 1024);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0008;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x66d9d0, 1.6);
rim.position.set(-9, 7, -8);
scene.add(rim);
const model = {
temperature: 20,
vapor: 11.3,
saturation: 23.38,
humidity: 48.33,
valid: true,
flagged: false
};
const palette = {
cold: new THREE.Color(0x88b9ff),
neutral: new THREE.Color(0x9edbd1),
warm: new THREE.Color(0xffb56f),
bgCold: new THREE.Color(0x091822),
bgNeutral: new THREE.Color(0x08191f),
bgWarm: new THREE.Color(0x211b18)
};
const targetBackground = palette.bgNeutral.clone();
const targetSunColor = palette.neutral.clone();
// Procedural low-poly island.
function terrainHeight(x, z) {
const r = Math.hypot(x, z);
const falloff = Math.max(0, 1 - Math.pow(r / 6.4, 1.75));
const noise =
0.25 * Math.sin(x * 1.36) +
0.20 * Math.cos(z * 1.17) +
0.12 * Math.sin((x + z) * 2.05);
return -0.78 + falloff * (1.8 + noise);
}
function buildTerrain() {
const segments = 18;
const size = 13;
const positions = [];
const colors = [];
const indices = [];
const low = new THREE.Color(0x315650);
const mid = new THREE.Color(0x71836a);
const high = new THREE.Color(0xb0a879);
const color = new THREE.Color();
for (let iz = 0; iz <= segments; iz++) {
for (let ix = 0; ix <= segments; ix++) {
const x = (ix / segments - 0.5) * size;
const z = (iz / segments - 0.5) * size;
const y = terrainHeight(x, z);
positions.push(x, y, z);
const h = THREE.MathUtils.clamp((y + 0.6) / 2.5, 0, 1);
if (h < 0.52) {
color.copy(low).lerp(mid, h / 0.52);
} else {
color.copy(mid).lerp(high, (h - 0.52) / 0.48);
}
colors.push(color.r, color.g, color.b);
}
}
for (let iz = 0; iz < segments; iz++) {
for (let ix = 0; ix < segments; ix++) {
const a = iz * (segments + 1) + ix;
const b = a + 1;
const c = a + segments + 1;
const d = c + 1;
if ((ix + iz) % 2 === 0) {
indices.push(a, c, b, b, c, d);
} else {
indices.push(a, c, d, a, d, b);
}
}
}
const indexed = new THREE.BufferGeometry();
indexed.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
indexed.setAttribute("color", new THREE.Float32BufferAttribute(colors, 3));
indexed.setIndex(indices);
indexed.computeVertexNormals();
const geometry = indexed.toNonIndexed();
indexed.dispose();
const material = new THREE.MeshStandardMaterial({
vertexColors: true,
flatShading: true,
roughness: 1,
metalness: 0
});
const terrain = new THREE.Mesh(geometry, material);
terrain.receiveShadow = true;
scene.add(terrain);
return terrain;
}
const terrain = buildTerrain();
// Faceted pedestal.
const pedestalMaterial = new THREE.MeshStandardMaterial({
color: 0x18343a,
roughness: 0.76,
metalness: 0.12,
flatShading: true
});
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(7.15, 7.55, 0.58, 48, 1, false),
pedestalMaterial
);
pedestal.position.y = -1.08;
pedestal.receiveShadow = true;
scene.add(pedestal);
const pedestalTop = new THREE.Mesh(
new THREE.CylinderGeometry(7.12, 7.12, 0.08, 48),
new THREE.MeshStandardMaterial({
color: 0x2d5554,
roughness: 0.86,
flatShading: true
})
);
pedestalTop.position.y = -0.74;
pedestalTop.receiveShadow = true;
scene.add(pedestalTop);
// Small angular trees.
const treeGroup = new THREE.Group();
scene.add(treeGroup);
const trunkMaterial = new THREE.MeshStandardMaterial({
color: 0x59483b,
flatShading: true,
roughness: 1
});
const foliageMaterials = [
new THREE.MeshStandardMaterial({ color: 0x315c4f, flatShading: true, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x47715d, flatShading: true, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x64836a, flatShading: true, roughness: 1 })
];
const treePoints = [
[-4.6, -1.9], [-3.8, 2.9], [-2.9, -4.3], [-1.9, 4.4],
[3.8, -2.2], [4.6, 1.5], [2.9, 4.0], [1.8, -4.7],
[-5.0, 0.3], [0.7, -4.9], [5.0, -0.3], [-0.8, 4.9]
];
treePoints.forEach(([x, z], i) => {
const group = new THREE.Group();
const scale = 0.68 + (i % 4) * 0.09;
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.07, 0.11, 0.72, 5),
trunkMaterial
);
trunk.position.y = 0.36;
trunk.castShadow = true;
const lower = new THREE.Mesh(
new THREE.ConeGeometry(0.48, 1.25, 5),
foliageMaterials[i % foliageMaterials.length]
);
lower.position.y = 1.05;
lower.castShadow = true;
const top = new THREE.Mesh(
new THREE.ConeGeometry(0.34, 0.9, 5),
foliageMaterials[(i + 1) % foliageMaterials.length]
);
top.position.y = 1.62;
top.castShadow = true;
group.add(trunk, lower, top);
group.position.set(x, terrainHeight(x, z), z);
group.scale.setScalar(scale);
group.rotation.y = i * 0.73;
treeGroup.add(group);
});
// Angular stones.
const rockMaterial = new THREE.MeshStandardMaterial({
color: 0x65706a,
flatShading: true,
roughness: 0.95
});
[
[-2.2, 1.7, 0.38], [2.4, 0.9, 0.28], [1.5, -2.7, 0.34],
[-3.4, -0.4, 0.25], [3.7, 2.9, 0.2]
].forEach(([x, z, s]) => {
const rock = new THREE.Mesh(new THREE.DodecahedronGeometry(s, 0), rockMaterial);
rock.position.set(x, terrainHeight(x, z) + s * 0.55, z);
rock.scale.y = 0.72;
rock.rotation.set(i => i, 0.4, 0.2);
rock.castShadow = true;
scene.add(rock);
});
// Central atmospheric sensor.
const sensor = new THREE.Group();
scene.add(sensor);
const mast = new THREE.Mesh(
new THREE.CylinderGeometry(0.065, 0.09, 3.15, 6),
new THREE.MeshStandardMaterial({
color: 0x9bb8b3,
metalness: 0.48,
roughness: 0.42,
flatShading: true
})
);
mast.position.y = 2.28;
mast.castShadow = true;
sensor.add(mast);
const coreMaterial = new THREE.MeshStandardMaterial({
color: 0x78ead2,
emissive: 0x2b9e89,
emissiveIntensity: 0.85,
roughness: 0.24,
metalness: 0.15,
flatShading: true
});
const core = new THREE.Mesh(new THREE.IcosahedronGeometry(0.64, 1), coreMaterial);
core.position.y = 4.13;
core.castShadow = true;
sensor.add(core);
const coreCage = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.94, 1),
new THREE.MeshBasicMaterial({
color: 0xb6fff0,
wireframe: true,
transparent: true,
opacity: 0.34
})
);
coreCage.position.copy(core.position);
sensor.add(coreCage);
const coreLight = new THREE.PointLight(0x69e9cc, 1.3, 8, 2);
coreLight.position.copy(core.position);
sensor.add(coreLight);
// Transparent measurement chamber.
const chamberGeometry = new THREE.BoxGeometry(13.3, 10.4, 13.3);
const chamberEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(chamberGeometry),
new THREE.LineBasicMaterial({
color: 0x91e8db,
transparent: true,
opacity: 0.095
})
);
chamberEdges.position.y = 4.18;
scene.add(chamberEdges);
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0x70dcca,
transparent: true,
opacity: 0.14,
depthWrite: false
});
const rings = [];
[0.05, 3.1, 6.3].forEach((y, i) => {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(4.72 + i * 0.12, 0.018, 3, 64),
ringMaterial
);
ring.rotation.x = Math.PI / 2;
ring.position.y = y;
scene.add(ring);
rings.push(ring);
});
// Low-poly vapor particles, rendered as one instanced mesh.
const MAX_PUFFS = 140;
const puffGeometry = new THREE.IcosahedronGeometry(0.36, 0);
const puffMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.25,
roughness: 0.85,
depthWrite: false,
flatShading: true
});
const puffMesh = new THREE.InstancedMesh(puffGeometry, puffMaterial, MAX_PUFFS);
puffMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
puffMesh.frustumCulled = false;
puffMesh.count = 0;
scene.add(puffMesh);
const puffSeeds = [];
const dummy = new THREE.Object3D();
for (let i = 0; i < MAX_PUFFS; i++) {
const seed = {
angle: Math.random() * Math.PI * 2,
radius: 0.45 + Math.random() * 3.3,
base: Math.random() * 8,
speed: 0.16 + Math.random() * 0.26,
scale: 0.55 + Math.random() * 1.15,
phase: Math.random() * Math.PI * 2
};
puffSeeds.push(seed);
const c = new THREE.Color().setHSL(
0.49 + Math.random() * 0.035,
0.32 + Math.random() * 0.22,
0.76 + Math.random() * 0.16
);
puffMesh.setColorAt(i, c);
}
puffMesh.instanceColor.needsUpdate = true;
// Condensation droplets.
const MAX_DROPS = 50;
const dropMesh = new THREE.InstancedMesh(
new THREE.OctahedronGeometry(0.085, 0),
new THREE.MeshBasicMaterial({
color: 0x9ceeff,
transparent: true,
opacity: 0.82,
depthWrite: false
}),
MAX_DROPS
);
dropMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
dropMesh.frustumCulled = false;
dropMesh.count = 0;
scene.add(dropMesh);
const dropSeeds = Array.from({ length: MAX_DROPS }, () => ({
x: (Math.random() - 0.5) * 8,
z: (Math.random() - 0.5) * 8,
base: Math.random() * 9,
speed: 2.1 + Math.random() * 2.3,
scale: 0.6 + Math.random() * 0.9
}));
// Sparse background motes.
const motePositions = new Float32Array(120 * 3);
for (let i = 0; i < 120; i++) {
motePositions[i * 3] = (Math.random() - 0.5) * 26;
motePositions[i * 3 + 1] = Math.random() * 15 - 1;
motePositions[i * 3 + 2] = (Math.random() - 0.5) * 26;
}
const moteGeometry = new THREE.BufferGeometry();
moteGeometry.setAttribute("position", new THREE.BufferAttribute(motePositions, 3));
const motes = new THREE.Points(
moteGeometry,
new THREE.PointsMaterial({
color: 0xbfe9df,
size: 0.035,
transparent: true,
opacity: 0.28,
depthWrite: false
})
);
scene.add(motes);
// Camera controls implemented directly, without addons.
const cameraState = {
theta: 0.72,
phi: 1.02,
radius: 19.2,
target: new THREE.Vector3(0, 2.25, 0),
dragging: false,
pointerX: 0,
pointerY: 0
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.theta = 0.72;
cameraState.phi = 1.02;
cameraState.radius = 19.2;
updateCamera();
}
canvas.addEventListener("pointerdown", (event) => {
cameraState.dragging = true;
cameraState.pointerX = event.clientX;
cameraState.pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!cameraState.dragging) return;
const dx = event.clientX - cameraState.pointerX;
const dy = event.clientY - cameraState.pointerY;
cameraState.pointerX = event.clientX;
cameraState.pointerY = event.clientY;
cameraState.theta -= dx * 0.005;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - dy * 0.004, 0.38, 1.38);
updateCamera();
});
function stopDragging(event) {
cameraState.dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.012,
12.5,
29
);
updateCamera();
}, { passive: false });
document.querySelector("#resetCamera").addEventListener("click", resetCamera);
// UI elements.
const tempRange = document.querySelector("#tempRange");
const tempInput = document.querySelector("#tempInput");
const vaporRange = document.querySelector("#vaporRange");
const vaporInput = document.querySelector("#vaporInput");
const tempWrap = document.querySelector("#tempWrap");
const vaporWrap = document.querySelector("#vaporWrap");
const rhValue = document.querySelector("#rhValue");
const rhFill = document.querySelector("#rhFill");
const satValue = document.querySelector("#satValue");
const actualValue = document.querySelector("#actualValue");
const tempValue = document.querySelector("#tempValue");
const marginValue = document.querySelector("#marginValue");
const condition = document.querySelector("#condition");
const statusPill = document.querySelector("#statusPill");
const flags = document.querySelector("#flags");
function saturationPressure(t) {
return 6.112 * Math.exp((17.67 * t) / (t + 243.5));
}
function updateRangeFill(input) {
const min = Number(input.min);
const max = Number(input.max);
const value = Number(input.value);
const pct = ((value - min) / (max - min)) * 100;
input.style.setProperty("--pct", `${Math.max(0, Math.min(100, pct))}%`);
}
function setFlagMarkup(items, kind) {
flags.className = `flags ${kind}`;
flags.replaceChildren();
const title = document.createElement("div");
title.className = "flag-title";
title.textContent =
kind === "error" ? "✕ Invalid input" :
kind === "warning" ? "⚠ State flagged" :
"✓ Inputs valid";
flags.appendChild(title);
items.forEach((item) => {
const copy = document.createElement("p");
copy.className = "flag-copy";
copy.textContent = item;
flags.appendChild(copy);
});
}
function updateModel() {
const temperature = tempInput.valueAsNumber;
const vapor = vaporInput.valueAsNumber;
const issues = [];
let saturation = NaN;
let humidity = NaN;
let margin = NaN;
let valid = true;
if (!Number.isFinite(temperature)) {
valid = false;
issues.push("Temperature must be a finite number.");
} else if (temperature < -60 || temperature > 60) {
valid = false;
issues.push("Temperature is outside the supported −60 to 60 °C range.");
}
if (!Number.isFinite(vapor)) {
valid = false;
issues.push("Vapor pressure must be a finite number.");
} else if (vapor < 0 || vapor > 60) {
valid = false;
issues.push("Vapor pressure is outside the supported 0 to 60 hPa range.");
}
if (valid) {
saturation = saturationPressure(temperature);
humidity = vapor === 0 ? 0 : (100 * vapor) / saturation;
margin = saturation - vapor;
if (humidity > 100.0001) {
issues.push(
`Supersaturated by ${Math.abs(margin).toFixed(1)} hPa; condensation is expected.`
);
}
}
model.temperature = temperature;
model.vapor = vapor;
model.saturation = saturation;
model.humidity = humidity;
model.valid = valid;
model.flagged = issues.length > 0;
tempWrap.classList.toggle("invalid", !Number.isFinite(temperature) || temperature < -60 || temperature > 60);
vaporWrap.classList.toggle("invalid", !Number.isFinite(vapor) || vapor < 0 || vapor > 60);
if (!valid) {
rhValue.textContent = "—";
rhFill.style.width = "0%";
satValue.textContent = "—";
actualValue.textContent = "—";
tempValue.textContent = "—";
marginValue.textContent = "—";
condition.textContent = "State not evaluable";
statusPill.textContent = "Invalid input";
statusPill.className = "status-pill error";
setFlagMarkup(issues, "error");
} else {
const roundedRH = humidity >= 100 ? Math.ceil(humidity) : Math.round(humidity);
rhValue.textContent = roundedRH;
rhFill.style.width = `${Math.min(100, Math.max(0, humidity))}%`;
satValue.textContent = saturation.toFixed(1);
actualValue.textContent = vapor.toFixed(1);
tempValue.textContent = temperature.toFixed(1);
marginValue.textContent = margin.toFixed(1);
if (humidity > 100.0001) {
condition.textContent = "Condensation expected";
statusPill.textContent = "State flagged";
statusPill.className = "status-pill warning";
rhFill.style.background = "linear-gradient(90deg, #e99d5f, #ff7f77)";
rhValue.style.color = "#ffb56f";
setFlagMarkup(issues, "warning");
} else if (humidity >= 99.9) {
condition.textContent = "Saturation reached";
statusPill.textContent = "Valid state";
statusPill.className = "status-pill warning";
rhFill.style.background = "linear-gradient(90deg, #4abfae, #ffcb7f)";
rhValue.style.color = "#edf8f5";
setFlagMarkup(["The vapor is at saturation; condensation may begin."], "warning");
} else {
condition.textContent =
humidity < 25 ? "Dry vapor" :
humidity < 50 ? "Light vapor" :
humidity < 72 ? "Balanced vapor" :
humidity < 90 ? "Humid air" :
"Near saturation";
statusPill.textContent = "Valid state";
statusPill.className = "status-pill";
rhFill.style.background = "linear-gradient(90deg, #4abfae, #7ce9cf)";
rhValue.style.color = "#edf8f5";
setFlagMarkup(
["No condensation predicted in the simplified unsaturated-vapor model."],
"valid"
);
}
}
updateRangeFill(tempRange);
updateRangeFill(vaporRange);
updateVisualModel();
}
function updateVisualModel() {
const tempNorm = THREE.MathUtils.clamp((model.temperature + 60) / 120, 0, 1);
if (tempNorm < 0.5) {
targetBackground.copy(palette.bgCold).lerp(palette.bgNeutral, tempNorm * 2);
targetSunColor.copy(palette.cold).lerp(palette.neutral, tempNorm * 2);
} else {
targetBackground.copy(palette.bgNeutral).lerp(palette.bgWarm, (tempNorm - 0.5) * 2);
targetSunColor.copy(palette.neutral).lerp(palette.warm, (tempNorm - 0.5) * 2);
}
const humidity = Number.isFinite(model.humidity)
? THREE.MathUtils.clamp(model.humidity, 0, 150)
: 0;
puffMesh.count = model.valid
? Math.floor(MAX_PUFFS * Math.pow(THREE.MathUtils.clamp(humidity / 100, 0, 1), 1.38))
: 0;
puffMaterial.opacity = 0.13 + 0.25 * THREE.MathUtils.clamp(humidity / 100, 0, 1);
if (humidity > 100.0001) {
dropMesh.count = Math.min(MAX_DROPS, 7 + Math.ceil((humidity - 100) * 2));
} else if (humidity >= 99.8) {
dropMesh.count = 5;
} else {
dropMesh.count = 0;
}
const coreScale = 0.78 + Math.min(humidity, 130) * 0.0024;
core.scale.setScalar(coreScale);
coreCage.scale.setScalar(1 + Math.min(humidity, 130) * 0.0013);
coreMaterial.emissiveIntensity = 0.45 + Math.min(humidity, 120) * 0.008;
coreLight.intensity = 0.6 + Math.min(humidity, 120) * 0.012;
ringMaterial.opacity = 0.08 + Math.min(humidity, 100) * 0.001;
}
tempRange.addEventListener("input", () => {
tempInput.value = tempRange.value;
updateModel();
});
vaporRange.addEventListener("input", () => {
vaporInput.value = vaporRange.value;
updateModel();
});
tempInput.addEventListener("input", () => {
const value = tempInput.valueAsNumber;
if (Number.isFinite(value) && value >= -60 && value <= 60) {
tempRange.value = value;
}
updateModel();
});
vaporInput.addEventListener("input", () => {
const value = vaporInput.valueAsNumber;
if (Number.isFinite(value) && value >= 0 && value <= 60) {
vaporRange.value = value;
}
updateModel();
});
document.querySelectorAll(".preset").forEach((button) => {
button.addEventListener("click", () => {
const temperature = Number(button.dataset.temp);
const vapor = Number(button.dataset.vapor);
tempInput.value = temperature;
vaporInput.value = vapor;
tempRange.value = temperature;
vaporRange.value = vapor;
updateModel();
});
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
const delta = Math.min(clock.getDelta(), 0.05);
scene.background.lerp(targetBackground, 0.035);
scene.fog.color.copy(scene.background);
sun.color.lerp(targetSunColor, 0.04);
const humidityFactor = Number.isFinite(model.humidity)
? THREE.MathUtils.clamp(model.humidity / 100, 0, 1)
: 0;
for (let i = 0; i < puffMesh.count; i++) {
const seed = puffSeeds[i];
const rise = (seed.base + elapsed * seed.speed) % 8.2;
const y = 1.0 + rise;
const angle = seed.angle + elapsed * 0.075;
const radialPulse = 0.82 + Math.sin(elapsed * 0.65 + seed.phase) * 0.13;
const radius = seed.radius * radialPulse * (0.75 + humidityFactor * 0.3);
dummy.position.set(
Math.cos(angle) * radius,
y,
Math.sin(angle) * radius
);
dummy.rotation.set(
seed.phase + elapsed * 0.13,
seed.angle + elapsed * 0.2,
seed.phase * 0.5
);
const scale = seed.scale * (0.68 + humidityFactor * 0.42);
dummy.scale.set(scale * 1.2, scale, scale * 1.08);
dummy.updateMatrix();
puffMesh.setMatrixAt(i, dummy.matrix);
}
puffMesh.instanceMatrix.needsUpdate = true;
for (let i = 0; i < dropMesh.count; i++) {
const seed = dropSeeds[i];
const y = 8.6 - ((seed.base + elapsed * seed.speed) % 9.2);
dummy.position.set(seed.x, y, seed.z);
dummy.rotation.set(elapsed * 2.1 + i, elapsed * 1.4, 0);
dummy.scale.set(seed.scale * 0.55, seed.scale * 1.8, seed.scale * 0.55);
dummy.updateMatrix();
dropMesh.setMatrixAt(i, dummy.matrix);
}
dropMesh.instanceMatrix.needsUpdate = true;
core.rotation.y = elapsed * 0.28;
core.rotation.x = Math.sin(elapsed * 0.35) * 0.16;
coreCage.rotation.y = -elapsed * 0.19;
coreCage.rotation.z = elapsed * 0.08;
rings[0].rotation.z = elapsed * 0.025;
rings[1].rotation.z = -elapsed * 0.018;
rings[2].rotation.z = elapsed * 0.012;
motes.rotation.y = elapsed * 0.006;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
resetCamera();
updateModel();
animate();
</script>
</body>
</html>
```