Prompt specification
Build or customize the Three.js 3D scene "Dripping cave mineral deposition exhibit" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Dripping cave mineral deposition exhibit
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/dripping-cave-mineral-deposition-exhibit-x1154
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring karst caves and sinkholes. Animate droplets from ceiling tips to a shallow pool beside enlarged deposit profiles; show gradual schematic growth with a clear accelerated-time label and no false rate claims. Stylized solid forms.
Working Three.js Starter (dripping-cave-mineral-deposition-exhibit-x1154):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Karst Caves and Sinkholes — Schematic Study</title>
<style>
:root {
color-scheme: dark;
--ink: #eef7f3;
--muted: #a9c1bd;
--panel: rgba(8, 24, 30, 0.84);
--line: rgba(171, 224, 210, 0.2);
--accent: #72e0c1;
--warm: #e9bd72;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #07151c;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
z-index: 10;
pointer-events: none;
}
.panel {
pointer-events: auto;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
#study-panel {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 20px;
border-radius: 18px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 0.68rem;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: var(--ink);
font-size: clamp(1.5rem, 3vw, 2.15rem);
line-height: 1.02;
letter-spacing: -0.04em;
}
.subtitle {
margin: 10px 0 16px;
color: var(--muted);
font-size: 0.88rem;
line-height: 1.45;
}
.time-badge {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 11px 13px;
border: 1px solid rgba(114, 224, 193, 0.32);
border-radius: 11px;
background: rgba(62, 179, 151, 0.09);
}
.time-badge span {
color: #c9e8df;
font-size: 0.69rem;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.time-badge b {
color: var(--accent);
font-size: 1.35rem;
line-height: 1;
letter-spacing: -0.04em;
}
.calibration {
margin: 10px 1px 0;
color: #9bb3af;
font-size: 0.72rem;
line-height: 1.45;
}
#controls-panel {
right: 22px;
bottom: 22px;
width: min(340px, calc(100vw - 44px));
padding: 15px;
border-radius: 15px;
}
.sequence-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 9px;
color: #dcece8;
font-size: 0.72rem;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#sequence-percent {
color: var(--accent);
font-variant-numeric: tabular-nums;
}
.progress-track {
position: relative;
height: 6px;
overflow: hidden;
border-radius: 999px;
background: rgba(220, 239, 234, 0.1);
}
#progress-fill {
width: 0%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #3ca98d, #9ce7cf);
transition: width 120ms linear;
}
.button-row {
display: flex;
gap: 8px;
margin-top: 12px;
}
button {
appearance: none;
border: 1px solid var(--line);
border-radius: 9px;
padding: 9px 12px;
color: var(--ink);
background: rgba(218, 239, 233, 0.07);
font: inherit;
font-size: 0.76rem;
font-weight: 700;
cursor: pointer;
transition: background 150ms ease, border-color 150ms ease;
}
button:hover {
border-color: rgba(114, 224, 193, 0.52);
background: rgba(114, 224, 193, 0.12);
}
button:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
#pause-button {
flex: 1;
}
#camera-help {
margin: 11px 1px 0;
color: #839c98;
font-size: 0.68rem;
line-height: 1.4;
}
.scene-label {
position: fixed;
z-index: 8;
left: 0;
top: 0;
max-width: 210px;
padding: 7px 10px;
border: 1px solid rgba(194, 229, 220, 0.22);
border-radius: 999px;
color: #e9f6f2;
background: rgba(8, 23, 29, 0.76);
box-shadow: 0 7px 22px rgba(0, 0, 0, 0.2);
font-size: 0.66rem;
font-weight: 750;
letter-spacing: 0.055em;
line-height: 1.2;
text-align: center;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
transform: translate(-50%, -100%);
will-change: left, top;
}
.scene-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 13px;
background: rgba(194, 229, 220, 0.42);
}
.scene-label.warm {
color: #ffe4b5;
border-color: rgba(233, 189, 114, 0.35);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
color: var(--muted);
background: #07151c;
font-size: 0.8rem;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 450ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
#study-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px;
}
.subtitle {
display: none;
}
.time-badge {
margin-top: 12px;
}
#controls-panel {
right: 12px;
bottom: 12px;
width: calc(100vw - 24px);
}
.scene-label {
font-size: 0.58rem;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive schematic karst landscape"></main>
<section id="study-panel" class="hud panel" aria-labelledby="scene-title">
<div class="eyebrow">Schematic hydrogeology study</div>
<h1 id="scene-title">Karst caves<br>& sinkholes</h1>
<p class="subtitle">
Ceiling droplets feed a shallow pool beside an enlarged deposit profile.
Drag to orbit and use the wheel to inspect the solid forms.
</p>
<div class="time-badge" aria-label="Accelerated schematic time, sixty times">
<span>Accelerated schematic time</span>
<b>×60</b>
</div>
<p class="calibration">
Visual sequence only — not calibrated to real deposition rates, dimensions,
chronology, or geological time.
</p>
</section>
<section id="controls-panel" class="hud panel" aria-label="Sequence controls">
<div class="sequence-title">
<span>Illustrative deposit sequence</span>
<span id="sequence-percent">0%</span>
</div>
<div class="progress-track" aria-hidden="true">
<div id="progress-fill"></div>
</div>
<div class="button-row">
<button id="pause-button" type="button">Pause sequence</button>
<button id="replay-button" type="button">Replay</button>
<button id="reset-camera" type="button">Reset view</button>
</div>
<p id="camera-help">
Drag: orbit · Wheel/pinch: zoom · Arrow keys: orbit · Space: pause
</p>
</section>
<div id="pool-label" class="scene-label">Shallow receiving pool</div>
<div id="profile-label" class="scene-label warm">Enlarged deposit profile · schematic</div>
<div id="sink-label" class="scene-label">Sinkhole shaft</div>
<div id="loading">Loading the karst field…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const host = document.getElementById("scene");
const loading = document.getElementById("loading");
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.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
host.appendChild(renderer.domElement);
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Three-dimensional karst landscape. Drag to orbit and use the wheel to zoom."
);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07151c);
scene.fog = new THREE.Fog(0x07151c, 25, 43);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraTarget = new THREE.Vector3(0, 0.35, 0);
const cameraState = {
theta: 0.64,
phi: 0.91,
radius: 18.5,
targetTheta: 0.64,
targetPhi: 0.91,
targetRadius: 18.5
};
function updateCamera() {
const s = new THREE.Spherical(
cameraState.radius,
cameraState.phi,
cameraState.theta
);
camera.position.setFromSpherical(s).add(cameraTarget);
camera.lookAt(cameraTarget);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xc7ecf0, 0x3f3428, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe0ad, 3.2);
sun.position.set(-8, 15, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 14;
sun.shadow.camera.bottom = -14;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 38;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x75c9d4, 0.85);
fill.position.set(11, 7, -8);
scene.add(fill);
const materials = {
limestone: new THREE.MeshStandardMaterial({
color: 0xd9cda6,
roughness: 0.9,
flatShading: true
}),
limestoneTop: new THREE.MeshStandardMaterial({
color: 0xded3ad,
roughness: 0.94,
flatShading: true
}),
limestoneSide: new THREE.MeshStandardMaterial({
color: 0x817a62,
roughness: 1,
flatShading: true
}),
rock: new THREE.MeshStandardMaterial({
color: 0x969278,
roughness: 1,
flatShading: true
}),
darkRock: new THREE.MeshStandardMaterial({
color: 0x4e5149,
roughness: 1,
flatShading: true
}),
cave: new THREE.MeshBasicMaterial({
color: 0x061218,
side: THREE.DoubleSide
}),
caveInner: new THREE.MeshBasicMaterial({
color: 0x0b2028,
side: THREE.DoubleSide
}),
shaft: new THREE.MeshStandardMaterial({
color: 0x303b3b,
roughness: 1,
side: THREE.BackSide,
flatShading: true
}),
poolBed: new THREE.MeshStandardMaterial({
color: 0x315d5d,
roughness: 0.85,
flatShading: true
}),
water: new THREE.MeshStandardMaterial({
color: 0x58bfc4,
roughness: 0.22,
metalness: 0.08,
transparent: true,
opacity: 0.78,
side: THREE.DoubleSide
}),
drop: new THREE.MeshStandardMaterial({
color: 0xc9ffff,
emissive: 0x4caeb8,
emissiveIntensity: 0.65,
roughness: 0.15,
metalness: 0.12
}),
depositA: new THREE.MeshStandardMaterial({
color: 0x73523d,
roughness: 1,
flatShading: true
}),
depositB: new THREE.MeshStandardMaterial({
color: 0xa67845,
roughness: 1,
flatShading: true
}),
depositC: new THREE.MeshStandardMaterial({
color: 0xd4aa69,
roughness: 1,
flatShading: true
}),
depositD: new THREE.MeshStandardMaterial({
color: 0xf0dfb2,
roughness: 1,
flatShading: true
}),
plinth: new THREE.MeshStandardMaterial({
color: 0x263d42,
roughness: 0.88,
flatShading: true
}),
shrub: new THREE.MeshStandardMaterial({
color: 0x456653,
roughness: 1,
flatShading: true
})
};
function addMesh(geometry, material, position, cast = true, receive = true) {
const mesh = new THREE.Mesh(geometry, material);
if (position) mesh.position.copy(position);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
scene.add(mesh);
return mesh;
}
// Diorama base.
const base = addMesh(
new THREE.CylinderGeometry(11.8, 12.15, 0.65, 64),
materials.plinth,
new THREE.Vector3(0, -4.65, 0)
);
const floor = addMesh(
new THREE.CircleGeometry(42, 64),
new THREE.MeshStandardMaterial({
color: 0x0a1b21,
roughness: 1
}),
new THREE.Vector3(0, -5.02, 0),
false,
true
);
floor.rotation.x = -Math.PI / 2;
// The outer contour is authored in world X/Z, then converted to Shape X/Y.
const terrainShape = new THREE.Shape();
const terrainPoints = [
[-8.6, -4.7],
[-6.2, -6.8],
[-1.6, -7.4],
[3.7, -6.8],
[7.4, -4.8],
[8.7, -0.8],
[7.7, 4.2],
[4.6, 6.6],
[0.2, 7.7],
[-4.8, 6.5],
[-8.0, 3.3],
[-9.0, -0.6]
];
terrainShape.moveTo(terrainPoints[0][0], -terrainPoints[0][1]);
for (let i = 1; i < terrainPoints.length; i++) {
terrainShape.lineTo(terrainPoints[i][0], -terrainPoints[i][1]);
}
terrainShape.closePath();
function addSinkHole(x, z, radius) {
const hole = new THREE.Path();
hole.absarc(x, -z, radius, 0, Math.PI * 2, true);
terrainShape.holes.push(hole);
}
addSinkHole(-4.25, -1.0, 1.48);
addSinkHole(3.65, -2.8, 0.95);
const terrainGeometry = new THREE.ExtrudeGeometry(terrainShape, {
depth: 4.2,
bevelEnabled: false,
curveSegments: 24,
steps: 1
});
terrainGeometry.rotateX(-Math.PI / 2);
const terrain = addMesh(
terrainGeometry,
[materials.limestoneTop, materials.limestoneSide],
new THREE.Vector3(0, -4.2, 0)
);
const terrainCap = addMesh(
new THREE.ShapeGeometry(terrainShape, 24),
materials.limestoneTop,
new THREE.Vector3(0, 0.012, 0),
false,
true
);
terrainCap.rotation.x = -Math.PI / 2;
function createSinkhole(x, z, radius) {
const shaft = addMesh(
new THREE.CylinderGeometry(
radius * 0.98,
radius * 0.67,
4.12,
28,
1,
true
),
materials.shaft,
new THREE.Vector3(x, -2.05, z),
false,
true
);
const bottom = addMesh(
new THREE.CircleGeometry(radius * 0.67, 32),
materials.cave,
new THREE.Vector3(x, -4.08, z),
false,
false
);
bottom.rotation.x = -Math.PI / 2;
const rim = addMesh(
new THREE.TorusGeometry(radius + 0.02, 0.12, 7, 44),
materials.limestone,
new THREE.Vector3(x, 0.055, z)
);
rim.rotation.x = Math.PI / 2;
}
createSinkhole(-4.25, -1.0, 1.48);
createSinkhole(3.65, -2.8, 0.95);
function createRock(x, z, sx, sy, sz, material = materials.rock, y = 0.18) {
const rock = addMesh(
new THREE.DodecahedronGeometry(1, 0),
material,
new THREE.Vector3(x, y, z)
);
rock.scale.set(sx, sy, sz);
rock.rotation.set(
Math.random() * 0.45,
Math.random() * Math.PI,
Math.random() * 0.3
);
return rock;
}
[
[-5.95, -1.4, 0.8, 0.55, 0.7],
[-2.6, -1.8, 0.62, 0.38, 0.54],
[1.95, -2.7, 0.74, 0.44, 0.62],
[4.95, -2.7, 0.63, 0.42, 0.55],
[6.25, -0.3, 0.9, 0.56, 0.7],
[-6.4, 1.55, 0.62, 0.38, 0.55],
[-3.1, 3.65, 0.6, 0.32, 0.62]
].forEach((r) => createRock(...r));
function createShrub(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.02, z);
group.scale.setScalar(scale);
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.075, 0.65, 6),
materials.darkRock
);
trunk.position.y = 0.325;
trunk.castShadow = true;
group.add(trunk);
for (let i = 0; i < 2; i++) {
const crown = new THREE.Mesh(
new THREE.ConeGeometry(0.34 - i * 0.07, 0.9 - i * 0.16, 7),
materials.shrub
);
crown.position.y = 0.75 + i * 0.35;
crown.castShadow = true;
group.add(crown);
}
scene.add(group);
}
[
[-6.1, -3.6, 0.85],
[-1.8, -4.1, 0.65],
[5.9, -4.0, 0.72],
[6.6, 1.4, 0.6],
[-6.7, 3.6, 0.72],
[1.6, 4.9, 0.56]
].forEach((p) => createShrub(...p));
// Stylized limestone cave facade.
const facade = new THREE.Group();
facade.position.set(-2.25, 0, 5.9);
scene.add(facade);
const facadeShape = new THREE.Shape();
facadeShape.moveTo(-3.45, 0);
facadeShape.lineTo(-3.12, 0.85);
facadeShape.lineTo(-3.28, 2.05);
facadeShape.lineTo(-2.72, 4.45);
facadeShape.lineTo(-1.83, 5.08);
facadeShape.lineTo(-0.88, 4.86);
facadeShape.lineTo(0.05, 5.22);
facadeShape.lineTo(0.92, 4.62);
facadeShape.lineTo(1.52, 3.2);
facadeShape.lineTo(1.35, 1.25);
facadeShape.lineTo(3.25, 0);
facadeShape.closePath();
const facadeGeometry = new THREE.ExtrudeGeometry(facadeShape, {
depth: 0.7,
bevelEnabled: false,
steps: 1
});
const facadeMesh = new THREE.Mesh(facadeGeometry, materials.limestone);
facadeMesh.castShadow = true;
facadeMesh.receiveShadow = true;
facade.add(facadeMesh);
function makeArchShape(width, height) {
const radius = width;
const spring = height - radius;
const shape = new THREE.Shape();
shape.moveTo(-radius, 0);
shape.lineTo(radius, 0);
shape.lineTo(radius, spring);
shape.absarc(0, spring, radius, 0, Math.PI, false);
shape.lineTo(-radius, 0);
shape.closePath();
return shape;
}
const caveOpening = new THREE.Mesh(
new THREE.ShapeGeometry(makeArchShape(1.75, 4.15), 40),
materials.cave
);
caveOpening.position.z = 0.711;
facade.add(caveOpening);
const caveGlow = new THREE.Mesh(
new THREE.ShapeGeometry(makeArchShape(1.43, 3.72), 40),
materials.caveInner
);
caveGlow.position.set(0, 0.05, 0.713);
facade.add(caveGlow);
function makeStalactite(parent, x, z, ceilingY, length, radius) {
const cone = new THREE.Mesh(
new THREE.ConeGeometry(radius, length, 7),
materials.limestone
);
// Cone points upward by default; rotate so the tip points down.
cone.rotation.z = Math.PI;
cone.position.set(x, ceilingY - length * 0.5, z);
cone.castShadow = true;
cone.receiveShadow = true;
parent.add(cone);
return cone;
}
const dripTips = [];
const ceilingXs = [-1.28, -0.72, -0.12, 0.52, 1.12];
ceilingXs.forEach((x, index) => {
const ceilingY =
2.4 + Math.sqrt(Math.max(0, 1.75 * 1.75 - x * x)) - 0.035;
const length = 0.58 + (index % 3) * 0.24;
const radius = 0.14 + (index % 2) * 0.035;
makeStalactite(facade, x, 0.76, ceilingY, length, radius);
if (index === 0 || index === 2 || index === 4) {
dripTips.push(
new THREE.Vector3(x, ceilingY - length - 0.035, 0.79)
);
}
});
facade.updateMatrixWorld(true);
// Shallow pool.
const poolCenter = new THREE.Vector3(-1.0, 0, 5.08);
const poolScale = new THREE.Vector2(2.45, 1.2);
const basin = addMesh(
new THREE.CylinderGeometry(1, 1, 0.12, 48),
materials.poolBed,
new THREE.Vector3(poolCenter.x, -0.015, poolCenter.z),
false,
true
);
basin.scale.set(poolScale.x, 1, poolScale.y);
const pool = addMesh(
new THREE.CircleGeometry(1, 64),
materials.water,
new THREE.Vector3(poolCenter.x, 0.055, poolCenter.z),
false,
true
);
pool.rotation.x = -Math.PI / 2;
pool.scale.set(poolScale.x, poolScale.y, 1);
[
[-3.5, 4.25, 0.28, 0.18, 0.24],
[-3.32, 5.76, 0.22, 0.14, 0.2],
[1.28, 4.18, 0.24, 0.15, 0.2],
[1.35, 5.83, 0.31, 0.18, 0.23]
].forEach((r) => createRock(...r, materials.darkRock, 0.12));
// A small real-scale-looking deposit beside the pool, synchronized with
// the enlarged schematic profile.
const smallDeposit = new THREE.Group();
smallDeposit.position.set(1.68, 0.08, 5.05);
scene.add(smallDeposit);
const smallCone = new THREE.Mesh(
new THREE.ConeGeometry(0.32, 1.02, 8),
materials.depositD
);
smallCone.position.y = 0.51;
smallCone.castShadow = true;
smallCone.receiveShadow = true;
smallDeposit.add(smallCone);
// Enlarged deposit profile on a cutaway plinth.
const profile = new THREE.Group();
profile.position.set(3.48, 0, 4.48);
scene.add(profile);
const profilePlinth = new THREE.Mesh(
new THREE.BoxGeometry(3.82, 0.24, 1.36),
materials.plinth
);
profilePlinth.position.set(0, 0.12, 0.36);
profilePlinth.castShadow = true;
profilePlinth.receiveShadow = true;
profile.add(profilePlinth);
function moundShape(radius, height) {
const shape = new THREE.Shape();
shape.moveTo(-radius, 0);
shape.lineTo(radius, 0);
shape.quadraticCurveTo(radius * 0.7, height * 0.73, 0, height);
shape.quadraticCurveTo(-radius * 0.7, height * 0.73, -radius, 0);
shape.closePath();
return shape;
}
const profileLayers = [];
const layerSpecs = [
[1.67, 0.58, materials.depositA],
[1.39, 0.98, materials.depositB],
[1.11, 1.38, materials.depositC],
[0.78, 1.78, materials.depositD]
];
layerSpecs.forEach(([radius, height, material], index) => {
const group = new THREE.Group();
group.position.set(0, 0.245, index * 0.16);
const layer = new THREE.Mesh(
new THREE.ExtrudeGeometry(moundShape(radius, height), {
depth: 0.22,
bevelEnabled: true,
bevelThickness: 0.025,
bevelSize: 0.025,
bevelSegments: 1,
curveSegments: 18,
steps: 1
}),
material
);
layer.castShadow = true;
layer.receiveShadow = true;
group.add(layer);
profile.add(group);
profileLayers.push(group);
});
const callout = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(1.45, 0.43, 5.02),
new THREE.Vector3(1.92, 0.34, 4.96)
]),
new THREE.LineDashedMaterial({
color: 0xe9c486,
dashSize: 0.09,
gapSize: 0.06,
transparent: true,
opacity: 0.8
})
);
callout.computeLineDistances();
scene.add(callout);
const calloutDot = addMesh(
new THREE.SphereGeometry(0.045, 10, 8),
materials.depositD,
new THREE.Vector3(1.45, 0.43, 5.02),
false,
false
);
// Droplets and expanding pool ripples.
const droplets = [];
const rippleGeometry = new THREE.RingGeometry(0.085, 0.125, 32);
const endPositions = [
new THREE.Vector3(-2.72, 0.075, 5.02),
new THREE.Vector3(-1.87, 0.075, 4.88),
new THREE.Vector3(-0.96, 0.075, 5.16)
];
dripTips.forEach((localTip, index) => {
const start = facade.localToWorld(localTip.clone());
const drop = new THREE.Mesh(
new THREE.SphereGeometry(0.058, 12, 10),
materials.drop
);
drop.scale.set(0.78, 1.42, 0.78);
drop.castShadow = true;
scene.add(drop);
droplets.push({
mesh: drop,
start,
end: endPositions[index],
offset: index * 0.31 + 0.08,
speed: 0.29 + index * 0.035,
lastPhase: index * 0.31 + 0.08
});
});
const ripples = [];
function spawnRipple(position) {
const material = new THREE.MeshBasicMaterial({
color: 0xc3ffff,
transparent: true,
opacity: 0.75,
side: THREE.DoubleSide,
depthWrite: false
});
const ring = new THREE.Mesh(rippleGeometry, material);
ring.rotation.x = -Math.PI / 2;
ring.position.copy(position);
ring.position.y += 0.008;
scene.add(ring);
ripples.push({ mesh: ring, age: 0 });
}
// Screen-space callouts.
const labels = [
{
element: document.getElementById("pool-label"),
point: new THREE.Vector3(-1.05, 0.25, 5.0)
},
{
element: document.getElementById("profile-label"),
point: new THREE.Vector3(3.45, 2.28, 5.2)
},
{
element: document.getElementById("sink-label"),
point: new THREE.Vector3(-4.25, 0.35, -1.0)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
labels.forEach(({ element, point }) => {
projected.copy(point).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
element.style.display = visible ? "block" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y - 15}px`;
}
});
}
// Direct camera controls: no addons or example 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;
cameraState.targetTheta -= dx * 0.006;
cameraState.targetPhi = THREE.MathUtils.clamp(
cameraState.targetPhi - dy * 0.005,
0.3,
1.38
);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined) {
if (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();
cameraState.targetRadius = THREE.MathUtils.clamp(
cameraState.targetRadius * Math.exp(event.deltaY * 0.001),
10,
29
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
function resetCamera() {
cameraState.targetTheta = 0.64;
cameraState.targetPhi = 0.91;
cameraState.targetRadius = 18.5;
}
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") cameraState.targetTheta += 0.12;
if (event.key === "ArrowRight") cameraState.targetTheta -= 0.12;
if (event.key === "ArrowUp") cameraState.targetPhi -= 0.08;
if (event.key === "ArrowDown") cameraState.targetPhi += 0.08;
if (event.code === "Space") {
event.preventDefault();
togglePause();
}
});
const pauseButton = document.getElementById("pause-button");
const replayButton = document.getElementById("replay-button");
const resetButton = document.getElementById("reset-camera");
const progressFill = document.getElementById("progress-fill");
const sequencePercent = document.getElementById("sequence-percent");
let paused = false;
let sequenceTime = 0;
const sequenceDuration = 60;
function togglePause() {
paused = !paused;
pauseButton.textContent = paused ? "Resume sequence" : "Pause sequence";
}
function replay() {
sequenceTime = 0;
paused = false;
pauseButton.textContent = "Pause sequence";
ripples.forEach(({ mesh }) => {
scene.remove(mesh);
mesh.material.dispose();
});
ripples.length = 0;
droplets.forEach((drop) => {
drop.lastPhase = drop.offset;
});
}
pauseButton.addEventListener("click", togglePause);
replayButton.addEventListener("click", replay);
resetButton.addEventListener("click", resetCamera);
function smoothstep(value) {
const t = THREE.MathUtils.clamp(value, 0, 1);
return t * t * (3 - 2 * t);
}
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (!paused) {
sequenceTime = Math.min(sequenceTime + delta, sequenceDuration);
}
const progress = sequenceTime / sequenceDuration;
const overallGrowth = 0.08 + smoothstep(progress) * 0.92;
profileLayers.forEach((layer, index) => {
const delayedProgress = smoothstep(
(progress - index * 0.075) / (1 - index * 0.075)
);
const g = 0.05 + delayedProgress * 0.95;
layer.scale.set(0.62 + g * 0.38, g, 1);
});
smallDeposit.scale.y = overallGrowth;
droplets.forEach((drop, index) => {
const phase = (sequenceTime * drop.speed + drop.offset) % 1;
if (phase < drop.lastPhase) {
spawnRipple(drop.end);
}
drop.lastPhase = phase;
const fall = phase * phase;
drop.mesh.visible = phase < 0.985;
drop.mesh.position.lerpVectors(drop.start, drop.end, fall);
const drift = Math.sin(phase * Math.PI * 2 + index) * 0.035 * phase;
drop.mesh.position.x += drift;
drop.mesh.position.z -= phase * 0.16;
});
for (let i = ripples.length - 1; i >= 0; i--) {
const ripple = ripples[i];
ripple.age += delta;
const life = ripple.age / 1.25;
const scale = 1 + life * 7.5;
ripple.mesh.scale.setScalar(scale);
ripple.mesh.material.opacity = Math.max(0, 0.72 * (1 - life));
if (life >= 1) {
scene.remove(ripple.mesh);
ripple.mesh.material.dispose();
ripples.splice(i, 1);
}
}
materials.water.opacity = 0.76 + Math.sin(sequenceTime * 1.8) * 0.025;
const cameraEase = 1 - Math.pow(0.001, delta);
cameraState.theta = THREE.MathUtils.lerp(
cameraState.theta,
cameraState.targetTheta,
cameraEase
);
cameraState.phi = THREE.MathUtils.lerp(
cameraState.phi,
cameraState.targetPhi,
cameraEase
);
cameraState.radius = THREE.MathUtils.lerp(
cameraState.radius,
cameraState.targetRadius,
cameraEase
);
updateCamera();
updateLabels();
progressFill.style.width = `${progress * 100}%`;
sequencePercent.textContent = `${Math.round(progress * 100)}%`;
renderer.render(scene, camera);
}
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", onResize);
renderer.setAnimationLoop(animate);
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 500);
</script>
</body>
</html>
```