Prompt specification
Build or customize the Three.js 3D scene "Dhobi Ghat washing basin and drying rail" 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: Dhobi Ghat washing basin and drying rail
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/dhobi-ghat-washing-basin-and-drying-rail-x3009
Scene Description Prompt:
A low-poly Mumbai Dhobi Ghat washing basin has stone surfaces and overhead drying rails, separating work, water, and passage. Three.js from cdnjs, one HTML file.
Working Three.js Starter (dhobi-ghat-washing-basin-and-drying-rail-x3009):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mumbai Dhobi Ghat — Low-Poly Basin</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d7c5aa;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 18px 20px;
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 14px;
color: #fff8e9;
background: linear-gradient(
135deg,
rgba(39, 30, 27, 0.86),
rgba(69, 48, 39, 0.68)
);
box-shadow: 0 16px 45px rgba(44, 30, 20, 0.2);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: #f0b36b;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.24em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 4vw, 38px);
font-weight: 800;
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
margin: 10px 0 0;
color: rgba(255, 248, 233, 0.72);
font-size: 13px;
line-height: 1.45;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 15px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 8px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 999px;
color: rgba(255, 248, 233, 0.84);
background: rgba(255, 255, 255, 0.07);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend i {
width: 8px;
height: 8px;
border-radius: 2px;
}
.hint {
position: fixed;
right: 22px;
bottom: 20px;
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 9px;
color: rgba(255, 248, 233, 0.85);
background: rgba(48, 37, 31, 0.65);
box-shadow: 0 8px 30px rgba(39, 26, 19, 0.14);
backdrop-filter: blur(10px);
font-size: 11px;
letter-spacing: 0.025em;
pointer-events: none;
}
@media (max-width: 620px) {
.title-card {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
.subtitle {
display: none;
}
.legend {
margin-top: 10px;
}
.hint {
right: 14px;
bottom: 14px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="title-card">
<div class="eyebrow">Mumbai · Open-Air Laundry</div>
<h1>DHOBI<br />GHAT</h1>
<p class="subtitle">
A low-poly study of a communal washing basin, with stone work slabs,
shared water channels, and a clearly separated public passage.
</p>
<div class="legend" aria-label="Scene legend">
<span><i style="background:#d59a5b"></i>Work</span>
<span><i style="background:#4aa8ad"></i>Water</span>
<span><i style="background:#c8a77f"></i>Passage</span>
</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const mount = document.getElementById("scene");
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
mount.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd9c6a9);
scene.fog = new THREE.Fog(0xd9c6a9, 29, 68);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
150
);
const hemiLight = new THREE.HemisphereLight(0xffe4bd, 0x5c6675, 2.25);
scene.add(hemiLight);
const sun = new THREE.DirectionalLight(0xffd3a0, 3.2);
sun.position.set(-10, 19, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 22;
sun.shadow.camera.bottom = -22;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.normalBias = 0.035;
sun.shadow.bias = -0.00012;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xa6d8e5, 0.65);
fill.position.set(11, 8, -10);
scene.add(fill);
// ------------------------------------------------------------
// Shared materials and geometry helpers
// ------------------------------------------------------------
const materialCache = new Map();
function standard(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
flatShading: true
})
);
}
return materialCache.get(color);
}
function addBox(width, height, depth, color, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
typeof color === "number" ? standard(color) : color
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
topRadius,
bottomRadius,
height,
color,
x,
y,
z,
segments = 8,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments,
1,
false
),
typeof color === "number" ? standard(color) : color
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addSphere(radius, color, x, y, z, parent = scene, detail = 1) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, 7, 5),
typeof color === "number" ? standard(color) : color
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const up = new THREE.Vector3(0, 1, 0);
function addRod(start, end, radius, color, parent = scene, segments = 6) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, segments),
typeof color === "number" ? standard(color) : color
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(up, direction.normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let seed = 9137;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
function choose(items) {
return items[Math.floor(random() * items.length)];
}
// ------------------------------------------------------------
// Ground, pavement and spatial divisions
// ------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
standard(0xb89b77)
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.34;
ground.receiveShadow = true;
scene.add(ground);
// Irregular foreground paving around the working zone.
const groundStoneColors = [0xbda17d, 0xc7aa84, 0xb09270, 0xd0b48d];
for (let x = -12; x <= 12; x += 1.55) {
for (let z = -10; z <= 12; z += 1.7) {
if (x > -7 && x < 7.3 && z > -7 && z < 7.5) continue;
addBox(
1.38,
0.08,
1.5,
choose(groundStoneColors),
x + (random() - 0.5) * 0.12,
-0.27,
z + (random() - 0.5) * 0.12
);
}
}
// Warm ochre work slabs: a distinct zone immediately beside the tanks.
const workColors = [0xc88b52, 0xd29a61, 0xbe804d, 0xd7a26d];
for (let x = -0.5; x <= 0.5; x += 1.28) {
for (let z = -5.5; z <= 5.5; z += 1.48) {
addBox(
1.19,
0.3,
1.38,
choose(workColors),
x,
-0.08,
z
);
}
}
// Pale, orderly passage paving.
const passageColors = [0xc8aa82, 0xd0b48e, 0xbea078, 0xd6bc97];
for (let x = 2.75; x <= 6.0; x += 1.58) {
for (let z = -6.2; z <= 7.0; z += 1.62) {
addBox(
1.43,
0.16,
1.47,
choose(passageColors),
x,
-0.16,
z
);
}
}
// Curb separating work slabs from the public passage.
addBox(0.24, 0.42, 14.2, 0xa78969, 2.18, -0.04, 0.4);
// Narrow drainage channel between work area and passage.
addBox(0.3, 0.12, 13.7, 0x4b504a, 1.82, -0.2, 0.35);
for (let z = -6.1; z < 6.8; z += 0.42) {
addBox(0.34, 0.025, 0.08, 0x76776d, 1.82, -0.125, z);
}
// ------------------------------------------------------------
// Communal washing basin
// ------------------------------------------------------------
const tankCenters = [-5.0, -2.6];
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x4aa8ad,
roughness: 0.18,
metalness: 0.08,
transparent: true,
opacity: 0.9,
flatShading: true
});
const waterSurfaces = [];
// Common foundation beneath both channels.
addBox(5.3, 0.24, 11.0, 0x857966, -3.8, -0.16, 0);
for (const tankX of tankCenters) {
const innerWidth = 2.08;
const innerLength = 9.8;
// Dark stone bottom.
addBox(innerWidth, 0.12, innerLength, 0x596b68, tankX, 0.04, 0);
// Water surface.
const water = addBox(
innerWidth - 0.05,
0.055,
innerLength - 0.05,
waterMaterial,
tankX,
0.32,
0
);
water.castShadow = false;
waterSurfaces.push(water);
// Coping and side walls.
addBox(0.25, 0.75, 10.65, 0xa7967d, tankX - 1.25, 0.43, 0);
addBox(0.25, 0.75, 10.65, 0xb5a386, tankX + 1.25, 0.43, 0);
addBox(2.75, 0.75, 0.26, 0xc0aa8b, tankX, 0.43, -5.32);
addBox(2.75, 0.75, 0.26, 0xb09b7e, tankX, 0.43, 5.32);
// Small chips and worn blocks along the rim.
for (let z = -4.7; z < 5.1; z += 1.05) {
addBox(
0.42,
0.1,
0.82,
choose([0xbca88a, 0xcbb493, 0xa99274]),
tankX - 1.28,
0.84,
z
);
addBox(
0.42,
0.1,
0.82,
choose([0xbca88a, 0xcbb493, 0xa99274]),
tankX + 1.28,
0.84,
z
);
}
}
// Central stone divider between the two water channels.
addBox(0.32, 0.83, 10.7, 0xb19d80, -3.8, 0.45, 0);
// Front steps down into the basin.
for (const tankX of tankCenters) {
addBox(2.55, 0.2, 0.48, 0xb6a084, tankX, 0.02, 5.66);
addBox(2.55, 0.12, 0.48, 0xc0aa8b, tankX, -0.08, 6.04);
addBox(2.55, 0.07, 0.48, 0xc8b392, tankX, -0.16, 6.42);
}
// Low-poly ripples.
const ripples = [];
for (let i = 0; i < 14; i++) {
const rippleMaterial = new THREE.MeshBasicMaterial({
color: 0xd5ffff,
transparent: true,
opacity: 0.22,
depthWrite: false,
side: THREE.DoubleSide
});
const ripple = new THREE.Mesh(
new THREE.RingGeometry(0.14, 0.175, 16),
rippleMaterial
);
ripple.rotation.x = -Math.PI / 2;
ripple.position.set(
choose(tankCenters) + (random() - 0.5) * 1.55,
0.355,
(random() - 0.5) * 8.8
);
scene.add(ripple);
ripples.push({
mesh: ripple,
phase: random() * Math.PI * 2,
speed: 0.55 + random() * 0.45
});
}
// ------------------------------------------------------------
// Background stone building and arched entrances
// ------------------------------------------------------------
const facade = addBox(
19.5,
6.45,
1.55,
0xb79876,
-0.35,
2.9,
-7.15
);
// Foundation and roof coping.
addBox(19.8, 0.55, 1.8, 0x917a60, -0.35, 0.0, -7.15);
addBox(20.0, 0.28, 1.95, 0xc4aa86, -0.35, 6.2, -7.15);
addBox(19.6, 0.55, 1.8, 0xb59a79, -0.35, 6.55, -7.15);
function addArchOpening(x, width, height) {
const radius = width / 2;
const shape = new THREE.Shape();
shape.moveTo(-radius, 0);
shape.lineTo(radius, 0);
shape.lineTo(radius, height - radius);
shape.absarc(0, height - radius, radius, 0, Math.PI, false);
shape.lineTo(-radius, 0);
shape.closePath();
const opening = new THREE.Mesh(
new THREE.ShapeGeometry(shape, 12),
new THREE.MeshStandardMaterial({
color: 0x302d28,
roughness: 1,
flatShading: true
})
);
opening.position.set(x, 0.27, -6.365);
opening.receiveShadow = true;
scene.add(opening);
// Pale jambs emphasize the recessed arch.
addBox(0.2, height - radius, 0.2, 0xc8ad89, x - radius - 0.08, 0.27, -6.34);
addBox(0.2, height - radius, 0.2, 0xc8ad89, x + radius + 0.08, 0.27, -6.34);
addBox(width + 0.55, 0.16, 0.22, 0xc8ad89, x, height + 0.18, -6.34);
// Threshold.
addBox(width + 0.55, 0.15, 0.65, 0xa48a6d, x, 0.14, -6.12);
}
[-7.1, -3.25, 1.55, 6.35].forEach((x, index) => {
addArchOpening(x, 1.55, index % 2 === 0 ? 2.8 : 2.55);
});
// Upper windows with dark shutters.
for (const x of [-8.1, -5.1, -1.35, 2.45, 5.35, 8.25]) {
addBox(0.92, 1.08, 0.12, 0x4b4236, x, 4.35, -6.34);
addBox(0.13, 1.12, 0.15, 0x7b694f, x, 4.35, -6.25);
addBox(1.05, 0.12, 0.25, 0xc6aa83, x, 3.78, -6.23);
}
// Masonry seam lines.
for (let y = 1.05; y < 6; y += 0.94) {
addBox(18.7, 0.025, 0.02, 0x927b61, -0.35, y, -6.365);
}
for (let x = -9.2; x < 9; x += 1.48) {
addBox(0.025, 6.0, 0.02, 0x9b8266, x, 3.1, -6.36);
}
// Rooftop water tanks.
for (const x of [-7.4, 0.8, 7.7]) {
addCylinder(0.55, 0.55, 1.05, 0x627878, x, 7.35, -7.1, 10);
addCylinder(0.64, 0.64, 0.12, 0x45585b, x, 7.92, -7.1, 10);
for (const dx of [-0.32, 0.32]) {
addBox(0.09, 0.55, 0.09, 0x665b4e, x + dx, 6.98, -7.1);
}
}
// Distant urban blocks.
const distantColors = [0xa88f72, 0xb49a7b, 0x9f896f, 0xc0a17c];
for (let i = 0; i < 12; i++) {
const width = 2.5 + random() * 3;
const height = 3 + random() * 6;
const x = -18 + i * 3.2 + (random() - 0.5) * 1.1;
const z = -14 - random() * 6;
addBox(
width,
height,
3 + random() * 3,
choose(distantColors),
x,
height / 2 - 0.3,
z
);
}
// ------------------------------------------------------------
// Overhead drying rails and laundry
// ------------------------------------------------------------
const railColor = 0x566266;
const railX = [-0.7, 1.35];
const railHeight = 4.45;
for (const z of [-5.6, 0, 5.6]) {
addRod(
[railX[0], 0.05, z],
[railX[0], railHeight, z],
0.065,
railColor
);
addRod(
[railX[1], 0.05, z],
[railX[1], railHeight, z],
0.065,
railColor
);
addRod(
[railX[0], railHeight, z],
[railX[1], railHeight, z],
0.075,
railColor
);
addBox(0.38, 0.12, 0.38, 0x817866, railX[0], 0.0, z);
addBox(0.38, 0.12, 0.38, 0x817866, railX[1], 0.0, z);
}
for (const x of railX) {
addRod(
[x, railHeight, -5.6],
[x, railHeight, 5.6],
0.075,
railColor
);
}
const laundry = [
0xe95f47,
0xf1b84b,
0x3f8fa3,
0xf0e2c5,
0x7d5aa6,
0xdb805f,
0x6f9f6a,
0xe7d9c5
];
const swayingClothes = [];
function addHangingCloth(x, z, color, width, height, phase) {
const group = new THREE.Group();
group.position.set(x, railHeight - 0.03, z);
group.userData.phase = phase;
group.userData.baseRotation = (random() - 0.5) * 0.12;
addBox(
width,
height,
0.045,
color,
0,
-height / 2,
0,
group
);
// Slightly offset folded end adds a faceted cloth silhouette.
addBox(
width * 0.82,
0.3,
0.05,
color,
width * 0.07,
-height + 0.12,
0.018,
group
);
// Peg.
addBox(0.1, 0.15, 0.09, 0x9a7046, 0, 0.02, 0.01, group);
scene.add(group);
swayingClothes.push(group);
}
let clothIndex = 0;
for (const x of railX) {
for (let z = -4.9; z <= 4.9; z += 1.2) {
addHangingCloth(
x,
z,
laundry[clothIndex % laundry.length],
0.62 + random() * 0.42,
0.9 + random() * 0.75,
random() * Math.PI * 2
);
clothIndex++;
}
}
// ------------------------------------------------------------
// Workers and washing tools
// ------------------------------------------------------------
function addWorker({
x,
z,
shirt,
dhoti,
skin = 0x9b6847,
scale = 1,
facing = 0
}) {
const worker = new THREE.Group();
worker.position.set(x, 0.08, z);
worker.rotation.y = facing;
worker.scale.setScalar(scale);
// Legs and feet.
addRod(
[-0.12, 0.12, -0.14],
[-0.06, 0.67, -0.1],
0.085,
skin,
worker
);
addRod(
[0.12, 0.12, 0.14],
[0.06, 0.67, 0.1],
0.085,
skin,
worker
);
addBox(0.2, 0.11, 0.32, 0x3c3028, -0.1, 0.08, -0.19, worker);
addBox(0.2, 0.11, 0.32, 0x3c3028, 0.1, 0.08, 0.19, worker);
// Dhoti and torso.
addCylinder(0.26, 0.38, 0.58, dhoti, 0, 0.69, 0, 7, worker);
addCylinder(0.25, 0.31, 0.78, shirt, -0.08, 1.25, 0, 7, worker);
// Neck and head.
addCylinder(0.08, 0.09, 0.18, skin, -0.14, 1.69, 0, 6, worker);
const head = addSphere(0.2, skin, -0.17, 1.88, 0, worker);
head.scale.set(0.93, 1.05, 0.95);
// Hair.
const hair = addSphere(0.205, 0x28221e, -0.16, 1.94, 0, worker);
hair.scale.set(0.94, 0.62, 0.97);
// Forward-reaching arms.
addRod(
[-0.15, 1.48, -0.25],
[-0.4, 1.15, -0.31],
0.07,
skin,
worker
);
addRod(
[-0.4, 1.15, -0.31],
[-0.73, 0.85, -0.26],
0.065,
skin,
worker
);
addRod(
[-0.12, 1.48, 0.25],
[-0.32, 1.08, 0.3],
0.07,
skin,
worker
);
addRod(
[-0.32, 1.08, 0.3],
[-0.65, 0.82, 0.25],
0.065,
skin,
worker
);
scene.add(worker);
return worker;
}
addWorker({
x: -0.45,
z: -1.85,
shirt: 0x3d879a,
dhoti: 0xe6d5b5,
skin: 0x9a6749,
facing: Math.PI / 2
});
addWorker({
x: 0.45,
z: 2.35,
shirt: 0xd65a3c,
dhoti: 0xf0dfbd,
skin: 0x85583e,
facing: -Math.PI / 2,
scale: 0.94
});
addWorker({
x: 0.15,
z: -4.25,
shirt: 0xe4ae3c,
dhoti: 0x756b61,
skin: 0xa87550,
facing: Math.PI / 2,
scale: 0.88
});
function addBucket(x, y, z, color, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
addCylinder(0.27, 0.2, 0.42, color, 0, 0.21, 0, 8, group);
addCylinder(0.28, 0.28, 0.055, 0x414d4c, 0, 0.425, 0, 8, group);
const handle = new THREE.Mesh(
new THREE.TorusGeometry(0.25, 0.025, 4, 12, Math.PI),
standard(0x515a57)
);
handle.position.set(0, 0.44, 0);
handle.castShadow = true;
group.add(handle);
scene.add(group);
}
addBucket(0.9, 0.08, -0.8, 0x4b9fa7, 1.0);
addBucket(-0.6, 0.08, 3.6, 0xe09b38, 0.86);
addBucket(-5.65, 0.12, -4.7, 0xd9664c, 0.72);
addBucket(4.55, -0.05, 2.4, 0x497d8a, 0.92);
// Scrub brushes resting on the work slabs.
for (let i = 0; i < 5; i++) {
const brush = new THREE.Group();
brush.position.set(
-0.9 + random() * 1.7,
0.16,
-4.8 + random() * 9.4
);
brush.rotation.y = random() * Math.PI;
addBox(0.44, 0.08, 0.17, 0x8a5937, 0, 0, 0, brush);
addBox(0.36, 0.07, 0.1, 0xd6b472, 0, 0.07, 0, brush);
scene.add(brush);
}
// Laundry baskets.
function addBasket(x, z, color) {
const group = new THREE.Group();
group.position.set(x, 0.08, z);
addCylinder(0.43, 0.32, 0.58, color, 0, 0.29, 0, 8, group);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const slat = addBox(
0.055,
0.5,
0.04,
0xe4c18c,
Math.cos(angle) * 0.39,
0.32,
Math.sin(angle) * 0.39,
group
);
slat.rotation.y = -angle;
}
scene.add(group);
}
addBasket(0.65, 4.5, 0xd97945);
addBasket(5.15, -2.2, 0x5e8d91);
// Foam clusters in the water.
const foamMaterial = new THREE.MeshBasicMaterial({
color: 0xeaf8ed,
transparent: true,
opacity: 0.74
});
for (let i = 0; i < 30; i++) {
const foam = new THREE.Mesh(
new THREE.SphereGeometry(0.055 + random() * 0.055, 5, 4),
foamMaterial
);
foam.position.set(
choose(tankCenters) + (random() - 0.5) * 1.65,
0.37,
(random() - 0.5) * 8.8
);
foam.scale.y = 0.45;
scene.add(foam);
}
// A few small foreground stones for depth.
for (let i = 0; i < 18; i++) {
const rock = addSphere(
0.08 + random() * 0.12,
choose([0x8f806d, 0xa18c73, 0x7d776d]),
-10 + random() * 21,
-0.19,
8 + random() * 7
);
rock.scale.set(1.4, 0.6, 1);
}
// ------------------------------------------------------------
// Custom camera controls: orbit, zoom and reset
// ------------------------------------------------------------
const controls = {
target: new THREE.Vector3(-0.7, 1.35, -0.3),
theta: 0.67,
phi: 0.86,
radius: 27
};
const desired = {
theta: controls.theta,
phi: controls.phi,
radius: controls.radius
};
let dragging = false;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi + dy * 0.005,
0.38,
1.36
);
});
function stopDragging(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
15,
43
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
desired.theta = 0.67;
desired.phi = 0.86;
desired.radius = 27;
});
function updateCamera() {
controls.theta += (desired.theta - controls.theta) * 0.075;
controls.phi += (desired.phi - controls.phi) * 0.075;
controls.radius += (desired.radius - controls.radius) * 0.075;
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x +
controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z +
controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
updateCamera();
// Gentle water movement.
waterSurfaces.forEach((water, index) => {
water.position.y =
0.32 + Math.sin(elapsed * 0.75 + index * 1.7) * 0.007;
});
// Expanding surface ripples.
ripples.forEach((ripple) => {
const cycle = (elapsed * ripple.speed + ripple.phase) % 1;
const scale = 0.65 + cycle * 2.8;
ripple.mesh.scale.setScalar(scale);
ripple.mesh.material.opacity = (1 - cycle) * 0.25;
});
// Laundry moves very slightly in the warm air.
swayingClothes.forEach((cloth) => {
cloth.rotation.z =
cloth.userData.baseRotation +
Math.sin(elapsed * 0.8 + cloth.userData.phase) * 0.035;
cloth.rotation.x =
Math.sin(elapsed * 0.55 + cloth.userData.phase) * 0.018;
});
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```