Prompt specification
Build or customize the Three.js 3D scene "Saint-Louis island street and bridge slice" 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: Saint-Louis island street and bridge slice
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/saint-louis-island-street-and-bridge-slice-x2951
Scene Description Prompt:
Saint-Louis island street and bridge slice. Build a bounded low-poly scene with referenced bridge silhouette, river edge, and selected island facades. Make the water-separated urban relationship readable without modeling the whole delta. Please build this with Three.js from cdnjs in one self-contained HTML file, using low-poly forms.
Working Three.js Starter (saint-louis-island-street-and-bridge-slice-x2951):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#e7dfd1">
<title>Saint-Louis — Island & Faidherbe Bridge</title>
<style>
:root {
--ink: #26383a;
--muted: #647274;
--paper: rgba(249, 246, 238, 0.92);
--line: rgba(38, 56, 58, 0.18);
--accent: #ad5f45;
--water: #397f86;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7dfd1;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas.dragging { cursor: grabbing; }
.title-card {
position: absolute;
z-index: 4;
top: 22px;
left: 24px;
width: min(360px, calc(100vw - 48px));
padding: 18px 20px 17px;
border: 1px solid var(--line);
border-radius: 3px;
background: var(--paper);
box-shadow: 0 12px 35px rgba(47, 42, 31, 0.12);
backdrop-filter: blur(10px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3.1vw, 39px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.025em;
}
.subtitle {
margin: 11px 0 0;
max-width: 305px;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.rule {
display: flex;
align-items: center;
gap: 9px;
margin-top: 14px;
padding-top: 12px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.rule::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
}
.controls {
position: absolute;
z-index: 5;
top: 22px;
right: 24px;
display: flex;
gap: 8px;
}
button {
min-height: 36px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 3px;
background: var(--paper);
color: var(--ink);
font: 700 10px/1 ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.09em;
text-transform: uppercase;
cursor: pointer;
box-shadow: 0 6px 20px rgba(47, 42, 31, 0.08);
backdrop-filter: blur(10px);
}
button:hover { border-color: rgba(38, 56, 58, 0.38); }
button:active { transform: translateY(1px); }
#labels {
position: absolute;
inset: 0;
z-index: 3;
pointer-events: none;
}
.label {
position: absolute;
min-width: max-content;
padding: 7px 9px 6px;
border: 1px solid rgba(38, 56, 58, 0.18);
border-left: 3px solid var(--accent);
border-radius: 2px;
background: rgba(249, 246, 238, 0.9);
color: var(--ink);
box-shadow: 0 5px 16px rgba(47, 42, 31, 0.09);
transform: translate(-50%, -50%);
transition: opacity 140ms ease;
backdrop-filter: blur(6px);
}
.label strong {
display: block;
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.label small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.label.water {
border-left-color: var(--water);
}
.label::after {
content: "";
position: absolute;
left: 50%;
top: calc(100% + 4px);
width: 1px;
height: 13px;
background: rgba(38, 56, 58, 0.42);
}
.footer {
position: absolute;
z-index: 4;
right: 24px;
bottom: 21px;
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 3px;
background: rgba(249, 246, 238, 0.78);
color: var(--muted);
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(8px);
}
.footer strong {
color: var(--ink);
font-weight: 700;
}
.north {
position: absolute;
z-index: 4;
left: 25px;
bottom: 22px;
display: grid;
place-items: center;
width: 39px;
height: 39px;
border: 1px solid var(--line);
border-radius: 50%;
background: rgba(249, 246, 238, 0.78);
color: var(--ink);
font-size: 10px;
font-weight: 800;
pointer-events: none;
}
.north span {
position: absolute;
top: 5px;
font-size: 14px;
}
@media (max-width: 720px) {
.title-card {
top: 14px;
left: 14px;
width: min(315px, calc(100vw - 28px));
padding: 14px 16px;
}
.subtitle { display: none; }
.rule { margin-top: 10px; padding-top: 9px; }
.controls {
top: auto;
right: 14px;
bottom: 54px;
}
button {
min-height: 34px;
padding: 0 10px;
font-size: 9px;
}
.footer {
right: 14px;
bottom: 14px;
max-width: 245px;
font-size: 9px;
}
.north {
left: 14px;
bottom: 14px;
}
.label small { display: none; }
}
</style>
</head>
<body>
<div id="app">
<canvas id="scene" aria-label="Interactive low-poly model of Saint-Louis island and the Faidherbe Bridge"></canvas>
<section class="title-card">
<div class="eyebrow">Saint-Louis · Sénégal</div>
<h1>Island city<br>& seven steel arches</h1>
<p class="subtitle">
A bounded urban slice joining the historic island, the Senegal River edge,
the northern quay, and the landmark silhouette of Pont Faidherbe.
</p>
<div class="rule">Schematic model · not to scale</div>
</section>
<div class="controls">
<button id="toggle-labels" type="button">Labels on</button>
<button id="reset-view" type="button">Reset view</button>
</div>
<div id="labels" aria-hidden="true">
<div class="label" data-anchor="bridge">
<strong>Pont Faidherbe</strong>
<small>Seven-span steel silhouette</small>
</div>
<div class="label water" data-anchor="river">
<strong>Fleuve Sénégal</strong>
<small>Water-separated urban edge</small>
</div>
<div class="label" data-anchor="facades">
<strong>Façades de l’île</strong>
<small>Selected street elevations</small>
</div>
<div class="label" data-anchor="north">
<strong>Rive nord</strong>
<small>Quai and bridge approach</small>
</div>
</div>
<div class="north"><span>↑</span>N</div>
<div class="footer"><strong>Drag</strong> orbit · <strong>Scroll</strong> zoom · <strong>Shift-drag</strong> pan</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 orthographic camera
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#e7dfd1");
scene.fog = new THREE.Fog("#e7dfd1", 72, 135);
const camera = new THREE.OrthographicCamera(-25, 25, 21, -21, 0.1, 180);
const controls = {
target: new THREE.Vector3(0, 2.0, 2.0),
yaw: 0.73,
pitch: 0.69,
radius: 57,
dragging: false,
panning: false,
previousX: 0,
previousY: 0
};
function updateCamera() {
const { target, yaw, pitch, radius } = controls;
const horizontal = radius * Math.cos(pitch);
camera.position.set(
target.x + horizontal * Math.sin(yaw),
target.y + radius * Math.sin(pitch),
target.z - horizontal * Math.cos(yaw)
);
camera.lookAt(target);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(40, 40 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight("#fff7e7", "#657572", 2.25));
const sun = new THREE.DirectionalLight("#fff0d3", 3.1);
sun.position.set(-19, 31, -24);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 30;
sun.shadow.camera.bottom = -30;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 85;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#cce6e9", 0.8);
fill.position.set(24, 15, 25);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.88,
metalness: options.metalness ?? 0,
flatShading: options.flatShading ?? true,
side: options.side ?? THREE.FrontSide,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
emissive: options.emissive ?? "#000000",
emissiveIntensity: options.emissiveIntensity ?? 0
});
}
const M = {
plinth: material("#596765", { roughness: 0.96 }),
stage: material("#e7dfd1", { roughness: 1 }),
mainlandTop: material("#c9ad82", { roughness: 1 }),
islandTop: material("#d6bd91", { roughness: 1 }),
earthSide: material("#8e6e50", { roughness: 1, side: THREE.DoubleSide }),
stone: material("#b9aa91", { roughness: 0.95 }),
paleStone: material("#d8cfb9", { roughness: 0.92 }),
road: material("#a77e62", { roughness: 1 }),
sidewalk: material("#c8b99f", { roughness: 0.95 }),
iron: material("#344b4d", { roughness: 0.63, metalness: 0.58 }),
ironLight: material("#5d6c68", { roughness: 0.68, metalness: 0.44 }),
wood: material("#8f5d3e", { roughness: 0.9 }),
darkWood: material("#513c31", { roughness: 0.96 }),
window: material("#29464b", { roughness: 0.45 }),
windowLight: material("#789095", { roughness: 0.5 }),
cream: material("#e8dcc2", { roughness: 0.92 }),
green: material("#65795b", { roughness: 1 }),
greenLight: material("#82916b", { roughness: 1 }),
trunk: material("#7a5a3f", { roughness: 1 }),
black: material("#293637", { roughness: 0.72 })
};
const architecture = {
ochre: material("#c78658", { roughness: 0.94 }),
cream: material("#dfd2b6", { roughness: 0.95 }),
rose: material("#b76f61", { roughness: 0.95 }),
blue: material("#7e9fa0", { roughness: 0.92 }),
sand: material("#c4a979", { roughness: 0.96 }),
white: material("#e6dfcb", { roughness: 0.92 }),
civic: material("#d9c49f", { roughness: 0.91 })
};
function addBox(parent, width, height, depth, mat, x, y, z, shadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = shadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
mat,
x,
y,
z,
segments = 8,
shadow = true
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = shadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const up = new THREE.Vector3(0, 1, 0);
function addRod(parent, start, end, radius, mat, segments = 6) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, segments),
mat
);
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;
}
function addSphere(parent, radius, mat, x, y, z, detail = 0) {
const geometry = detail
? new THREE.IcosahedronGeometry(radius, detail)
: new THREE.DodecahedronGeometry(radius, 0);
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// A deterministic random generator keeps the model composition stable.
let randomState = 728341;
function random() {
randomState = (randomState * 1664525 + 1013904223) >>> 0;
return randomState / 4294967296;
}
function range(min, max) {
return min + (max - min) * random();
}
// -------------------------------------------------------------------------
// Bounded diorama base and faceted river
// -------------------------------------------------------------------------
const model = new THREE.Group();
scene.add(model);
addBox(model, 38, 1.5, 34.6, M.plinth, 0, -1.0, 2.5);
const stage = new THREE.Mesh(
new THREE.PlaneGeometry(220, 220),
M.stage
);
stage.rotation.x = -Math.PI / 2;
stage.position.y = -1.82;
stage.receiveShadow = true;
scene.add(stage);
const waterGeometry = new THREE.PlaneGeometry(37, 33, 18, 16);
waterGeometry.rotateX(-Math.PI / 2);
const waterPositions = waterGeometry.attributes.position;
for (let i = 0; i < waterPositions.count; i++) {
const x = waterPositions.getX(i);
const z = waterPositions.getZ(i);
const wave =
Math.sin(x * 0.72 + z * 0.38) * 0.035 +
Math.sin(z * 1.14 - x * 0.23) * 0.025;
waterPositions.setY(i, wave + range(-0.015, 0.015));
}
const facetedWater = waterGeometry.toNonIndexed();
const waterColors = [];
const waterPalette = [
new THREE.Color("#3d8388"),
new THREE.Color("#438c90"),
new THREE.Color("#397b82"),
new THREE.Color("#4a9092")
];
for (let i = 0; i < facetedWater.attributes.position.count; i += 3) {
const color = waterPalette[Math.floor(random() * waterPalette.length)];
for (let j = 0; j < 3; j++) {
waterColors.push(color.r, color.g, color.b);
}
}
facetedWater.setAttribute(
"color",
new THREE.Float32BufferAttribute(waterColors, 3)
);
facetedWater.computeVertexNormals();
const waterMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.32,
metalness: 0.08,
flatShading: true,
transparent: true,
opacity: 0.97
});
const water = new THREE.Mesh(facetedWater, waterMaterial);
water.position.set(0, 0.05, 2.5);
water.receiveShadow = true;
model.add(water);
// -------------------------------------------------------------------------
// Custom flat land polygons
// -------------------------------------------------------------------------
function buildLand(points, topMaterial, sideMaterial) {
const shape = new THREE.Shape();
shape.moveTo(points[0][0], -points[0][1]);
for (let i = 1; i < points.length; i++) {
shape.lineTo(points[i][0], -points[i][1]);
}
shape.closePath();
const topGeometry = new THREE.ShapeGeometry(shape);
topGeometry.rotateX(-Math.PI / 2);
const top = new THREE.Mesh(topGeometry, topMaterial);
top.position.y = 1.15;
top.receiveShadow = true;
model.add(top);
const vertices = [];
const indices = [];
const bottom = -0.12;
for (let i = 0; i < points.length; i++) {
const next = (i + 1) % points.length;
const a = points[i];
const b = points[next];
const offset = vertices.length / 3;
vertices.push(
a[0], 1.15, a[1],
a[0], bottom, a[1],
b[0], 1.15, b[1],
b[0], bottom, b[1]
);
indices.push(
offset, offset + 2, offset + 1,
offset + 2, offset + 3, offset + 1
);
}
const sideGeometry = new THREE.BufferGeometry();
sideGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices, 3)
);
sideGeometry.setIndex(indices);
sideGeometry.computeVertexNormals();
const sides = new THREE.Mesh(sideGeometry, sideMaterial);
sides.receiveShadow = true;
model.add(sides);
return top;
}
const islandPoints = [
[-17.5, 5.2],
[-10.0, 4.8],
[-3.0, 5.4],
[3.0, 5.1],
[9.0, 5.5],
[14.0, 5.0],
[17.8, 6.0],
[17.6, 18.8],
[-17.6, 18.8]
];
const mainlandPoints = [
[-17.8, -14.0],
[17.8, -14.0],
[17.8, -5.7],
[10.0, -5.4],
[4.0, -5.7],
[-3.0, -5.3],
[-10.0, -5.8],
[-17.8, -5.2]
];
buildLand(islandPoints, M.islandTop, M.earthSide);
buildLand(mainlandPoints, M.mainlandTop, M.earthSide);
// A narrow dark shoreline line makes the two banks immediately legible.
function addShoreline(points) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map(([x, z]) => new THREE.Vector3(x, 1.18, z))
);
const line = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({ color: "#74614d" })
);
model.add(line);
}
addShoreline(islandPoints.slice(0, 7));
addShoreline([
mainlandPoints[7],
mainlandPoints[6],
mainlandPoints[5],
mainlandPoints[4],
mainlandPoints[3],
mainlandPoints[2]
]);
// -------------------------------------------------------------------------
// Streets, promenades, quay walls, and river-edge details
// -------------------------------------------------------------------------
addBox(model, 31.4, 0.055, 3.05, M.road, 0, 1.18, 9.25);
addBox(model, 32.8, 0.09, 1.05, M.sidewalk, 0, 1.19, 6.68);
addBox(model, 31.6, 0.08, 0.42, M.paleStone, 0, 1.19, 7.52);
addBox(model, 31.6, 0.08, 0.42, M.paleStone, 0, 1.19, 10.98);
// Street aligned with the bridge landing.
addBox(model, 3.25, 0.06, 8.3, M.road, -1.5, 1.19, 12.85);
// Northern quay road.
addBox(model, 32.5, 0.055, 2.5, M.road, 0, 1.18, -9.25);
addBox(model, 33.2, 0.08, 0.55, M.paleStone, 0, 1.19, -7.8);
// River-facing masonry courses, interrupted at the bridge.
for (let x = -16.5; x <= 16.5; x += 1.8) {
if (Math.abs(x + 1.5) < 2.4) continue;
addBox(
model,
1.63,
0.92,
0.45,
random() > 0.5 ? M.stone : M.paleStone,
x,
0.62,
4.96,
false
);
addBox(
model,
1.65,
0.85,
0.42,
random() > 0.5 ? M.stone : M.paleStone,
x,
0.57,
-5.48,
false
);
}
// Low-poly riprap at both water edges.
const rockMaterials = [
material("#777b70"),
material("#8b8977"),
material("#656e67"),
material("#a09a84")
];
for (let i = 0; i < 65; i++) {
const x = range(-17, 17);
if (Math.abs(x + 1.5) < 2.1) continue;
const islandRock = addSphere(
model,
range(0.16, 0.34),
rockMaterials[Math.floor(random() * rockMaterials.length)],
x,
range(0.08, 0.22),
range(4.64, 5.08),
0
);
islandRock.scale.set(range(0.8, 1.4), range(0.55, 0.9), range(0.7, 1.2));
islandRock.rotation.set(random(), random(), random());
if (i % 2 === 0) {
const northRock = addSphere(
model,
range(0.15, 0.28),
rockMaterials[Math.floor(random() * rockMaterials.length)],
x,
range(0.08, 0.2),
range(-5.8, -5.46),
0
);
northRock.scale.set(1.2, 0.65, 0.9);
northRock.rotation.y = random() * Math.PI;
}
}
// Quay bollards.
for (const x of [-15, -10, 7, 11, 15]) {
addCylinder(model, 0.12, 0.16, 0.55, M.iron, x, 1.48, -5.9, 6);
addCylinder(model, 0.19, 0.19, 0.08, M.iron, x, 1.77, -5.9, 6);
}
// -------------------------------------------------------------------------
// Selected island facades
// -------------------------------------------------------------------------
function darkerAccent(color) {
return material(new THREE.Color(color).multiplyScalar(0.73));
}
function makeBuilding({
x,
width,
height,
front = 12.55,
depth = 4.45,
color,
style = "shutters",
civic = false
}) {
const group = new THREE.Group();
model.add(group);
const wall = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
color
);
wall.position.set(x, 1.15 + height / 2, front + depth / 2);
wall.castShadow = true;
wall.receiveShadow = true;
group.add(wall);
const accent = darkerAccent(color.color);
// Stone base and cornice.
addBox(group, width + 0.08, 0.36, depth + 0.06, M.paleStone, x, 1.32, front + depth / 2);
addBox(group, width + 0.22, 0.17, depth + 0.16, M.cream, x, 1.15 + height - 0.05, front + depth / 2);
addBox(group, width + 0.13, 0.42, depth + 0.08, accent, x, 1.15 + height + 0.16, front + depth / 2);
// Ground-floor doorway.
const doorWidth = civic ? 1.05 : 0.68;
addBox(group, doorWidth + 0.13, 1.48, 0.09, M.cream, x, 1.92, front - 0.055);
addBox(group, doorWidth, 1.31, 0.10, M.window, x, 1.88, front - 0.11);
const floors = civic ? 3 : Math.max(1, Math.floor((height - 1.8) / 1.45));
const columns = width > 4.3 ? 3 : 2;
for (let floor = 0; floor < floors; floor++) {
const windowY = 3.23 + floor * 1.43;
for (let column = 0; column < columns; column++) {
const windowX =
x - width / 2 + (width / (columns + 1)) * (column + 1);
addBox(group, 0.88, 1.02, 0.08, M.cream, windowX, windowY, front - 0.052);
addBox(
group,
0.66,
0.80,
0.09,
random() > 0.84 ? M.windowLight : M.window,
windowX,
windowY,
front - 0.105
);
if (style === "shutters") {
const shutterMaterial = new THREE.MeshStandardMaterial({
color: accent,
roughness: 0.94,
flatShading: true
});
addBox(group, 0.17, 0.91, 0.09, shutterMaterial, windowX - 0.49, windowY, front - 0.11);
addBox(group, 0.17, 0.91, 0.09, shutterMaterial, windowX + 0.49, windowY, front - 0.11);
for (let slat = 0; slat < 4; slat++) {
addBox(
group,
0.13,
0.025,
0.025,
M.cream,
windowX - 0.49,
windowY - 0.30 + slat * 0.20,
front - 0.165,
false
);
addBox(
group,
0.13,
0.025,
0.025,
M.cream,
windowX + 0.49,
windowY - 0.30 + slat * 0.20,
front - 0.165,
false
);
}
}
}
}
// A small colonial balcony or awning provides facade variety.
if (style === "balcony") {
const balconyY = 3.02;
addBox(group, width * 0.72, 0.11, 0.68, M.paleStone, x, balconyY, front - 0.32);
for (let rail = 0; rail < 8; rail++) {
const rx = x - width * 0.31 + (width * 0.62 * rail) / 7;
addBox(group, 0.035, 0.65, 0.035, M.iron, rx, balconyY + 0.36, front - 0.61, false);
}
addBox(group, width * 0.65, 0.045, 0.045, M.iron, x, balconyY + 0.69, front - 0.61, false);
}
if (style === "awning") {
const awning = addBox(
group,
width * 0.58,
0.085,
0.86,
accent,
x,
2.52,
front - 0.40
);
awning.rotation.x = -0.13;
}
return group;
}
makeBuilding({
x: -14.8,
width: 3.6,
height: 5.7,
color: architecture.ochre,
style: "awning"
});
makeBuilding({
x: -11.2,
width: 3.2,
height: 6.7,
color: architecture.cream,
style: "balcony"
});
makeBuilding({
x: -8.0,
width: 3.0,
height: 4.8,
color: architecture.blue,
style: "shutters"
});
makeBuilding({
x: -4.9,
width: 2.4,
height: 7.0,
color: architecture.rose,
style: "shutters"
});
makeBuilding({
x: 7.3,
width: 3.4,
height: 6.2,
color: architecture.sand,
style: "balcony"
});
makeBuilding({
x: 10.7,
width: 3.1,
height: 4.9,
color: architecture.white,
style: "awning"
});
makeBuilding({
x: 14.0,
width: 3.2,
height: 6.6,
color: architecture.ochre,
style: "shutters"
});
// Civic facade: pediment, clock, arched openings, and pale stone.
const civicGroup = new THREE.Group();
model.add(civicGroup);
const civicX = 2.9;
const civicFront = 12.52;
const civicHeight = 7.25;
const civicBody = new THREE.Mesh(
new THREE.BoxGeometry(5.0, civicHeight, 4.5),
architecture.civic
);
civicBody.position.set(civicX, 1.15 + civicHeight / 2, civicFront + 2.25);
civicBody.castShadow = true;
civicBody.receiveShadow = true;
civicGroup.add(civicBody);
addBox(civicGroup, 5.2, 0.36, 4.58, M.paleStone, civicX, 1.32, civicFront + 2.25);
addBox(civicGroup, 5.25, 0.18, 4.65, M.cream, civicX, 8.25, civicFront + 2.25);
function archGeometry(width, height) {
const shape = new THREE.Shape();
const radius = width / 2;
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 new THREE.ShapeGeometry(shape, 10);
}
for (const offset of [-1.7, 1.7]) {
const opening = new THREE.Mesh(
archGeometry(0.88, 1.65),
M.window
);
opening.position.set(civicX + offset, 1.49, civicFront - 0.055);
civicGroup.add(opening);
addBox(
civicGroup,
0.15,
1.65,
0.13,
M.cream,
civicX + offset - 0.5,
2.31,
civicFront - 0.1
);
addBox(
civicGroup,
0.15,
1.65,
0.13,
M.cream,
civicX + offset + 0.5,
2.31,
civicFront - 0.1
);
}
const civicDoor = new THREE.Mesh(
archGeometry(1.18, 2.05),
M.window
);
civicDoor.position.set(civicX, 1.48, civicFront - 0.06);
civicGroup.add(civicDoor);
// Upper rectangular windows.
for (const row of [3.55, 5.15, 6.75]) {
for (const offset of [-1.65, 0, 1.65]) {
addBox(civicGroup, 0.84, 1.02, 0.08, M.cream, civicX + offset, row, civicFront - 0.052);
addBox(civicGroup, 0.62, 0.8, 0.09, M.window, civicX + offset, row, civicFront - 0.105);
}
}
// Triangular pediment.
const pedimentShape = new THREE.Shape();
pedimentShape.moveTo(-2.85, 0);
pedimentShape.lineTo(2.85, 0);
pedimentShape.lineTo(0, 1.45);
pedimentShape.closePath();
const pediment = new THREE.Mesh(
new THREE.ShapeGeometry(pedimentShape),
M.cream
);
pediment.position.set(civicX, 8.32, civicFront - 0.04);
civicGroup.add(pediment);
// Clock face and hands.
const clock = new THREE.Mesh(
new THREE.CircleGeometry(0.43, 24),
new THREE.MeshStandardMaterial({
color: "#eee2c6",
roughness: 0.75,
side: THREE.DoubleSide
})
);
clock.position.set(civicX, 7.03, civicFront - 0.075);
civicGroup.add(clock);
addBox(civicGroup, 0.035, 0.28, 0.035, M.iron, civicX, 7.10, civicFront - 0.12, false);
const minuteHand = addBox(civicGroup, 0.22, 0.035, 0.035, M.iron, civicX + 0.10, 7.03, civicFront - 0.13, false);
minuteHand.rotation.z = -0.35;
// -------------------------------------------------------------------------
// Faidherbe Bridge: seven arched steel spans with masonry piers
// -------------------------------------------------------------------------
const bridge = new THREE.Group();
model.add(bridge);
const bridgeX = -1.5;
const bridgeStart = -5.8;
const bridgeEnd = 5.9;
const bridgeWidth = 2.18;
const deckY = 3.26;
const archSpringY = 3.37;
const archRise = 2.33;
const spanCount = 7;
const spanLength = (bridgeEnd - bridgeStart) / spanCount;
// Deck.
addBox(
bridge,
bridgeWidth,
0.27,
bridgeEnd - bridgeStart,
M.ironLight,
bridgeX,
deckY,
(bridgeStart + bridgeEnd) / 2
);
addBox(
bridge,
bridgeWidth - 0.24,
0.055,
bridgeEnd - bridgeStart,
M.road,
bridgeX,
deckY + 0.16,
(bridgeStart + bridgeEnd) / 2,
false
);
// Internal masonry piers and end abutments.
for (let i = 1; i < spanCount; i++) {
const z = bridgeStart + i * spanLength;
addBox(
bridge,
1.16,
3.48,
0.48,
i % 2 ? M.stone : M.paleStone,
bridgeX,
1.62,
z
);
addBox(
bridge,
1.35,
0.18,
0.63,
M.paleStone,
bridgeX,
3.35,
z
);
addBox(
bridge,
1.42,
0.24,
0.72,
M.stone,
bridgeX,
0.04,
z
);
}
addBox(bridge, 1.48, 3.65, 0.76, M.paleStone, bridgeX, 1.66, bridgeStart);
addBox(bridge, 1.48, 3.65, 0.76, M.paleStone, bridgeX, 1.66, bridgeEnd);
// Paired arch ribs, vertical hangers, and lateral cross-bracing.
for (let span = 0; span < spanCount; span++) {
const z0 = bridgeStart + span * spanLength;
const z1 = z0 + spanLength;
const segments = 8;
for (const side of [-0.83, 0.83]) {
for (let segment = 0; segment < segments; segment++) {
const t0 = segment / segments;
const t1 = (segment + 1) / segments;
const y0 = archSpringY + archRise * Math.sin(Math.PI * t0);
const y1 = archSpringY + archRise * Math.sin(Math.PI * t1);
addRod(
bridge,
[bridgeX + side, y0, z0 + spanLength * t0],
[bridgeX + side, y1, z0 + spanLength * t1],
0.073,
M.iron,
6
);
}
for (let hanger = 1; hanger < segments; hanger++) {
const t = hanger / segments;
const z = z0 + spanLength * t;
const archY = archSpringY + archRise * Math.sin(Math.PI * t);
addRod(
bridge,
[bridgeX + side, deckY + 0.20, z],
[bridgeX + side, archY, z],
0.044,
M.ironLight,
5
);
}
}
// Cross-bracing ties the two ribs together.
for (let point = 0; point <= segments; point++) {
const t = point / segments;
const z = z0 + spanLength * t;
const y = archSpringY + archRise * Math.sin(Math.PI * t);
addRod(
bridge,
[bridgeX - 0.83, y, z],
[bridgeX + 0.83, y, z],
0.042,
M.ironLight,
5
);
}
}
// Parapet rails and uprights.
for (const side of [-1.02, 1.02]) {
addBox(
bridge,
0.065,
0.065,
bridgeEnd - bridgeStart,
M.iron,
bridgeX + side,
deckY + 0.77,
(bridgeStart + bridgeEnd) / 2,
false
);
const count = 16;
for (let i = 0; i <= count; i++) {
const z = bridgeStart + (bridgeEnd - bridgeStart) * (i / count);
addBox(
bridge,
0.045,
0.62,
0.045,
M.iron,
bridgeX + side,
deckY + 0.49,
z,
false
);
}
}
function addRamp(startZ, startY, endZ, endY) {
const deltaZ = endZ - startZ;
const deltaY = endY - startY;
const length = Math.sqrt(deltaZ * deltaZ + deltaY * deltaY);
const angle = -Math.atan2(deltaY, deltaZ);
const ramp = addBox(
bridge,
bridgeWidth,
0.27,
length,
M.ironLight,
bridgeX,
(startY + endY) / 2,
(startZ + endZ) / 2
);
ramp.rotation.x = angle;
const road = addBox(
bridge,
bridgeWidth - 0.22,
0.045,
length - 0.08,
M.road,
bridgeX,
(startY + endY) / 2 + 0.17,
(startZ + endZ) / 2,
false
);
road.rotation.x = angle;
}
addRamp(-8.85, 1.27, bridgeStart, deckY + 0.13);
addRamp(bridgeEnd, deckY + 0.13, 8.65, 1.27);
// -------------------------------------------------------------------------
// Minimal northern context: quay edge and two low warehouses
// -------------------------------------------------------------------------
makeBuilding({
x: -12.6,
width: 5.0,
height: 2.8,
front: -12.2,
depth: 2.4,
color: architecture.sand,
style: "shutters"
});
makeBuilding({
x: 12.2,
width: 5.6,
height: 2.5,
front: -12.4,
depth: 2.3,
color: architecture.cream,
style: "awning"
});
// -------------------------------------------------------------------------
// Trees, lamps, benches, and people for scale
// -------------------------------------------------------------------------
function addTree(x, z, scale = 1, groundY = 1.15) {
const group = new THREE.Group();
model.add(group);
const trunkHeight = 1.8 * scale;
addCylinder(
group,
0.13 * scale,
0.18 * scale,
trunkHeight,
M.trunk,
x,
groundY + trunkHeight / 2,
z,
6
);
const crown = addSphere(
group,
0.92 * scale,
M.green,
x,
groundY + trunkHeight + 0.28 * scale,
z,
0
);
crown.scale.set(1.1, 0.85, 1.0);
const crown2 = addSphere(
group,
0.62 * scale,
M.greenLight,
x + 0.42 * scale,
groundY + trunkHeight + 0.12 * scale,
z + 0.08 * scale,
0
);
crown2.scale.set(1.0, 0.82, 1.1);
}
for (const [x, z, scale] of [
[-14.7, 6.85, 0.86],
[-10.6, 6.85, 0.75],
[10.8, 6.8, 0.84],
[14.8, 6.9, 0.72],
[-15.2, -10.5, 0.9],
[14.7, -10.6, 0.82]
]) {
addTree(x, z, scale);
}
function addLamp(x, z, groundY = 1.15) {
addCylinder(model, 0.045, 0.065, 2.65, M.iron, x, groundY + 1.325, z, 6);
addBox(model, 0.42, 0.055, 0.055, M.iron, x, groundY + 2.63, z, false);
addBox(model, 0.24, 0.24, 0.24, M.cream, x + 0.14, groundY + 2.52, z, false);
addCylinder(model, 0.20, 0.13, 0.12, M.iron, x + 0.14, groundY + 2.68, z, 6, false);
}
for (const x of [-13, -7, 7, 13]) {
addLamp(x, 7.85);
}
for (const x of [-10, 10]) {
addLamp(x, -7.48);
}
function addBench(x, z) {
addBox(model, 1.25, 0.09, 0.32, M.wood, x, 1.62, z, false);
addBox(model, 1.25, 0.35, 0.065, M.wood, x, 1.86, z - 0.15, false);
addBox(model, 0.08, 0.45, 0.28, M.iron, x - 0.48, 1.39, z, false);
addBox(model, 0.08, 0.45, 0.28, M.iron, x + 0.48, 1.39, z, false);
}
addBench(-11.8, 6.55);
addBench(12.4, 6.55);
const peopleColors = [
material("#8d5545"),
material("#315e67"),
material("#d0b77e"),
material("#596a4f"),
material("#b97962")
];
function addPerson(x, z, scale = 1) {
const shirt = peopleColors[Math.floor(random() * peopleColors.length)];
addCylinder(
model,
0.115 * scale,
0.145 * scale,
0.62 * scale,
shirt,
x,
1.15 + 0.31 * scale,
z,
6
);
addSphere(
model,
0.135 * scale,
M.darkWood,
x,
1.15 + 0.76 * scale,
z,
0
);
addBox(
model,
0.065 * scale,
0.31 * scale,
0.065 * scale,
M.darkWood,
x - 0.065 * scale,
1.15 + 0.16 * scale,
z,
false
);
addBox(
model,
0.065 * scale,
0.31 * scale,
0.065 * scale,
M.darkWood,
x + 0.065 * scale,
1.15 + 0.16 * scale,
z,
false
);
}
const people = [
[-12.6, 8.8, 0.95],
[-11.9, 9.5, 0.9],
[-5.7, 9.4, 1.0],
[4.9, 8.7, 0.92],
[8.5, 9.5, 1.05],
[14.6, 9.0, 0.86],
[-1.7, 10.1, 1.0],
[-1.0, 13.9, 0.92]
];
for (const [x, z, scale] of people) {
addPerson(x, z, scale);
}
// -------------------------------------------------------------------------
// Low-poly pirogue on the river
// -------------------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(8.1, 0.16, 0.4);
boat.rotation.y = -0.58;
model.add(boat);
const hullVertices = [
0, 0.34, 1.85,
0.55, 0.34, 0.58,
0.48, 0.34, -1.48,
-0.48, 0.34, -1.48,
-0.55, 0.34, 0.58,
0, -0.08, 1.56,
0.33, -0.07, 0.50,
0.31, -0.07, -1.25,
-0.31, -0.07, -1.25,
-0.33, -0.07, 0.50
];
const hullIndices = [
0, 1, 5, 1, 6, 5,
1, 2, 6, 2, 7, 6,
2, 3, 7, 3, 8, 7,
3, 4, 8, 4, 9, 8,
4, 0, 9, 0, 5, 9
];
const hullGeometry = new THREE.BufferGeometry();
hullGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(hullVertices, 3)
);
hullGeometry.setIndex(hullIndices);
hullGeometry.computeVertexNormals();
const hull = new THREE.Mesh(hullGeometry, M.wood);
hull.castShadow = true;
hull.receiveShadow = true;
boat.add(hull);
addBox(boat, 0.68, 0.05, 1.85, M.darkWood, 0, 0.31, -0.02, false);
addBox(boat, 0.045, 0.045, 3.0, M.cream, 0, 0.38, 0, false);
addCylinder(boat, 0.035, 0.035, 2.5, M.cream, 0.18, 0.4, 0, 5, false);
// A seated boatman.
addCylinder(boat, 0.11, 0.15, 0.42, architecture.blue, 0, 0.55, 0.62, 6);
addSphere(boat, 0.13, M.darkWood, 0, 0.89, 0.62, 0);
// Subtle wake marks.
addBox(model, 2.8, 0.018, 0.07, M.paleStone, 9.8, 0.17, -0.25, false);
addBox(model, 2.2, 0.018, 0.055, M.paleStone, 10.1, 0.17, -0.55, false);
// -------------------------------------------------------------------------
// Labels projected from scene anchors
// -------------------------------------------------------------------------
const anchors = {
bridge: new THREE.Vector3(bridgeX, 6.15, 0.45),
river: new THREE.Vector3(9.7, 0.25, 0.0),
facades: new THREE.Vector3(7.3, 7.4, 12.8),
north: new THREE.Vector3(11.0, 1.6, -5.8)
};
const labelElements = [...document.querySelectorAll(".label")].map((element) => ({
element,
anchor: anchors[element.dataset.anchor]
}));
let labelsVisible = true;
function updateLabels() {
if (!labelsVisible) return;
const width = window.innerWidth;
const height = window.innerHeight;
for (const { element, anchor } of labelElements) {
const projected = anchor.clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.08 &&
Math.abs(projected.y) < 1.08;
element.style.opacity = visible ? "1" : "0";
element.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
}
}
document.querySelector("#toggle-labels").addEventListener("click", (event) => {
labelsVisible = !labelsVisible;
event.currentTarget.textContent = labelsVisible ? "Labels on" : "Labels off";
for (const { element } of labelElements) {
element.style.opacity = labelsVisible ? "1" : "0";
}
});
// -------------------------------------------------------------------------
// Direct HTML camera controls: orbit, pan, and zoom
// -------------------------------------------------------------------------
function resetView() {
controls.target.set(0, 2.0, 2.0);
controls.yaw = 0.73;
controls.pitch = 0.69;
controls.radius = 57;
camera.zoom = 1;
camera.updateProjectionMatrix();
updateCamera();
}
document.querySelector("#reset-view").addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
canvas.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.panning = event.shiftKey || event.button === 2;
controls.previousX = event.clientX;
controls.previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.previousX;
const dy = event.clientY - controls.previousY;
controls.previousX = event.clientX;
controls.previousY = event.clientY;
if (controls.panning) {
const scale = 0.025 / camera.zoom;
const right = new THREE.Vector3();
const forward = new THREE.Vector3();
camera.matrixWorld.extractBasis(right, forward, new THREE.Vector3());
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(forward, dy * scale);
} else {
controls.yaw -= dx * 0.006;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.005,
0.32,
1.27
);
}
updateCamera();
});
function endPointer(event) {
controls.dragging = false;
controls.panning = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
const factor = Math.exp(-event.deltaY * 0.001);
camera.zoom = THREE.MathUtils.clamp(
camera.zoom * factor,
0.62,
2.4
);
camera.updateProjectionMatrix();
}, { passive: false });
// Pinch zoom for touch devices.
let pinchDistance = null;
canvas.addEventListener("touchstart", (event) => {
if (event.touches.length === 2) {
const a = event.touches[0];
const b = event.touches[1];
pinchDistance = Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);
}
}, { passive: true });
canvas.addEventListener("touchmove", (event) => {
if (event.touches.length === 2 && pinchDistance) {
event.preventDefault();
const a = event.touches[0];
const b = event.touches[1];
const distance = Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);
camera.zoom = THREE.MathUtils.clamp(
camera.zoom * (distance / pinchDistance),
0.62,
2.4
);
camera.updateProjectionMatrix();
pinchDistance = distance;
}
}, { passive: false });
canvas.addEventListener("touchend", () => {
pinchDistance = null;
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
const animationClock = new THREE.Clock();
function animate() {
const elapsed = animationClock.getElapsedTime();
// Gentle motion keeps the water scene alive without breaking the low-poly style.
boat.position.y = 0.16 + Math.sin(elapsed * 0.72) * 0.035;
boat.rotation.z = Math.sin(elapsed * 0.51) * 0.012;
water.position.y = 0.05 + Math.sin(elapsed * 0.33) * 0.012;
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```