Prompt specification
Build or customize the Three.js 3D scene "Emergency water distribution after the earthquake" 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: Emergency water distribution after the earthquake
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/emergency-water-distribution-after-the-earthquake-x2466
Scene Description Prompt:
Show low-poly volunteers distributing water beside a damaged street after San Francisco’s 1906 earthquake. Create one HTML file using Three.js from cdnjs.
Working Three.js Starter (emergency-water-distribution-after-the-earthquake-x2466):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Water for the Neighborhood — San Francisco, 1906</title>
<style>
:root {
--ink: #29251f;
--paper: rgba(245, 237, 215, 0.9);
--paper-solid: #f1e7d0;
--accent: #a64d32;
--line: rgba(57, 48, 37, 0.24);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9baa3;
color: var(--ink);
font-family: Arial, Helvetica, sans-serif;
}
#scene,
#scene canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
#scene canvas {
cursor: grab;
touch-action: none;
outline: none;
}
#scene canvas:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 43%, transparent 42%, rgba(42, 33, 24, 0.2) 100%),
linear-gradient(180deg, rgba(56, 43, 29, 0.06), transparent 35%, rgba(38, 29, 22, 0.08));
mix-blend-mode: multiply;
}
.title-card {
position: fixed;
top: 28px;
left: 30px;
z-index: 5;
width: min(420px, calc(100vw - 60px));
padding: 19px 22px 20px;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.42);
border-left: 5px solid var(--accent);
box-shadow: 0 12px 36px rgba(46, 34, 22, 0.16);
backdrop-filter: blur(8px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: #8a3f2b;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 42px);
font-weight: 700;
line-height: 0.98;
letter-spacing: -0.025em;
}
.title-card p {
max-width: 350px;
margin: 12px 0 0;
color: #51483c;
font-family: Georgia, "Times New Roman", serif;
font-size: 14px;
line-height: 1.45;
}
.controls {
position: fixed;
z-index: 7;
top: 28px;
right: 30px;
display: flex;
gap: 8px;
}
button {
appearance: none;
border: 1px solid var(--line);
border-radius: 2px;
padding: 10px 13px;
background: var(--paper);
color: var(--ink);
box-shadow: 0 5px 16px rgba(45, 33, 22, 0.1);
cursor: pointer;
font: 700 11px/1 Arial, Helvetica, sans-serif;
letter-spacing: 0.05em;
text-transform: uppercase;
backdrop-filter: blur(7px);
}
button:hover {
background: #fff4d9;
border-color: rgba(120, 65, 40, 0.45);
}
button:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 3px;
}
.scene-label {
position: fixed;
z-index: 5;
left: 30px;
bottom: 27px;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 12px;
background: rgba(242, 232, 209, 0.84);
border: 1px solid rgba(255, 255, 255, 0.35);
color: #4b4236;
font-size: 11px;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(7px);
}
.scene-label::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: #b65337;
box-shadow: 0 0 0 3px rgba(182, 83, 55, 0.18);
}
.hint {
position: fixed;
z-index: 5;
right: 30px;
bottom: 27px;
color: rgba(246, 235, 211, 0.9);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.06em;
text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #c9baa3;
color: #55483a;
font: 700 11px/1 Arial, sans-serif;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 0.45s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 680px) {
.title-card {
top: 16px;
left: 16px;
width: calc(100vw - 32px);
padding: 15px 17px 16px;
}
.title-card p {
display: none;
}
.controls {
top: auto;
right: 16px;
bottom: 58px;
}
.scene-label {
left: 16px;
bottom: 16px;
}
.hint {
display: none;
}
button {
padding: 9px 10px;
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="vignette"></div>
<section class="title-card" aria-label="Scene description">
<div class="eyebrow">San Francisco · April 1906</div>
<h1>Water for the<br />neighborhood</h1>
<p>
After the earthquake, volunteers turn a damaged wagon into a neighborhood
water station, sharing clean water with residents carrying buckets.
</p>
</section>
<nav class="controls" aria-label="Scene controls">
<button id="pause" type="button">Pause</button>
<button id="reset" type="button">Reset view</button>
</nav>
<div class="scene-label">Emergency water distribution point</div>
<div class="hint">Drag to orbit · Scroll to zoom</div>
<div id="loading">Preparing the relief station…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const container = document.getElementById("scene");
const pauseButton = document.getElementById("pause");
const resetButton = document.getElementById("reset");
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
container.appendChild(renderer.domElement);
renderer.domElement.tabIndex = 0;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc9baa3);
scene.fog = new THREE.Fog(0xc9baa3, 31, 72);
const camera = new THREE.OrthographicCamera(-15, 15, 10, -10, 0.1, 120);
const target = new THREE.Vector3(0.4, 2.0, -1.2);
let currentTheta = 0.66;
let currentPhi = 0.98;
let currentZoom = 1.0;
let desiredTheta = currentTheta;
let desiredPhi = currentPhi;
let desiredZoom = currentZoom;
const clock = new THREE.Clock();
let paused = false;
let simulationTime = 0;
// Deterministic randomness keeps the damaged city stable between reloads.
let randomSeed = 1906;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
const range = (min, max) => min + (max - min) * random();
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.94,
metalness: 0,
flatShading: true,
...options
});
}
const palette = {
ground: material(0x81786a),
road: material(0x565350),
roadDark: material(0x3b3937),
soil: material(0x5b4b3e),
plasterA: material(0xb7a58c),
plasterB: material(0xc1b69e),
plasterC: material(0x9a826d),
brick: material(0x8c5541),
timber: material(0x604a36),
timberLight: material(0x8c6847),
interior: material(0x342f2b),
rubble: material(0x837666),
rubbleLight: material(0xa0927e),
iron: material(0x3c3b38, { metalness: 0.35 }),
blue: material(0x577883),
water: material(0x6595a0, {
transparent: true,
opacity: 0.78,
roughness: 0.22
})
};
function addMesh(parent, geometry, mat, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(parent, size, position, mat) {
return addMesh(
parent,
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat,
...position
);
}
function addCylinder(parent, radiusTop, radiusBottom, height, position, mat, segments = 8) {
return addMesh(
parent,
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat,
...position
);
}
function cylinderBetween(parent, a, b, radius, mat, segments = 6) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = addMesh(
parent,
new THREE.CylinderGeometry(radius, radius, length, segments),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xe9dfc8, 0x55483e, 2.05));
const sun = new THREE.DirectionalLight(0xffe3b4, 3.15);
sun.position.set(-12, 23, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.0006;
scene.add(sun);
const coolFill = new THREE.DirectionalLight(0x9bb3b5, 0.65);
coolFill.position.set(16, 10, -15);
scene.add(coolFill);
// -------------------------------------------------------------------------
// Ground, street, fissures and rubble
// -------------------------------------------------------------------------
const ground = addMesh(
scene,
new THREE.PlaneGeometry(82, 54),
palette.ground,
0,
-0.13,
0
);
ground.rotation.x = -Math.PI / 2;
ground.castShadow = false;
addBox(scene, [48, 0.16, 9.2], [0, 0, 0], palette.road);
// Broken curb stones.
for (let side = -1; side <= 1; side += 2) {
for (let x = -22; x <= 22; x += 2.2) {
if (random() < 0.28) continue;
const stone = addBox(
scene,
[range(1.1, 2.0), range(0.17, 0.28), 0.42],
[x + range(-0.25, 0.25), 0.12, side * 4.73],
random() > 0.5 ? palette.rubble : palette.rubbleLight
);
stone.rotation.y = range(-0.08, 0.08);
stone.rotation.z = range(-0.04, 0.04);
}
}
function addStreetCrack(points, width) {
const shape = new THREE.Shape();
shape.moveTo(points[0][0], -points[0][1] - width * 0.5);
for (let i = 1; i < points.length; i++) {
shape.lineTo(points[i][0], -points[i][1] - width * 0.5);
}
for (let i = points.length - 1; i >= 0; i--) {
shape.lineTo(points[i][0], -points[i][1] + width * 0.5);
}
shape.closePath();
const crack = addMesh(
scene,
new THREE.ShapeGeometry(shape),
palette.roadDark,
0,
0.091,
0
);
crack.rotation.x = -Math.PI / 2;
crack.castShadow = false;
}
addStreetCrack(
[
[-23, -1.2], [-18, -0.5], [-14, -0.9], [-10, 0.4],
[-6, 0.1], [-2, 1.2], [2, 0.8], [6, 2.1], [10, 1.8],
[15, 2.7], [23, 2.4]
],
0.34
);
addStreetCrack(
[
[-18, -0.5], [-17, 1.1], [-14.7, 2.2], [-13.2, 3.8]
],
0.2
);
addStreetCrack(
[
[2, 0.8], [2.7, -1.2], [4.3, -2.1], [5.3, -3.8]
],
0.19
);
addStreetCrack(
[
[10, 1.8], [11.5, 1.0], [13.2, 1.4], [16, 0.3], [20, 0.7]
],
0.18
);
// Irregular asphalt patches.
for (let i = 0; i < 30; i++) {
const patch = addMesh(
scene,
new THREE.CircleGeometry(range(0.25, 0.85), 6),
random() > 0.5 ? palette.soil : palette.roadDark,
range(-22, 22),
0.092,
range(-3.9, 3.9)
);
patch.rotation.x = -Math.PI / 2;
patch.rotation.z = range(0, Math.PI);
patch.scale.set(range(0.8, 1.8), range(0.5, 1.4), 1);
patch.material = patch.material.clone();
patch.material.opacity = 0.45;
patch.material.transparent = true;
patch.castShadow = false;
}
function addRubble(parent, count, centerX = 0, centerZ = 0, spreadX = 2, spreadZ = 1) {
const rockGeometry = new THREE.DodecahedronGeometry(1, 0);
for (let i = 0; i < count; i++) {
const rock = addMesh(
parent,
rockGeometry,
random() > 0.45 ? palette.rubble : palette.rubbleLight,
centerX + range(-spreadX, spreadX),
range(0.12, 0.48),
centerZ + range(-spreadZ, spreadZ)
);
rock.scale.set(range(0.15, 0.6), range(0.12, 0.46), range(0.16, 0.66));
rock.rotation.set(range(0, 3), range(0, 3), range(0, 3));
}
}
addRubble(scene, 42, -7.5, -4.7, 6.2, 1.5);
addRubble(scene, 35, 3.7, -4.7, 6.0, 1.5);
addRubble(scene, 23, 14, -4.8, 5.2, 1.5);
addRubble(scene, 28, -1, 5.1, 10, 1.0);
addRubble(scene, 18, 10, 5.0, 4.5, 1.1);
// -------------------------------------------------------------------------
// Damaged buildings
// -------------------------------------------------------------------------
function extrudedFacade(parent, points, depth, mat, z) {
const shape = new THREE.Shape();
shape.moveTo(points[0][0], points[0][1]);
for (let i = 1; i < points.length; i++) {
shape.lineTo(points[i][0], points[i][1]);
}
shape.closePath();
const mesh = addMesh(
parent,
new THREE.ExtrudeGeometry(shape, {
depth,
bevelEnabled: false,
curveSegments: 1
}),
mat,
0,
0,
z
);
return mesh;
}
function damagedBuilding(x, z, width, height, depth, wallMaterial) {
const building = new THREE.Group();
building.position.set(x, 0, z);
scene.add(building);
// Rear wall, one surviving side wall and interior floors.
addBox(
building,
[width, height, 0.28],
[0, height / 2, -depth / 2],
palette.interior
);
addBox(
building,
[0.28, height, depth],
[-width / 2 + 0.14, height / 2, 0],
wallMaterial
);
const floors = 2 + Math.floor(random() * 2);
for (let f = 1; f <= floors; f++) {
const floorY = (height / (floors + 1)) * f;
addBox(
building,
[width - 0.3, 0.16, depth - 0.3],
[0, floorY, -0.05],
palette.timber
);
}
// Two jagged facade remnants leave the interior exposed.
extrudedFacade(
building,
[
[-width / 2, 0],
[width * 0.035, 0],
[width * 0.035, height * 0.62],
[-width * 0.04, height * 0.74],
[-width * 0.22, height * 0.61],
[-width * 0.36, height * 0.79],
[-width / 2, height * 0.67]
],
0.28,
wallMaterial,
depth / 2 - 0.28
);
extrudedFacade(
building,
[
[width * 0.16, 0],
[width / 2, 0],
[width / 2, height * 0.86],
[width * 0.36, height * 0.74],
[width * 0.27, height * 0.94],
[width * 0.16, height * 0.65]
],
0.28,
wallMaterial,
depth / 2 - 0.28
);
// Dark window openings.
const windowMaterial = material(0x242322);
const windows = [
[-width * 0.31, height * 0.27, width * 0.13],
[-width * 0.31, height * 0.51, width * 0.13],
[width * 0.34, height * 0.27, width * 0.12],
[width * 0.34, height * 0.58, width * 0.12]
];
windows.forEach(([wx, wy, ww]) => {
if (wy > height * 0.78) return;
addBox(
building,
[ww, 1.08, 0.055],
[wx, wy, depth / 2 + 0.025],
windowMaterial
);
addBox(
building,
[ww + 0.13, 0.07, 0.09],
[wx, wy - 0.52, depth / 2 + 0.08],
palette.timberLight
);
});
// Broken roof beams.
for (let i = 0; i < 4; i++) {
const bx = -width * 0.35 + i * width * 0.22;
cylinderBetween(
building,
[bx, height * range(0.63, 0.78), depth / 2 - 0.12],
[bx + range(-0.5, 0.5), height * range(0.95, 1.08), -depth / 2 + 0.2],
0.075,
palette.timber,
5
);
}
// A few collapsed bricks along the facade.
for (let i = 0; i < 10; i++) {
const brick = addBox(
building,
[range(0.18, 0.42), range(0.12, 0.25), range(0.18, 0.35)],
[range(-width / 2, width / 2), range(0.08, 0.35), depth / 2 + range(0.2, 0.8)],
palette.brick
);
brick.rotation.set(range(-0.2, 0.2), range(0, Math.PI), range(-0.2, 0.2));
}
return building;
}
damagedBuilding(-15, -9.5, 7.4, 9.4, 4.2, palette.plasterA);
damagedBuilding(-6.7, -9.0, 8.1, 12.0, 4.5, palette.plasterB);
damagedBuilding(2.9, -9.7, 8.3, 10.7, 4.4, palette.plasterC);
damagedBuilding(11.1, -9.5, 7.5, 12.8, 4.6, palette.plasterA);
damagedBuilding(19.5, -11.0, 7.0, 9.0, 4.2, palette.plasterB);
// Distant silhouettes give the street a continuing cityscape.
for (let i = 0; i < 9; i++) {
const h = range(5, 12);
const distant = addBox(
scene,
[range(3.5, 6), h, 4],
[-25 + i * 6.1, h / 2, -17 - range(0, 4)],
i % 2 ? palette.plasterC : palette.plasterA
);
distant.castShadow = false;
}
// -------------------------------------------------------------------------
// Street furniture and damaged utilities
// -------------------------------------------------------------------------
function makeLampPost(x, z, leaning = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
addCylinder(group, 0.09, 0.13, 4.6, [0, 2.3, 0], palette.iron, 7);
addBox(group, [0.65, 0.12, 0.65], [0, 0.06, 0], palette.iron);
addBox(group, [0.5, 0.1, 0.5], [0, 4.62, 0], palette.iron);
addCylinder(group, 0.2, 0.3, 0.5, [0, 4.92, 0], palette.iron, 6);
group.rotation.z = leaning;
group.rotation.x = range(-0.1, 0.1);
}
makeLampPost(8.4, -4.0, -0.13);
makeLampPost(-8.6, 4.2, 0.19);
// Toppled utility pole and hanging wires.
const fallenPole = addCylinder(
scene,
0.09,
0.12,
6.8,
[-11.5, 0.38, 3.5],
palette.timber,
7
);
fallenPole.rotation.z = Math.PI / 2;
fallenPole.rotation.y = 0.18;
const wireMaterial = new THREE.LineBasicMaterial({
color: 0x302c28,
transparent: true,
opacity: 0.75
});
function addWire(points) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map((p) => new THREE.Vector3(...p))
);
scene.add(new THREE.Line(geometry, wireMaterial));
}
addWire([
[-15.8, 4.8, -5.4],
[-13.6, 3.9, -3.8],
[-10.6, 2.6, -1.5],
[-8.4, 2.0, 0.4]
]);
// -------------------------------------------------------------------------
// Relief station: cart, tank, sign, spigot and flowing water
// -------------------------------------------------------------------------
function makeSignTexture(text) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 160;
const context = canvas.getContext("2d");
context.fillStyle = "#6c4b30";
context.fillRect(0, 0, canvas.width, canvas.height);
context.strokeStyle = "#d2a46b";
context.lineWidth = 10;
context.strokeRect(12, 12, canvas.width - 24, canvas.height - 24);
context.fillStyle = "#f0d6a0";
context.font = "bold 74px Georgia";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, canvas.width / 2, canvas.height / 2 + 3);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function makeBucket(parent, position, scale = 1) {
const group = new THREE.Group();
group.position.set(...position);
group.scale.setScalar(scale);
parent.add(group);
const bucketMaterial = material(0x75573c);
bucketMaterial.side = THREE.DoubleSide;
addCylinder(group, 0.235, 0.175, 0.34, [0, 0, 0], bucketMaterial, 8);
const rim = addMesh(
group,
new THREE.TorusGeometry(0.235, 0.024, 4, 8),
palette.iron,
0,
0.17,
0
);
rim.rotation.x = Math.PI / 2;
const water = addMesh(
group,
new THREE.CircleGeometry(0.205, 8),
palette.water,
0,
0.132,
0
);
water.rotation.x = -Math.PI / 2;
water.castShadow = false;
const handle = addMesh(
group,
new THREE.TorusGeometry(0.2, 0.012, 4, 8, Math.PI),
palette.iron,
0,
0.17,
0
);
handle.rotation.y = Math.PI / 2;
return group;
}
const cart = new THREE.Group();
cart.position.set(-1.25, 0, -0.2);
cart.rotation.y = -0.035;
scene.add(cart);
// Wagon bed and rails.
addBox(cart, [3.6, 0.19, 1.75], [0, 0.78, 0], palette.timberLight);
addBox(cart, [3.65, 0.27, 0.13], [0, 1.07, 0.83], palette.timber);
addBox(cart, [3.65, 0.27, 0.13], [0, 1.07, -0.83], palette.timber);
addBox(cart, [0.13, 0.25, 1.65], [1.7, 1.07, 0], palette.timber);
// Tank.
const tankMaterial = material(0x56675e);
addCylinder(cart, 0.64, 0.64, 1.45, [-0.28, 1.58, 0], tankMaterial, 12);
addCylinder(cart, 0.69, 0.69, 0.12, [-0.28, 2.34, 0], palette.iron, 12);
addCylinder(cart, 0.69, 0.69, 0.12, [-0.28, 0.91, 0], palette.iron, 12);
[-0.05, 1.55].forEach((y) => {
const band = addMesh(
cart,
new THREE.TorusGeometry(0.65, 0.035, 4, 12),
palette.iron,
-0.28,
y,
0
);
band.rotation.x = Math.PI / 2;
});
// Wheels, hubs and spokes.
function makeWheel(x, z) {
const wheel = new THREE.Group();
wheel.position.set(x, 0.57, z);
cart.add(wheel);
const tire = addCylinder(
wheel,
0.58,
0.58,
0.18,
[0, 0, 0],
palette.iron,
12
);
tire.rotation.x = Math.PI / 2;
const hub = addCylinder(
wheel,
0.16,
0.16,
0.23,
[0, 0, 0],
palette.timberLight,
8
);
hub.rotation.x = Math.PI / 2;
for (let i = 0; i < 4; i++) {
const spoke = addBox(
wheel,
[0.07, 0.96, 0.055],
[0, 0, 0.105],
palette.timberLight
);
spoke.rotation.z = i * Math.PI / 4;
}
}
makeWheel(-1.2, 0.94);
makeWheel(-1.2, -0.94);
makeWheel(1.2, 0.94);
makeWheel(1.2, -0.94);
cylinderBetween(
cart,
[-1.2, 0.57, -1.02],
[-1.2, 0.57, 1.02],
0.075,
palette.iron,
8
);
// Pull handles.
cylinderBetween(
cart,
[-1.65, 0.68, 0.55],
[-3.3, 0.52, 0.72],
0.075,
palette.timber,
6
);
cylinderBetween(
cart,
[-1.65, 0.68, -0.55],
[-3.3, 0.52, -0.72],
0.075,
palette.timber,
6
);
// Spigot and bucket beneath it.
cylinderBetween(
cart,
[0.16, 1.28, 0.42],
[0.16, 1.28, 0.95],
0.045,
palette.iron,
7
);
cylinderBetween(
cart,
[0.16, 1.28, 0.95],
[0.16, 1.06, 0.95],
0.045,
palette.iron,
7
);
const spigotHandle = addBox(
cart,
[0.27, 0.055, 0.055],
[0.16, 1.42, 0.81],
palette.iron
);
spigotHandle.rotation.z = 0.25;
makeBucket(cart, [0.16, 0.25, 0.95]);
const streamMaterial = material(0x81b2b8, {
transparent: true,
opacity: 0.7,
roughness: 0.18
});
const waterStream = addCylinder(
cart,
0.035,
0.045,
0.61,
[0.16, 0.735, 0.95],
streamMaterial,
7
);
waterStream.castShadow = false;
const droplets = [];
const dropletGeometry = new THREE.IcosahedronGeometry(0.045, 0);
for (let i = 0; i < 5; i++) {
const drop = addMesh(
cart,
dropletGeometry,
streamMaterial,
0.16,
0.45,
0.95
);
drop.castShadow = false;
droplets.push(drop);
}
// Painted sign on the wagon.
const signMaterial = new THREE.MeshBasicMaterial({
map: makeSignTexture("WATER"),
side: THREE.DoubleSide
});
const sign = addMesh(
cart,
new THREE.PlaneGeometry(1.55, 0.48),
signMaterial,
0.62,
0.92,
0.895
);
sign.castShadow = false;
// Crates and a barrel beside the station.
function makeCrate(parent, x, y, z, size = 0.7) {
addBox(
parent,
[size, size, size],
[x, y, z],
palette.timberLight
);
for (const offset of [-0.27, 0.27]) {
addBox(
parent,
[size + 0.025, 0.08, size + 0.025],
[x + offset * size, y, z],
palette.timber
);
addBox(
parent,
[size + 0.025, size, 0.08],
[x + offset * size, y, z],
palette.timber
);
}
}
makeCrate(scene, -4.25, 0.38, 0.9, 0.72);
makeCrate(scene, -4.35, 1.05, 0.82, 0.64);
makeCrate(scene, -3.45, 0.34, 1.45, 0.63);
const barrel = new THREE.Group();
barrel.position.set(-4.5, 0, -1.25);
scene.add(barrel);
addCylinder(barrel, 0.47, 0.43, 1.0, [0, 0.52, 0], palette.timber, 10);
[0.18, 0.82].forEach((y) => {
const hoop = addMesh(
barrel,
new THREE.TorusGeometry(0.455, 0.027, 4, 10),
palette.iron,
0,
y,
0
);
hoop.rotation.x = Math.PI / 2;
});
// -------------------------------------------------------------------------
// Low-poly volunteers and residents
// -------------------------------------------------------------------------
const volunteers = [];
function createVolunteer({
x,
z,
rotation = 0,
pose = "stand",
coat = 0x4e5661,
trousers = 0x38352f,
skin = 0xb88160,
female = false,
hat = 0x5c4937,
scale = 1,
apron = false
}) {
const person = new THREE.Group();
person.position.set(x, 0, z);
person.rotation.y = rotation;
person.scale.setScalar(scale);
scene.add(person);
const coatMaterial = material(coat);
const trouserMaterial = material(trousers);
const skinMaterial = material(skin);
const hatMaterial = material(hat);
const bootMaterial = material(0x2d2925);
if (female) {
addCylinder(
person,
0.25,
0.42,
0.72,
[0, 0.73, 0],
coatMaterial,
8
);
cylinderBetween(person, [-0.12, 0.45, 0], [-0.13, 0.12, 0], 0.075, trouserMaterial);
cylinderBetween(person, [0.12, 0.45, 0], [0.13, 0.12, 0.02], 0.075, trouserMaterial);
} else {
cylinderBetween(person, [-0.13, 0.9, 0], [-0.14, 0.15, 0], 0.09, trouserMaterial);
cylinderBetween(person, [0.13, 0.9, 0], [0.14, 0.15, 0.02], 0.09, trouserMaterial);
}
addCylinder(
person,
0.245,
0.3,
0.63,
[0, 1.18, 0],
coatMaterial,
7
);
addCylinder(person, 0.075, 0.075, 0.13, [0, 1.54, 0], skinMaterial, 6);
const head = addMesh(
person,
new THREE.SphereGeometry(0.19, 8, 6),
skinMaterial,
0,
1.69,
0
);
head.scale.set(0.9, 1.08, 0.9);
addMesh(
person,
new THREE.ConeGeometry(0.055, 0.09, 5),
skinMaterial,
0,
1.68,
0.185
).rotation.x = Math.PI / 2;
if (female) {
addCylinder(
person,
0.205,
0.225,
0.12,
[0, 1.84, 0],
hatMaterial,
8
);
const scarf = addMesh(
person,
new THREE.SphereGeometry(0.205, 8, 5),
hatMaterial,
0,
1.78,
-0.035
);
scarf.scale.set(1, 0.65, 1);
addMesh(
person,
new THREE.SphereGeometry(0.07, 5, 4),
hatMaterial,
0,
1.78,
-0.2
);
} else {
addCylinder(
person,
0.16,
0.18,
0.13,
[0, 1.85, 0],
hatMaterial,
8
);
addCylinder(
person,
0.255,
0.255,
0.035,
[0, 1.81, 0.035],
hatMaterial,
8
);
}
// Shoes.
addBox(person, [0.19, 0.13, 0.31], [-0.14, 0.09, 0.07], bootMaterial);
addBox(person, [0.19, 0.13, 0.31], [0.14, 0.09, 0.09], bootMaterial);
let leftElbow = [-0.37, 1.1, 0.02];
let leftHand = [-0.33, 0.81, 0.04];
let rightElbow = [0.37, 1.1, 0.02];
let rightHand = [0.33, 0.81, 0.04];
if (pose === "hold" || pose === "receive") {
leftElbow = [-0.4, 1.13, 0.14];
leftHand = [-0.14, 0.91, 0.49];
rightElbow = [0.4, 1.13, 0.14];
rightHand = [0.14, 0.91, 0.49];
} else if (pose === "carry") {
leftElbow = [-0.39, 1.05, 0.09];
leftHand = [-0.15, 0.77, 0.45];
rightElbow = [0.39, 1.05, 0.09];
rightHand = [0.15, 0.77, 0.45];
} else if (pose === "pour") {
leftElbow = [-0.4, 1.16, 0.13];
leftHand = [-0.25, 1.03, 0.5];
rightElbow = [0.37, 1.2, 0.29];
rightHand = [0.12, 1.3, 0.64];
}
cylinderBetween(person, [-0.26, 1.4, 0], leftElbow, 0.085, coatMaterial);
cylinderBetween(person, leftElbow, leftHand, 0.075, coatMaterial);
cylinderBetween(person, [0.26, 1.4, 0], rightElbow, 0.085, coatMaterial);
cylinderBetween(person, rightElbow, rightHand, 0.075, coatMaterial);
addMesh(person, new THREE.SphereGeometry(0.075, 6, 4), skinMaterial, ...leftHand);
addMesh(person, new THREE.SphereGeometry(0.075, 6, 4), skinMaterial, ...rightHand);
if (apron) {
const apronMaterial = material(0xd8c9a8);
addBox(person, [0.43, 0.58, 0.045], [0, 1.13, 0.275], apronMaterial);
addBox(person, [0.1, 0.36, 0.045], [-0.13, 1.42, 0.265], apronMaterial);
addBox(person, [0.1, 0.36, 0.045], [0.13, 1.42, 0.265], apronMaterial);
}
if (pose === "hold" || pose === "carry" || pose === "receive") {
const bucketY = pose === "receive" ? 0.82 : pose === "carry" ? 0.64 : 0.76;
makeBucket(person, [0, bucketY, 0.53], 0.83);
}
person.userData.phase = random() * Math.PI * 2;
person.userData.baseY = 0;
volunteers.push(person);
return person;
}
// Station workers.
createVolunteer({
x: -1.75,
z: 1.38,
rotation: Math.PI,
pose: "hold",
coat: 0x8b4937,
trousers: 0x3b3832,
skin: 0xb77b57,
hat: 0x604835,
apron: true
});
createVolunteer({
x: -0.46,
z: 1.55,
rotation: Math.PI + 0.15,
pose: "pour",
coat: 0xdad0b8,
trousers: 0x47423b,
skin: 0xc18a63,
hat: 0x6d5138,
apron: true
});
// Residents waiting with containers.
createVolunteer({
x: 1.08,
z: 1.67,
rotation: -1.35,
pose: "receive",
coat: 0x495663,
trousers: 0x3b3731,
skin: 0x9c6847,
hat: 0x66523c
});
createVolunteer({
x: 2.35,
z: 2.42,
rotation: -1.4,
pose: "carry",
coat: 0x77654f,
trousers: 0x3e3a33,
skin: 0xc28a64,
female: true,
hat: 0x6e4d43
});
createVolunteer({
x: 3.55,
z: 2.72,
rotation: -1.35,
pose: "stand",
coat: 0x61453d,
trousers: 0x383630,
skin: 0x8f5c40,
hat: 0x4e4336
});
createVolunteer({
x: 4.85,
z: 2.9,
rotation: -1.35,
pose: "carry",
coat: 0x5d6670,
trousers: 0x3d3934,
skin: 0xb98160,
female: true,
hat: 0x70564c
});
createVolunteer({
x: 6.1,
z: 3.0,
rotation: -1.35,
pose: "stand",
coat: 0x8b7353,
trousers: 0x4a4237,
skin: 0xa76d49,
hat: 0x5b4937
});
// A child beside the line.
const child = createVolunteer({
x: 0.48,
z: 3.05,
rotation: -1.2,
pose: "stand",
coat: 0x8e6a4d,
trousers: 0x494039,
skin: 0xc18d67,
hat: 0x705039,
scale: 0.72
});
child.position.y = 0.02;
// A plank bridge over one of the fissures.
const plankA = addBox(
scene,
[3.1, 0.13, 0.48],
[7.7, 0.18, 1.75],
palette.timberLight
);
plankA.rotation.y = -0.11;
const plankB = plankA.clone();
plankB.position.z += 0.56;
scene.add(plankB);
// -------------------------------------------------------------------------
// Smoke and drifting dust
// -------------------------------------------------------------------------
const smokePuffs = [];
const smokeGeometry = new THREE.DodecahedronGeometry(0.8, 0);
for (let i = 0; i < 13; i++) {
const smokeMaterial = new THREE.MeshStandardMaterial({
color: 0x777168,
transparent: true,
opacity: 0.12,
depthWrite: false,
roughness: 1,
flatShading: true
});
const puff = addMesh(
scene,
smokeGeometry,
smokeMaterial,
-6.6 + range(-0.7, 0.7),
4.5,
-7.5 + range(-0.5, 0.5)
);
puff.castShadow = false;
puff.receiveShadow = false;
smokePuffs.push({
mesh: puff,
offset: i / smokePuffs.length,
drift: range(-0.7, 0.7)
});
}
const dustCount = 130;
const dustPositions = new Float32Array(dustCount * 3);
for (let i = 0; i < dustCount; i++) {
dustPositions[i * 3] = range(-25, 25);
dustPositions[i * 3 + 1] = range(0.5, 11);
dustPositions[i * 3 + 2] = range(-10, 11);
}
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xe9d8b5,
size: 0.065,
transparent: true,
opacity: 0.46,
depthWrite: false,
sizeAttenuation: true
})
);
scene.add(dust);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan-free drag and wheel zoom
// -------------------------------------------------------------------------
function updateCamera() {
const radius = 33;
const sinPhi = Math.sin(currentPhi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(currentTheta),
target.y + radius * Math.cos(currentPhi),
target.z + radius * sinPhi * Math.cos(currentTheta)
);
camera.lookAt(target);
camera.zoom = currentZoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const halfHeight = aspect < 1 ? 17.5 : 11.2;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(width, height);
updateCamera();
}
let pointerActive = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
pointerActive = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointerActive) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desiredTheta -= deltaX * 0.006;
desiredPhi = THREE.MathUtils.clamp(
desiredPhi - deltaY * 0.005,
0.57,
1.34
);
});
function endPointer(event) {
pointerActive = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredZoom = THREE.MathUtils.clamp(
desiredZoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.85
);
},
{ passive: false }
);
function resetView() {
desiredTheta = 0.66;
desiredPhi = 0.98;
desiredZoom = 1.0;
}
resetButton.addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") desiredTheta += 0.12;
if (event.key === "ArrowRight") desiredTheta -= 0.12;
if (event.key === "ArrowUp") desiredPhi = Math.max(0.57, desiredPhi - 0.08);
if (event.key === "ArrowDown") desiredPhi = Math.min(1.34, desiredPhi + 0.08);
});
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
pauseButton.setAttribute("aria-pressed", String(paused));
});
window.addEventListener("resize", resize);
resize();
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (!paused) simulationTime += delta;
currentTheta = THREE.MathUtils.lerp(currentTheta, desiredTheta, 0.09);
currentPhi = THREE.MathUtils.lerp(currentPhi, desiredPhi, 0.09);
currentZoom = THREE.MathUtils.lerp(currentZoom, desiredZoom, 0.11);
updateCamera();
// Quiet human movement.
volunteers.forEach((person, index) => {
const amplitude = index === 6 ? 0.006 : 0.011;
person.position.y =
person.userData.baseY +
Math.sin(simulationTime * 1.55 + person.userData.phase) * amplitude;
person.rotation.z =
Math.sin(simulationTime * 0.7 + person.userData.phase) * 0.006;
});
// Water pulse and falling droplets.
waterStream.scale.y = 0.96 + Math.sin(simulationTime * 9.0) * 0.05;
streamMaterial.opacity = 0.65 + Math.sin(simulationTime * 7.0) * 0.08;
droplets.forEach((drop, index) => {
const t = (simulationTime * 1.55 + index / droplets.length) % 1;
drop.position.y = 1.03 - t * 0.58;
drop.position.x = 0.16 + Math.sin(t * 8 + index) * 0.018;
drop.position.z = 0.95 + Math.cos(t * 7 + index) * 0.015;
drop.scale.setScalar(0.7 + t * 0.8);
});
// Rising smoke.
smokePuffs.forEach((puff, index) => {
const t = (simulationTime * 0.085 + puff.offset) % 1;
puff.mesh.position.y = 4.4 + t * 8.2;
puff.mesh.position.x = -6.6 + puff.drift * t + Math.sin(t * 7 + index) * 0.25;
puff.mesh.position.z = -7.4 + Math.cos(t * 5 + index) * 0.3;
puff.mesh.scale.setScalar(0.55 + t * 2.4);
puff.mesh.material.opacity = Math.sin(Math.PI * t) * 0.15;
puff.mesh.rotation.y = t * 0.8 + index;
});
// Dust drifts slowly through the sunlight.
const positions = dustGeometry.attributes.position.array;
for (let i = 0; i < dustCount; i++) {
positions[i * 3 + 1] += delta * (0.055 + (i % 5) * 0.008);
positions[i * 3] += Math.sin(simulationTime * 0.23 + i) * delta * 0.025;
if (positions[i * 3 + 1] > 11.5) positions[i * 3 + 1] = 0.4;
}
dustGeometry.attributes.position.needsUpdate = true;
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
document.getElementById("loading").classList.add("hidden");
</script>
</body>
</html>
```