Prompt specification
Build or customize the Three.js 3D scene "Fishing-gear repair beside an Accra lane" 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: Fishing-gear repair beside an Accra lane
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/fishing-gear-repair-beside-an-accra-lane-x2882
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: Fishing-gear repair beside an Accra lane. Create a compact referenced Jamestown vignette with nets being repaired, household frontage, and passing pedestrians. Show skilled work respectfully and keep the path through the scene clear. Return one self-contained HTML file.
Working Three.js Starter (fishing-gear-repair-beside-an-accra-lane-x2882):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Jamestown, Accra — Fishing-Gear Repair</title>
<style>
:root {
--ink: #23343a;
--paper: rgba(255, 250, 237, 0.94);
--accent: #b95735;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9d6dc;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.card {
position: fixed;
z-index: 10;
top: 22px;
left: 22px;
width: min(360px, calc(100vw - 44px));
padding: 18px 20px 17px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 16px;
background: var(--paper);
box-shadow: 0 14px 38px rgba(35, 52, 58, 0.17);
backdrop-filter: blur(10px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 30px);
line-height: 1.04;
letter-spacing: -0.035em;
}
.card p {
margin: 10px 0 0;
color: #526168;
font-size: 13px;
line-height: 1.48;
}
.controls {
position: fixed;
z-index: 10;
right: 20px;
bottom: 18px;
display: flex;
align-items: center;
gap: 10px;
padding: 8px 10px 8px 13px;
border: 1px solid rgba(255, 255, 255, 0.68);
border-radius: 999px;
background: rgba(255, 250, 237, 0.9);
color: #526168;
box-shadow: 0 8px 24px rgba(35, 52, 58, 0.13);
font-size: 12px;
backdrop-filter: blur(8px);
}
button {
border: 0;
border-radius: 999px;
padding: 8px 12px;
background: var(--ink);
color: #fffaf0;
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
}
button:hover { background: #354b53; }
button:focus-visible { outline: 3px solid #e08b60; outline-offset: 2px; }
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #b9d6dc;
color: #40545b;
font-size: 13px;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
@media (max-width: 600px) {
.card {
top: 12px;
left: 12px;
width: min(310px, calc(100vw - 24px));
padding: 14px 16px;
}
.card p { font-size: 12px; }
.controls { right: 10px; bottom: 10px; }
.controls .hint { display: none; }
}
</style>
</head>
<body>
<div id="loading">Preparing Jamestown vignette…</div>
<section class="card" aria-label="Scene title">
<div class="eyebrow">Jamestown · Accra</div>
<h1>Fishing-gear repair<br>beside the lane</h1>
<p>
An interpretive coastal-lane vignette: nets are mended with care while
household life continues around the Old Jamestown lighthouse.
</p>
</section>
<div class="controls">
<span class="hint">Drag to orbit · Scroll to zoom</span>
<button id="reset" type="button">Reset view</button>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9d6dc);
scene.fog = new THREE.Fog(0xb9d6dc, 25, 52);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive low-poly view of fishing-gear repair in Jamestown, Accra"
);
document.body.prepend(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 1.0, -1.4);
let radius = 24.5;
let theta = 0.48;
let phi = 0.43;
const defaultView = { radius, theta, phi };
function updateCamera() {
const horizontal = radius * Math.sin(phi);
camera.position.set(
target.x + horizontal * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + horizontal * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xffefd0, 0x6b5948, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffedc5, 3.25);
sun.position.set(-8, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 42;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9fcbd7, 0.7);
fill.position.set(10, 6, -10);
scene.add(fill);
let seed = 1937;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
const materialCache = new Map();
function material(color, roughness = 0.88, metalness = 0) {
const key = `${color}-${roughness}-${metalness}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: true
})
);
}
return materialCache.get(key);
}
function mesh(geometry, mat, x = 0, y = 0, z = 0, parent = scene) {
const object = new THREE.Mesh(geometry, mat);
object.position.set(x, y, z);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(w, h, d, color, x = 0, y = 0, z = 0, parent = scene) {
return mesh(
new THREE.BoxGeometry(w, h, d),
material(color),
x,
y,
z,
parent
);
}
function cylinder(
rTop,
rBottom,
h,
color,
x = 0,
y = 0,
z = 0,
parent = scene,
sides = 8
) {
return mesh(
new THREE.CylinderGeometry(rTop, rBottom, h, sides),
material(color),
x,
y,
z,
parent
);
}
function sphere(r, color, x = 0, y = 0, z = 0, parent = scene, detail = 1) {
return mesh(
new THREE.IcosahedronGeometry(r, detail),
material(color),
x,
y,
z,
parent
);
}
function torus(radius, tube, color, x, y, z, parent = scene) {
const object = mesh(
new THREE.TorusGeometry(radius, tube, 5, 12),
material(color),
x,
y,
z,
parent
);
object.rotation.x = Math.PI / 2;
return object;
}
// Diorama base, continuous lane, and raised side walks.
box(27, 0.6, 23, 0x8d593b, 0, -0.42, -0.6);
box(26.5, 0.12, 22.5, 0xa27d55, 0, -0.09, -0.6);
box(6.35, 0.09, 20.8, 0xc8aa79, 0, 0.005, 0);
box(6.8, 0.13, 20.7, 0xb08c60, -6.65, 0, 0);
box(6.8, 0.13, 20.7, 0xb08c60, 6.65, 0, 0);
for (const side of [-1, 1]) {
box(0.16, 0.14, 20.8, 0x765c48, side * 3.28, 0.02, 0);
box(0.25, 0.06, 20.8, 0x6e756d, side * 3.53, -0.005, 0);
for (let z = -9.8; z < 10; z += 1.05) {
box(
0.45,
0.15,
0.8,
z % 2 < 0 ? 0xaa8d68 : 0xb79a73,
side * 3.55,
0.07,
z
);
}
}
// Small, level paving stones preserve an uncluttered route.
const pavingGeometry = new THREE.BoxGeometry(0.78, 0.035, 0.78);
const paving = new THREE.InstancedMesh(
pavingGeometry,
material(0xffffff),
13 * 5
);
paving.receiveShadow = true;
const dummy = new THREE.Object3D();
const pavingColor = new THREE.Color();
let pavingIndex = 0;
for (let row = 0; row < 5; row++) {
for (let column = 0; column < 13; column++) {
const x = (column - 6) * 0.87 + (row % 2 ? 0.08 : 0);
const z = -8.3 + row * 4.25;
dummy.position.set(x, 0.074, z);
dummy.rotation.y = (random() - 0.5) * 0.025;
dummy.updateMatrix();
paving.setMatrixAt(pavingIndex, dummy.matrix);
const shade = 0.77 + random() * 0.1;
pavingColor.setHSL(0.105, 0.34, shade);
paving.setColorAt(pavingIndex, pavingColor);
pavingIndex++;
}
}
paving.instanceMatrix.needsUpdate = true;
paving.instanceColor.needsUpdate = true;
scene.add(paving);
// Sea and a compact suggestion of Jamestown's coastal setting.
const sea = mesh(
new THREE.PlaneGeometry(55, 25),
material(0x4f9caa, 0.56),
0,
-0.21,
-19
);
sea.rotation.x = -Math.PI / 2;
sea.castShadow = false;
for (let i = 0; i < 13; i++) {
const ripple = box(
1.6 + random() * 2.4,
0.025,
0.07,
0xb9d8d7,
-12 + random() * 24,
-0.14,
-12 - random() * 8
);
ripple.castShadow = false;
}
function gableRoof(width, depth, eaveHeight, roofHeight) {
const w = width / 2 + 0.28;
const d = depth / 2 + 0.3;
const ridge = eaveHeight + roofHeight;
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-w, eaveHeight, -d,
w, eaveHeight, -d,
0, ridge, -d,
-w, eaveHeight, d,
w, eaveHeight, d,
0, ridge, d
], 3)
);
geometry.setIndex([
0, 2, 1,
3, 4, 5,
0, 3, 5, 0, 5, 2,
1, 2, 5, 1, 5, 4,
0, 1, 4, 0, 4, 3,
2, 0, 3, 2, 3, 5
]);
geometry.computeVertexNormals();
return geometry;
}
function makeWindow(parent, x, y, z, w, h) {
box(w, h, 0.08, 0x284852, x, y, z, parent);
box(w + 0.14, 0.09, 0.12, 0xe8dcc0, x, y + h / 2, z + 0.03, parent);
box(w + 0.14, 0.09, 0.12, 0xe8dcc0, x, y - h / 2, z + 0.03, parent);
box(0.09, h + 0.12, 0.12, 0xe8dcc0, x - w / 2, y, z + 0.03, parent);
box(0.09, h + 0.12, 0.12, 0xe8dcc0, x + w / 2, y, z + 0.03, parent);
box(0.055, h, 0.14, 0xd8cbae, x, y, z + 0.045, parent);
box(w, 0.055, 0.14, 0xd8cbae, x, y, z + 0.045, parent);
}
function makeHouse({
x,
z,
w,
d,
h,
wall,
roof,
door,
awning = false,
balcony = false
}) {
const house = new THREE.Group();
house.position.set(x, 0, z);
scene.add(house);
box(w + 0.12, 0.3, d + 0.12, 0x8f7963, 0, 0.15, 0, house);
box(w, h, d, wall, 0, h / 2, 0, house);
const roofMesh = mesh(
gableRoof(w, d, h, 1.05),
material(roof),
0,
0,
0,
house
);
roofMesh.material.side = THREE.DoubleSide;
box(w + 0.65, 0.13, 0.15, 0x5d4b3f, 0, h + 0.03, d / 2 + 0.3, house);
box(w + 0.65, 0.13, 0.15, 0x5d4b3f, 0, h + 0.03, -d / 2 - 0.3, house);
const front = d / 2 + 0.04;
box(1.05, 2.18, 0.12, 0xd9cbae, -w * 0.24, 1.12, front, house);
box(0.82, 1.93, 0.13, door, -w * 0.24, 1.05, front + 0.04, house);
sphere(0.055, 0xd7b66d, -w * 0.24 + 0.24, 1.03, front + 0.13, house);
makeWindow(house, w * 0.23, h * 0.58, front, 1.16, 1.18);
makeWindow(house, -w * 0.22, h * 0.72, front, 0.76, 0.74);
makeWindow(house, w * 0.23, h * 0.78, front, 0.74, 0.74);
box(1.35, 0.17, 0.65, 0xb6a58a, -w * 0.24, 0.09, front + 0.23, house);
// A narrow painted band and irregular weathering marks.
box(w + 0.02, 0.13, 0.035, roof, 0, 0.62, front + 0.02, house);
for (let i = 0; i < 8; i++) {
const mark = box(
0.04 + random() * 0.12,
0.12 + random() * 0.45,
0.018,
i % 2 ? 0x8b755e : 0xc3aa83,
(random() - 0.5) * w * 0.9,
0.4 + random() * (h - 0.8),
front + 0.025,
house
);
mark.castShadow = false;
}
// Side windows.
const sideWindow = new THREE.Group();
sideWindow.position.set(w / 2 + 0.02, h * 0.57, -0.5);
sideWindow.rotation.y = Math.PI / 2;
house.add(sideWindow);
makeWindow(sideWindow, 0, 0, 0, 0.95, 1.0);
if (balcony) {
box(w * 0.62, 0.14, 1.08, 0xd5c9ad, 0, h * 0.47, front + 0.48, house);
for (let i = 0; i < 7; i++) {
box(
0.055,
0.83,
0.055,
0x5c5348,
-w * 0.28 + i * (w * 0.56 / 6),
h * 0.47 + 0.47,
front + 0.93,
house
);
}
box(w * 0.62, 0.07, 0.08, 0x5c5348, 0, h * 0.47 + 0.89, front + 0.93, house);
}
if (awning) {
const canopy = box(
w * 0.58,
0.08,
1.45,
0xb85b3e,
0,
h * 0.4,
front + 0.67,
house
);
canopy.rotation.x = 0.17;
for (const side of [-1, 1]) {
cylinder(
0.035,
0.035,
1.2,
0x554b40,
side * w * 0.25,
h * 0.4 - 0.49,
front + 1.12,
house,
6
);
}
}
return house;
}
makeHouse({
x: -8.2,
z: -5.1,
w: 5.8,
d: 5.3,
h: 4.4,
wall: 0xe4d6b8,
roof: 0x69564b,
door: 0x2f6a68
});
makeHouse({
x: 8.1,
z: -5.2,
w: 6.1,
d: 5.5,
h: 5.0,
wall: 0xd2b994,
roof: 0x795247,
door: 0x8a4638,
awning: true,
balcony: true
});
makeHouse({
x: -9.0,
z: 4.2,
w: 4.5,
d: 3.8,
h: 3.5,
wall: 0xc7d1c1,
roof: 0x5b5550,
door: 0x536e69
});
// Old Jamestown lighthouse, reduced to a respectful, low-poly landmark.
const lighthouse = new THREE.Group();
lighthouse.position.set(6.6, 0, -10.25);
scene.add(lighthouse);
for (let i = 0; i < 7; i++) {
const rock = sphere(
0.55 + random() * 0.32,
i % 2 ? 0x8b8271 : 0x756f63,
(random() - 0.5) * 1.8,
0.05,
(random() - 0.5) * 1.1,
lighthouse,
0
);
rock.scale.set(1.3, 0.55, 1);
}
cylinder(0.55, 0.88, 3.5, 0xf2ead5, 0, 1.82, 0, lighthouse, 10);
cylinder(0.66, 0.69, 0.48, 0xb9503d, 0, 2.35, 0, lighthouse, 10);
cylinder(0.76, 0.76, 0.16, 0xd9cfb9, 0, 3.57, 0, lighthouse, 10);
cylinder(0.42, 0.42, 0.62, 0x375b63, 0, 3.93, 0, lighthouse, 8);
cylinder(0, 0.62, 0.52, 0x75483d, 0, 4.48, 0, lighthouse, 8);
torus(0.56, 0.035, 0x5b5147, 0, 3.61, 0, lighthouse);
// Distant low-rise coastal skyline.
for (let i = 0; i < 12; i++) {
const height = 0.7 + random() * 2.2;
const width = 0.8 + random() * 1.4;
box(
width,
height,
1.1 + random(),
i % 3 === 0 ? 0xb7aa91 : 0xc8bea8,
-10 + i * 1.8,
height / 2 - 0.05,
-12.2 - random() * 0.6
);
}
function makeNetFrame({
x,
z,
rotation = 0,
width = 3,
height = 2.05,
repair = false
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
const wood = 0x806044;
cylinder(
0.065,
0.085,
height + 0.3,
wood,
-width / 2,
height / 2 + 0.12,
0,
group,
7
);
cylinder(
0.065,
0.085,
height + 0.3,
wood,
width / 2,
height / 2 + 0.12,
0,
group,
7
);
const topBar = cylinder(
0.07,
0.07,
width + 0.23,
0x927050,
0,
height + 0.12,
0,
group,
7
);
topBar.rotation.z = Math.PI / 2;
const positions = [];
const verticalLines = 17;
const horizontalLines = 11;
function sagAt(px) {
return 0.11 * (1 - Math.pow((2 * px) / width, 2));
}
for (let i = 0; i < verticalLines; i++) {
const px = -width / 2 + 0.08 + (i / (verticalLines - 1)) * (width - 0.16);
for (let j = 0; j < horizontalLines; j++) {
const y0 = 0.26 + (j / horizontalLines) * (height - 0.22);
const y1 = 0.26 + ((j + 1) / horizontalLines) * (height - 0.22);
positions.push(px, y0, sagAt(px), px, y1, sagAt(px));
}
}
for (let j = 0; j < horizontalLines; j++) {
const y = 0.26 + (j / horizontalLines) * (height - 0.22);
for (let i = 0; i < verticalLines - 1; i++) {
const x0 = -width / 2 + 0.08 + (i / (verticalLines - 1)) * (width - 0.16);
const x1 = -width / 2 + 0.08 + ((i + 1) / (verticalLines - 1)) * (width - 0.16);
positions.push(x0, y, sagAt(x0), x1, y, sagAt(x1));
}
}
const netGeometry = new THREE.BufferGeometry();
netGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
const net = new THREE.LineSegments(
netGeometry,
new THREE.LineBasicMaterial({
color: 0xe0d5a9,
transparent: true,
opacity: 0.9
})
);
group.add(net);
// Bright floats and lower weights distinguish working fishing gear.
for (let i = 0; i < 8; i++) {
const px = -width / 2 + 0.12 + i * ((width - 0.24) / 7);
sphere(
0.105,
i % 3 === 0 ? 0xe28a3d : 0xe0c35d,
px,
height + 0.1,
sagAt(px),
group,
0
);
sphere(
0.055,
0x695d4c,
px,
0.23,
sagAt(px),
group,
0
);
}
if (repair) {
const patchPositions = [];
const patchX = width * 0.17;
const patchY = 0.8;
const patchSize = 0.58;
for (let i = 0; i <= 5; i++) {
const px = patchX - patchSize / 2 + i * patchSize / 5;
patchPositions.push(px, patchY, 0.15, px, patchY + patchSize, 0.15);
}
for (let i = 0; i <= 5; i++) {
const py = patchY + i * patchSize / 5;
patchPositions.push(
patchX - patchSize / 2, py, 0.15,
patchX + patchSize / 2, py, 0.15
);
}
const patchGeometry = new THREE.BufferGeometry();
patchGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(patchPositions, 3)
);
group.add(
new THREE.LineSegments(
patchGeometry,
new THREE.LineBasicMaterial({ color: 0x4c9189 })
)
);
for (let i = 0; i < 4; i++) {
sphere(
0.035,
0xe8a357,
patchX - patchSize / 2 + i * patchSize / 3,
patchY + i * 0.14,
0.17,
group,
0
);
}
}
return group;
}
const mainNet = makeNetFrame({
x: -4.7,
z: 2.25,
rotation: 0.05,
width: 3.0,
height: 2.08,
repair: true
});
makeNetFrame({
x: 5.75,
z: 0.25,
rotation: -0.18,
width: 2.45,
height: 1.8
});
function makeCrate(x, z, color = 0x477f84, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
box(1.05, 0.12, 0.72, color, 0, 0.08, 0, group);
for (const side of [-1, 1]) {
for (const end of [-1, 1]) {
box(
0.09,
0.66,
0.09,
color,
side * 0.47,
0.38,
end * 0.29,
group
);
}
}
for (let i = 0; i < 3; i++) {
box(1.0, 0.11, 0.07, color, 0, 0.22 + i * 0.19, 0.32, group);
box(1.0, 0.11, 0.07, color, 0, 0.22 + i * 0.19, -0.32, group);
}
return group;
}
function makeBasket(x, z, scale = 1, color = 0x9e7444) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(0.39, 0.28, 0.52, color, 0, 0.28, 0, group, 9);
torus(0.39, 0.035, 0xb28a58, 0, 0.54, 0, group);
torus(0.31, 0.03, 0x765438, 0, 0.31, 0, group);
const handle = torus(0.36, 0.025, 0x755439, 0, 0.67, 0, group);
handle.rotation.x = 0;
handle.rotation.y = Math.PI / 2;
handle.scale.y = 1.1;
return group;
}
function makeBowl(x, z, color = 0x376e87) {
const bowl = new THREE.Group();
bowl.position.set(x, 0, z);
scene.add(bowl);
cylinder(0.34, 0.22, 0.17, color, 0, 0.12, 0, bowl, 12);
torus(0.34, 0.035, color, 0, 0.21, 0, bowl);
return bowl;
}
function makeRopeCoil(x, z, scale = 1) {
const coil = new THREE.Group();
coil.position.set(x, 0.05, z);
coil.scale.setScalar(scale);
scene.add(coil);
for (let i = 0; i < 4; i++) {
const ring = torus(
0.26 - i * 0.035,
0.045,
i % 2 ? 0xc3a56d : 0x9b7b4e,
i * 0.018,
i * 0.045,
i * 0.014,
coil
);
ring.scale.y = 0.84;
}
return coil;
}
// Household frontage, gear storage and workbench.
makeCrate(5.75, 3.2, 0x477f84, 1.05);
makeCrate(6.75, 3.05, 0xb36543, 0.86);
makeCrate(5.55, 4.0, 0xc4974f, 0.72);
makeBasket(6.65, 4.15, 0.88);
makeBasket(5.35, 3.95, 0.65, 0x7f6246);
makeBowl(4.95, 3.05, 0x34768c);
makeBowl(7.45, 2.45, 0xb4533b);
const workbench = new THREE.Group();
workbench.position.set(-6.25, 0, 3.35);
workbench.rotation.y = 0.06;
scene.add(workbench);
box(1.75, 0.13, 0.78, 0x8a6344, 0, 0.83, 0, workbench);
for (const x of [-0.72, 0.72]) {
for (const z of [-0.27, 0.27]) {
box(0.1, 0.8, 0.1, 0x6d4e38, x, 0.4, z, workbench);
}
}
makeRopeCoil(-6.25, 3.95, 0.85);
makeRopeCoil(-7.0, 3.55, 0.62);
makeBasket(-6.4, 4.45, 0.75);
// Mending tools and floats laid out beside the net.
for (let i = 0; i < 5; i++) {
sphere(
0.12,
i % 2 ? 0xe5913f : 0xd5b64e,
-6.7 + i * 0.29,
0.98,
3.25 + (i % 2) * 0.16,
scene,
0
);
}
const spool = cylinder(
0.18,
0.18,
0.4,
0x8e6943,
-5.82,
1.05,
3.37,
scene,
10
);
spool.rotation.z = Math.PI / 2;
const needle = cylinder(
0.012,
0.012,
0.52,
0xd7c8a8,
-5.35,
0.98,
3.32,
scene,
5
);
needle.rotation.z = Math.PI / 2;
// Low-poly people, with restrained proportions and everyday clothing.
function makePerson({
skin = 0x8b5638,
shirt = 0xc77745,
trousers = 0x354c54,
dress = null,
wrap = null
}) {
const root = new THREE.Group();
scene.add(root);
const torso = cylinder(
0.24,
0.29,
0.57,
shirt,
0,
1.18,
0,
root,
7
);
box(0.42, 0.15, 0.3, trousers, 0, 0.88, 0, root);
const head = sphere(0.205, skin, 0, 1.64, 0, root, 1);
head.scale.set(0.94, 1.08, 0.96);
cylinder(0.075, 0.085, 0.13, skin, 0, 1.43, 0, root, 7);
const nose = mesh(
new THREE.ConeGeometry(0.045, 0.10, 5),
material(skin),
0,
1.62,
0.2,
root
);
nose.rotation.x = Math.PI / 2;
sphere(0.022, 0x263238, -0.072, 1.69, 0.18, root, 0);
sphere(0.022, 0x263238, 0.072, 1.69, 0.18, root, 0);
if (wrap) {
const cap = sphere(0.218, wrap, 0, 1.69, -0.015, root, 1);
cap.scale.set(1.02, 0.75, 1.02);
box(0.36, 0.11, 0.28, wrap, 0, 1.8, -0.08, root);
}
if (dress) {
cylinder(
0.18,
0.35,
0.59,
dress,
0,
0.83,
0,
root,
8
);
}
const leftHip = new THREE.Group();
const rightHip = new THREE.Group();
leftHip.position.set(-0.13, 0.87, 0);
rightHip.position.set(0.13, 0.87, 0);
root.add(leftHip, rightHip);
for (const hip of [leftHip, rightHip]) {
cylinder(0.085, 0.075, 0.42, trousers, 0, -0.21, 0, hip, 7);
const knee = new THREE.Group();
knee.position.y = -0.42;
hip.add(knee);
cylinder(0.07, 0.06, 0.41, trousers, 0, -0.205, 0, knee, 7);
box(0.15, 0.1, 0.27, 0x3f3932, 0, -0.42, 0.06, knee);
}
const leftShoulder = new THREE.Group();
const rightShoulder = new THREE.Group();
leftShoulder.position.set(-0.29, 1.39, 0);
rightShoulder.position.set(0.29, 1.39, 0);
root.add(leftShoulder, rightShoulder);
for (const shoulder of [leftShoulder, rightShoulder]) {
shoulder.rotation.z = shoulder === leftShoulder ? -0.06 : 0.06;
cylinder(0.075, 0.065, 0.33, shirt, 0, -0.165, 0, shoulder, 7);
const elbow = new THREE.Group();
elbow.position.y = -0.33;
shoulder.add(elbow);
cylinder(0.062, 0.052, 0.32, skin, 0, -0.16, 0, elbow, 7);
sphere(0.073, skin, 0, -0.34, 0, elbow, 0);
}
return {
root,
torso,
head,
leftHip,
rightHip,
leftKnee: leftHip.children[1],
rightKnee: rightHip.children[1],
leftShoulder,
rightShoulder,
leftElbow: leftShoulder.children[1],
rightElbow: rightShoulder.children[1]
};
}
const workers = [];
const seatedWorker = makePerson({
skin: 0x855238,
shirt: 0x3c7773,
trousers: 0x3a4243,
wrap: 0xd5b56c
});
seatedWorker.root.position.set(-3.92, -0.31, 3.32);
seatedWorker.root.rotation.y = Math.PI;
seatedWorker.leftHip.rotation.x = -1.28;
seatedWorker.rightHip.rotation.x = -1.28;
seatedWorker.leftKnee.rotation.x = 1.25;
seatedWorker.rightKnee.rotation.x = 1.25;
seatedWorker.rightShoulder.rotation.x = -1.06;
seatedWorker.rightElbow.rotation.x = -0.38;
seatedWorker.leftShoulder.rotation.x = -0.82;
seatedWorker.leftElbow.rotation.x = -0.55;
workers.push(seatedWorker);
cylinder(0.27, 0.30, 0.12, 0x806044, -3.92, 0.48, 3.33, scene, 8);
cylinder(0.055, 0.07, 0.45, 0x75543d, -3.92, 0.23, 3.33, scene, 7);
const standingWorker = makePerson({
skin: 0x9a6747,
shirt: 0xc56843,
trousers: 0x3c5360
});
standingWorker.root.position.set(-5.65, 0, 3.38);
standingWorker.root.rotation.y = Math.PI;
standingWorker.rightShoulder.rotation.x = -0.95;
standingWorker.rightElbow.rotation.x = -0.5;
standingWorker.leftShoulder.rotation.x = -0.45;
standingWorker.leftElbow.rotation.x = -0.45;
workers.push(standingWorker);
const walkers = [];
const walkerSpecs = [
{
x: -1.15, z: 7.0, dir: -1, speed: 1.08,
skin: 0x8b5a3c, shirt: 0xd29a4c, trousers: 0x36515b
},
{
x: 1.02, z: 4.9, dir: -1, speed: 0.86,
skin: 0x6f4633, shirt: 0x397b77, trousers: 0x544943, wrap: 0xb84c3e
},
{
x: -0.78, z: 1.5, dir: 1, speed: 0.94,
skin: 0xa47252, shirt: 0xe1c08a, dress: 0xe1c08a, trousers: 0x554c43
},
{
x: 1.12, z: -2.0, dir: -1, speed: 1.14,
skin: 0x805238, shirt: 0x4b6d8a, trousers: 0x5d5146
},
{
x: -0.55, z: -6.2, dir: 1, speed: 0.78,
skin: 0x9b6847, shirt: 0x9a5c49, trousers: 0x3d4a50
}
];
walkerSpecs.forEach((spec, index) => {
const person = makePerson(spec);
person.root.position.set(spec.x, 0, spec.z);
person.root.rotation.y = spec.dir < 0 ? Math.PI : 0;
person.root.userData = {
direction: spec.dir,
speed: spec.speed,
phase: index * 1.27,
baseY: 0
};
walkers.push(person);
});
// A pedestrian carrying a household basket.
const carrier = makePerson({
skin: 0x744832,
shirt: 0x3e7c78,
trousers: 0x574b41,
wrap: 0xe2c98f
});
carrier.root.position.set(1.03, 0, 7.9);
carrier.root.rotation.y = Math.PI;
carrier.root.userData = {
direction: -1,
speed: 0.78,
phase: 2.4,
baseY: 0,
carrier: true
};
carrier.leftShoulder.rotation.x = -0.86;
carrier.rightShoulder.rotation.x = -0.86;
carrier.leftElbow.rotation.x = -0.48;
carrier.rightElbow.rotation.x = -0.48;
const carriedBasket = makeBasket(0, 0, 0.66);
carriedBasket.position.set(0, 0.62, 0.47);
carriedBasket.rotation.x = -0.1;
carrier.root.add(carriedBasket);
walkers.push(carrier);
// A modest laundry detail beneath the balcony.
const laundry = new THREE.Group();
laundry.position.set(8.12, 3.58, -2.0);
scene.add(laundry);
const clothColors = [0xd8d0b5, 0x5b8a8c, 0xb86246];
for (let i = 0; i < 3; i++) {
const cloth = box(
0.48,
0.72,
0.035,
clothColors[i],
(i - 1) * 0.57,
-0.35,
0,
laundry
);
cloth.userData.sway = i * 0.7;
}
// A paddle leaning against the net frame.
const paddle = new THREE.Group();
paddle.position.set(-6.15, 0, 2.75);
paddle.rotation.z = -0.25;
paddle.rotation.x = 0.08;
scene.add(paddle);
cylinder(0.045, 0.045, 2.0, 0x9a7048, 0, 1.0, 0, paddle, 7);
const blade = box(0.34, 0.68, 0.07, 0x8c623f, 0, 2.02, 0, paddle);
blade.rotation.x = 0.08;
// A few plants soften the hard domestic edges.
function makePlant(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
cylinder(0.25, 0.18, 0.36, 0xa35e42, 0, 0.18, 0, group, 8);
for (let i = 0; i < 7; i++) {
const leaf = sphere(
0.12,
i % 2 ? 0x547957 : 0x71895a,
(random() - 0.5) * 0.34,
0.48 + random() * 0.33,
(random() - 0.5) * 0.34,
group,
0
);
leaf.scale.set(0.55, 1.7, 0.55);
leaf.rotation.z = (random() - 0.5) * 0.8;
}
}
makePlant(6.65, 5.15);
makePlant(-8.3, 1.1);
makePlant(4.85, -1.75);
// A few distant birds, built from simple line segments.
const birdMaterial = new THREE.LineBasicMaterial({ color: 0x50676d });
for (let i = 0; i < 4; i++) {
const x = -5 + i * 3.1;
const y = 7.8 + (i % 2) * 0.7;
const z = -14 - i * 0.6;
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x - 0.35, y, z),
new THREE.Vector3(x, y + 0.14, z),
new THREE.Vector3(x + 0.35, y, z)
]);
scene.add(new THREE.Line(geometry, birdMaterial));
}
// Direct camera controls; no examples/addons are used.
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
theta -= dx * 0.005;
phi = THREE.MathUtils.clamp(phi + dy * 0.0035, 0.22, 1.05);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && 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 + event.deltaY * 0.012, 15, 34);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset").addEventListener("click", () => {
radius = defaultView.radius;
theta = defaultView.theta;
phi = defaultView.phi;
updateCamera();
});
renderer.domElement.addEventListener("dblclick", () => {
radius = defaultView.radius;
theta = defaultView.theta;
phi = defaultView.phi;
updateCamera();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
// The seated craftsperson makes small, repeated tying motions.
seatedWorker.rightShoulder.rotation.x =
-1.04 + Math.sin(elapsed * 2.6) * 0.085;
seatedWorker.rightElbow.rotation.x =
-0.4 + Math.sin(elapsed * 3.1 + 0.4) * 0.11;
seatedWorker.leftShoulder.rotation.x =
-0.84 + Math.sin(elapsed * 2.15 + 0.8) * 0.055;
standingWorker.rightShoulder.rotation.x =
-0.96 + Math.sin(elapsed * 1.8) * 0.09;
standingWorker.rightElbow.rotation.x =
-0.48 + Math.sin(elapsed * 2.2 + 0.5) * 0.08;
seatedWorker.torso.rotation.y = Math.sin(elapsed * 1.2) * 0.025;
standingWorker.torso.rotation.y = Math.sin(elapsed * 0.9 + 1) * 0.025;
walkers.forEach((person, index) => {
const data = person.root.userData;
const phase = elapsed * 6.2 + data.phase;
person.root.position.z += data.direction * data.speed * dt;
if (person.root.position.z > 10.25) {
person.root.position.z = -10.25;
data.direction = 1;
person.root.rotation.y = 0;
} else if (person.root.position.z < -10.25) {
person.root.position.z = 10.25;
data.direction = -1;
person.root.rotation.y = Math.PI;
}
const stride = Math.sin(phase);
person.leftHip.rotation.x = stride * 0.52;
person.rightHip.rotation.x = -stride * 0.52;
person.leftKnee.rotation.x = Math.max(0, -stride) * 0.68;
person.rightKnee.rotation.x = Math.max(0, stride) * 0.68;
person.root.position.y = data.baseY + Math.abs(Math.cos(phase)) * 0.018;
if (!data.carrier) {
person.leftShoulder.rotation.x = -stride * 0.42;
person.rightShoulder.rotation.x = stride * 0.42;
person.leftElbow.rotation.x = -0.12 - Math.max(0, stride) * 0.16;
person.rightElbow.rotation.x = -0.12 - Math.max(0, -stride) * 0.16;
}
person.torso.rotation.y = Math.sin(phase * 0.5) * 0.025;
});
laundry.children.forEach((cloth) => {
cloth.rotation.x = Math.sin(elapsed * 1.25 + cloth.userData.sway) * 0.07;
cloth.rotation.z = Math.sin(elapsed * 0.9 + cloth.userData.sway) * 0.035;
});
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
});
</script>
</body>
</html>
```