Prompt specification
Build or customize the Three.js 3D scene "Old Montréal quay bollard and paving edge" 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: Old Montréal quay bollard and paving edge
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/old-montr-al-quay-bollard-and-paving-edge-x2761
Scene Description Prompt:
A voxel Old Montréal quay fragment with a mooring bollard, paving, and water boundary. Create standalone HTML using Three.js from cdnjs.
Working Three.js Starter (old-montr-al-quay-bollard-and-paving-edge-x2761):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Old Montréal — Voxel Quay</title>
<style>
:root {
color-scheme: light;
--ink: #23302f;
--paper: rgba(244, 241, 231, 0.9);
--accent: #a65238;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9d1cb;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.title-card {
position: fixed;
top: 24px;
left: 24px;
z-index: 10;
width: min(330px, calc(100vw - 48px));
padding: 18px 20px 17px;
color: var(--ink);
background: var(--paper);
border: 1px solid rgba(35, 48, 47, 0.12);
box-shadow: 0 12px 36px rgba(38, 53, 49, 0.13);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 2px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 42px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 10px 0 0;
color: #596460;
font-size: 12px;
line-height: 1.5;
}
.controls {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 10;
display: flex;
align-items: center;
gap: 14px;
padding: 9px 10px 9px 14px;
color: #35413e;
background: rgba(244, 241, 231, 0.84);
border: 1px solid rgba(35, 48, 47, 0.12);
box-shadow: 0 8px 28px rgba(38, 53, 49, 0.11);
backdrop-filter: blur(12px);
font-size: 11px;
user-select: none;
}
.controls span {
white-space: nowrap;
}
.controls b {
color: #7a817d;
font-weight: 700;
}
button {
padding: 7px 10px;
color: #f5f1e7;
background: #2e3c39;
border: 0;
border-radius: 2px;
cursor: pointer;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: background 160ms ease, transform 160ms ease;
}
button:hover {
background: #a65238;
}
button:active {
transform: translateY(1px);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
color: #41504c;
background: #c9d1cb;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 450ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 640px) {
.title-card {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
.subtitle {
display: none;
}
.controls {
right: 14px;
bottom: 14px;
left: 14px;
justify-content: space-between;
gap: 8px;
}
.controls span {
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>
</head>
<body>
<div id="loading">Assembling the quay…</div>
<header class="title-card">
<div class="eyebrow">Quay fragment · Montréal</div>
<h1>Old Montréal</h1>
<p class="subtitle">
Weathered granite, cast iron, and the blue edge of the St. Lawrence.
</p>
</header>
<nav class="controls" aria-label="Scene controls">
<span><b>Drag</b> orbit · <b>Shift-drag</b> pan · <b>Scroll</b> zoom</span>
<button id="reset" type="button">Reset view</button>
</nav>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc9d1cb);
scene.fog = new THREE.Fog(0xc9d1cb, 19, 38);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel model of an old Montréal quay"
);
document.body.prepend(renderer.domElement);
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xe8f1e9, 0x5a5145, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d3, 3.25);
sun.position.set(-7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0004;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9fc4d4, 0.8);
fill.position.set(8, 5, -7);
scene.add(fill);
// -------------------------------------------------------------------------
// Shared helpers
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const world = new THREE.Group();
scene.add(world);
function material(color, roughness = 0.9, metalness = 0) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: true
});
}
function addBox(
parent,
size,
position,
mat,
{ cast = true, receive = true } = {}
) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
parent.add(mesh);
return mesh;
}
function seededRandom(seed) {
let value = seed >>> 0;
return function () {
value += 0x6d2b79f5;
let t = value;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const random = seededRandom(1847);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const plinthMaterial = material(0x2c4245, 0.88);
const coreMaterial = material(0x4a504c, 0.96);
const jointMaterial = material(0x555b55, 1);
const stoneMaterials = [
material(0x777a70),
material(0x85877a),
material(0x6e756e),
material(0x8c8c7d),
material(0x747a70),
material(0x939184)
];
const pavingMaterials = [
material(0x8d9187),
material(0x96998e),
material(0x7f877f),
material(0xa09d8e),
material(0x8b8b80),
material(0x777f7a)
];
const curbMaterial = material(0xa5a498, 0.94);
const darkIron = material(0x293231, 0.72, 0.35);
const ironEdge = material(0x3d4845, 0.68, 0.38);
const rustMaterial = material(0x86523a, 0.96, 0.08);
const timberMaterial = material(0x5b4637, 0.98);
const timberLight = material(0x735842, 0.97);
const ropeMaterial = material(0xb09a70, 0.98);
const algaeMaterial = material(0x52664c, 1);
const darkAlgaeMaterial = material(0x3e5544, 1);
// -------------------------------------------------------------------------
// Diorama base and water volume
// -------------------------------------------------------------------------
addBox(
world,
[10.8, 0.35, 9.6],
[0, -1.66, -0.04],
plinthMaterial
);
addBox(
world,
[10.3, 0.68, 4.45],
[0, -1.16, 2.30],
material(0x244d5b, 0.62, 0.08)
);
// Large stone core beneath the paving.
addBox(
world,
[10.3, 2.05, 4.55],
[0, -0.48, -2.22],
coreMaterial
);
// -------------------------------------------------------------------------
// Voxel masonry along the water-facing quay wall
// -------------------------------------------------------------------------
const wallRows = [-1.25, -0.75, -0.25, 0.25];
wallRows.forEach((y, rowIndex) => {
let x = -5.08;
let blockIndex = 0;
const widths = [0.72, 0.92, 1.16, 0.66, 1.04, 0.81, 1.22];
while (x < 5.02) {
const width = Math.min(
widths[(blockIndex + rowIndex * 2) % widths.length],
5.08 - x
);
if (width < 0.16) break;
const mat = stoneMaterials[
(blockIndex * 3 + rowIndex) % stoneMaterials.length
];
addBox(
world,
[Math.max(0.08, width - 0.025), 0.455, 0.23],
[x + width / 2, y, 0.145],
mat
);
x += width;
blockIndex++;
}
});
// Exposed side masonry on both ends of the fragment.
[-5.08, 5.08].forEach((x, sideIndex) => {
wallRows.forEach((y, rowIndex) => {
for (let z = -4.08; z < -0.05; z += 0.88) {
const depth = Math.min(0.84, -0.05 - z);
if (depth < 0.12) continue;
const mat = stoneMaterials[
(rowIndex + sideIndex + Math.round(Math.abs(z))) %
stoneMaterials.length
];
addBox(
world,
[0.23, 0.455, depth - 0.025],
[x, y, z + depth / 2],
mat
);
}
});
});
// Irregular moss and mineral staining at the waterline.
for (let i = 0; i < 24; i++) {
const x = -4.8 + random() * 9.6;
const y = -0.86 + random() * 0.3;
const width = 0.12 + random() * 0.44;
const height = 0.06 + random() * 0.13;
addBox(
world,
[width, height, 0.025],
[x, y, 0.273],
i % 3 === 0 ? darkAlgaeMaterial : algaeMaterial,
{ cast: false }
);
}
// -------------------------------------------------------------------------
// Cobbled paving
// -------------------------------------------------------------------------
const pavingRows = 6;
const pavingColumns = 11;
for (let row = 0; row < pavingRows; row++) {
for (let column = 0; column < pavingColumns; column++) {
const x = -4.45 + column * 0.89;
const z = -4.05 + row * 0.75;
let width = 0.84;
let depth = 0.69;
// A few larger replacement stones.
if ((row === 1 && column === 8) || (row === 4 && column === 2)) {
width = 0.86;
depth = 0.70;
}
const mat = pavingMaterials[
(row * 2 + column * 3 + Math.floor(random() * 3)) %
pavingMaterials.length
];
addBox(
world,
[width, 0.14, depth],
[x, 0.59, z],
mat
);
}
}
// Granite curb blocks define the edge of the quay.
for (let i = 0; i < 14; i++) {
const width = 10.15 / 14;
const x = -5.075 + width * (i + 0.5);
addBox(
world,
[width - 0.025, 0.22, 0.34],
[x, 0.60, 0.16],
i % 4 === 0 ? stoneMaterials[5] : curbMaterial
);
}
// Drain slots set into the paving near the edge.
for (let i = 0; i < 6; i++) {
addBox(
world,
[0.055, 0.018, 0.23],
[-2.15 + i * 0.09, 0.67, -0.03],
jointMaterial,
{ cast: false }
);
}
// -------------------------------------------------------------------------
// Water: instanced, subtly animated voxel cells
// -------------------------------------------------------------------------
const waterColumns = 12;
const waterRows = 9;
const waterCount = waterColumns * waterRows;
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.3,
metalness: 0.12,
flatShading: true
});
const waterCells = new THREE.InstancedMesh(
unitBox,
waterMaterial,
waterCount
);
waterCells.castShadow = false;
waterCells.receiveShadow = true;
waterCells.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
world.add(waterCells);
const dummy = new THREE.Object3D();
const waterColor = new THREE.Color();
const waterPalette = [
0x397b8c,
0x3f8795,
0x4b929c,
0x327185,
0x559ba2,
0x438492
];
const waterData = [];
for (let row = 0; row < waterRows; row++) {
for (let column = 0; column < waterColumns; column++) {
const x = -4.675 + column * 0.85;
const z = 0.49 + row * 0.47;
const phase = random() * Math.PI * 2;
waterData.push({ x, z, phase });
waterColor.setHex(
waterPalette[
(row + column * 2 + Math.floor(random() * 3)) %
waterPalette.length
]
);
waterCells.setColorAt(waterData.length - 1, waterColor);
}
}
waterCells.instanceColor.needsUpdate = true;
function updateWater(time) {
waterData.forEach((cell, index) => {
const wave =
Math.sin(time * 1.35 + cell.phase) * 0.018 +
Math.sin(time * 0.72 + cell.x * 0.7 + cell.z * 0.45) * 0.01;
dummy.position.set(cell.x, -0.78 + wave, cell.z);
dummy.scale.set(0.82, 0.085, 0.435);
dummy.rotation.set(0, 0, 0);
dummy.updateMatrix();
waterCells.setMatrixAt(index, dummy.matrix);
});
waterCells.instanceMatrix.needsUpdate = true;
}
// Pale broken reflections close to the masonry edge.
const foamMaterial = new THREE.MeshStandardMaterial({
color: 0xbad6d3,
roughness: 0.5,
transparent: true,
opacity: 0.72
});
for (let i = 0; i < 19; i++) {
const width = 0.12 + random() * 0.32;
addBox(
world,
[width, 0.022, 0.035],
[-4.7 + random() * 9.4, -0.715, 0.38 + random() * 0.1],
foamMaterial,
{ cast: false }
);
}
// A few scattered glints farther into the water.
const glintMaterial = new THREE.MeshStandardMaterial({
color: 0x8fc5c4,
roughness: 0.45,
transparent: true,
opacity: 0.58
});
for (let i = 0; i < 24; i++) {
addBox(
world,
[0.15 + random() * 0.35, 0.018, 0.035],
[-4.4 + random() * 8.8, -0.70, 0.8 + random() * 3.45],
glintMaterial,
{ cast: false }
);
}
// -------------------------------------------------------------------------
// Cast-iron mooring bollard
// -------------------------------------------------------------------------
const bollard = new THREE.Group();
bollard.position.set(1.7, 0.67, -0.29);
world.add(bollard);
addBox(bollard, [0.78, 0.13, 0.72], [0, 0.065, 0], darkIron);
addBox(bollard, [0.58, 0.14, 0.54], [0, 0.19, 0], ironEdge);
addBox(bollard, [0.34, 0.64, 0.34], [0, 0.56, 0], darkIron);
addBox(bollard, [0.54, 0.13, 0.50], [0, 0.92, 0], ironEdge);
addBox(bollard, [0.68, 0.18, 0.62], [0, 1.075, 0], darkIron);
addBox(bollard, [0.50, 0.07, 0.46], [0, 1.20, 0], ironEdge);
// Cast seams and small areas of worn rust.
addBox(
bollard,
[0.055, 0.34, 0.012],
[0.173, 0.56, 0.166],
rustMaterial,
{ cast: false }
);
addBox(
bollard,
[0.12, 0.045, 0.012],
[-0.16, 0.31, 0.176],
rustMaterial,
{ cast: false }
);
addBox(
bollard,
[0.06, 0.045, 0.012],
[0.19, 1.08, 0.312],
rustMaterial,
{ cast: false }
);
// Square coil of old rope beside the bollard.
const ropeSegments = [
[0.56, 0.10, 0.08, -0.26],
[0.42, 0.10, 0.08, -0.47],
[0.08, 0.10, 0.30, -0.60],
[0.36, 0.10, 0.08, -0.73],
[0.62, 0.10, 0.08, -0.73],
[0.08, 0.10, 0.26, -0.61],
[0.08, 0.10, 0.15, -0.39],
[0.25, 0.10, 0.08, -0.26],
[0.08, 0.10, 0.10, -0.34]
];
ropeSegments.forEach(([x, w, h, z]) => {
addBox(
world,
[w, h, 0.075],
[0.55 + x, 0.70, z],
ropeMaterial
);
});
// -------------------------------------------------------------------------
// Weathered timber rubbing posts at the quay edge
// -------------------------------------------------------------------------
[-3.45, -3.08, -2.71].forEach((x, index) => {
addBox(
world,
[0.19, 1.08, 0.22],
[x, -0.13, 0.32],
index === 1 ? timberLight : timberMaterial
);
});
addBox(
world,
[1.15, 0.16, 0.17],
[-3.08, 0.27, 0.32],
timberLight
);
// -------------------------------------------------------------------------
// Ground and shadows
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(80, 80),
material(0xc9d1cb, 1)
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -1.845;
ground.receiveShadow = true;
scene.add(ground);
// -------------------------------------------------------------------------
// Camera controls implemented without Three.js addons
// -------------------------------------------------------------------------
const initialTarget = new THREE.Vector3(0, -0.28, -0.02);
const initialRadius = 12.8;
const initialTheta = 0.66;
const initialPhi = 0.91;
const target = initialTarget.clone();
let radius = initialRadius;
let theta = initialTheta;
let phi = initialPhi;
const pointers = new Map();
let activePointer = null;
let panMode = false;
let previousPinchDistance = 0;
let previousPinchCenter = new THREE.Vector2();
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
camera.updateMatrixWorld();
}
function resetCamera() {
target.copy(initialTarget);
radius = initialRadius;
theta = initialTheta;
phi = initialPhi;
updateCamera();
}
function rotateCamera(deltaX, deltaY) {
theta -= deltaX * 0.006;
phi = THREE.MathUtils.clamp(phi + deltaY * 0.005, 0.3, 1.38);
}
function panCamera(deltaX, deltaY) {
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
0
);
const cameraUp = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
1
);
const panScale = radius * 0.00115;
target.addScaledVector(right, -deltaX * panScale);
target.addScaledVector(cameraUp, deltaY * panScale);
target.x = THREE.MathUtils.clamp(target.x, -5, 5);
target.y = THREE.MathUtils.clamp(target.y, -1.5, 1.5);
target.z = THREE.MathUtils.clamp(target.z, -4, 4);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
activePointer = event.pointerId;
panMode =
event.button === 1 ||
event.button === 2 ||
event.shiftKey ||
event.altKey;
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(
a.x - b.x,
a.y - b.y
);
previousPinchCenter.set(
(a.x + b.x) / 2,
(a.y + b.y) / 2
);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1 && event.pointerId === activePointer) {
const deltaX = event.clientX - previous.x;
const deltaY = event.clientY - previous.y;
if (panMode) {
panCamera(deltaX, deltaY);
} else {
rotateCamera(deltaX, deltaY);
}
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
const center = new THREE.Vector2(
(a.x + b.x) / 2,
(a.y + b.y) / 2
);
if (previousPinchDistance > 0) {
radius = THREE.MathUtils.clamp(
radius * (previousPinchDistance / Math.max(distance, 1)),
7,
20
);
}
panCamera(
center.x - previousPinchCenter.x,
center.y - previousPinchCenter.y
);
previousPinchDistance = distance;
previousPinchCenter.copy(center);
}
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (activePointer === event.pointerId) {
activePointer = null;
}
if (pointers.size < 2) {
previousPinchDistance = 0;
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
7,
20
);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset").addEventListener("click", resetCamera);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let firstFrame = true;
function animate() {
const elapsed = clock.getElapsedTime();
updateWater(elapsed);
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
document.getElementById("loading").classList.add("hidden");
}
}
updateCamera();
updateWater(0);
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```