Prompt specification
Build or customize the Three.js 3D scene "Pumping cone conceptual model" 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: Pumping cone conceptual model
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/pumping-cone-conceptual-model-x1208
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring aquifers and wells. Animate a schematic water-table depression around a pumping well with an explanatory label; provide pause and reset and avoid presenting the geometry as a calculated drawdown prediction. Low-poly.
Working Three.js Starter (pumping-cone-conceptual-model-x1208):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Aquifers & Wells — Schematic Water-Table Response</title>
<style>
:root {
--ink: #173239;
--muted: #50666b;
--panel: rgba(250, 252, 248, 0.92);
--line: rgba(23, 50, 57, 0.14);
--cyan: #087e91;
--cyan-light: #73d8d3;
--orange: #e87335;
--blue: #3e7181;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7eee9;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
#viewport canvas:focus-visible {
outline: 3px solid var(--cyan);
outline-offset: -4px;
}
.panel {
position: fixed;
z-index: 10;
top: 20px;
left: 20px;
width: min(370px, calc(100vw - 40px));
padding: 20px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 20px;
background: var(--panel);
box-shadow:
0 18px 50px rgba(37, 62, 61, 0.13),
inset 0 1px 0 rgba(255, 255, 255, 0.9);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.eyebrow {
margin: 0 0 8px;
color: var(--cyan);
font-size: 0.71rem;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(1.7rem, 3vw, 2.35rem);
line-height: 1.02;
letter-spacing: -0.045em;
}
.lede {
margin: 12px 0 15px;
color: var(--muted);
font-size: 0.94rem;
line-height: 1.48;
}
.notice {
display: flex;
align-items: flex-start;
gap: 9px;
padding: 10px 11px;
border: 1px solid rgba(221, 118, 56, 0.23);
border-radius: 12px;
background: rgba(255, 238, 221, 0.76);
color: #714125;
font-size: 0.77rem;
font-weight: 750;
line-height: 1.35;
}
.notice::before {
content: "!";
flex: 0 0 auto;
width: 18px;
height: 18px;
display: grid;
place-items: center;
border-radius: 50%;
background: var(--orange);
color: white;
font-size: 0.72rem;
}
.legend {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px 12px;
margin-top: 16px;
padding-top: 15px;
border-top: 1px solid var(--line);
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
color: #3d555a;
font-size: 0.76rem;
line-height: 1.25;
}
.swatch {
flex: 0 0 auto;
width: 12px;
height: 12px;
border-radius: 3px;
}
.swatch.water {
background: var(--cyan-light);
border: 1px solid var(--cyan);
}
.swatch.pump {
background: var(--orange);
}
.swatch.observation {
background: var(--blue);
}
.swatch.guide {
height: 2px;
border-radius: 0;
background: repeating-linear-gradient(
90deg,
var(--cyan) 0 5px,
transparent 5px 8px
);
}
.microcopy {
margin: 13px 0 0;
color: #6a7d80;
font-size: 0.69rem;
line-height: 1.45;
}
.controls {
position: fixed;
z-index: 20;
top: 20px;
right: 20px;
display: flex;
gap: 8px;
padding: 7px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 15px;
background: rgba(250, 252, 248, 0.88);
box-shadow: 0 12px 35px rgba(37, 62, 61, 0.13);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.controls button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 7px;
min-height: 38px;
padding: 0 13px;
border: 0;
border-radius: 10px;
background: transparent;
color: var(--ink);
cursor: pointer;
font-size: 0.82rem;
font-weight: 750;
transition:
background 150ms ease,
transform 150ms ease;
}
.controls button:hover {
background: #e7efea;
}
.controls button:active {
transform: translateY(1px);
}
.controls button:focus-visible {
outline: 3px solid rgba(8, 126, 145, 0.28);
outline-offset: 1px;
}
.controls .primary {
background: var(--ink);
color: white;
}
.controls .primary:hover {
background: #254950;
}
.button-icon {
font-size: 1rem;
line-height: 1;
}
#leader {
position: fixed;
inset: 0;
z-index: 7;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
#leader line {
stroke: rgba(8, 126, 145, 0.72);
stroke-width: 1.5;
stroke-dasharray: 3 4;
}
#leader circle {
fill: #f8fff9;
stroke: var(--cyan);
stroke-width: 2;
}
.callout {
position: fixed;
z-index: 8;
top: 0;
left: 0;
width: min(278px, calc(100vw - 32px));
padding: 14px 15px;
border: 1px solid rgba(8, 126, 145, 0.22);
border-radius: 15px;
background: rgba(246, 253, 249, 0.95);
box-shadow: 0 12px 30px rgba(33, 73, 76, 0.14);
pointer-events: none;
}
.callout-kicker {
display: block;
margin-bottom: 4px;
color: var(--cyan);
font-size: 0.65rem;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.callout strong {
display: block;
font-size: 0.94rem;
letter-spacing: -0.015em;
}
.callout p {
margin: 6px 0 0;
color: #526a6e;
font-size: 0.76rem;
line-height: 1.42;
}
.drag-hint {
position: fixed;
z-index: 5;
right: 22px;
bottom: 19px;
padding: 8px 11px;
border-radius: 9px;
background: rgba(248, 251, 247, 0.75);
color: #64797c;
font-size: 0.7rem;
pointer-events: none;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
#loading {
position: fixed;
z-index: 50;
inset: 0;
display: grid;
place-items: center;
background: #e7eee9;
color: var(--muted);
font-size: 0.88rem;
letter-spacing: 0.04em;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 700px) {
.panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px;
border-radius: 16px;
}
h1 {
font-size: 1.55rem;
}
.lede {
margin: 8px 0 10px;
font-size: 0.82rem;
}
.legend,
.microcopy {
display: none;
}
.notice {
font-size: 0.7rem;
}
.controls {
top: auto;
right: 12px;
bottom: 12px;
}
.controls button {
min-height: 36px;
padding: 0 11px;
}
.drag-hint {
display: none;
}
.callout {
width: min(235px, calc(100vw - 32px));
padding: 11px 12px;
}
.callout p {
font-size: 0.7rem;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<section class="panel" aria-labelledby="title">
<p class="eyebrow">Interactive hydrogeology cutaway</p>
<h1 id="title">Aquifers & wells</h1>
<p class="lede">
Watch a stylized water table dip around an active pumping well.
The bowl shape, dashed guides, and timing are deliberately schematic.
</p>
<div class="notice">
Illustrative geometry only — not a calculated drawdown prediction.
</div>
<div class="legend" aria-label="Scene legend">
<div class="legend-item">
<span class="swatch water"></span>
<span>Water table</span>
</div>
<div class="legend-item">
<span class="swatch pump"></span>
<span>Active pumping well</span>
</div>
<div class="legend-item">
<span class="swatch observation"></span>
<span>Observation wells</span>
</div>
<div class="legend-item">
<span class="swatch guide"></span>
<span>Visual guides only</span>
</div>
</div>
<p class="microcopy">
No scale, pumping rate, aquifer parameters, or predictive calculation is
represented. The depression is an explanatory animation.
</p>
</section>
<nav class="controls" aria-label="Animation controls">
<button id="pause" class="primary" type="button" aria-pressed="false">
<span id="pause-icon" class="button-icon" aria-hidden="true">Ⅱ</span>
<span id="pause-label">Pause</span>
</button>
<button id="reset" type="button">
<span class="button-icon" aria-hidden="true">↺</span>
<span>Reset</span>
</button>
</nav>
<svg id="leader" aria-hidden="true">
<line id="leader-line" x1="0" y1="0" x2="0" y2="0"></line>
<circle id="leader-dot" cx="0" cy="0" r="4"></circle>
</svg>
<aside id="callout" class="callout">
<span class="callout-kicker">Schematic response</span>
<strong>Why the surface dips</strong>
<p>
Water is withdrawn at the orange well. The nearby water table is shown
lowering; its depth and extent are not hydraulically calculated.
</p>
</aside>
<div class="drag-hint">Drag to orbit · Scroll to zoom · Double-click to reset view</div>
<div id="status" class="sr-only" aria-live="polite"></div>
<div id="loading">Loading 3D scene…</div>
<noscript>This interactive scene requires JavaScript.</noscript>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Core setup
// -------------------------------------------------------------------------
const viewport = document.getElementById("viewport");
const loading = document.getElementById("loading");
const pauseButton = document.getElementById("pause");
const pauseIcon = document.getElementById("pause-icon");
const pauseLabel = document.getElementById("pause-label");
const resetButton = document.getElementById("reset");
const status = document.getElementById("status");
const callout = document.getElementById("callout");
const leaderLine = document.getElementById("leader-line");
const leaderDot = document.getElementById("leader-dot");
const renderer = new THREE.WebGLRenderer({
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;
renderer.domElement.setAttribute(
"aria-label",
"Interactive low-poly aquifer cutaway with a pumping well and observation wells"
);
renderer.domElement.setAttribute("tabindex", "0");
viewport.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7eee9);
scene.fog = new THREE.Fog(0xe7eee9, 28, 54);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xf6fff9, 0x7e8174, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff4d8, 3.1);
sun.position.set(-8, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbbe9ed, 1.2);
fill.position.set(10, 5, -9);
scene.add(fill);
const colors = {
bedrock: 0x59645f,
sand: 0xc5a064,
sandLight: 0xddbd82,
sandDark: 0xa98553,
water: 0x087e91,
waterLight: 0x87e0d7,
waterDeep: 0x0a7084,
pipe: 0x496f78,
pipeDark: 0x284d58,
orange: 0xe87335,
orangeDark: 0xa9461e,
white: 0xeaf3ec
};
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
flatShading: true,
...options
});
}
function addBox(width, height, depth, material, x, y, z, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Geological block
// -------------------------------------------------------------------------
const shadowFloor = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
standardMaterial(0xdce6df, { roughness: 1 })
);
shadowFloor.rotation.x = -Math.PI / 2;
shadowFloor.position.y = -3.02;
shadowFloor.receiveShadow = true;
scene.add(shadowFloor);
addBox(
14.8,
0.5,
8.2,
standardMaterial(colors.bedrock),
0,
-2.72,
0
);
const aquiferMaterial = new THREE.MeshPhongMaterial({
color: colors.sand,
transparent: true,
opacity: 0.25,
shininess: 16,
side: THREE.DoubleSide,
depthWrite: false
});
const aquiferVolume = new THREE.Mesh(
new THREE.BoxGeometry(14, 2.9, 7.5),
aquiferMaterial
);
aquiferVolume.position.y = -1.0;
aquiferVolume.receiveShadow = true;
aquiferVolume.renderOrder = 1;
scene.add(aquiferVolume);
const aquiferEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(aquiferVolume.geometry),
new THREE.LineBasicMaterial({
color: 0x6e806f,
transparent: true,
opacity: 0.28
})
);
aquiferEdges.position.copy(aquiferVolume.position);
scene.add(aquiferEdges);
// Opaque rear wall and strips establish the cutaway ground surface.
addBox(
14.25,
3.8,
0.3,
standardMaterial(colors.sand),
0,
-0.55,
-3.72
);
addBox(
14.4,
0.34,
2.6,
standardMaterial(colors.sandLight),
0,
1.38,
-2.43
);
addBox(
0.95,
0.34,
7.5,
standardMaterial(colors.sandLight),
-6.72,
1.38,
0
);
addBox(
0.95,
0.34,
7.5,
standardMaterial(colors.sandLight),
6.72,
1.38,
0
);
// Subtle strata lines on the rear cut face.
const strataMaterial = new THREE.LineBasicMaterial({
color: 0x947744,
transparent: true,
opacity: 0.42
});
[-1.85, -1.05, -0.2, 0.7].forEach((y) => {
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-6.9, y, -3.555),
new THREE.Vector3(6.9, y, -3.555)
]);
scene.add(new THREE.Line(geometry, strataMaterial));
});
// Deterministic low-poly grains suspended in the porous aquifer.
let randomSeed = 7391;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
const grainGeometry = new THREE.IcosahedronGeometry(1, 0);
const grainMaterials = [
standardMaterial(colors.sandDark, { transparent: true, opacity: 0.58 }),
standardMaterial(colors.sandLight, { transparent: true, opacity: 0.48 }),
standardMaterial(0xb89558, { transparent: true, opacity: 0.54 })
];
for (let i = 0; i < 54; i += 1) {
const grain = new THREE.Mesh(
grainGeometry,
grainMaterials[i % grainMaterials.length]
);
const size = 0.08 + random() * 0.18;
grain.scale.set(size, size * (0.6 + random() * 0.7), size);
grain.position.set(
-6.55 + random() * 13.1,
-2.25 + random() * 2.45,
-3.25 + random() * 6.5
);
grain.rotation.set(random() * 3, random() * 3, random() * 3);
scene.add(grain);
}
// A few faceted trees provide surface context without obscuring the cutaway.
function addTree(x, z, scale = 1) {
const group = new THREE.Group();
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.09, 0.13, 0.55, 5),
standardMaterial(0x765238)
);
trunk.position.y = 0.27;
trunk.castShadow = true;
group.add(trunk);
const crown = new THREE.Mesh(
new THREE.ConeGeometry(0.46, 1.05, 6),
standardMaterial(0x668f66)
);
crown.position.y = 0.95;
crown.castShadow = true;
group.add(crown);
group.position.set(x, 1.55, z);
group.scale.setScalar(scale);
scene.add(group);
}
addTree(-5.4, -2.8, 0.95);
addTree(-2.3, -2.4, 0.78);
addTree(2.2, -2.6, 0.9);
addTree(5.2, -2.25, 0.7);
// -------------------------------------------------------------------------
// Animated schematic water table
// -------------------------------------------------------------------------
const waterWidth = 13.7;
const waterDepth = 7.1;
const waterBaseLevel = 0.62;
const pumpingX = 0;
const pumpingZ = 0.5;
const segmentsX = 38;
const segmentsZ = 22;
const waterPositions = [];
const waterColors = [];
const waterIndices = [];
for (let zIndex = 0; zIndex <= segmentsZ; zIndex += 1) {
const z = -waterDepth / 2 + (zIndex / segmentsZ) * waterDepth;
for (let xIndex = 0; xIndex <= segmentsX; xIndex += 1) {
const x = -waterWidth / 2 + (xIndex / segmentsX) * waterWidth;
waterPositions.push(x, waterBaseLevel, z);
waterColors.push(0.45, 0.86, 0.82);
if (xIndex < segmentsX && zIndex < segmentsZ) {
const a = zIndex * (segmentsX + 1) + xIndex;
const b = a + 1;
const c = a + segmentsX + 1;
const d = c + 1;
// Alternating diagonals keep the mesh intentionally faceted.
if ((xIndex + zIndex) % 2 === 0) {
waterIndices.push(a, c, b, b, c, d);
} else {
waterIndices.push(a, c, d, a, d, b);
}
}
}
}
const waterGeometry = new THREE.BufferGeometry();
waterGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(waterPositions, 3)
);
waterGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(waterColors, 3)
);
waterGeometry.setIndex(waterIndices);
waterGeometry.computeVertexNormals();
const waterMaterial = standardMaterial(0xffffff, {
vertexColors: true,
transparent: true,
opacity: 0.9,
roughness: 0.48,
metalness: 0.04,
side: THREE.DoubleSide,
depthWrite: false
});
const waterMesh = new THREE.Mesh(waterGeometry, waterMaterial);
waterMesh.receiveShadow = true;
waterMesh.renderOrder = 3;
scene.add(waterMesh);
const waterWire = new THREE.Mesh(
waterGeometry,
new THREE.MeshBasicMaterial({
color: 0x075d6a,
wireframe: true,
transparent: true,
opacity: 0.075,
depthWrite: false
})
);
waterWire.renderOrder = 4;
waterMesh.add(waterWire);
// Dashed rings are visual emphasis only; they have no numeric meaning.
const guideRadii = [1.35, 2.55, 3.75];
const guideLines = guideRadii.map((radius) => {
const positions = [];
const segments = 72;
for (let i = 0; i < segments; i += 1) {
const angle = (i / segments) * Math.PI * 2;
positions.push(
Math.cos(angle) * radius,
waterBaseLevel,
pumpingZ + Math.sin(angle) * radius
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
const material = new THREE.LineDashedMaterial({
color: 0x087e91,
transparent: true,
opacity: 0,
dashSize: 0.16,
gapSize: 0.12,
depthWrite: false
});
const line = new THREE.LineLoop(geometry, material);
line.computeLineDistances();
line.renderOrder = 5;
line.frustumCulled = false;
scene.add(line);
return line;
});
let elapsed = 0;
let pumpProgress = 0;
let currentDepression = 0;
function smoothStep(value) {
const t = THREE.MathUtils.clamp(value, 0, 1);
return t * t * (3 - 2 * t);
}
// This is an intentionally arbitrary visual profile, not a hydrologic model.
function waterHeight(x, z) {
const radius = Math.hypot(x - pumpingX, z - pumpingZ);
const influence = Math.exp(-Math.pow(radius / 3.15, 2));
const gentlePulse =
0.04 *
pumpProgress *
Math.sin(radius * 2.45 - elapsed * 2.2) *
Math.exp(-radius * 0.35);
return (
waterBaseLevel -
currentDepression * influence +
gentlePulse
);
}
const shallowColor = new THREE.Color(colors.waterLight);
const deepColor = new THREE.Color(colors.waterDeep);
const temporaryColor = new THREE.Color();
function updateWater() {
pumpProgress = smoothStep(elapsed / 5.5);
currentDepression =
1.18 *
pumpProgress *
(1 + 0.035 * Math.sin(elapsed * 1.7));
const positionAttribute = waterGeometry.getAttribute("position");
const colorAttribute = waterGeometry.getAttribute("color");
for (let i = 0; i < positionAttribute.count; i += 1) {
const x = positionAttribute.getX(i);
const z = positionAttribute.getZ(i);
const y = waterHeight(x, z);
positionAttribute.setY(i, y);
const colorMix = THREE.MathUtils.clamp(
(y + 0.85) / 1.55,
0,
1
);
temporaryColor.copy(deepColor).lerp(shallowColor, colorMix);
colorAttribute.setXYZ(
i,
temporaryColor.r,
temporaryColor.g,
temporaryColor.b
);
}
positionAttribute.needsUpdate = true;
colorAttribute.needsUpdate = true;
waterGeometry.computeVertexNormals();
guideLines.forEach((line, index) => {
const radius = guideRadii[index];
const positions = line.geometry.getAttribute("position");
for (let i = 0; i < positions.count; i += 1) {
const x = positions.getX(i);
const z = positions.getZ(i);
positions.setY(i, waterHeight(x, z));
}
positions.needsUpdate = true;
line.computeLineDistances();
line.material.opacity = pumpProgress * 0.46;
line.visible = pumpProgress > 0.015;
});
}
// -------------------------------------------------------------------------
// Wells
// -------------------------------------------------------------------------
const casingMaterial = new THREE.MeshPhongMaterial({
color: 0xd7e6e1,
transparent: true,
opacity: 0.4,
shininess: 35,
depthWrite: false
});
const observationMaterial = standardMaterial(colors.pipe);
const pipeMaterial = standardMaterial(colors.pipeDark);
const pumpMaterial = standardMaterial(colors.orange);
const pumpDarkMaterial = standardMaterial(colors.orangeDark);
const pumpGroup = new THREE.Group();
pumpGroup.position.set(pumpingX, 0, pumpingZ);
scene.add(pumpGroup);
const pumpCasing = new THREE.Mesh(
new THREE.CylinderGeometry(0.25, 0.25, 3.85, 10),
casingMaterial
);
pumpCasing.position.y = -0.03;
pumpCasing.castShadow = true;
pumpGroup.add(pumpCasing);
const pumpColumn = new THREE.Mesh(
new THREE.CylinderGeometry(0.09, 0.09, 3.45, 8),
pipeMaterial
);
pumpColumn.position.y = 0.08;
pumpColumn.castShadow = true;
pumpGroup.add(pumpColumn);
const pumpScreen = new THREE.Mesh(
new THREE.CylinderGeometry(0.31, 0.31, 0.68, 10),
pumpDarkMaterial
);
pumpScreen.position.y = -1.72;
pumpScreen.castShadow = true;
pumpGroup.add(pumpScreen);
const motor = new THREE.Mesh(
new THREE.CylinderGeometry(0.43, 0.43, 0.58, 8),
pumpMaterial
);
motor.position.y = 1.98;
motor.castShadow = true;
pumpGroup.add(motor);
const motorCap = new THREE.Mesh(
new THREE.CylinderGeometry(0.36, 0.43, 0.16, 8),
pumpDarkMaterial
);
motorCap.position.y = 2.34;
motorCap.castShadow = true;
pumpGroup.add(motorCap);
const outlet = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.14, 1.2, 8),
pumpMaterial
);
outlet.rotation.z = Math.PI / 2;
outlet.position.set(0.76, 1.9, 0);
outlet.castShadow = true;
pumpGroup.add(outlet);
const rotor = new THREE.Group();
rotor.position.y = 2.48;
pumpGroup.add(rotor);
for (let i = 0; i < 4; i += 1) {
const blade = new THREE.Mesh(
new THREE.BoxGeometry(0.62, 0.055, 0.14),
pumpDarkMaterial
);
blade.position.x = 0.29;
blade.rotation.y = (i / 4) * Math.PI * 2;
const holder = new THREE.Group();
holder.rotation.y = (i / 4) * Math.PI * 2;
blade.rotation.y = 0;
holder.add(blade);
rotor.add(holder);
}
const centerMarker = new THREE.Mesh(
new THREE.TorusGeometry(0.29, 0.035, 5, 14),
new THREE.MeshBasicMaterial({ color: 0x5ee3df })
);
centerMarker.rotation.x = Math.PI / 2;
pumpGroup.add(centerMarker);
const particleGeometry = new THREE.SphereGeometry(0.065, 6, 4);
const particleMaterial = new THREE.MeshBasicMaterial({ color: 0x79eee5 });
const particles = [];
for (let i = 0; i < 8; i += 1) {
const particle = new THREE.Mesh(particleGeometry, particleMaterial);
particle.renderOrder = 6;
pumpGroup.add(particle);
particles.push(particle);
}
const observationWells = [
{ x: -4.35, z: 1.3 },
{ x: 4.25, z: -0.95 }
];
observationWells.forEach(({ x, z }) => {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
const casing = new THREE.Mesh(
new THREE.CylinderGeometry(0.17, 0.17, 3.62, 8),
observationMaterial
);
casing.position.y = -0.22;
casing.castShadow = true;
group.add(casing);
const screen = new THREE.Mesh(
new THREE.CylinderGeometry(0.22, 0.22, 0.58, 8),
pipeMaterial
);
screen.position.y = -1.77;
group.add(screen);
const cap = new THREE.Mesh(
new THREE.CylinderGeometry(0.25, 0.25, 0.14, 8),
new THREE.MeshStandardMaterial({
color: 0x71969e,
roughness: 0.7,
flatShading: true
})
);
cap.position.y = 1.64;
cap.castShadow = true;
group.add(cap);
const marker = new THREE.Mesh(
new THREE.TorusGeometry(0.22, 0.032, 5, 12),
new THREE.MeshBasicMaterial({ color: 0x5ee3df })
);
marker.rotation.x = Math.PI / 2;
group.add(marker);
});
function updateWells() {
rotor.rotation.y = elapsed * 4.1;
centerMarker.position.y = waterHeight(pumpingX, pumpingZ);
observationWells.forEach(({ x, z }) => {
const group = scene.children.find(
(child) =>
child.isGroup &&
Math.abs(child.position.x - x) < 0.001 &&
Math.abs(child.position.z - z) < 0.001
);
if (group) {
const marker = group.children.find((child) => child.isMesh);
if (marker) marker.position.y = waterHeight(x, z);
}
});
particles.forEach((particle, index) => {
const phase = (elapsed * 0.38 + index / particles.length) % 1;
particle.position.set(
Math.sin(index * 1.7) * 0.025,
1.45 - phase * 3.0,
0.24
);
});
}
// -------------------------------------------------------------------------
// Direct camera controls — no examples/addons are imported
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, -0.2, 0);
let cameraTheta = 0.72;
let cameraPhi = 1.02;
let cameraRadius = 18.6;
function updateCamera() {
const sinPhi = Math.sin(cameraPhi);
camera.position.set(
cameraTarget.x + cameraRadius * sinPhi * Math.sin(cameraTheta),
cameraTarget.y + cameraRadius * Math.cos(cameraPhi),
cameraTarget.z + cameraRadius * sinPhi * Math.cos(cameraTheta)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraTheta = 0.72;
cameraPhi = 1.02;
cameraRadius = 18.6;
updateCamera();
}
const canvas = renderer.domElement;
const pointers = new Map();
let previousPinchDistance = 0;
function currentPinchDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
canvas.addEventListener("pointerdown", (event) => {
if (event.pointerType === "mouse" && event.button !== 0) return;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
canvas.setPointerCapture(event.pointerId);
if (pointers.size === 2) {
previousPinchDistance = currentPinchDistance();
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
cameraTheta -= dx * 0.006;
cameraPhi = THREE.MathUtils.clamp(
cameraPhi + dy * 0.005,
0.45,
1.42
);
} else if (pointers.size === 2) {
const distance = currentPinchDistance();
if (previousPinchDistance > 0 && distance > 0) {
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * (previousPinchDistance / distance),
11,
28
);
}
previousPinchDistance = distance;
}
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance =
pointers.size === 2 ? currentPinchDistance() : 0;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("lostpointercapture", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * Math.exp(event.deltaY * 0.001),
11,
28
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
cameraTheta += 0.08;
break;
case "ArrowRight":
cameraTheta -= 0.08;
break;
case "ArrowUp":
cameraPhi = THREE.MathUtils.clamp(cameraPhi - 0.06, 0.45, 1.42);
break;
case "ArrowDown":
cameraPhi = THREE.MathUtils.clamp(cameraPhi + 0.06, 0.45, 1.42);
break;
case "+":
case "=":
cameraRadius = Math.max(11, cameraRadius - 0.7);
break;
case "-":
cameraRadius = Math.min(28, cameraRadius + 0.7);
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
// -------------------------------------------------------------------------
// Controls
// -------------------------------------------------------------------------
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
let paused = prefersReducedMotion;
function updatePauseButton() {
pauseIcon.textContent = paused ? "▶" : "Ⅱ";
pauseLabel.textContent = paused ? "Resume" : "Pause";
pauseButton.setAttribute("aria-pressed", String(paused));
pauseButton.setAttribute(
"aria-label",
paused ? "Resume animation" : "Pause animation"
);
}
pauseButton.addEventListener("click", () => {
paused = !paused;
updatePauseButton();
status.textContent = paused
? "Animation paused."
: "Animation resumed.";
});
resetButton.addEventListener("click", () => {
elapsed = 0;
paused = false;
resetCamera();
updatePauseButton();
status.textContent =
"Scene reset. The schematic animation has restarted.";
});
updatePauseButton();
resetCamera();
// -------------------------------------------------------------------------
// Anchored explanatory label
// -------------------------------------------------------------------------
const labelAnchor = new THREE.Vector3();
const projectedAnchor = new THREE.Vector3();
function updateLabel() {
labelAnchor.set(
0.78,
waterHeight(0.78, 1.15),
1.15
);
projectedAnchor.copy(labelAnchor).project(camera);
const visible =
projectedAnchor.z > -1 &&
projectedAnchor.z < 1;
callout.style.visibility = visible ? "visible" : "hidden";
leaderLine.style.visibility = visible ? "visible" : "hidden";
leaderDot.style.visibility = visible ? "visible" : "hidden";
if (!visible) return;
const anchorX = (projectedAnchor.x * 0.5 + 0.5) * window.innerWidth;
const anchorY = (-projectedAnchor.y * 0.5 + 0.5) * window.innerHeight;
const calloutWidth = callout.offsetWidth;
const calloutHeight = callout.offsetHeight;
let left = anchorX + 48;
let top = anchorY - calloutHeight - 38;
left = THREE.MathUtils.clamp(
left,
14,
Math.max(14, window.innerWidth - calloutWidth - 14)
);
top = THREE.MathUtils.clamp(
top,
14,
Math.max(14, window.innerHeight - calloutHeight - 14)
);
callout.style.transform = `translate3d(${left}px, ${top}px, 0)`;
leaderLine.setAttribute("x1", anchorX);
leaderLine.setAttribute("y1", anchorY);
leaderLine.setAttribute("x2", left + 16);
leaderLine.setAttribute("y2", top + calloutHeight * 0.46);
leaderDot.setAttribute("cx", anchorX);
leaderDot.setAttribute("cy", anchorY);
}
// -------------------------------------------------------------------------
// Resize and animation loop
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
resize();
let previousTime = performance.now();
function animate(now) {
const delta = Math.min(0.05, (now - previousTime) / 1000);
previousTime = now;
if (!paused) elapsed += delta;
updateWater();
updateWells();
updateCamera();
updateLabel();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updateWater();
updateWells();
renderer.render(scene, camera);
loading.remove();
requestAnimationFrame(animate);
</script>
</body>
</html>
```