Prompt specification
Build or customize the Three.js 3D scene "Rainy street-market shelter" 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: Rainy street-market shelter
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/rainy-street-market-shelter-x0483
Scene Description Prompt:
Build a stylized rainy street market with dry counters, connected shelter, and visible canopy drainage. Use Three.js from cdnjs in standalone HTML.
Working Three.js Starter (rainy-street-market-shelter-x0483):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rainy Street Market</title>
<style>
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #172630;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
z-index: 10;
pointer-events: none;
color: #f6f1df;
}
.title-card {
position: absolute;
top: 24px;
left: 24px;
padding: 17px 20px 16px;
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 16px;
background: rgba(17, 31, 39, 0.76);
box-shadow: 0 16px 45px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(14px);
}
.eyebrow {
margin-bottom: 5px;
color: #9ed8cd;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(21px, 2.5vw, 31px);
line-height: 1.05;
letter-spacing: -0.04em;
}
.subtitle {
margin-top: 7px;
color: rgba(246, 241, 223, 0.72);
font-size: 12px;
}
.weather {
position: absolute;
top: 24px;
right: 24px;
display: flex;
align-items: center;
gap: 9px;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 999px;
background: rgba(17, 31, 39, 0.72);
backdrop-filter: blur(12px);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.12em;
}
.weather-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #8de1d0;
box-shadow: 0 0 0 5px rgba(141, 225, 208, 0.12);
animation: pulse 1.7s ease-in-out infinite;
}
@keyframes pulse {
50% {
box-shadow: 0 0 0 9px rgba(141, 225, 208, 0);
}
}
.features {
position: absolute;
left: 24px;
bottom: 24px;
display: flex;
flex-wrap: wrap;
gap: 8px;
max-width: min(560px, calc(100vw - 48px));
}
.feature {
padding: 8px 11px;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 999px;
background: rgba(17, 31, 39, 0.68);
color: rgba(246, 241, 223, 0.82);
backdrop-filter: blur(10px);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.11em;
}
.controls {
position: absolute;
right: 24px;
bottom: 24px;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 10px;
background: rgba(17, 31, 39, 0.68);
color: rgba(246, 241, 223, 0.7);
backdrop-filter: blur(10px);
font-size: 11px;
}
@media (max-width: 700px) {
.title-card { top: 14px; left: 14px; }
.weather { top: 14px; right: 14px; }
.subtitle { display: none; }
.features { left: 14px; bottom: 14px; }
.controls { right: 14px; bottom: 14px; }
.feature:nth-child(2) { display: none; }
}
</style>
</head>
<body>
<div class="hud">
<div class="title-card">
<div class="eyebrow">After-hours market</div>
<h1>Rainy Street Market</h1>
<div class="subtitle">A connected shelter, dry counters, and a working drainage system.</div>
</div>
<div class="weather">
<span class="weather-dot"></span>
LIVE RAIN
</div>
<div class="features">
<div class="feature">SHARED CANOPY</div>
<div class="feature">DRY COUNTERS</div>
<div class="feature">GUTTER → DOWNPIPE → DRAIN</div>
</div>
<div class="controls">Drag to orbit · Scroll to zoom</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Renderer, scene, and lighting
// ---------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
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;
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x182832);
scene.fog = new THREE.FogExp2(0x182832, 0.025);
const camera = new THREE.PerspectiveCamera(
46,
window.innerWidth / window.innerHeight,
0.1,
120
);
const clock = new THREE.Clock();
const hemi = new THREE.HemisphereLight(0x9bc8dc, 0x344038, 1.7);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xc7e2ef, 2.4);
keyLight.position.set(-9, 16, -11);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -18;
keyLight.shadow.camera.right = 18;
keyLight.shadow.camera.top = 15;
keyLight.shadow.camera.bottom = -12;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 45;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xffb56b, 0.65);
fillLight.position.set(10, 7, 7);
scene.add(fillLight);
// Deterministic pseudo-random values keep the scene consistent.
let seed = 915273;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function range(a, b) {
return a + (b - a) * random();
}
// ---------------------------------------------------------------------
// Geometry helpers
// ---------------------------------------------------------------------
function standard(color, roughness = 0.75, metalness = 0, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: true,
...extra
});
}
function box(parent, w, h, d, material, x = 0, y = 0, z = 0, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
radiusTop,
radiusBottom,
height,
material,
x = 0,
y = 0,
z = 0,
segments = 12
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function sphere(parent, radius, material, x = 0, y = 0, z = 0, segments = 14) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, segments, Math.max(8, segments / 2)),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function torus(parent, radius, tube, material, x, y, z) {
const mesh = new THREE.Mesh(
new THREE.TorusGeometry(radius, tube, 8, 32),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Materials
// ---------------------------------------------------------------------
const mats = {
wall: standard(0x29464b, 0.92),
wallTrim: standard(0x38595b, 0.85),
platform: standard(0xa79f8b, 0.94),
platformEdge: standard(0x6d746e, 0.88),
darkMetal: standard(0x263c42, 0.42, 0.38),
gutter: standard(0x31555c, 0.38, 0.45),
wood: standard(0x8c5a38, 0.82),
woodDark: standard(0x593d31, 0.9),
woodLight: standard(0xb47b4e, 0.78),
teal: standard(0x348f8a, 0.76),
coral: standard(0xd96954, 0.78),
cream: standard(0xe9dfbd, 0.86),
red: standard(0xc94e3d, 0.65),
green: standard(0x5e8e48, 0.76),
orange: standard(0xdf873b, 0.68),
yellow: standard(0xd9b249, 0.72),
purple: standard(0x765475, 0.76),
blue: standard(0x4e789b, 0.7),
white: standard(0xe9e4d7, 0.86),
ceramic: standard(0xb5c6bd, 0.5),
black: standard(0x172326, 0.85)
};
const bulbMaterial = standard(0xffd48c, 0.35, 0, {
emissive: 0xffa83d,
emissiveIntensity: 2.2
});
const waterMaterial = new THREE.MeshBasicMaterial({
color: 0x8de6e2,
transparent: true,
opacity: 0.76,
depthWrite: false
});
// ---------------------------------------------------------------------
// Procedural cobblestone texture
// ---------------------------------------------------------------------
function createCobbleTexture() {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 1024;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#35444a";
ctx.fillRect(0, 0, 1024, 1024);
const rows = 10;
const cols = 8;
const h = 1024 / rows;
const w = 1024 / cols;
for (let row = 0; row < rows; row++) {
const offset = row % 2 === 0 ? -w * 0.5 : 0;
for (let col = -1; col <= cols; col++) {
const x = col * w + offset;
const y = row * h;
const lightness = 37 + Math.floor(random() * 15);
ctx.fillStyle = `hsl(195, 11%, ${lightness}%)`;
ctx.fillRect(x + 3, y + 3, w - 7, h - 7);
ctx.fillStyle = "rgba(255,255,255,0.035)";
ctx.fillRect(x + 5, y + 5, w - 11, 3);
ctx.fillStyle = "rgba(0,0,0,0.09)";
ctx.fillRect(x + 5, y + h - 9, w - 11, 4);
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(5, 4);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const streetMaterial = standard(0x71838a, 0.27, 0.16, {
map: createCobbleTexture()
});
const ground = new THREE.Mesh(new THREE.PlaneGeometry(44, 34), streetMaterial);
ground.rotation.x = -Math.PI / 2;
ground.position.z = -4;
ground.receiveShadow = true;
scene.add(ground);
// ---------------------------------------------------------------------
// Raised dry market floor and rear wall
// ---------------------------------------------------------------------
box(scene, 22.5, 0.28, 4.8, mats.platform, 0, 0.14, 2.05, false);
box(scene, 22.6, 0.12, 0.18, mats.platformEdge, 0, 0.25, -0.32, false);
box(scene, 22.3, 4.7, 0.32, mats.wall, 0, 2.35, 4.62);
// Tile seams emphasize that the sheltered floor remains dry.
for (let z = -0.1; z < 4.4; z += 0.62) {
box(scene, 22, 0.012, 0.018, mats.platformEdge, 0, 0.287, z, false);
}
for (let x = -10.5; x <= 10.5; x += 1.5) {
box(scene, 0.018, 0.012, 4.65, mats.platformEdge, x, 0.288, 2.05, false);
}
// Wall pilasters and upper trim.
for (let x = -10; x <= 10; x += 2.5) {
box(scene, 0.18, 4.4, 0.16, mats.wallTrim, x, 2.25, 4.40);
}
box(scene, 22.3, 0.2, 0.22, mats.wallTrim, 0, 4.25, 4.38);
box(scene, 22.3, 0.16, 0.20, mats.wallTrim, 0, 0.65, 4.39);
// Background buildings give the market depth.
const buildingMaterialA = standard(0x263d47, 0.94);
const buildingMaterialB = standard(0x314951, 0.94);
[
[-15, 3.2, 7.2, 6.5, 4.0],
[-11.8, 2.8, 10.2, 4.4, 4.7],
[12.2, 3.4, 8.2, 4.8, 4.3],
[16, 4.5, 5.4, 6.8, 4.8]
].forEach((b, i) => {
box(
scene,
b[2],
b[3],
b[4],
i % 2 ? buildingMaterialA : buildingMaterialB,
b[0],
b[1],
b[5],
false
);
});
// ---------------------------------------------------------------------
// One continuous connected canopy
// ---------------------------------------------------------------------
const roofGroup = new THREE.Group();
roofGroup.position.set(0, 4.08, 2.0);
roofGroup.rotation.x = -0.1;
scene.add(roofGroup);
const canopyColors = [
mats.cream,
mats.teal,
mats.cream,
mats.coral,
mats.cream,
mats.teal,
mats.cream,
mats.coral,
mats.cream,
mats.teal
];
for (let i = 0; i < 10; i++) {
box(
roofGroup,
2.02,
0.13,
4.82,
canopyColors[i],
-9 + i * 2,
0,
0
);
}
// Front scalloped valance, still visibly connected from stall to stall.
for (let i = 0; i < 10; i++) {
box(
scene,
1.96,
0.34,
0.09,
canopyColors[i],
-9 + i * 2,
3.65,
-0.43
);
}
// Shared metal gutter beneath the front eave.
const gutter = cylinder(
scene,
0.13,
0.13,
20.8,
mats.gutter,
0,
3.43,
-0.49,
18
);
gutter.rotation.z = Math.PI / 2;
sphere(scene, 0.13, mats.gutter, -10.4, 3.43, -0.49);
sphere(scene, 0.13, mats.gutter, 10.4, 3.43, -0.49);
// Supports.
const postMaterial = standard(0x315b59, 0.52, 0.28);
for (const x of [-10, -5, 0, 5, 10]) {
cylinder(scene, 0.075, 0.09, 3.5, postMaterial, x, 2.03, -0.24);
cylinder(scene, 0.065, 0.08, 4.05, postMaterial, x, 2.3, 4.28);
const brace = box(
scene,
4.5,
0.09,
0.09,
postMaterial,
x,
3.74,
2.0
);
brace.rotation.x = -0.1;
}
// ---------------------------------------------------------------------
// Counters and market stalls
// ---------------------------------------------------------------------
const counterX = [-7.5, -2.5, 2.5, 7.5];
const frontColors = [mats.teal, mats.coral, mats.teal, mats.coral];
for (let i = 0; i < counterX.length; i++) {
const x = counterX[i];
box(scene, 4.58, 1.08, 0.84, frontColors[i], x, 0.82, 0.67);
box(scene, 4.86, 0.15, 1.08, mats.woodLight, x, 1.43, 0.63);
// Counter paneling.
for (let p = -1.6; p <= 1.6; p += 0.8) {
box(scene, 0.035, 0.73, 0.025, mats.woodDark, x + p, 0.82, 0.235, false);
}
box(scene, 4.66, 0.09, 0.12, mats.woodDark, x, 0.29, 0.24);
}
function createSign(text, background, accent, x) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = accent;
ctx.lineWidth = 12;
ctx.strokeRect(10, 10, canvas.width - 20, canvas.height - 20);
ctx.fillStyle = "#f7efd6";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 76px system-ui, sans-serif";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 3);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const material = new THREE.MeshBasicMaterial({ map: texture });
const sign = new THREE.Mesh(new THREE.PlaneGeometry(3.45, 0.86), material);
sign.rotation.y = Math.PI;
sign.position.set(x, 2.87, -0.56);
scene.add(sign);
cylinder(scene, 0.018, 0.018, 0.48, mats.darkMetal, x - 1.25, 3.24, -0.51, 8);
cylinder(scene, 0.018, 0.018, 0.48, mats.darkMetal, x + 1.25, 3.24, -0.51, 8);
}
createSign("FRESH PRODUCE", "#315a58", "#e7bd73", -7.5);
createSign("BAKERY", "#914c3c", "#efd59a", -2.5);
createSign("TEA & SPICE", "#315a58", "#e7bd73", 2.5);
createSign("FLOWERS", "#914c3c", "#efd59a", 7.5);
// ---------------------------------------------------------------------
// Shelves and jars behind the counters
// ---------------------------------------------------------------------
box(scene, 20.8, 0.12, 0.72, mats.woodDark, 0, 2.12, 3.83);
box(scene, 20.8, 0.12, 0.72, mats.woodDark, 0, 3.25, 3.83);
for (const shelfY of [2.18, 3.31]) {
for (let x = -9.8; x <= 9.8; x += 0.72) {
const jarMaterial = [mats.ceramic, mats.yellow, mats.red, mats.green][
Math.floor(random() * 4)
];
cylinder(scene, 0.13, 0.14, 0.38, jarMaterial, x, shelfY + 0.2, 3.75, 10);
cylinder(scene, 0.145, 0.145, 0.055, mats.darkMetal, x, shelfY + 0.41, 3.75, 10);
}
}
// ---------------------------------------------------------------------
// Market goods
// ---------------------------------------------------------------------
function fruitTray(x, z, fruitMaterial, leafMaterial) {
box(scene, 1.28, 0.11, 0.78, mats.woodDark, x, 1.56, z);
box(scene, 1.34, 0.09, 0.09, mats.woodLight, x, 1.64, z - 0.38);
for (let ix = 0; ix < 4; ix++) {
for (let iz = 0; iz < 2; iz++) {
const fruit = sphere(
scene,
0.125,
fruitMaterial,
x - 0.42 + ix * 0.28,
1.73 + range(-0.02, 0.03),
z - 0.17 + iz * 0.32
);
fruit.scale.y = 0.9;
if (random() > 0.55) {
const leaf = sphere(
scene,
0.055,
leafMaterial,
fruit.position.x,
1.86,
fruit.position.z,
8
);
leaf.scale.set(1.5, 0.2, 0.65);
leaf.rotation.z = range(-0.5, 0.5);
}
}
}
}
fruitTray(-8.45, 0.58, mats.red, mats.green);
fruitTray(-6.45, 0.58, mats.orange, mats.green);
// Bakery goods.
box(scene, 3.8, 0.08, 0.83, mats.woodLight, -2.5, 1.56, 0.62);
for (let i = 0; i < 6; i++) {
const bread = sphere(
scene,
0.23,
i % 2 ? mats.yellow : mats.woodLight,
-4.0 + i * 0.6,
1.76,
0.62
);
bread.scale.set(1.45, 0.62, 0.9);
const score = box(
scene,
0.025,
0.025,
0.29,
mats.woodDark,
bread.position.x - 0.07,
1.9,
0.62,
false
);
score.rotation.y = -0.5;
}
// Spice jars.
for (let i = 0; i < 8; i++) {
const x = 0.65 + i * 0.53;
const jarMat = [mats.red, mats.yellow, mats.orange, mats.purple][i % 4];
cylinder(scene, 0.16, 0.17, 0.42, jarMat, x, 1.73, 0.59, 12);
cylinder(scene, 0.175, 0.175, 0.06, mats.woodDark, x, 1.97, 0.59, 12);
}
// Flower pots.
for (let i = 0; i < 3; i++) {
const x = 6.3 + i * 1.2;
cylinder(scene, 0.24, 0.18, 0.38, mats.ceramic, x, 1.7, 0.62, 12);
cylinder(scene, 0.19, 0.19, 0.03, mats.woodDark, x, 1.9, 0.62, 12);
for (let f = 0; f < 5; f++) {
const fx = x + range(-0.22, 0.22);
const fz = 0.62 + range(-0.18, 0.18);
const fy = range(2.03, 2.32);
cylinder(scene, 0.015, 0.018, fy - 1.9, mats.green, fx, (fy + 1.9) / 2, fz, 6);
sphere(scene, 0.09, f % 2 ? mats.yellow : mats.purple, fx, fy, fz, 10);
}
}
// ---------------------------------------------------------------------
// String lights
// ---------------------------------------------------------------------
const lightCurve = new THREE.CatmullRomCurve3(
Array.from({ length: 9 }, (_, i) => {
const t = i / 8;
return new THREE.Vector3(
-10 + t * 20,
3.18 - Math.sin(t * Math.PI) * 0.34,
0.54
);
})
);
const wire = new THREE.Mesh(
new THREE.TubeGeometry(lightCurve, 80, 0.014, 6, false),
mats.black
);
scene.add(wire);
for (let i = 0; i < 16; i++) {
const p = lightCurve.getPointAt((i + 0.5) / 16);
sphere(scene, 0.065, bulbMaterial, p.x, p.y - 0.1, p.z, 10);
}
for (const x of [-7.5, -2.5, 2.5, 7.5]) {
const light = new THREE.PointLight(0xffb768, 22, 7, 2);
light.position.set(x, 2.8, 0.35);
scene.add(light);
}
// ---------------------------------------------------------------------
// Drainage system: roof runoff, shared gutter, downpipes, street channel
// ---------------------------------------------------------------------
// Moving water glints on the sloped canopy.
const roofRunoff = [];
for (let i = 0; i < 16; i++) {
const streak = new THREE.Mesh(
new THREE.BoxGeometry(0.027, 0.016, 0.34),
waterMaterial
);
streak.position.set(range(-9.6, 9.6), 0.083, range(-2.25, 2.25));
streak.userData.speed = range(0.8, 1.5);
roofGroup.add(streak);
roofRunoff.push(streak);
}
// Water traveling along the shared gutter.
const gutterFlow = [];
for (let i = 0; i < 22; i++) {
const glint = new THREE.Mesh(
new THREE.BoxGeometry(0.22, 0.018, 0.07),
waterMaterial
);
glint.position.set(range(-10.2, 10.2), 3.552, -0.49);
glint.userData.offset = range(0, 20.8);
scene.add(glint);
gutterFlow.push(glint);
}
const pipeCurves = [];
const pipeDrops = [];
for (const x of [-7.5, 0, 7.5]) {
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(x, 3.43, -0.49),
new THREE.Vector3(x, 1.45, -0.49),
new THREE.Vector3(x, 0.78, -0.57),
new THREE.Vector3(x, 0.5, -1.02),
new THREE.Vector3(x, 0.35, -1.43)
]);
pipeCurves.push(curve);
const pipe = new THREE.Mesh(
new THREE.TubeGeometry(curve, 48, 0.095, 10, false),
mats.gutter
);
pipe.castShadow = true;
pipe.receiveShadow = true;
scene.add(pipe);
// A bright inner line makes water movement inside the pipe visible.
const visibleCurve = new THREE.CatmullRomCurve3(
curve.points.map((p) => new THREE.Vector3(p.x + 0.02, p.y, p.z - 0.105))
);
const waterLine = new THREE.Mesh(
new THREE.TubeGeometry(visibleCurve, 48, 0.022, 7, false),
waterMaterial
);
scene.add(waterLine);
for (let i = 0; i < 6; i++) {
const bead = sphere(scene, 0.043, waterMaterial, x, 3, -0.6, 8);
bead.castShadow = false;
pipeDrops.push({
mesh: bead,
curve: visibleCurve,
offset: i / 6,
speed: range(0.16, 0.23)
});
}
// Visible outlet stream entering the street drain.
const outletCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(x, 0.36, -1.42),
new THREE.Vector3(x, 0.23, -1.49),
new THREE.Vector3(x, 0.08, -1.5)
]);
const outlet = new THREE.Mesh(
new THREE.TubeGeometry(outletCurve, 18, 0.034, 7, false),
waterMaterial
);
scene.add(outlet);
}
// Continuous recessed drain channel.
box(scene, 21.6, 0.045, 0.38, mats.black, 0, 0.035, -1.5, false);
for (let x = -10.5; x <= 10.5; x += 0.42) {
box(scene, 0.035, 0.035, 0.34, mats.darkMetal, x, 0.069, -1.5, false);
}
// ---------------------------------------------------------------------
// Wet street puddles and reflected light streaks
// ---------------------------------------------------------------------
const puddleMaterial = standard(0x8ab0ba, 0.12, 0.38, {
transparent: true,
opacity: 0.28,
depthWrite: false
});
for (let i = 0; i < 18; i++) {
const puddle = new THREE.Mesh(new THREE.CircleGeometry(1, 32), puddleMaterial);
puddle.rotation.x = -Math.PI / 2;
puddle.position.set(range(-15, 15), 0.012, range(-11.5, -0.8));
puddle.scale.set(range(0.45, 1.5), range(0.2, 0.55), 1);
puddle.renderOrder = 1;
scene.add(puddle);
}
// ---------------------------------------------------------------------
// Street lamps
// ---------------------------------------------------------------------
for (const x of [-11.6, 11.6]) {
cylinder(scene, 0.075, 0.11, 4.3, mats.darkMetal, x, 2.15, -1.7);
box(scene, 0.46, 0.58, 0.46, mats.darkMetal, x, 4.2, -1.7);
box(scene, 0.32, 0.4, 0.32, bulbMaterial, x, 4.2, -1.83);
const lamp = new THREE.PointLight(0xffbd70, 28, 8, 2);
lamp.position.set(x, 4.1, -1.9);
scene.add(lamp);
}
// ---------------------------------------------------------------------
// Stylized shoppers with umbrellas
// ---------------------------------------------------------------------
function createPerson(x, z, umbrellaColor, coatColor) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
const coat = standard(coatColor, 0.82);
const skin = standard(0xc99572, 0.9);
cylinder(group, 0.11, 0.09, 0.72, mats.black, -0.13, 0.43, 0, 8);
cylinder(group, 0.11, 0.09, 0.72, mats.black, 0.13, 0.43, 0, 8);
cylinder(group, 0.23, 0.31, 0.72, coat, 0, 1.11, 0, 10);
sphere(group, 0.2, skin, 0, 1.7, 0, 12);
cylinder(group, 0.22, 0.24, 0.09, mats.darkMetal, 0, 1.87, 0, 12);
const arm = cylinder(group, 0.065, 0.07, 0.62, coat, 0.24, 1.22, 0, 8);
arm.rotation.z = -0.18;
const umbrella = new THREE.Group();
umbrella.position.set(0.13, 2.35, 0);
group.add(umbrella);
const umbrellaMaterial = standard(umbrellaColor, 0.48, 0.05, {
side: THREE.DoubleSide
});
const canopy = new THREE.Mesh(
new THREE.SphereGeometry(
0.95,
20,
10,
0,
Math.PI * 2,
0,
Math.PI / 2
),
umbrellaMaterial
);
canopy.scale.y = 0.35;
canopy.castShadow = true;
umbrella.add(canopy);
cylinder(umbrella, 0.018, 0.018, 1.15, mats.darkMetal, 0, -0.48, 0, 8);
const rim = torus(umbrella, 0.95, 0.025, mats.darkMetal, 0, 0, 0);
rim.rotation.x = Math.PI / 2;
for (let i = 0; i < 8; i++) {
const a = (i / 8) * Math.PI * 2;
const points = [
new THREE.Vector3(0, 0.33, 0),
new THREE.Vector3(Math.cos(a) * 0.95, 0, Math.sin(a) * 0.95)
];
const rib = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({ color: 0x203238 })
);
umbrella.add(rib);
}
}
createPerson(-4.3, -3.4, 0xd96b56, 0x315e72);
createPerson(4.6, -4.7, 0x477f87, 0xa06b45);
// ---------------------------------------------------------------------
// Rain streaks
// ---------------------------------------------------------------------
const rainCount = 1000;
const rainPositions = new Float32Array(rainCount * 6);
const rainData = [];
for (let i = 0; i < rainCount; i++) {
rainData.push({
x: range(-22, 22),
y: range(0, 16),
z: range(-20, 9),
speed: range(8.5, 14)
});
}
const rainGeometry = new THREE.BufferGeometry();
rainGeometry.setAttribute(
"position",
new THREE.BufferAttribute(rainPositions, 3)
);
const rain = new THREE.LineSegments(
rainGeometry,
new THREE.LineBasicMaterial({
color: 0xc4e9f1,
transparent: true,
opacity: 0.42,
depthWrite: false
})
);
rain.frustumCulled = false;
scene.add(rain);
// ---------------------------------------------------------------------
// Rain splash rings
// ---------------------------------------------------------------------
const splashes = [];
const splashGeometry = new THREE.RingGeometry(0.055, 0.072, 18);
for (let i = 0; i < 42; i++) {
const material = new THREE.MeshBasicMaterial({
color: 0xb9e7ea,
transparent: true,
opacity: 0.5,
side: THREE.DoubleSide,
depthWrite: false
});
const mesh = new THREE.Mesh(splashGeometry, material);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(range(-16, 16), 0.025, range(-12, -0.75));
mesh.userData.life = random();
scene.add(mesh);
splashes.push(mesh);
}
// ---------------------------------------------------------------------
// Custom camera controls — no addons
// ---------------------------------------------------------------------
const target = new THREE.Vector3(0, 2.0, 1.25);
const spherical = new THREE.Spherical(19.5, 1.05, 2.56);
const desiredSpherical = spherical.clone();
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
function updateCamera() {
spherical.radius += (desiredSpherical.radius - spherical.radius) * 0.08;
spherical.theta += (desiredSpherical.theta - spherical.theta) * 0.08;
spherical.phi += (desiredSpherical.phi - spherical.phi) * 0.08;
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
desiredSpherical.theta -= dx * 0.006;
desiredSpherical.phi = THREE.MathUtils.clamp(
desiredSpherical.phi - dy * 0.005,
0.38,
1.34
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
});
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("contextmenu", (e) => e.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredSpherical.radius = THREE.MathUtils.clamp(
desiredSpherical.radius + event.deltaY * 0.012,
10,
30
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
desiredSpherical.set(19.5, 1.05, 2.56);
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
// Rain movement.
for (let i = 0; i < rainCount; i++) {
const drop = rainData[i];
drop.y -= drop.speed * dt;
drop.x += dt * 0.35;
// Rain is removed from beneath the connected roof, keeping the
// sheltered counters and floor visibly dry.
const beneathShelter =
drop.x > -10.85 &&
drop.x < 10.85 &&
drop.z > -0.58 &&
drop.z < 4.72;
if (drop.y < 0.02 || (beneathShelter && drop.y < 4.55)) {
drop.x = range(-22, 22);
drop.y = range(12, 17);
drop.z = range(-20, 9);
}
const p = i * 6;
rainPositions[p] = drop.x;
rainPositions[p + 1] = drop.y;
rainPositions[p + 2] = drop.z;
rainPositions[p + 3] = drop.x + 0.08;
rainPositions[p + 4] = drop.y + 0.52;
rainPositions[p + 5] = drop.z + 0.025;
}
rainGeometry.attributes.position.needsUpdate = true;
// Water flowing down the canopy.
for (const streak of roofRunoff) {
streak.position.z -= streak.userData.speed * dt;
if (streak.position.z < -2.32) {
streak.position.z = 2.25;
streak.position.x = range(-9.6, 9.6);
}
}
// Water moving through the shared gutter.
for (const glint of gutterFlow) {
glint.position.x = ((glint.userData.offset + elapsed * 1.9) % 20.8) - 10.4;
}
// Water droplets traveling down each visible downpipe.
for (const drop of pipeDrops) {
const t = (drop.offset + elapsed * drop.speed) % 1;
const p = drop.curve.getPointAt(t);
drop.mesh.position.copy(p);
}
// Expanding street splash rings.
for (const splash of splashes) {
splash.userData.life += dt * 1.7;
if (splash.userData.life >= 1) {
splash.userData.life = 0;
splash.position.set(range(-16, 16), 0.025, range(-12, -0.75));
}
const life = splash.userData.life;
const scale = 0.4 + life * 3.5;
splash.scale.setScalar(scale);
splash.material.opacity = (1 - life) * 0.48;
}
updateCamera();
renderer.render(scene, camera);
}
updateCamera();
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```