Prompt specification
Build or customize the Three.js 3D scene "Fast and slow reservoir response tanks" 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: Fast and slow reservoir response tanks
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/fast-and-slow-reservoir-response-tanks-x1210
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts climate timescales. Compare two toy thermal reservoirs with identical forcing but different response times; show lag explicitly under the displayed first-order model and mark parameters synthetic. Stylized solid forms.
Working Three.js Starter (fast-and-slow-reservoir-response-tanks-x1210):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Climate Timescales — Toy Thermal Reservoirs</title>
<style>
:root {
color-scheme: dark;
--bg: #07111f;
--panel: rgba(10, 23, 40, 0.86);
--line: rgba(164, 196, 226, 0.20);
--text: #eef6ff;
--muted: #9eb1c8;
--forcing: #ffad5a;
--fast: #55d6ff;
--slow: #bd98ff;
--synthetic: #ffd166;
}
* { 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;
}
#stage, #stage canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
#stage canvas { touch-action: none; }
#hud {
position: absolute;
inset: 0;
pointer-events: none;
}
.panel {
position: absolute;
border: 1px solid var(--line);
border-radius: 16px;
background:
linear-gradient(145deg, rgba(19, 38, 62, 0.92), rgba(8, 20, 36, 0.90));
box-shadow: 0 16px 46px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(14px);
}
.title-card {
top: 20px;
left: 20px;
width: 390px;
padding: 18px 20px 17px;
}
.eyebrow {
margin-bottom: 7px;
color: #8fd9ff;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 2.3vw, 36px);
line-height: 1.02;
letter-spacing: -0.04em;
}
.subtitle {
margin-top: 9px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.badges {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 13px;
}
.badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 9px;
border-radius: 999px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.badge.synthetic {
color: #241a03;
background: var(--synthetic);
}
.badge.identical {
color: #d9f4ff;
border: 1px solid rgba(85, 214, 255, 0.34);
background: rgba(85, 214, 255, 0.10);
}
.readout {
top: 20px;
right: 20px;
width: 285px;
padding: 15px 17px;
}
.readout h2,
.model-card h2,
.chart-card h2 {
margin: 0 0 10px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
color: #b8c9dc;
}
.value-row {
display: grid;
grid-template-columns: 12px 1fr auto;
align-items: center;
gap: 9px;
min-height: 29px;
color: #d9e6f3;
font-size: 12px;
}
.dot {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: 0 0 14px currentColor;
}
.dot.forcing { color: var(--forcing); background: var(--forcing); }
.dot.fast { color: var(--fast); background: var(--fast); }
.dot.slow { color: var(--slow); background: var(--slow); }
.value {
font-variant-numeric: tabular-nums;
font-weight: 750;
color: #fff;
}
.readout-note {
margin-top: 9px;
padding-top: 9px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.model-card {
left: 20px;
bottom: 20px;
width: 425px;
padding: 17px 19px 16px;
}
.equation {
margin: 5px 0 10px;
padding: 9px 11px;
border-left: 3px solid #65d8ff;
border-radius: 0 8px 8px 0;
background: rgba(85, 214, 255, 0.07);
color: #f4fbff;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 13px;
line-height: 1.55;
}
.equation .small {
display: block;
margin-top: 4px;
color: #b7c9dc;
font-size: 11px;
}
.parameter-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px 12px;
margin-top: 11px;
color: #c8d7e6;
font-size: 11px;
line-height: 1.35;
}
.parameter-grid strong { color: #fff; }
.model-note {
margin-top: 12px;
padding-top: 10px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10.5px;
line-height: 1.45;
}
.model-note strong { color: var(--synthetic); }
.chart-card {
right: 20px;
bottom: 20px;
width: min(630px, calc(100vw - 485px));
padding: 15px 16px 12px;
}
.chart-head {
display: flex;
justify-content: space-between;
gap: 12px;
align-items: flex-start;
}
.chart-head h2 { margin-bottom: 3px; }
.chart-subtitle {
color: var(--muted);
font-size: 10.5px;
}
.chart-legend {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 6px 12px;
margin-top: 4px;
color: #c6d6e6;
font-size: 10px;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 5px;
white-space: nowrap;
}
.legend-line {
width: 18px;
height: 0;
border-top: 2px solid currentColor;
}
.legend-line.dashed { border-top-style: dashed; }
#plot {
display: block;
width: 100%;
height: auto;
margin-top: 3px;
overflow: visible;
}
#plot text {
font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
.controls {
position: absolute;
left: 20px;
bottom: 20px;
display: none;
gap: 7px;
pointer-events: auto;
}
button {
border: 1px solid rgba(155, 190, 220, 0.25);
border-radius: 9px;
padding: 7px 10px;
color: #eaf5ff;
background: rgba(13, 31, 51, 0.9);
font: inherit;
font-size: 11px;
cursor: pointer;
}
button:hover {
border-color: rgba(85, 214, 255, 0.7);
background: rgba(22, 48, 73, 0.95);
}
#hint {
position: absolute;
left: 50%;
bottom: 13px;
transform: translateX(-50%);
padding: 6px 10px;
border-radius: 999px;
color: rgba(210, 225, 240, 0.72);
background: rgba(4, 12, 22, 0.56);
font-size: 10px;
letter-spacing: 0.03em;
}
@media (max-width: 1040px) {
.title-card { width: 330px; }
.model-card { width: 365px; }
.chart-card { width: calc(100vw - 405px); }
.readout { width: 250px; }
}
@media (max-width: 760px) {
.title-card {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 13px 15px;
}
.subtitle { display: none; }
.readout {
top: 119px;
right: 10px;
width: 220px;
padding: 10px 12px;
}
.model-card {
top: 119px;
left: 10px;
bottom: auto;
width: calc(100vw - 250px);
min-width: 210px;
max-height: 39vh;
overflow: auto;
padding: 12px;
}
.chart-card {
right: 10px;
bottom: 10px;
width: calc(100vw - 20px);
max-height: 47vh;
overflow: auto;
}
#hint { display: none; }
}
</style>
</head>
<body>
<div id="stage"></div>
<div id="hud">
<section class="panel title-card">
<div class="eyebrow">Climate timescales · synthetic laboratory</div>
<h1>One forcing.<br>Two memories.</h1>
<div class="subtitle">
Two toy thermal reservoirs receive exactly the same periodic forcing.
Their different response times produce different temperature lags.
</div>
<div class="badges">
<span class="badge synthetic">Synthetic parameters</span>
<span class="badge identical">Identical F(t)</span>
</div>
</section>
<section class="panel readout">
<h2>Live model state</h2>
<div class="value-row">
<span class="dot forcing"></span>
<span>Common forcing</span>
<span class="value" id="vForce">18.0 °C</span>
</div>
<div class="value-row">
<span class="dot fast"></span>
<span>Fast reservoir</span>
<span class="value" id="vFast">18.0 °C</span>
</div>
<div class="value-row">
<span class="dot slow"></span>
<span>Slow reservoir</span>
<span class="value" id="vSlow">18.0 °C</span>
</div>
<div class="readout-note">
Model time: <span id="vTime">0 yr</span><br>
One animation cycle = 120 model years.
</div>
</section>
<section class="panel model-card">
<h2>Displayed first-order model</h2>
<div class="equation">
dT<sub>τ</sub>/dt = [F(t) − T<sub>τ</sub>]/τ<br>
F(t) = T<sub>0</sub> + A sin(ωt), ω = 2π/P
<span class="small">
Periodic steady state:
T<sub>τ</sub>(t) = T<sub>0</sub> + B<sub>τ</sub> sin(ωt − φ<sub>τ</sub>)
</span>
<span class="small">
B<sub>τ</sub> = A/√(1+(ωτ)²),
φ<sub>τ</sub> = atan(ωτ),
Δt<sub>τ</sub> = φ<sub>τ</sub>/ω
</span>
</div>
<div class="parameter-grid">
<div>Period: <strong>P = 120 yr</strong></div>
<div>Baseline: <strong>T<sub>0</sub> = 18 °C</strong></div>
<div>Amplitude: <strong>A = 6 °C</strong></div>
<div>Fast τ: <strong>8 yr</strong></div>
<div>Slow τ: <strong>50 yr</strong></div>
<div>Peak lag:
<strong><span id="vLagFast">—</span> / <span id="vLagSlow">—</span></strong>
</div>
</div>
<div class="model-note">
<strong>SYNTHETIC PARAMETERS.</strong> These values are illustrative, not
estimates for Earth. τ is the e-folding response time; the arrows in
the plot show sinusoidal peak-to-peak phase lag in periodic steady state.
</div>
</section>
<section class="panel chart-card">
<div class="chart-head">
<div>
<h2>Identical input, delayed response</h2>
<div class="chart-subtitle">Temperature and common forcing · °C versus model year</div>
</div>
<div class="chart-legend">
<span class="legend-item" style="color:var(--forcing)">
<span class="legend-line dashed"></span> Forcing
</span>
<span class="legend-item" style="color:var(--fast)">
<span class="legend-line"></span> Fast
</span>
<span class="legend-item" style="color:var(--slow)">
<span class="legend-line"></span> Slow
</span>
</div>
</div>
<svg id="plot" viewBox="0 0 640 310" role="img"
aria-label="Synthetic forcing and delayed thermal reservoir responses">
<defs>
<marker id="arrowFast" viewBox="0 0 10 10" refX="9" refY="5"
markerWidth="6" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#55d6ff"></path>
</marker>
<marker id="arrowSlow" viewBox="0 0 10 10" refX="9" refY="5"
markerWidth="6" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#bd98ff"></path>
</marker>
</defs>
<g id="gridLayer"></g>
<g id="curveLayer"></g>
<g id="peakLayer"></g>
<g id="lagLayer"></g>
<line id="cursorLine" x1="48" x2="48" y1="25" y2="198"
stroke="rgba(235,245,255,.60)" stroke-width="1"
stroke-dasharray="3 4"></line>
<circle id="cursorForce" cx="48" cy="100" r="4.5"
fill="#ffad5a" stroke="#07111f" stroke-width="1.5"></circle>
<circle id="cursorFast" cx="48" cy="100" r="4.5"
fill="#55d6ff" stroke="#07111f" stroke-width="1.5"></circle>
<circle id="cursorSlow" cx="48" cy="100" r="4.5"
fill="#bd98ff" stroke="#07111f" stroke-width="1.5"></circle>
</svg>
</section>
<div id="hint">Drag to orbit · scroll to zoom · use the buttons to pause or 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";
// ------------------------------------------------------------
// Synthetic first-order climate-timescale model
// ------------------------------------------------------------
const P = 120; // forcing period, model years
const T0 = 18; // baseline temperature, °C
const A = 6; // forcing amplitude, °C
const tauFast = 8; // synthetic response time, years
const tauSlow = 50; // synthetic response time, years
const omega = 2 * Math.PI / P;
const phaseFast = Math.atan(omega * tauFast);
const phaseSlow = Math.atan(omega * tauSlow);
const lagFast = phaseFast / omega;
const lagSlow = phaseSlow / omega;
const ampFast = A / Math.sqrt(1 + Math.pow(omega * tauFast, 2));
const ampSlow = A / Math.sqrt(1 + Math.pow(omega * tauSlow, 2));
document.getElementById("vLagFast").textContent = `${lagFast.toFixed(1)} yr`;
document.getElementById("vLagSlow").textContent = `${lagSlow.toFixed(1)} yr`;
const forcingAt = t => T0 + A * Math.sin(omega * t);
// Exact periodic steady-state solution of:
// dT/dt = (F(t) - T) / tau
const responseAt = (t, tau) => {
const x = omega * tau;
return T0 + A * (
Math.sin(omega * t) - x * Math.cos(omega * t)
) / (1 + x * x);
};
// ------------------------------------------------------------
// Three.js scene
// ------------------------------------------------------------
const stage = document.getElementById("stage");
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111f);
scene.fog = new THREE.Fog(0x07111f, 15, 31);
const camera = new THREE.PerspectiveCamera(
42, window.innerWidth / window.innerHeight, 0.1, 100
);
const cameraTarget = new THREE.Vector3(0, 1.7, 0);
const initialCamera = { radius: 13.8, phi: 1.07, theta: 0.12 };
const cameraCurrent = { ...initialCamera };
const cameraGoal = { ...initialCamera };
function updateCamera() {
const { radius, phi, theta } = cameraCurrent;
camera.position.set(
cameraTarget.x + radius * Math.sin(phi) * Math.sin(theta),
cameraTarget.y + radius * Math.cos(phi),
cameraTarget.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Direct camera controls: no examples/jsm or addon modules.
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;
cameraGoal.theta -= dx * 0.006;
cameraGoal.phi = THREE.MathUtils.clamp(
cameraGoal.phi - dy * 0.005, 0.55, 1.39
);
});
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();
cameraGoal.radius = THREE.MathUtils.clamp(
cameraGoal.radius + event.deltaY * 0.012, 8.5, 19
);
}, { passive: false });
// Lighting
scene.add(new THREE.HemisphereLight(0xbfe9ff, 0x172238, 2.0));
const keyLight = new THREE.DirectionalLight(0xffffff, 3.0);
keyLight.position.set(5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x679dff, 1.5);
rimLight.position.set(-7, 5, -5);
scene.add(rimLight);
// Platform and grid
const platformMat = new THREE.MeshStandardMaterial({
color: 0x0c1c2d,
roughness: 0.82,
metalness: 0.08
});
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(7.1, 7.4, 0.18, 72),
platformMat
);
platform.position.y = -0.17;
platform.receiveShadow = true;
scene.add(platform);
const grid = new THREE.GridHelper(14, 28, 0x35516c, 0x1b3047);
grid.position.y = -0.072;
grid.material.transparent = true;
grid.material.opacity = 0.46;
scene.add(grid);
const darkMat = new THREE.MeshStandardMaterial({
color: 0x16273a,
roughness: 0.62,
metalness: 0.22
});
const baseMat = new THREE.MeshStandardMaterial({
color: 0x24384d,
roughness: 0.55,
metalness: 0.30
});
const orangeMat = new THREE.MeshStandardMaterial({
color: 0xff9c45,
emissive: 0xff6d1f,
emissiveIntensity: 0.85,
roughness: 0.34,
metalness: 0.12
});
const sourceMat = new THREE.MeshStandardMaterial({
color: 0xffb05f,
emissive: 0xff6f21,
emissiveIntensity: 1.4,
roughness: 0.28,
metalness: 0.08
});
// Shared forcing source
const source = new THREE.Mesh(
new THREE.SphereGeometry(0.48, 32, 24),
sourceMat
);
source.position.set(0, 4.55, -1.55);
source.castShadow = true;
scene.add(source);
const sourceLight = new THREE.PointLight(0xff8b3d, 28, 10, 2);
sourceLight.position.copy(source.position);
scene.add(sourceLight);
const sourceRingA = new THREE.Mesh(
new THREE.TorusGeometry(0.82, 0.035, 10, 64),
orangeMat
);
sourceRingA.position.copy(source.position);
sourceRingA.rotation.x = 0.55;
source.add(sourceRingA);
const sourceRingB = sourceRingA.clone();
sourceRingB.rotation.set(1.1, 0.4, 0.2);
source.add(sourceRingB);
// Label sprite helper
function makeLabel(title, subtitle, accent = "#9fd7ee") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 180;
const ctx = canvas.getContext("2d");
function roundedRect(x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
roundedRect(5, 5, 630, 170, 24);
ctx.fillStyle = "rgba(7, 19, 34, 0.88)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 3;
ctx.stroke();
ctx.textAlign = "center";
ctx.fillStyle = "#f4fbff";
ctx.font = "800 43px system-ui, sans-serif";
ctx.fillText(title, 320, 72);
ctx.fillStyle = accent;
ctx.font = "600 29px system-ui, sans-serif";
ctx.fillText(subtitle, 320, 125);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(2.85, 0.80, 1);
return sprite;
}
const sharedLabel = makeLabel(
"IDENTICAL FORCING F(t)",
"one shared signal drives both reservoirs",
"#ffb25f"
);
sharedLabel.position.set(0, 5.55, -1.55);
scene.add(sharedLabel);
const coldColor = new THREE.Color("#3f83ff");
const midColor = new THREE.Color("#9c67e8");
const hotColor = new THREE.Color("#ff7855");
function temperatureColor(temp, out) {
const n = THREE.MathUtils.clamp((temp - 10) / 16, 0, 1);
if (n < 0.5) {
out.copy(coldColor).lerp(midColor, n * 2);
} else {
out.copy(midColor).lerp(hotColor, (n - 0.5) * 2);
}
return out;
}
const tankSignals = [];
function makeTank(x, accentHex, title, subtitle, accentCss) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
const accent = new THREE.Color(accentHex);
const base = new THREE.Mesh(
new THREE.CylinderGeometry(1.14, 1.25, 0.24, 48),
baseMat
);
base.position.y = 0.12;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const foot = new THREE.Mesh(
new THREE.CylinderGeometry(0.98, 1.05, 0.22, 48),
darkMat
);
foot.position.y = 0.33;
foot.castShadow = true;
group.add(foot);
const accentRing = new THREE.Mesh(
new THREE.TorusGeometry(1.08, 0.065, 12, 64),
new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.5,
roughness: 0.35
})
);
accentRing.rotation.x = Math.PI / 2;
accentRing.position.y = 0.26;
group.add(accentRing);
const coreMaterial = new THREE.MeshStandardMaterial({
color: 0x477de6,
emissive: 0x193b78,
emissiveIntensity: 0.38,
roughness: 0.40,
metalness: 0.05
});
const core = new THREE.Mesh(
new THREE.CylinderGeometry(0.82, 0.94, 1.34, 48),
coreMaterial
);
core.position.y = 1.18;
core.castShadow = true;
core.receiveShadow = true;
group.add(core);
const cap = new THREE.Mesh(
new THREE.CylinderGeometry(0.85, 0.85, 0.12, 48),
coreMaterial
);
cap.position.y = 1.89;
cap.castShadow = true;
group.add(cap);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.86, 0.075, 12, 64),
accentMaterial(accent)
);
rim.rotation.x = Math.PI / 2;
rim.position.y = 1.96;
group.add(rim);
for (const y of [0.76, 1.18, 1.60]) {
const band = new THREE.Mesh(
new THREE.TorusGeometry(0.90, 0.026, 8, 64),
accentMaterial(accent)
);
band.rotation.x = Math.PI / 2;
band.position.y = y;
group.add(band);
}
// Identical forcing phase ring above each tank.
const signalRing = new THREE.Mesh(
new THREE.TorusGeometry(0.68, 0.035, 10, 64),
orangeMat
);
signalRing.rotation.x = Math.PI / 2;
signalRing.position.set(x, 2.40, 0);
scene.add(signalRing);
const bead = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 18, 12),
sourceMat
);
scene.add(bead);
const cone = new THREE.Mesh(
new THREE.ConeGeometry(0.22, 0.50, 24),
orangeMat
);
cone.rotation.z = Math.PI;
cone.position.set(x, 3.18, 0);
scene.add(cone);
// Shared source branches to the two identical forcing indicators.
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(0, 4.48, -1.55),
new THREE.Vector3(x * 0.45, 4.12, -1.05),
new THREE.Vector3(x, 3.55, -0.18),
new THREE.Vector3(x, 3.30, 0)
]);
const branch = new THREE.Mesh(
new THREE.TubeGeometry(curve, 42, 0.045, 8, false),
orangeMat
);
scene.add(branch);
const label = makeLabel(title, subtitle, accentCss);
label.position.set(x, 2.03, 0.92);
scene.add(label);
tankSignals.push({ x, bead, cone, coreMaterial });
}
function accentMaterial(color) {
return new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.22,
roughness: 0.48,
metalness: 0.08
});
}
makeTank(
-2.55, 0x55d6ff,
"FAST RESERVOIR",
`τ = ${tauFast} yr · peak lag ${lagFast.toFixed(1)} yr`,
"#55d6ff"
);
makeTank(
2.55, 0xbd98ff,
"SLOW RESERVOIR",
`τ = ${tauSlow} yr · peak lag ${lagSlow.toFixed(1)} yr`,
"#bd98ff"
);
// ------------------------------------------------------------
// SVG plot
// ------------------------------------------------------------
const X0 = 48;
const X1 = 620;
const Y0 = 25;
const Y1 = 198;
const Y_MIN = 10;
const Y_MAX = 26;
const plotX = t => X0 + (t / P) * (X1 - X0);
const plotY = value => Y0 +
((Y_MAX - value) / (Y_MAX - Y_MIN)) * (Y1 - Y0);
function pathFor(fn, samples = 260) {
let path = "";
for (let i = 0; i <= samples; i++) {
const t = P * i / samples;
path += `${i === 0 ? "M" : "L"}${plotX(t).toFixed(2)},${plotY(fn(t)).toFixed(2)}`;
}
return path;
}
let gridMarkup = "";
for (const value of [10, 14, 18, 22, 26]) {
const y = plotY(value);
gridMarkup += `
<line x1="${X0}" x2="${X1}" y1="${y}" y2="${y}"
stroke="rgba(170,195,220,.13)" stroke-width="1"/>
<text x="${X0 - 9}" y="${y + 4}" text-anchor="end"
fill="#8fa4ba" font-size="10">${value}</text>
`;
}
for (const t of [0, 30, 60, 90, 120]) {
const x = plotX(t);
gridMarkup += `
<line x1="${x}" x2="${x}" y1="${Y0}" y2="${Y1}"
stroke="rgba(170,195,220,.10)" stroke-width="1"/>
<text x="${x}" y="215" text-anchor="middle"
fill="#8fa4ba" font-size="10">${t}</text>
`;
}
gridMarkup += `
<text x="12" y="18" fill="#a8bad0" font-size="10">°C</text>
<text x="620" y="215" text-anchor="end" fill="#8fa4ba" font-size="10">model year</text>
`;
document.getElementById("gridLayer").innerHTML = gridMarkup;
document.getElementById("curveLayer").innerHTML = `
<path d="${pathFor(forcingAt)}" fill="none" stroke="#ffad5a"
stroke-width="2.2" stroke-dasharray="7 5"/>
<path d="${pathFor(t => responseAt(t, tauFast))}" fill="none"
stroke="#55d6ff" stroke-width="2.8"/>
<path d="${pathFor(t => responseAt(t, tauSlow))}" fill="none"
stroke="#bd98ff" stroke-width="2.8"/>
`;
const forcingPeakTime = P / 4;
const fastPeakTime = forcingPeakTime + lagFast;
const slowPeakTime = forcingPeakTime + lagSlow;
document.getElementById("peakLayer").innerHTML = `
<line x1="${plotX(forcingPeakTime)}" x2="${plotX(forcingPeakTime)}"
y1="${Y0}" y2="${Y1}" stroke="#ffad5a" stroke-width="1.3"
stroke-dasharray="4 4" opacity=".78"/>
<line x1="${plotX(fastPeakTime)}" x2="${plotX(fastPeakTime)}"
y1="${Y0}" y2="${Y1}" stroke="#55d6ff" stroke-width="1.3"
stroke-dasharray="4 4" opacity=".70"/>
<line x1="${plotX(slowPeakTime)}" x2="${plotX(slowPeakTime)}"
y1="${Y0}" y2="${Y1}" stroke="#bd98ff" stroke-width="1.3"
stroke-dasharray="4 4" opacity=".70"/>
<circle cx="${plotX(forcingPeakTime)}" cy="${plotY(forcingAt(forcingPeakTime))}"
r="4" fill="#ffad5a"/>
<circle cx="${plotX(fastPeakTime)}" cy="${plotY(responseAt(fastPeakTime, tauFast))}"
r="4" fill="#55d6ff"/>
<circle cx="${plotX(slowPeakTime)}" cy="${plotY(responseAt(slowPeakTime, tauSlow))}"
r="4" fill="#bd98ff"/>
`;
document.getElementById("lagLayer").innerHTML = `
<text x="${X0}" y="237" fill="#8fa4ba" font-size="10"
font-weight="700" letter-spacing="1.2">
PEAK-TO-PEAK PHASE LAG
</text>
<line x1="${plotX(forcingPeakTime)}" x2="${plotX(fastPeakTime)}"
y1="253" y2="253" stroke="#55d6ff" stroke-width="1.8"
marker-end="url(#arrowFast)"/>
<text x="${plotX(fastPeakTime) + 8}" y="257" fill="#55d6ff"
font-size="11" font-weight="700">${lagFast.toFixed(1)} yr</text>
<line x1="${plotX(forcingPeakTime)}" x2="${plotX(slowPeakTime)}"
y1="285" y2="285" stroke="#bd98ff" stroke-width="1.8"
marker-end="url(#arrowSlow)"/>
<text x="${plotX(slowPeakTime) + 8}" y="289" fill="#bd98ff"
font-size="11" font-weight="700">${lagSlow.toFixed(1)} yr</text>
`;
const cursorLine = document.getElementById("cursorLine");
const cursorForce = document.getElementById("cursorForce");
const cursorFast = document.getElementById("cursorFast");
const cursorSlow = document.getElementById("cursorSlow");
// ------------------------------------------------------------
// Controls and animation
// ------------------------------------------------------------
const controls = document.createElement("div");
controls.className = "controls";
controls.style.display = "flex";
controls.style.pointerEvents = "auto";
const pauseButton = document.createElement("button");
pauseButton.textContent = "Pause";
pauseButton.setAttribute("aria-label", "Pause animation");
const resetButton = document.createElement("button");
resetButton.textContent = "Reset view";
resetButton.setAttribute("aria-label", "Reset camera view");
controls.append(pauseButton, resetButton);
document.getElementById("hud").appendChild(controls);
let paused = false;
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
});
resetButton.addEventListener("click", () => {
cameraGoal.radius = initialCamera.radius;
cameraGoal.phi = initialCamera.phi;
cameraGoal.theta = initialCamera.theta;
});
const secondsPerCycle = 24;
let elapsed = 0;
let lastTime = performance.now();
const workingColor = new THREE.Color();
function animate(now) {
requestAnimationFrame(animate);
const dt = Math.min((now - lastTime) / 1000, 0.05);
lastTime = now;
if (!paused) elapsed += dt;
const modelTime = (elapsed / secondsPerCycle * P) % P;
const forcing = forcingAt(modelTime);
const fastTemp = responseAt(modelTime, tauFast);
const slowTemp = responseAt(modelTime, tauSlow);
const phase = omega * modelTime;
// Smooth camera controls.
cameraCurrent.radius += (cameraGoal.radius - cameraCurrent.radius) * 0.09;
cameraCurrent.phi += (cameraGoal.phi - cameraCurrent.phi) * 0.09;
cameraCurrent.theta += (cameraGoal.theta - cameraCurrent.theta) * 0.09;
updateCamera();
// Temperature-colored solid reservoir cores.
temperatureColor(fastTemp, workingColor);
tankSignals[0].coreMaterial.color.copy(workingColor);
tankSignals[0].coreMaterial.emissive.copy(workingColor);
tankSignals[0].coreMaterial.emissiveIntensity = 0.32;
temperatureColor(slowTemp, workingColor);
tankSignals[1].coreMaterial.color.copy(workingColor);
tankSignals[1].coreMaterial.emissive.copy(workingColor);
tankSignals[1].coreMaterial.emissiveIntensity = 0.32;
// The two orange phase beads receive exactly the same signal.
for (const signal of tankSignals) {
signal.bead.position.set(
signal.x + 0.68 * Math.cos(phase),
2.40,
0.68 * Math.sin(phase)
);
const pulse = 0.5 + 0.5 * Math.sin(phase);
signal.cone.scale.set(
0.90 + 0.10 * pulse,
0.72 + 0.34 * pulse,
0.90 + 0.10 * pulse
);
}
const sourcePulse = 0.5 + 0.5 * Math.sin(phase);
source.scale.setScalar(0.93 + 0.12 * sourcePulse);
sourceLight.intensity = 20 + 20 * sourcePulse;
sourceMat.emissiveIntensity = 0.9 + 0.8 * sourcePulse;
sourceRingA.rotation.z += dt * 0.5;
sourceRingB.rotation.y -= dt * 0.4;
// Live values.
document.getElementById("vForce").textContent = `${forcing.toFixed(1)} °C`;
document.getElementById("vFast").textContent = `${fastTemp.toFixed(1)} °C`;
document.getElementById("vSlow").textContent = `${slowTemp.toFixed(1)} °C`;
document.getElementById("vTime").textContent = `${modelTime.toFixed(0)} yr`;
// Moving plot cursor and values.
const x = plotX(modelTime);
cursorLine.setAttribute("x1", x);
cursorLine.setAttribute("x2", x);
cursorForce.setAttribute("cx", x);
cursorForce.setAttribute("cy", plotY(forcing));
cursorFast.setAttribute("cx", x);
cursorFast.setAttribute("cy", plotY(fastTemp));
cursorSlow.setAttribute("cx", x);
cursorSlow.setAttribute("cy", plotY(slowTemp));
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
requestAnimationFrame(animate);
</script>
</body>
</html>
```