Prompt specification
Build or customize the Three.js 3D scene "Fisher and pedestrians along Havana's waterfront" 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: Fisher and pedestrians along Havana's waterfront
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/fisher-and-pedestrians-along-havana-s-waterfront-x2742
Scene Description Prompt:
Fisher and pedestrians along Havana's waterfront. Create a compact Malecón vignette with one fisher, walking pair, and referenced facade backdrop. Keep activities spaced along the promenade without obstructing the through-route. Please build this with Three.js from cdnjs in one self-contained HTML file, using low-poly forms.
Working Three.js Starter (fisher-and-pedestrians-along-havana-s-waterfront-x2742):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Malecón — Havana Waterfront Vignette</title>
<style>
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #9ccbd3;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.title {
position: fixed;
top: 24px;
left: 26px;
z-index: 2;
color: #173f43;
pointer-events: none;
text-shadow: 0 1px 12px rgba(255, 255, 255, .35);
}
.title .eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 7px;
font-size: 10px;
font-weight: 750;
letter-spacing: .24em;
text-transform: uppercase;
}
.title .eyebrow::before {
content: "";
width: 26px;
height: 2px;
background: currentColor;
}
.title h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 5vw, 58px);
font-weight: 500;
line-height: .95;
letter-spacing: -.035em;
}
.title p {
margin: 9px 0 0;
max-width: 270px;
font-size: 11px;
line-height: 1.5;
letter-spacing: .08em;
text-transform: uppercase;
opacity: .78;
}
.hint {
position: fixed;
right: 22px;
bottom: 20px;
z-index: 2;
padding: 9px 13px;
border: 1px solid rgba(23, 63, 67, .18);
border-radius: 999px;
color: #173f43;
background: rgba(241, 235, 214, .68);
backdrop-filter: blur(8px);
font-size: 10px;
font-weight: 700;
letter-spacing: .12em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 650px) {
.title { top: 18px; left: 18px; }
.title p { display: none; }
.hint { right: 12px; bottom: 12px; }
}
</style>
</head>
<body>
<div class="title">
<div class="eyebrow">Havana, Cuba</div>
<h1>Malecón</h1>
<p>A small waterfront vignette of fishing, strolling, and pastel facades.</p>
</div>
<div class="hint">Drag to orbit · Scroll to zoom</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 scene = new THREE.Scene();
scene.background = new THREE.Color(0x9dcdd5);
scene.fog = new THREE.Fog(0xaed5d7, 25, 58);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xdaf4f1, 0x8c755b, 2.1);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0c8, 3.0);
sun.position.set(-12, 18, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -23;
sun.shadow.camera.right = 23;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8fd3e1, 0.75);
fill.position.set(12, 7, -10);
scene.add(fill);
// Deterministic randomness keeps the vignette stable between reloads.
let seed = 1962;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...options
});
}
const M = {
promenade: material(0xcbbd99),
route: material(0xdfd2b7),
seawall: material(0x8e9487),
stoneA: material(0xa8aa99),
stoneB: material(0x979b8d),
stoneC: material(0xb0ae9b),
coping: material(0xc5c1a8),
iron: material(0x304c48, { roughness: 0.65 }),
darkWindow: material(0x244a52, { roughness: 0.38 }),
cream: material(0xf1dfb6),
white: material(0xf3ead1),
wood: material(0x806044),
trunk: material(0x8d7049),
leaf: material(0x416e49, { side: THREE.DoubleSide }),
leafLight: material(0x5c8450, { side: THREE.DoubleSide }),
lamp: material(0xf5d789, {
emissive: 0x9b6c25,
emissiveIntensity: 0.55
})
};
function mesh(geometry, mat, parent = scene) {
const object = new THREE.Mesh(geometry, mat);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(w, h, d, mat, x, y, z, parent = scene) {
const object = mesh(new THREE.BoxGeometry(w, h, d), mat, parent);
object.position.set(x, y, z);
return object;
}
function cylinderBetween(a, b, radius, mat, parent = scene, sides = 6) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const object = mesh(
new THREE.CylinderGeometry(radius, radius, length, sides),
mat,
parent
);
object.position.copy(a).add(b).multiplyScalar(0.5);
object.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return object;
}
function lowPolySphere(radius, color, x, y, z, parent = scene) {
const object = mesh(
new THREE.SphereGeometry(radius, 7, 5),
material(color),
parent
);
object.position.set(x, y, z);
return object;
}
// ------------------------------------------------------------
// Promenade and visibly unobstructed through-route
// ------------------------------------------------------------
box(32, 0.52, 9, M.promenade, 0, -0.16, 0);
box(31.7, 0.035, 2.25, M.route, 0, 0.12, 0.95);
// Fine paving seams reinforce the direction of the promenade.
for (let x = -15; x <= 15; x += 3) {
box(0.025, 0.012, 8.6, M.stoneC, x, 0.13, 0);
}
// Sidewalk in front of the facades.
box(32, 0.32, 2.2, M.coping, 0, 0.03, -5.25);
// Sea wall and individual low-poly stone courses.
box(31.8, 1.05, 0.62, M.seawall, 0, 0.08, 4.62);
box(32.1, 0.18, 0.82, M.coping, 0, 0.63, 4.55);
for (let row = 0; row < 2; row++) {
for (let i = 0; i < 26; i++) {
const mat = [M.stoneA, M.stoneB, M.stoneC][
Math.floor(random() * 3)
];
box(
1.14,
0.39,
0.12,
mat,
-15.55 + i * 1.22,
0.29 - row * 0.46,
4.95
);
}
}
// ------------------------------------------------------------
// Faceted ocean
// ------------------------------------------------------------
const waterPositions = [];
const waterColors = [];
const waterBaseY = [];
const waterColor = new THREE.Color();
function addWaterTriangle(a, b, c) {
const shade = 0.36 + random() * 0.09;
waterColor.setHSL(0.505 + random() * 0.025, 0.43, shade);
for (const p of [a, b, c]) {
waterPositions.push(p[0], p[1], p[2]);
waterBaseY.push(p[1]);
waterColors.push(waterColor.r, waterColor.g, waterColor.b);
}
}
const x0 = -30;
const x1 = 30;
const z0 = 5.0;
const z1 = 35;
const cols = 24;
const rows = 14;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
const xa = x0 + (x1 - x0) * col / cols;
const xb = x0 + (x1 - x0) * (col + 1) / cols;
const za = z0 + (z1 - z0) * row / rows;
const zb = z0 + (z1 - z0) * (row + 1) / rows;
const ya = -0.55 + random() * 0.045;
const yb = -0.55 + random() * 0.045;
const yc = -0.55 + random() * 0.045;
const yd = -0.55 + random() * 0.045;
addWaterTriangle([xa, ya, za], [xa, yb, zb], [xb, yc, zb]);
addWaterTriangle([xa, ya, za], [xb, yc, zb], [xb, yd, za]);
}
}
const waterGeometry = new THREE.BufferGeometry();
waterGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(waterPositions, 3)
);
waterGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(waterColors, 3)
);
waterGeometry.computeVertexNormals();
const water = mesh(
waterGeometry,
material(0xffffff, {
vertexColors: true,
roughness: 0.64,
metalness: 0.08
})
);
water.castShadow = false;
// Thin foam accents close to the wall.
const foam = [];
for (let i = 0; i < 15; i++) {
const piece = mesh(
new THREE.PlaneGeometry(0.55 + random() * 1.0, 0.055),
new THREE.MeshBasicMaterial({
color: 0xd5eee5,
transparent: true,
opacity: 0.62,
side: THREE.DoubleSide
})
);
piece.rotation.x = -Math.PI / 2;
piece.castShadow = false;
piece.receiveShadow = false;
foam.push({
mesh: piece,
x: -14 + random() * 28,
z: 5.35 + random() * 8,
speed: 0.12 + random() * 0.18
});
}
// ------------------------------------------------------------
// Pastel Havana-style facade backdrop
// ------------------------------------------------------------
function addWindow(parent, x, y, z, frameMat = M.white) {
box(0.88, 1.12, 0.13, frameMat, x, y, z, parent);
box(0.63, 0.84, 0.065, M.darkWindow, x, y, z + 0.09, parent);
box(0.06, 0.86, 0.08, frameMat, x, y, z + 0.13, parent);
}
function addBalcony(parent, x, y, z, width) {
box(width, 0.16, 0.68, M.white, x, y, z + 0.18, parent);
const barCount = Math.max(5, Math.floor(width / 0.32));
for (let i = 0; i <= barCount; i++) {
const bx = x - width / 2 + width * i / barCount;
box(0.035, 0.72, 0.035, M.iron, bx, y + 0.4, z + 0.47, parent);
}
box(width + 0.08, 0.055, 0.055, M.iron, x, y + 0.77, z + 0.47, parent);
}
function simpleFacade(x, width, height, color, accent, balcony = false) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
const wall = material(color);
const trim = material(accent);
const frontZ = -5.34;
box(width, height, 3.7, wall, 0, height / 2 + 0.12, -7.2, group);
box(width + 0.12, 0.22, 3.9, M.cream, 0, 0.22, -7.2, group);
box(width + 0.22, 0.28, 3.98, trim, 0, height + 0.10, -7.2, group);
box(width - 0.25, 0.48, 3.74, wall, 0, height + 0.43, -7.2, group);
const columns = Math.max(2, Math.floor(width / 1.25));
const floors = Math.max(1, Math.floor((height - 1.7) / 1.65));
for (let floor = 0; floor < floors; floor++) {
const y = 1.75 + floor * 1.65;
for (let col = 0; col < columns; col++) {
const wx = -width / 2 + width * (col + 0.5) / columns;
addWindow(group, wx, y, frontZ, trim);
if (balcony && floor === 1 && col % 2 === 0) {
addBalcony(group, wx, y - 0.72, frontZ, 1.0);
}
}
}
// A small projecting roof cornice catches the warm light.
box(width + 0.36, 0.14, 4.1, M.cream, 0, height + 0.67, -7.2, group);
return group;
}
simpleFacade(-10.8, 5.2, 6.7, 0xd98572, 0xf2d4ae, true);
simpleFacade(-5.35, 5.35, 7.7, 0xd9ae62, 0xf3dfb8, false);
simpleFacade(6.35, 4.65, 6.35, 0x79aaa0, 0xe5d7b3, true);
simpleFacade(11.0, 4.5, 7.05, 0xce8e84, 0xf0d8b0, false);
// Central colonnaded facade.
const central = new THREE.Group();
central.position.x = 0.35;
scene.add(central);
const centralWall = material(0xe6c98c);
const centralTrim = material(0xf5e5bc);
const frontZ = -5.34;
box(7.0, 8.15, 3.75, centralWall, 0, 4.2, -7.2, central);
box(7.2, 0.25, 3.95, M.cream, 0, 0.25, -7.2, central);
box(7.25, 0.34, 4.0, M.white, 0, 8.25, -7.2, central);
box(7.45, 0.16, 4.15, M.cream, 0, 8.48, -7.2, central);
function archShape(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();
return shape;
}
for (const ax of [-2.55, -0.85, 0.85, 2.55]) {
const arch = mesh(
new THREE.ShapeGeometry(archShape(1.2, 2.55)),
M.darkWindow,
central
);
arch.position.set(ax, 0.36, frontZ + 0.035);
}
for (const cx of [-3.22, -1.7, 0, 1.7, 3.22]) {
const column = mesh(
new THREE.CylinderGeometry(0.13, 0.16, 3.0, 8),
M.white,
central
);
column.position.set(cx, 1.73, frontZ + 0.25);
}
addBalcony(central, 0, 3.05, frontZ + 0.08, 6.45);
for (let i = 0; i < 5; i++) {
addWindow(central, -2.45 + i * 1.225, 4.55, frontZ, M.white);
addWindow(central, -2.45 + i * 1.225, 6.45, frontZ, M.white);
}
// Faceted pediment above the central facade.
const pedimentGeometry = new THREE.BufferGeometry();
pedimentGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-3.55, 0, 0,
3.55, 0, 0,
0, 1.25, 0
], 3)
);
pedimentGeometry.computeVertexNormals();
const pediment = mesh(pedimentGeometry, M.white, central);
pediment.position.set(0, 8.55, -5.32);
// ------------------------------------------------------------
// Palms, street lamps, and benches along the rear edge
// ------------------------------------------------------------
function createPalm(x, z, height, leanDirection = 1) {
const group = new THREE.Group();
group.position.set(x, 0.13, z);
scene.add(group);
const points = [
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(leanDirection * 0.13, height * 0.36, 0.04),
new THREE.Vector3(leanDirection * 0.35, height * 0.72, 0.12),
new THREE.Vector3(leanDirection * 0.62, height, 0.18)
];
for (let i = 0; i < points.length - 1; i++) {
cylinderBetween(
points[i],
points[i + 1],
0.17 - i * 0.025,
M.trunk,
group,
6
);
}
const crown = points[points.length - 1];
for (let i = 0; i < 7; i++) {
const angle = (i / 7) * Math.PI * 2 + 0.18;
const length = 2.0 + random() * 0.55;
const dx = Math.cos(angle);
const dz = Math.sin(angle);
const px = -dz;
const pz = dx;
const midX = dx * length * 0.58;
const midZ = dz * length * 0.58;
const width = 0.26;
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
0, 0, 0,
midX + px * width, -0.06, midZ + pz * width,
dx * length, -0.66, dz * length,
midX - px * width, -0.06, midZ - pz * width
], 3)
);
geometry.setIndex([0, 1, 2, 0, 2, 3]);
geometry.computeVertexNormals();
const frond = mesh(
geometry,
i % 2 ? M.leaf : M.leafLight,
group
);
frond.position.copy(crown);
}
lowPolySphere(0.23, 0x72563b, crown.x, crown.y, crown.z, group);
}
createPalm(-13.4, -4.35, 4.9, 1);
createPalm(-7.1, -4.5, 5.3, -1);
createPalm(2.0, -4.55, 4.8, 1);
createPalm(8.7, -4.45, 5.15, -1);
createPalm(14.0, -4.6, 4.75, 1);
function createLamp(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.14, z);
scene.add(group);
box(0.38, 0.12, 0.38, M.iron, 0, 0.06, 0, group);
const pole = mesh(
new THREE.CylinderGeometry(0.055, 0.08, 3.35, 6),
M.iron,
group
);
pole.position.y = 1.7;
box(0.43, 0.55, 0.43, M.lamp, 0, 3.48, 0, group);
box(0.58, 0.10, 0.58, M.iron, 0, 3.82, 0, group);
box(0.58, 0.10, 0.58, M.iron, 0, 3.12, 0, group);
for (const dx of [-0.19, 0.19]) {
for (const dz of [-0.19, 0.19]) {
box(0.035, 0.55, 0.035, M.iron, dx, 3.48, dz, group);
}
}
}
createLamp(-9.0, -3.9);
createLamp(-1.8, -3.95);
createLamp(7.7, -3.9);
createLamp(13.1, -3.85);
function createBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.14, z);
group.rotation.y = rotation;
scene.add(group);
for (let i = 0; i < 3; i++) {
box(2.0, 0.10, 0.16, M.wood, 0, 0.55, -0.24 + i * 0.22, group);
}
for (let i = 0; i < 2; i++) {
box(2.0, 0.13, 0.09, M.wood, 0, 0.88 + i * 0.25, -0.38, group);
}
for (const dx of [-0.75, 0.75]) {
box(0.10, 0.6, 0.10, M.iron, dx, 0.28, 0, group);
box(0.08, 1.0, 0.08, M.iron, dx, 0.65, -0.37, group);
}
}
createBench(-11.8, -3.05, Math.PI / 2);
createBench(10.1, -2.95, -Math.PI / 2);
// ------------------------------------------------------------
// One fisherman, set apart on the seawall side
// ------------------------------------------------------------
const fisher = new THREE.Group();
fisher.position.set(-5.15, 0.13, 3.28);
fisher.rotation.y = -0.10;
scene.add(fisher);
const stool = new THREE.Group();
fisher.add(stool);
box(0.78, 0.12, 0.70, M.wood, 0, 0.57, 0, stool);
for (const dx of [-0.28, 0.28]) {
for (const dz of [-0.23, 0.23]) {
cylinderBetween(
new THREE.Vector3(dx, 0, dz),
new THREE.Vector3(dx * 0.8, 0.55, dz * 0.8),
0.045,
M.wood,
stool
);
}
}
const fisherShirt = material(0xcf5847);
const fisherPants = material(0x36555b);
const skin = material(0xb97954);
box(0.66, 0.76, 0.40, fisherShirt, 0, 1.17, 0, fisher);
lowPolySphere(0.235, 0xc4875f, 0, 1.78, 0.015, fisher);
cylinderBetween(
new THREE.Vector3(0, 1.52, 0),
new THREE.Vector3(0, 1.68, 0),
0.09,
skin,
fisher
);
// Broad straw hat.
const hatBrim = mesh(
new THREE.CylinderGeometry(0.43, 0.43, 0.055, 10),
material(0xd8b96f),
fisher
);
hatBrim.position.set(0, 2.02, 0.015);
const hatCrown = mesh(
new THREE.CylinderGeometry(0.23, 0.29, 0.22, 8),
material(0xd8b96f),
fisher
);
hatCrown.position.set(0, 2.12, 0.015);
// Seated legs.
for (const side of [-0.18, 0.18]) {
cylinderBetween(
new THREE.Vector3(side, 0.83, 0.02),
new THREE.Vector3(side, 0.66, 0.48),
0.12,
fisherPants,
fisher
);
cylinderBetween(
new THREE.Vector3(side, 0.66, 0.48),
new THREE.Vector3(side, 0.13, 0.52),
0.10,
fisherPants,
fisher
);
box(0.24, 0.13, 0.38, M.iron, side, 0.08, 0.59, fisher);
}
// Arms reach toward the rod.
cylinderBetween(
new THREE.Vector3(-0.36, 1.43, 0),
new THREE.Vector3(-0.43, 1.15, 0.28),
0.10,
fisherShirt,
fisher
);
cylinderBetween(
new THREE.Vector3(-0.43, 1.15, 0.28),
new THREE.Vector3(-0.12, 1.04, 0.58),
0.075,
skin,
fisher
);
cylinderBetween(
new THREE.Vector3(0.36, 1.43, 0),
new THREE.Vector3(0.40, 1.19, 0.25),
0.10,
fisherShirt,
fisher
);
cylinderBetween(
new THREE.Vector3(0.40, 1.19, 0.25),
new THREE.Vector3(0.18, 1.05, 0.53),
0.075,
skin,
fisher
);
const rodStart = new THREE.Vector3(0.18, 1.05, 0.53);
const rodTip = new THREE.Vector3(0.45, 0.24, 3.05);
cylinderBetween(rodStart, rodTip, 0.025, M.wood, fisher);
const fishingLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
rodTip,
new THREE.Vector3(0.45, -0.62, 4.15)
]),
new THREE.LineBasicMaterial({
color: 0xf4ead0,
transparent: true,
opacity: 0.8
})
);
fisher.add(fishingLine);
// Small bucket and bait tin.
const bucket = mesh(
new THREE.CylinderGeometry(0.24, 0.19, 0.40, 8),
material(0x527f84),
fisher
);
bucket.position.set(0.92, 0.22, 0.08);
const bucketRim = mesh(
new THREE.TorusGeometry(0.24, 0.025, 4, 10),
M.iron,
fisher
);
bucketRim.rotation.x = Math.PI / 2;
bucketRim.position.set(0.92, 0.42, 0.08);
// ------------------------------------------------------------
// One walking pair, kept on the landward side of the route
// ------------------------------------------------------------
function createWalker({ top, bottom, skinColor, hairColor, dress = false }) {
const group = new THREE.Group();
const skinMat = material(skinColor);
const hairMat = material(hairColor);
if (dress) {
const skirt = mesh(
new THREE.CylinderGeometry(0.27, 0.43, 0.90, 7),
material(top),
group
);
skirt.position.y = 1.18;
} else {
box(0.60, 0.72, 0.34, material(top), 0, 1.27, 0, group);
}
cylinderBetween(
new THREE.Vector3(0, 1.58, 0),
new THREE.Vector3(0, 1.76, 0),
0.09,
skinMat,
group
);
lowPolySphere(0.235, skinColor, 0, 1.96, 0.015, group);
const hair = lowPolySphere(0.245, hairColor, 0, 2.07, -0.01, group);
hair.scale.set(1, 0.62, 1);
const legL = new THREE.Group();
const legR = new THREE.Group();
legL.position.set(-0.17, 0.88, 0);
legR.position.set(0.17, 0.88, 0);
group.add(legL, legR);
const pantsMat = material(bottom);
for (const leg of [legL, legR]) {
const upper = mesh(
new THREE.CylinderGeometry(0.105, 0.095, 0.70, 6),
pantsMat,
leg
);
upper.position.y = -0.35;
const lower = new THREE.Group();
lower.position.y = -0.68;
leg.add(lower);
const shin = mesh(
new THREE.CylinderGeometry(0.085, 0.07, 0.63, 6),
pantsMat,
lower
);
shin.position.y = -0.30;
box(0.20, 0.13, 0.35, M.iron, 0, -0.65, 0.10, lower);
}
const armL = new THREE.Group();
const armR = new THREE.Group();
armL.position.set(-0.39, 1.52, 0);
armR.position.set(0.39, 1.52, 0);
group.add(armL, armR);
for (const arm of [armL, armR]) {
const upper = mesh(
new THREE.CylinderGeometry(0.075, 0.065, 0.52, 6),
material(top),
arm
);
upper.position.y = -0.26;
const hand = lowPolySphere(0.075, skinColor, 0, -0.55, 0, arm);
hand.castShadow = true;
}
return { group, legL, legR, armL, armR };
}
const walkingPair = new THREE.Group();
walkingPair.rotation.y = Math.PI / 2;
walkingPair.position.set(4.15, 0.14, -2.48);
scene.add(walkingPair);
const walkerA = createWalker({
top: 0xe5a94c,
bottom: 0x44636b,
skinColor: 0xb87954,
hairColor: 0x3c2d26,
dress: true
});
walkerA.group.position.x = -0.46;
walkingPair.add(walkerA.group);
const walkerB = createWalker({
top: 0x5e91a0,
bottom: 0xe1d4b7,
skinColor: 0xc78d67,
hairColor: 0x302b27
});
walkerB.group.position.x = 0.46;
walkingPair.add(walkerB.group);
// ------------------------------------------------------------
// Sparse sky details
// ------------------------------------------------------------
const birds = [];
for (let i = 0; i < 5; i++) {
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-0.32, 0, 0),
new THREE.Vector3(0, -0.10, 0),
new THREE.Vector3(0.32, 0, 0)
]);
const bird = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({ color: 0x385b5e })
);
bird.position.set(-9 + i * 4.2, 9 + random() * 2.3, -4 + random() * 5);
scene.add(bird);
birds.push({ object: bird, phase: random() * Math.PI * 2 });
}
// ------------------------------------------------------------
// Direct camera controls — no external controls module
// ------------------------------------------------------------
const target = new THREE.Vector3(0, 1.45, -0.45);
let theta = 0.57;
let phi = 1.12;
let radius = 18.7;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
function updateCamera() {
const horizontal = Math.sin(phi) * radius;
camera.position.set(
target.x + horizontal * Math.sin(theta),
target.y + Math.cos(phi) * radius,
target.z + horizontal * Math.cos(theta)
);
camera.lookAt(target);
}
function resetCamera() {
theta = 0.57;
phi = 1.12;
radius = 18.7;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", event => {
if (event.button !== 0) return;
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;
theta = THREE.MathUtils.clamp(theta - dx * 0.005, -1.05, 1.05);
phi = THREE.MathUtils.clamp(phi - dy * 0.0045, 0.42, 1.34);
updateCamera();
});
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();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
10.5,
29
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
});
updateCamera();
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
const waterPositionAttribute = waterGeometry.getAttribute("position");
function animate() {
const elapsed = clock.getElapsedTime();
// Gentle, faceted water motion.
for (let i = 0; i < waterPositionAttribute.count; i++) {
const x = waterPositionAttribute.getX(i);
const z = waterPositionAttribute.getZ(i);
const wave =
Math.sin(elapsed * 0.85 + x * 0.46 + z * 0.21) * 0.035 +
Math.sin(elapsed * 0.42 - x * 0.17) * 0.018;
waterPositionAttribute.setY(i, waterBaseY[i] + wave);
}
waterPositionAttribute.needsUpdate = true;
waterGeometry.computeVertexNormals();
for (const piece of foam) {
piece.mesh.position.set(
piece.x,
-0.475,
5.3 + ((piece.z - 5.3 + elapsed * piece.speed) % 8.5)
);
}
// The pair strolls along the rear lane, leaving the central
// promenade route completely unobstructed.
const walkingPhase = elapsed * 4.8;
const stride = Math.sin(walkingPhase);
const oppositeStride = Math.sin(walkingPhase + Math.PI);
walkerA.legL.rotation.x = stride * 0.48;
walkerA.legR.rotation.x = oppositeStride * 0.48;
walkerA.armL.rotation.x = oppositeStride * 0.34;
walkerA.armR.rotation.x = stride * 0.34;
walkerB.legL.rotation.x = oppositeStride * 0.48;
walkerB.legR.rotation.x = stride * 0.48;
walkerB.armL.rotation.x = stride * 0.34;
walkerB.armR.rotation.x = oppositeStride * 0.34;
const bob = Math.abs(Math.sin(walkingPhase)) * 0.025;
walkerA.group.position.y = bob;
walkerB.group.position.y = bob * 0.9;
walkingPair.position.x = 4.15 + Math.sin(elapsed * 0.22) * 0.72;
for (const bird of birds) {
bird.object.position.y += Math.sin(elapsed * 0.8 + bird.phase) * 0.002;
bird.object.rotation.z = Math.sin(elapsed + bird.phase) * 0.06;
}
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```