Prompt specification
Build or customize the Three.js 3D scene "Canal Saint-Martin lock-and-street block" 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: Canal Saint-Martin lock-and-street block
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/canal-saint-martin-lock-and-street-block-x2851
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Canal Saint-Martin in Paris. Build a bounded voxel scene with a referenced lock, footbridge, tree-lined quay, and selected facades. Make the canal's level change readable within the compact urban setting. Voxel style.
Working Three.js Starter (canal-saint-martin-lock-and-street-block-x2851):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canal Saint-Martin — Voxel Diorama</title>
<style>
:root {
--ink: #243638;
--paper: #f3eddf;
--accent: #d7673f;
--water: #4b96a5;
--lower: #285e73;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8d2c4;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
canvas:active {
cursor: grabbing;
}
#hud {
position: fixed;
z-index: 5;
top: 24px;
left: 26px;
width: min(340px, calc(100vw - 52px));
padding: 18px 20px 17px;
background: rgba(247, 242, 230, 0.92);
border: 1px solid rgba(36, 54, 56, 0.14);
border-left: 5px solid var(--accent);
box-shadow: 0 12px 35px rgba(43, 49, 44, 0.13);
backdrop-filter: blur(8px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: #9c492f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 4vw, 36px);
font-weight: 600;
line-height: 0.98;
letter-spacing: -0.035em;
}
#hud p {
margin: 9px 0 14px;
color: #586867;
font-size: 12px;
line-height: 1.5;
}
.levels {
display: grid;
gap: 7px;
padding-top: 11px;
border-top: 1px solid rgba(36, 54, 56, 0.13);
}
.level {
display: grid;
grid-template-columns: 12px 1fr auto;
gap: 8px;
align-items: center;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.swatch {
width: 12px;
height: 12px;
background: var(--water);
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.swatch.lower {
background: var(--lower);
}
.level span:last-child {
color: #6c7774;
font-variant-numeric: tabular-nums;
}
#help {
position: fixed;
z-index: 5;
right: 22px;
bottom: 18px;
padding: 8px 11px;
color: rgba(36, 54, 56, 0.76);
background: rgba(247, 242, 230, 0.72);
border: 1px solid rgba(36, 54, 56, 0.1);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #d8d2c4;
color: #40514f;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 600px) {
#hud {
top: 12px;
left: 12px;
width: min(290px, calc(100vw - 24px));
padding: 13px 15px;
}
#hud p {
margin-bottom: 9px;
}
.levels {
gap: 5px;
}
#help {
right: 10px;
bottom: 10px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="loading">Building the canal…</div>
<aside id="hud">
<div class="eyebrow">Paris · 10e arrondissement</div>
<h1>Canal Saint-Martin</h1>
<p>
A bounded voxel interpretation of the lock at Bassin de la Villette,
its arched pedestrian bridge, tree-lined quays and canal-side facades.
</p>
<div class="levels">
<div class="level">
<i class="swatch"></i>
<span>Upper basin / lock chamber</span>
<span>+0.35 m</span>
</div>
<div class="level">
<i class="swatch lower"></i>
<span>Lower basin</span>
<span>−0.70 m</span>
</div>
</div>
</aside>
<div id="help">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional voxel model of Canal Saint-Martin"
);
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d2c4);
scene.fog = new THREE.Fog(0xd8d2c4, 85, 150);
const camera = new THREE.OrthographicCamera(-30, 30, 19, -19, 0.1, 200);
const target = new THREE.Vector3(0, 1.0, 0);
const controlState = {
theta: 0.64,
phi: 0.91,
zoom: 1,
desiredTheta: 0.64,
desiredPhi: 0.91,
desiredZoom: 1
};
const radius = 58;
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true,
...options
});
const M = {
base: material(0x596460),
baseEdge: material(0x8b887c),
ground: material(0xc5bda9),
groundLight: material(0xd5ccb8),
groundDark: material(0xb5ad9c),
stone: material(0x9b9788),
stoneLight: material(0xb4ad9b),
stoneDark: material(0x767b72),
cream: material(0xd9cbb0),
creamLight: material(0xeee1c8),
peach: material(0xc99172),
brick: material(0x9c5845),
brickLight: material(0xb96b52),
roof: material(0x46545a),
roofLight: material(0x617075),
iron: material(0x29383a, { roughness: 0.48, metalness: 0.52 }),
wood: material(0x73513c),
woodLight: material(0x977052),
glass: material(0x294d5b, { roughness: 0.24, metalness: 0.18 }),
glassWarm: material(0x8e8b6d, { roughness: 0.36 }),
shutter: material(0x55766e),
trunk: material(0x68503a),
leaf: material(0x607c5b),
leafLight: material(0x789064),
leafDark: material(0x486650),
soil: material(0x615f4f),
upperWater: material(0x4b9baa, { roughness: 0.28, metalness: 0.06 }),
lockWater: material(0x3f8799, { roughness: 0.3, metalness: 0.05 }),
lowerWater: material(0x285e73, { roughness: 0.32, metalness: 0.05 }),
waterFace: material(0x286d82, { roughness: 0.3 }),
ripple: new THREE.MeshBasicMaterial({ color: 0xa9d1d2 }),
boatGreen: material(0x315e5b),
boatRed: material(0x9c4f3c),
skin: material(0xc89573),
yellow: material(0xd0a449),
lamp: material(0xf1dca0, {
emissive: 0xe4b95c,
emissiveIntensity: 0.65,
roughness: 0.4
})
};
let seed = 1729;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function box(w, h, d, x, y, z, mat, options = {}) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
scene.add(mesh);
return mesh;
}
function addInstances(items, mat, castShadow = true) {
if (!items.length) return null;
const mesh = new THREE.InstancedMesh(unitBox, mat, items.length);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
items.forEach((item, index) => {
dummy.position.set(item.x, item.y, item.z);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(item.w, item.h, item.d);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
if (item.color !== undefined) {
color.set(item.color);
mesh.setColorAt(index, color);
}
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
const masonry = [];
const pavers = [];
function masonryBlock(w, h, d, x, y, z, color) {
masonry.push({ w, h, d, x, y, z, color });
}
function addWallRun(x0, x1, z, bottom, top, rows) {
const rowHeight = (top - bottom) / rows;
const blockWidth = 1.08;
const palette = [0xaaa391, 0x999783, 0xb4ac99, 0x8e9387];
for (let row = 0; row < rows; row++) {
let x = x0 - (row % 2 ? blockWidth * 0.5 : 0);
while (x < x1) {
const left = Math.max(x, x0);
const right = Math.min(x + blockWidth, x1);
if (right - left > 0.12) {
masonryBlock(
right - left - 0.025,
rowHeight - 0.025,
0.2,
(left + right) * 0.5,
bottom + rowHeight * (row + 0.5),
z,
palette[Math.floor(random() * palette.length)]
);
}
x += blockWidth;
}
}
}
function addPaver(x, y, z, w = 0.48, d = 0.3) {
const palette = [0xb5aa95, 0xc0b49c, 0xa9a18f, 0xc9bda4];
pavers.push({
x,
y,
z,
w,
h: 0.065,
d,
color: palette[Math.floor(random() * palette.length)]
});
}
function plaqueTexture(lines, accent = "#d7673f") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 512;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#293c3d";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, canvas.width, 24);
ctx.fillRect(0, canvas.height - 20, canvas.width, 20);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#f2ead9";
if (lines.length === 1) {
ctx.font = "700 82px Georgia, serif";
ctx.fillText(lines[0], 512, 245);
} else {
ctx.font = "700 70px Georgia, serif";
ctx.fillText(lines[0], 512, 155);
ctx.fillStyle = "#cbd6ce";
ctx.font = "700 44px system-ui, sans-serif";
for (let i = 1; i < lines.length; i++) {
ctx.fillText(lines[i], 512, 260 + (i - 1) * 82);
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function addPlaque(lines, w, h, x, y, z, rotationY = 0, accent) {
const mat = new THREE.MeshBasicMaterial({
map: plaqueTexture(lines, accent),
side: THREE.DoubleSide,
toneMapped: false
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(w, h), mat);
mesh.position.set(x, y, z);
mesh.rotation.y = rotationY;
scene.add(mesh);
return mesh;
}
// Lighting.
scene.add(new THREE.HemisphereLight(0xf4eddb, 0x5e6964, 2.15));
const sunlight = new THREE.DirectionalLight(0xfff0cf, 3.15);
sunlight.position.set(19, 34, 24);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -35;
sunlight.shadow.camera.right = 35;
sunlight.shadow.camera.top = 35;
sunlight.shadow.camera.bottom = -35;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 95;
sunlight.shadow.bias = -0.00035;
sunlight.shadow.normalBias = 0.035;
scene.add(sunlight);
const fill = new THREE.DirectionalLight(0x9fc7d0, 0.65);
fill.position.set(-25, 13, -18);
scene.add(fill);
// Neutral shadow floor beneath the finite model.
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(150, 150),
material(0xd8d2c4, { roughness: 1 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.73;
floor.receiveShadow = true;
scene.add(floor);
// Bounded diorama base.
box(44, 1.2, 28, 0, -2.1, 0, M.base);
box(43.65, 0.18, 27.65, 0, -1.41, 0, M.baseEdge);
const baseEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(new THREE.BoxGeometry(44, 1.2, 28)),
new THREE.LineBasicMaterial({ color: 0x3f504d, transparent: true, opacity: 0.45 })
);
baseEdges.position.y = -2.1;
scene.add(baseEdges);
// Canal beds and land masses.
box(26.6, 0.22, 7.0, -8.15, -1.17, 0, M.stoneDark);
box(8.5, 0.22, 7.0, 9.25, -1.17, 0, M.stoneDark);
box(8.0, 0.22, 7.0, 17.5, -1.34, 0, M.stoneDark);
// Upper quays, lock chamber banks and lower quays.
for (const side of [-1, 1]) {
box(27, 2.1, 10.5, -8.5, -0.25, side * 8.75, M.ground);
box(8.5, 2.1, 10.5, 9.25, -0.25, side * 8.75, M.groundLight);
box(8.5, 1.05, 10.5, 17.75, -0.775, side * 8.75, M.groundDark);
}
// Distinct water surfaces make the level change explicit.
box(26.4, 0.18, 6.62, -8.2, 0.26, 0, M.upperWater, { cast: false });
box(8.25, 0.18, 6.62, 9.16, 0.26, 0, M.lockWater, { cast: false });
box(7.9, 0.18, 6.62, 17.45, -0.81, 0, M.lowerWater, { cast: false });
// The visible blue face between the two levels.
box(0.16, 1.07, 6.62, 13.43, -0.175, 0, M.waterFace, { cast: false });
// Masonry revetments.
for (const side of [-1, 1]) {
addWallRun(-21.45, 5.0, side * 3.4, -1.06, 0.8, 4);
addWallRun(5.0, 13.45, side * 3.4, -1.06, 0.8, 4);
addWallRun(13.55, 21.45, side * 3.4, -1.23, -0.25, 2);
}
// Steps from the upper lock quay down toward the lower basin.
for (const side of [-1, 1]) {
for (let i = 0; i < 4; i++) {
const top = 0.64 - i * 0.28;
const height = top + 0.25;
box(
0.56,
height,
4.25,
13.78 + i * 0.56,
-0.25 + height * 0.5,
side * 5.65,
i % 2 ? M.stoneLight : M.stone
);
}
}
// Cobbled promenade.
for (const side of [-1, 1]) {
for (let x = -21.2; x < 21.5; x += 0.72) {
const groundY = x < 13.5 ? 0.8 : -0.25;
if (x > 13.25 && x < 15.75) continue;
for (const lane of [4.55, 5.18]) {
const jitter = (random() - 0.5) * 0.13;
addPaver(
x + jitter,
groundY + 0.025,
side * lane + (random() - 0.5) * 0.12,
0.42 + random() * 0.17,
0.27 + random() * 0.09
);
}
}
}
addInstances(
masonry,
material(0xffffff, { roughness: 0.93 }),
true
);
addInstances(pavers, material(0xffffff, { roughness: 0.95 }), false);
function makeGate(x, raised = false) {
const postHeight = 2.35;
const postY = 0.83;
for (const z of [-3.14, 3.14]) {
box(0.34, postHeight, 0.4, x, postY, z, M.iron);
box(0.58, 0.32, 0.65, x, 1.94, z, M.stoneDark);
}
box(0.4, 0.28, 6.72, x, 1.99, 0, M.iron);
const panelBottom = raised ? 0.47 : -0.55;
const panelTop = raised ? 1.65 : 1.52;
const panelHeight = panelTop - panelBottom;
const panelY = (panelTop + panelBottom) * 0.5;
for (let z = -2.88; z <= 2.89; z += 0.48) {
box(0.2, panelHeight, 0.43, x, panelY, z, raised ? M.woodLight : M.wood);
}
for (const y of [panelBottom + 0.16, panelTop - 0.16]) {
box(0.29, 0.13, 6.15, x, y, 0, M.iron);
}
box(0.45, 0.24, 0.3, x, 2.22, 0, M.yellow);
}
makeGate(5.08, false);
makeGate(13.45, true);
// Arched Passerelle-style footbridge.
const bridgeX = 9.2;
const bridgeDeckY = 2.25;
for (const z of [-3.42, 3.42]) {
box(2.55, 1.45, 0.72, bridgeX, 0.88, z, M.stoneLight);
box(2.75, 0.28, 0.86, bridgeX, 1.66, z, M.stone);
}
const archRadiusZ = 3.0;
const archRadiusY = 1.72;
const archCenterY = 0.26;
for (let i = 0; i <= 13; i++) {
const theta = (i / 13) * Math.PI;
const z = Math.cos(theta) * archRadiusZ;
const y = archCenterY + Math.sin(theta) * archRadiusY;
const rotationX = -theta - Math.PI / 2;
box(
2.18,
0.48,
0.66,
bridgeX,
y,
z,
i % 2 ? M.stoneLight : M.stone,
{ rotation: [rotationX, 0, 0] }
);
}
box(2.42, 0.34, 8.42, bridgeX, bridgeDeckY, 0, M.stoneLight);
for (let z = -3.95; z <= 3.95; z += 0.52) {
box(2.15, 0.1, 0.46, bridgeX, bridgeDeckY + 0.21, z, M.groundLight);
}
for (const side of [-1, 1]) {
const railX = bridgeX + side * 1.12;
box(0.12, 0.12, 8.35, railX, 3.27, 0, M.iron);
for (let z = -4.05; z <= 4.05; z += 0.72) {
box(0.12, 0.9, 0.12, railX, 2.83, z, M.iron);
}
}
addPlaque(
["PASSERELLE", "CANAL SAINT-MARTIN"],
2.85,
0.68,
bridgeX + 1.2,
2.93,
0.8,
Math.PI / 2,
"#d0a449"
);
// Staff gauge against the far side of the downstream gate.
box(0.18, 1.95, 0.16, 13.58, 0.24, -3.23, M.creamLight);
for (let i = 0; i < 8; i++) {
box(
0.32,
0.07,
0.09,
13.58,
-0.57 + i * 0.22,
-3.12,
i % 2 ? M.stoneDark : M.upperWater
);
}
// Small interpretive board beside the lock.
box(0.12, 1.4, 0.12, 10.35, 1.25, 6.55, M.iron);
box(0.12, 1.4, 0.12, 12.35, 1.25, 6.55, M.iron);
addPlaque(
["ÉCLUSE", "HAUTE +0,35 m", "BASSE −0,70 m"],
3.65,
1.4,
11.35,
2.02,
6.64,
0,
"#d7673f"
);
// Water glints.
for (let i = 0; i < 65; i++) {
const lower = i > 47;
const x = lower ? 14.1 + random() * 6.8 : -20.7 + random() * 33.3;
const z = (random() - 0.5) * 5.65;
const y = lower ? -0.705 : 0.365;
const w = 0.35 + random() * 1.35;
box(w, 0.025, 0.065, x, y, z, M.ripple, {
cast: false,
receive: false
});
}
function tree(x, z, groundY, scale = 1, variant = 0) {
box(
0.36 * scale,
2.45 * scale,
0.36 * scale,
x,
groundY + 1.225 * scale,
z,
M.trunk
);
box(
1.95 * scale,
1.75 * scale,
1.85 * scale,
x,
groundY + 3.05 * scale,
z,
variant % 2 ? M.leafLight : M.leaf
);
box(
1.15 * scale,
1.08 * scale,
1.16 * scale,
x - 0.85 * scale,
groundY + 2.75 * scale,
z + 0.12 * scale,
M.leafDark
);
box(
1.03 * scale,
1.0 * scale,
1.05 * scale,
x + 0.88 * scale,
groundY + 3.1 * scale,
z - 0.05 * scale,
M.leafLight
);
box(
1.12 * scale,
0.9 * scale,
1.18 * scale,
x + 0.05 * scale,
groundY + 4.0 * scale,
z,
variant % 2 ? M.leafDark : M.leafLight
);
box(
2.35 * scale,
0.18 * scale,
2.2 * scale,
x,
groundY + 0.09 * scale,
z,
M.stoneDark
);
}
const treePositions = [
[-19.1, -6.25, 0.8, 1.0],
[-13.4, -6.1, 0.8, 0.92],
[-7.8, -6.2, 0.8, 1.04],
[-2.0, -6.15, 0.8, 0.95],
[16.2, -6.15, -0.25, 1.0],
[-19.2, 6.15, 0.8, 0.92],
[-13.5, 6.15, 0.8, 1.0],
[-7.7, 6.1, 0.8, 0.94],
[-1.9, 6.15, 0.8, 1.02],
[16.0, 6.05, -0.25, 0.96]
];
treePositions.forEach((item, index) => tree(...item, index));
function streetlamp(x, z, groundY) {
box(0.12, 3.15, 0.12, x, groundY + 1.58, z, M.iron);
box(0.72, 0.1, 0.12, x + 0.27, groundY + 3.13, z, M.iron);
box(0.42, 0.52, 0.42, x + 0.58, groundY + 2.87, z, M.lamp);
box(0.52, 0.1, 0.52, x + 0.58, groundY + 3.16, z, M.iron);
}
streetlamp(-20.2, -5.95, 0.8);
streetlamp(-10.5, -5.95, 0.8);
streetlamp(-4.7, 5.95, 0.8);
streetlamp(17.1, 5.9, -0.25);
function bollard(x, z, groundY) {
box(0.22, 0.54, 0.22, x, groundY + 0.27, z, M.iron);
box(0.32, 0.12, 0.32, x, groundY + 0.52, z, M.iron);
}
for (let x = -18; x <= 18; x += 4.5) {
const y = x < 13.5 ? 0.8 : -0.25;
bollard(x, 3.92, y);
bollard(x, -3.92, y);
}
function facade({
x,
z,
width,
depth,
height,
base,
floors,
columns,
bodyMaterial,
roofMaterial,
trimMaterial,
shutters = true,
balconies = false
}) {
box(width, height, depth, x, base + height * 0.5, z, bodyMaterial);
const frontZ = z + depth * 0.5;
const floorHeight = (height - 1.0) / floors;
const windowHeight = Math.min(1.25, floorHeight * 0.67);
const spacing = width / (columns + 1);
box(width + 0.22, 0.22, depth + 0.2, x, base + 0.13, z, trimMaterial);
for (let floor = 0; floor < floors; floor++) {
const windowY =
base + 0.78 + floor * floorHeight + floorHeight * 0.5;
for (let column = 0; column < columns; column++) {
const wx = x - width * 0.5 + spacing * (column + 1);
const isWarm = (floor + column + Math.round(x)) % 7 === 0;
const glassMaterial = isWarm ? M.glassWarm : M.glass;
box(
spacing * 0.72,
windowHeight + 0.22,
0.13,
wx,
windowY,
frontZ + 0.08,
trimMaterial
);
box(
spacing * 0.53,
windowHeight,
0.15,
wx,
windowY,
frontZ + 0.16,
glassMaterial
);
box(
0.07,
windowHeight,
0.16,
wx,
windowY,
frontZ + 0.25,
trimMaterial
);
if (shutters) {
for (const direction of [-1, 1]) {
box(
spacing * 0.21,
windowHeight + 0.08,
0.12,
wx + direction * spacing * 0.39,
windowY,
frontZ + 0.18,
M.shutter
);
}
}
if (balconies && floor > 0 && floor < floors - 1) {
const balconyY = windowY - windowHeight * 0.5 - 0.26;
box(
spacing * 1.03,
0.12,
0.68,
wx,
balconyY,
frontZ + 0.3,
M.iron
);
box(
spacing * 1.03,
0.08,
0.08,
wx,
balconyY + 0.47,
frontZ + 0.59,
M.iron
);
for (let r = -2; r <= 2; r++) {
box(
0.06,
0.46,
0.06,
wx + r * spacing * 0.19,
balconyY + 0.23,
frontZ + 0.59,
M.iron
);
}
}
}
box(
width + 0.08,
0.12,
0.18,
x,
base + 0.78 + (floor + 1) * floorHeight,
frontZ + 0.11,
trimMaterial
);
}
// Stepped voxel mansard roof.
box(width + 0.38, 0.42, depth + 0.34, x, base + height + 0.2, z, trimMaterial);
box(width - 0.18, 0.58, depth - 0.1, x, base + height + 0.63, z, roofMaterial);
box(width - 1.02, 0.72, depth - 0.82, x, base + height + 1.16, z, roofMaterial);
for (const direction of [-1, 1]) {
box(
0.65,
1.3,
0.72,
x + direction * width * 0.27,
base + height + 1.7,
z - 0.45,
M.brickLight
);
box(
0.82,
0.18,
0.88,
x + direction * width * 0.27,
base + height + 2.39,
z - 0.45,
M.stoneDark
);
}
return frontZ;
}
const haussmannFront = facade({
x: -15.1,
z: -10.55,
width: 7.2,
depth: 4.8,
height: 7.05,
base: 0.8,
floors: 4,
columns: 5,
bodyMaterial: M.cream,
roofMaterial: M.roof,
trimMaterial: M.creamLight,
shutters: true,
balconies: true
});
const warehouseFront = facade({
x: -7.35,
z: -10.5,
width: 6.25,
depth: 5.0,
height: 5.4,
base: 0.8,
floors: 3,
columns: 4,
bodyMaterial: M.brick,
roofMaterial: M.roofLight,
trimMaterial: M.stoneLight,
shutters: false,
balconies: false
});
facade({
x: 15.2,
z: -10.55,
width: 6.55,
depth: 4.9,
height: 7.0,
base: -0.25,
floors: 4,
columns: 5,
bodyMaterial: M.peach,
roofMaterial: M.roof,
trimMaterial: M.creamLight,
shutters: true,
balconies: true
});
addPlaque(
["MAISON DU CANAL", "1862"],
3.1,
0.92,
-7.35,
4.35,
warehouseFront + 0.24,
0,
"#d0a449"
);
// A low, red-brick canal warehouse frames the near-left corner.
box(6.25, 4.35, 4.3, -17.55, 2.975, 10.25, M.brick);
box(6.55, 0.25, 4.55, -17.55, 5.25, 10.25, M.stoneLight);
box(5.75, 0.58, 3.7, -17.55, 5.65, 10.25, M.roofLight);
box(5.0, 0.45, 3.1, -17.55, 6.1, 10.25, M.roof);
for (let i = 0; i < 4; i++) {
box(
0.82,
1.1,
0.12,
-19.75 + i * 1.45,
3.72,
8.03,
M.glass
);
box(
1.02,
1.3,
0.12,
-19.75 + i * 1.45,
3.72,
7.99,
M.brickLight
);
}
// Voxel canal boats.
function boat(x, z, waterY, hullMaterial, scale = 1) {
const s = scale;
box(3.6 * s, 0.42 * s, 1.16 * s, x, waterY + 0.03 * s, z, hullMaterial);
box(3.05 * s, 0.23 * s, 0.88 * s, x, waterY + 0.31 * s, z, M.woodLight);
box(0.72 * s, 0.33 * s, 0.78 * s, x + 1.96 * s, waterY + 0.03 * s, z, hullMaterial);
box(0.55 * s, 0.29 * s, 0.62 * s, x - 1.96 * s, waterY + 0.03 * s, z, hullMaterial);
box(1.75 * s, 0.72 * s, 0.88 * s, x - 0.22 * s, waterY + 0.72 * s, z, M.creamLight);
box(1.92 * s, 0.12 * s, 1.02 * s, x - 0.22 * s, waterY + 1.13 * s, z, M.iron);
for (const side of [-1, 1]) {
box(
0.52 * s,
0.35 * s,
0.08 * s,
x - 0.55 * s,
waterY + 0.79 * s,
z + side * 0.47 * s,
M.glass
);
box(
0.52 * s,
0.35 * s,
0.08 * s,
x + 0.32 * s,
waterY + 0.79 * s,
z + side * 0.47 * s,
M.glass
);
}
box(0.12 * s, 0.68 * s, 0.12 * s, x + 1.28 * s, waterY + 0.68 * s, z, M.iron);
}
boat(-9.9, 1.35, 0.35, M.boatGreen, 0.92);
boat(17.25, -1.25, -0.7, M.boatRed, 0.84);
// Small figures establish scale.
function person(x, z, groundY, coatMaterial, scale = 1) {
const s = scale;
box(0.32 * s, 0.62 * s, 0.25 * s, x, groundY + 0.91 * s, z, coatMaterial);
box(0.28 * s, 0.28 * s, 0.28 * s, x, groundY + 1.38 * s, z, M.skin);
box(0.12 * s, 0.55 * s, 0.14 * s, x - 0.09 * s, groundY + 0.28 * s, z, M.iron);
box(0.12 * s, 0.55 * s, 0.14 * s, x + 0.09 * s, groundY + 0.28 * s, z, M.iron);
}
person(-18.5, -5.55, 0.8, M.brickLight, 0.9);
person(-16.6, -5.5, 0.8, M.shutter, 0.86);
person(-3.8, -5.55, 0.8, M.yellow, 0.92);
person(15.6, -5.55, -0.25, M.boatRed, 0.9);
person(10.6, 5.65, 0.8, M.roofLight, 0.94);
person(9.65, 2.6, 2.48, M.brickLight, 0.9);
person(8.75, -1.1, 2.48, M.shutter, 0.86);
// Base title plaque.
addPlaque(
["CANAL SAINT-MARTIN", "PARIS · BASSIN DE LA VILLETTE"],
15.5,
0.92,
-8.1,
-2.05,
14.015,
0,
"#d7673f"
);
// Camera controls implemented directly, without Three.js addons.
function updateCamera() {
const sinPhi = Math.sin(controlState.phi);
camera.position.set(
target.x + radius * sinPhi * Math.cos(controlState.theta),
target.y + radius * Math.cos(controlState.phi),
target.z + radius * sinPhi * Math.sin(controlState.theta)
);
camera.lookAt(target);
camera.zoom = controlState.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(34, 54 / 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);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
let dragging = false;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
controlState.desiredTheta -= dx * 0.006;
controlState.desiredPhi = THREE.MathUtils.clamp(
controlState.desiredPhi + dy * 0.005,
0.36,
1.29
);
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controlState.desiredZoom = THREE.MathUtils.clamp(
controlState.desiredZoom * Math.exp(-event.deltaY * 0.001),
0.68,
1.85
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
controlState.desiredTheta = 0.64;
controlState.desiredPhi = 0.91;
controlState.desiredZoom = 1;
});
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") controlState.desiredTheta -= 0.1;
if (event.key === "ArrowRight") controlState.desiredTheta += 0.1;
if (event.key === "ArrowUp") {
controlState.desiredPhi = Math.max(0.36, controlState.desiredPhi - 0.08);
}
if (event.key === "ArrowDown") {
controlState.desiredPhi = Math.min(1.29, controlState.desiredPhi + 0.08);
}
if (event.key === "+" || event.key === "=") {
controlState.desiredZoom = Math.min(1.85, controlState.desiredZoom * 1.08);
}
if (event.key === "-") {
controlState.desiredZoom = Math.max(0.68, controlState.desiredZoom / 1.08);
}
});
window.addEventListener("resize", resize);
resize();
updateCamera();
function animate() {
requestAnimationFrame(animate);
controlState.theta +=
(controlState.desiredTheta - controlState.theta) * 0.09;
controlState.phi +=
(controlState.desiredPhi - controlState.phi) * 0.09;
controlState.zoom +=
(controlState.desiredZoom - controlState.zoom) * 0.1;
updateCamera();
renderer.render(scene, camera);
}
renderer.render(scene, camera);
document.getElementById("loading").classList.add("hidden");
animate();
</script>
</body>
</html>
```