Prompt specification
Build or customize the Three.js 3D scene "Helsinki market canopy and quay 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: Helsinki market canopy and quay edge
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/helsinki-market-canopy-and-quay-edge-x2833
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Helsinki's waterfront Market Square. Build a referenced market canopy fragment beside a quay edge and bollard. Show the temporary stall structure separately from permanent waterfront paving and mooring infrastructure. Low-poly.
Working Three.js Starter (helsinki-market-canopy-and-quay-edge-x2833):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Helsinki Market Square — Waterfront Study</title>
<style>
:root {
--ink: #18313a;
--muted: #536c74;
--paper: rgba(250, 247, 238, 0.9);
--temporary: #c94f45;
--permanent: #356575;
--context: #8e7958;
--line: rgba(24, 49, 58, 0.17);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9d9e5;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#viewport,
#viewport canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
#viewport canvas {
touch-action: none;
outline: none;
}
.title-card {
position: fixed;
z-index: 5;
top: 22px;
left: 22px;
width: min(410px, calc(100vw - 44px));
padding: 17px 19px 16px;
border: 1px solid var(--line);
border-radius: 14px;
background: var(--paper);
box-shadow: 0 14px 38px rgba(26, 53, 61, 0.12);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 6px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 3.3vw, 38px);
font-weight: 500;
line-height: 1.05;
letter-spacing: -0.025em;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.panel {
position: fixed;
z-index: 6;
border: 1px solid var(--line);
border-radius: 13px;
background: var(--paper);
box-shadow: 0 12px 34px rgba(26, 53, 61, 0.11);
backdrop-filter: blur(12px);
}
.controls {
top: 22px;
right: 22px;
width: 210px;
padding: 13px;
}
.controls h2,
.legend h2 {
margin: 0 0 10px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
button {
min-height: 34px;
border: 1px solid rgba(24, 49, 58, 0.18);
border-radius: 8px;
background: rgba(255, 255, 255, 0.58);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
}
button:hover {
background: #fff;
}
button:focus-visible,
input:focus-visible {
outline: 2px solid #3a8198;
outline-offset: 2px;
}
.divider {
height: 1px;
margin: 12px 0 10px;
background: var(--line);
}
.layer {
display: flex;
align-items: center;
gap: 8px;
margin: 8px 0;
color: #304a52;
font-size: 11px;
cursor: pointer;
user-select: none;
}
.layer input {
width: 14px;
height: 14px;
margin: 0;
accent-color: var(--ink);
}
.swatch {
width: 8px;
height: 8px;
border-radius: 50%;
}
.swatch.temporary {
background: var(--temporary);
}
.swatch.permanent {
background: var(--permanent);
}
.swatch.context {
background: var(--context);
}
.legend {
left: 22px;
bottom: 22px;
width: 250px;
padding: 13px 15px;
}
.legend-row {
display: grid;
grid-template-columns: 10px 1fr;
gap: 8px;
margin: 8px 0;
font-size: 11px;
line-height: 1.35;
}
.legend-row strong {
display: block;
font-size: 11px;
}
.legend-row small {
color: var(--muted);
font-size: 10px;
}
.hint {
position: fixed;
z-index: 5;
right: 24px;
bottom: 18px;
color: rgba(24, 49, 58, 0.72);
font-size: 10px;
text-align: right;
pointer-events: none;
text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}
.callout {
position: fixed;
z-index: 4;
min-width: 145px;
max-width: 210px;
padding: 8px 10px 8px 11px;
border: 1px solid rgba(24, 49, 58, 0.2);
border-left: 3px solid var(--permanent);
border-radius: 7px;
background: rgba(250, 247, 238, 0.94);
box-shadow: 0 7px 20px rgba(26, 53, 61, 0.12);
pointer-events: none;
transform: translate(-50%, -100%);
transition: opacity 120ms ease;
}
.callout::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 19px;
background: currentColor;
opacity: 0.55;
}
.callout strong {
display: block;
font-size: 10px;
line-height: 1.2;
}
.callout small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
line-height: 1.35;
}
.callout.temporary {
border-left-color: var(--temporary);
color: var(--temporary);
}
.callout.permanent {
border-left-color: var(--permanent);
color: var(--permanent);
}
.callout.context {
border-left-color: var(--context);
color: var(--context);
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #b9d9e5;
color: var(--ink);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 400ms ease;
pointer-events: none;
}
.loading.hidden {
opacity: 0;
}
@media (max-width: 700px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
.subtitle {
display: none;
}
.controls {
top: auto;
right: 12px;
bottom: 12px;
width: 190px;
}
.legend,
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<header class="title-card">
<div class="eyebrow">60°10′ N · 24°57′ E · Kauppatori</div>
<h1>Helsinki Market Square</h1>
<p class="subtitle">
A low-poly waterfront study separating a temporary red-and-cream
market canopy fragment from the permanent stone quay and mooring edge.
</p>
</header>
<aside class="panel controls" aria-label="Scene controls">
<h2>View</h2>
<div class="button-row">
<button id="resetView" type="button">Reset</button>
<button id="topView" type="button">Plan view</button>
</div>
<div class="divider"></div>
<h2>Model layers</h2>
<label class="layer">
<input id="temporaryLayer" type="checkbox" checked>
<span class="swatch temporary"></span>
Temporary market canopy
</label>
<label class="layer">
<input id="permanentLayer" type="checkbox" checked>
<span class="swatch permanent"></span>
Permanent quay & mooring
</label>
<label class="layer">
<input id="contextLayer" type="checkbox" checked>
<span class="swatch context"></span>
Market Hall context
</label>
<div class="divider"></div>
<div class="button-row">
<button id="motionButton" type="button">Pause water</button>
</div>
</aside>
<aside class="panel legend">
<h2>Structure key</h2>
<div class="legend-row">
<span class="swatch temporary"></span>
<span>
<strong>Temporary / removable</strong>
<small>Fabric canopy, trestle, crates and tie-downs</small>
</span>
</div>
<div class="legend-row">
<span class="swatch permanent"></span>
<span>
<strong>Permanent / fixed</strong>
<small>Stone paving, quay wall, coping and bollards</small>
</span>
</div>
<div class="legend-row">
<span class="swatch context"></span>
<span>
<strong>Place context</strong>
<small>Historic Market Hall and distant city fabric</small>
</span>
</div>
</aside>
<div id="canopyCallout" class="callout temporary">
<strong>Temporary canopy fragment</strong>
<small>Freestanding bay, fabric panels and guy ropes</small>
</div>
<div id="quayCallout" class="callout permanent">
<strong>Permanent quay edge</strong>
<small>Fixed paving, coping and mooring infrastructure</small>
</div>
<div id="bollardCallout" class="callout permanent">
<strong>Cast-iron bollard</strong>
<small>Permanent mooring point</small>
</div>
<div id="hallCallout" class="callout context">
<strong>Old Market Hall</strong>
<small>Historic market-square context</small>
</div>
<div class="hint">
Drag to orbit · Shift/right-drag to pan · Scroll to zoom<br>
Arrow keys orbit · R resets · +/− zoom
</div>
<div id="loading" class="loading">Building the waterfront</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 camera
// ------------------------------------------------------------
const viewport = document.getElementById("viewport");
const loading = document.getElementById("loading");
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.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive low-poly model of Helsinki Market Square"
);
viewport.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9d9e5);
scene.fog = new THREE.Fog(0xb9d9e5, 42, 105);
const camera = new THREE.PerspectiveCamera(
41,
window.innerWidth / window.innerHeight,
0.1,
180
);
// Explicitly separated model layers.
const temporaryGroup = new THREE.Group();
temporaryGroup.name = "TemporaryMarketCanopy";
const permanentGroup = new THREE.Group();
permanentGroup.name = "PermanentWaterfrontAndMooring";
const contextGroup = new THREE.Group();
contextGroup.name = "HelsinkiMarketSquareContext";
scene.add(temporaryGroup, permanentGroup, contextGroup);
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(
0xd8efff,
0x786950,
2.15
);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe4b5, 3.2);
sun.position.set(-18, 30, 19);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -34;
sun.shadow.camera.right = 34;
sun.shadow.camera.top = 32;
sun.shadow.camera.bottom = -28;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 85;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const coolFill = new THREE.DirectionalLight(0x9dc9e1, 0.7);
coolFill.position.set(20, 12, -20);
scene.add(coolFill);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.85,
flatShading: true,
...options
});
const mats = {
pavingBase: material(0x77746b),
stone: material(0xa9a398),
stoneDark: material(0x696e6b),
coping: material(0xbeb9a8),
iron: material(0x263237, {
roughness: 0.58,
metalness: 0.55
}),
rope: material(0xb69a69),
wood: material(0x8a5c35),
woodLight: material(0xb47d47),
woodDark: material(0x604029),
canopyRed: material(0xbb4038, {
side: THREE.DoubleSide
}),
canopyCream: material(0xf0d9ad, {
side: THREE.DoubleSide
}),
crate: material(0x9b754c),
produceGreen: material(0x6f9b45),
produceRed: material(0xc94f38),
produceOrange: material(0xe39838),
produceYellow: material(0xd8bd4c),
brick: material(0x9f4d38),
brickLight: material(0xb35e43),
roofGreen: material(0x466f65),
roofDark: material(0x35564f),
plaster: material(0xe3dfcf),
glass: material(0x35545a, {
roughness: 0.35,
metalness: 0.12
}),
creamTrim: material(0xeee6cf),
darkWindow: material(0x314b50),
skin: material(0xc9946e),
coatBlue: material(0x4d7182),
coatRust: material(0xa95b42),
coatOchre: material(0xb99452)
};
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function addBox(parent, width, height, depth, x, y, z, mat, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
x,
y,
z,
mat,
segments = 10
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const up = new THREE.Vector3(0, 1, 0);
function addRod(parent, a, b, radius, mat, segments = 6) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radius,
radius,
length,
segments
),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
up,
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function triangleMesh(parent, a, b, c, mat) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(
[...a, ...b, ...c],
3
)
);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, mat);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeTextTexture(lines, options = {}) {
const {
width = 768,
height = 320,
background = "#f2e4c4",
foreground = "#263a3d",
border = "#263a3d"
} = options;
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, width, height);
ctx.strokeStyle = border;
ctx.lineWidth = 12;
ctx.strokeRect(12, 12, width - 24, height - 24);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
const step = height / (lines.length + 1);
lines.forEach((line, i) => {
const fontSize = i === 0 ? 74 : 43;
ctx.font = `${i === 0 ? 700 : 600} ${fontSize}px Arial`;
ctx.fillText(
line,
width / 2,
step * (i + 1),
width - 65
);
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
// ------------------------------------------------------------
// Permanent waterfront: paving, quay wall and mooring hardware
// ------------------------------------------------------------
addBox(
permanentGroup,
42,
0.35,
29.5,
0,
-0.02,
-14.75,
mats.pavingBase,
false
);
// Instanced, subtly varied granite setts.
const pavingGeometry = new THREE.BoxGeometry(0.91, 0.07, 0.79);
const pavingMaterial = material(0xffffff);
const columns = 42;
const rows = 31;
const paving = new THREE.InstancedMesh(
pavingGeometry,
pavingMaterial,
columns * rows
);
const dummy = new THREE.Object3D();
const pavingColor = new THREE.Color();
let pavingIndex = 0;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < columns; col++) {
const x = -20 + col * 0.98 + (Math.random() - 0.5) * 0.035;
const z = -29.1 + row * 0.94 + (Math.random() - 0.5) * 0.035;
dummy.position.set(x, 0.18, z);
dummy.rotation.set(
0,
(Math.random() - 0.5) * 0.035,
0
);
dummy.scale.set(
0.96 + Math.random() * 0.055,
1,
0.96 + Math.random() * 0.055
);
dummy.updateMatrix();
paving.setMatrixAt(pavingIndex, dummy.matrix);
const lightness = 0.57 + Math.random() * 0.13;
pavingColor.setHSL(
0.095 + Math.random() * 0.025,
0.08 + Math.random() * 0.08,
lightness
);
paving.setColorAt(pavingIndex, pavingColor);
pavingIndex++;
}
}
paving.instanceMatrix.needsUpdate = true;
paving.instanceColor.needsUpdate = true;
paving.receiveShadow = true;
permanentGroup.add(paving);
// Main quay wall and individual stone facing blocks.
addBox(
permanentGroup,
43,
2.55,
1.2,
0,
-1.12,
0.58,
mats.stoneDark
);
const blockGeometry = new THREE.BoxGeometry(1.05, 0.65, 0.14);
const blockMaterial = material(0xffffff);
const blockCount = 42 * 3;
const wallBlocks = new THREE.InstancedMesh(
blockGeometry,
blockMaterial,
blockCount
);
let blockIndex = 0;
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 42; col++) {
dummy.position.set(
-20.48 + col * 1.035,
-0.38 - row * 0.68,
1.235
);
dummy.rotation.set(0, 0, (Math.random() - 0.5) * 0.006);
dummy.scale.set(
1,
1,
0.94 + Math.random() * 0.12
);
dummy.updateMatrix();
wallBlocks.setMatrixAt(blockIndex, dummy.matrix);
pavingColor.setHSL(
0.11,
0.07,
0.47 + Math.random() * 0.13
);
wallBlocks.setColorAt(blockIndex, pavingColor);
blockIndex++;
}
}
wallBlocks.instanceMatrix.needsUpdate = true;
wallBlocks.instanceColor.needsUpdate = true;
wallBlocks.castShadow = true;
wallBlocks.receiveShadow = true;
permanentGroup.add(wallBlocks);
// Individual coping stones clearly establish the permanent edge.
const copingGeometry = new THREE.BoxGeometry(1.055, 0.28, 1.46);
const copingMaterial = material(0xffffff);
const coping = new THREE.InstancedMesh(
copingGeometry,
copingMaterial,
42
);
for (let i = 0; i < 42; i++) {
dummy.position.set(-20.48 + i * 1.035, 0.32, 0.46);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
coping.setMatrixAt(i, dummy.matrix);
pavingColor.setHSL(
0.11,
0.08,
0.66 + Math.random() * 0.09
);
coping.setColorAt(i, pavingColor);
}
coping.instanceMatrix.needsUpdate = true;
coping.instanceColor.needsUpdate = true;
coping.castShadow = true;
coping.receiveShadow = true;
permanentGroup.add(coping);
function createBollard(x, z, featured = false) {
const group = new THREE.Group();
group.position.set(x, 0.21, z);
group.scale.setScalar(featured ? 1.12 : 1);
permanentGroup.add(group);
addCylinder(group, 0.43, 0.48, 0.14, 0, 0.07, 0, mats.iron, 10);
addCylinder(group, 0.25, 0.32, 0.15, 0, 0.19, 0, mats.iron, 10);
addCylinder(group, 0.16, 0.25, 0.77, 0, 0.63, 0, mats.iron, 10);
addCylinder(group, 0.28, 0.28, 0.09, 0, 1.02, 0, mats.iron, 10);
const cap = new THREE.Mesh(
new THREE.SphereGeometry(0.27, 10, 5),
mats.iron
);
cap.position.y = 1.1;
cap.scale.y = 0.62;
cap.castShadow = true;
group.add(cap);
return group;
}
[-13.5, -8.0, 5.2, 12.1].forEach((x, index) => {
createBollard(x, -0.66, index === 2);
});
// Rope coil beside the featured bollard.
for (let i = 0; i < 4; i++) {
const coil = new THREE.Mesh(
new THREE.TorusGeometry(
0.34 + i * 0.08,
0.035,
5,
14
),
mats.rope
);
coil.rotation.x = Math.PI / 2;
coil.position.set(
6.25 + (Math.random() - 0.5) * 0.08,
0.27 + i * 0.025,
-1.35 + (Math.random() - 0.5) * 0.08
);
coil.castShadow = true;
permanentGroup.add(coil);
}
// Wall ladder and fixed black rubbing fenders.
addRod(
permanentGroup,
[9.2, -1.95, 1.35],
[9.2, 0.55, 1.35],
0.045,
mats.iron
);
addRod(
permanentGroup,
[9.8, -1.95, 1.35],
[9.8, 0.55, 1.35],
0.045,
mats.iron
);
for (let i = 0; i < 6; i++) {
addBox(
permanentGroup,
0.66,
0.06,
0.08,
9.5,
-1.72 + i * 0.42,
1.39,
mats.iron
);
}
[-15.5, -4.8, 11.5].forEach((x) => {
const fender = addCylinder(
permanentGroup,
0.18,
0.22,
0.8,
x,
-0.55,
1.34,
mats.iron,
8
);
fender.rotation.x = 0.08;
});
// ------------------------------------------------------------
// Low-poly water
// ------------------------------------------------------------
const waterGeometry = new THREE.PlaneGeometry(
90,
60,
36,
24
);
waterGeometry.rotateX(-Math.PI / 2);
waterGeometry.translate(0, -1.35, 30);
const waterPositions = waterGeometry.attributes.position;
const waterColors = [];
const waterColor = new THREE.Color();
for (let i = 0; i < waterPositions.count; i++) {
const x = waterPositions.getX(i);
const z = waterPositions.getZ(i);
const variation =
Math.sin(x * 0.23 + z * 0.18) * 0.025 +
Math.cos(z * 0.31 - x * 0.09) * 0.018;
waterColor.setHSL(
0.53,
0.38,
0.43 + variation
);
waterColors.push(
waterColor.r,
waterColor.g,
waterColor.b
);
}
waterGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(waterColors, 3)
);
const waterMaterial = material(0xffffff, {
vertexColors: true,
roughness: 0.32,
metalness: 0.14,
transparent: true,
opacity: 0.95
});
const water = new THREE.Mesh(waterGeometry, waterMaterial);
water.receiveShadow = true;
scene.add(water);
// ------------------------------------------------------------
// Temporary market canopy fragment
// ------------------------------------------------------------
const canopy = new THREE.Group();
canopy.position.set(-4.2, 0.22, -3.65);
temporaryGroup.add(canopy);
// Lightweight posts have no masonry or concrete foundations.
const postPositions = [
[-2.68, -1.47],
[2.68, -1.47],
[-2.68, 1.47],
[2.68, 1.47]
];
postPositions.forEach(([x, z]) => {
addCylinder(
canopy,
0.065,
0.075,
2.72,
x,
1.36,
z,
mats.woodDark,
7
);
addCylinder(
canopy,
0.095,
0.095,
0.045,
x,
0.035,
z,
mats.iron,
8
);
});
// Open frame identifies this as one fragment of a larger canopy.
addBox(canopy, 5.58, 0.10, 0.10, 0, 2.67, 1.48, mats.wood);
addBox(canopy, 5.58, 0.10, 0.10, 0, 2.67, -1.48, mats.wood);
addBox(canopy, 0.10, 0.10, 3.04, -2.68, 2.67, 0, mats.wood);
addBox(canopy, 0.10, 0.10, 3.04, 2.68, 2.67, 0, mats.wood);
addCylinder(
canopy,
0.065,
0.065,
5.62,
0,
3.42,
0,
mats.woodDark,
8
).rotation.z = Math.PI / 2;
// Alternating fabric panels form the low-poly pitched canopy.
const stripeCount = 8;
const stripeWidth = 6 / stripeCount;
for (let i = 0; i < stripeCount; i++) {
const x0 = -3 + i * stripeWidth + 0.012;
const x1 = -3 + (i + 1) * stripeWidth - 0.012;
const a = [x0, 2.72, 1.63];
const b = [x1, 2.72, 1.63];
const c = [x1, 3.43, 0];
const d = [x0, 3.43, 0];
const e = [x0, 2.72, -1.63];
const f = [x1, 2.72, -1.63];
const fabric = i % 2 === 0
? mats.canopyRed
: mats.canopyCream;
triangleMesh(canopy, a, b, c, fabric);
triangleMesh(canopy, a, c, d, fabric);
triangleMesh(canopy, d, c, f, fabric);
triangleMesh(canopy, d, f, e, fabric);
// Short scalloped valance along the water-facing edge.
addBox(
canopy,
stripeWidth - 0.025,
0.34,
0.035,
-3 + (i + 0.5) * stripeWidth,
2.51,
1.66,
fabric
);
}
// Guy ropes and removable-looking stakes.
const guyPoints = [
[[-2.68, 2.72, 1.47], [-3.35, 0.08, 2.35]],
[[2.68, 2.72, 1.47], [3.35, 0.08, 2.35]],
[[-2.68, 2.72, -1.47], [-3.25, 0.08, -2.32]],
[[2.68, 2.72, -1.47], [3.25, 0.08, -2.32]]
];
guyPoints.forEach(([a, b]) => {
addRod(canopy, a, b, 0.016, mats.rope, 5);
addCylinder(
canopy,
0.025,
0.035,
0.22,
b[0],
0.09,
b[2],
mats.iron,
6
);
});
// Simple trestle counter.
addBox(canopy, 5.15, 0.17, 1.12, 0, 1.13, 0.43, mats.woodLight);
addBox(canopy, 4.95, 0.11, 0.95, 0, 0.55, 0.18, mats.woodDark);
[-2.25, 2.25].forEach((x) => {
addBox(
canopy,
0.13,
1.05,
0.13,
x,
0.55,
0.8,
mats.woodDark
);
addBox(
canopy,
0.13,
1.05,
0.13,
x,
0.55,
0.02,
mats.woodDark
);
});
// Hanging market sign.
const signTexture = makeTextTexture([
"KAUPPA TORI",
"MARKET SQUARE"
]);
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(1.9, 0.72),
new THREE.MeshBasicMaterial({
map: signTexture,
side: THREE.DoubleSide,
toneMapped: false
})
);
sign.position.set(0, 2.03, 1.72);
sign.castShadow = true;
canopy.add(sign);
addRod(
canopy,
[-0.65, 2.37, 1.69],
[-0.65, 2.72, 1.69],
0.012,
mats.iron,
5
);
addRod(
canopy,
[0.65, 2.37, 1.69],
[0.65, 2.72, 1.69],
0.012,
mats.iron,
5
);
function createProduceCrate(x, z, fruitMaterial) {
const crate = new THREE.Group();
crate.position.set(x, 1.27, z);
canopy.add(crate);
addBox(crate, 0.78, 0.09, 0.58, 0, 0, 0, mats.crate);
addBox(crate, 0.78, 0.22, 0.07, 0, 0.1, 0.29, mats.crate);
addBox(crate, 0.78, 0.22, 0.07, 0, 0.1, -0.29, mats.crate);
addBox(crate, 0.07, 0.22, 0.58, -0.39, 0.1, 0, mats.crate);
addBox(crate, 0.07, 0.22, 0.58, 0.39, 0.1, 0, mats.crate);
const fruitGeometry = new THREE.DodecahedronGeometry(
0.115,
0
);
for (let i = 0; i < 7; i++) {
const fruit = new THREE.Mesh(
fruitGeometry,
fruitMaterial
);
fruit.position.set(
-0.25 + (i % 4) * 0.16,
0.16 + Math.floor(i / 4) * 0.08,
(Math.random() - 0.5) * 0.32
);
fruit.rotation.set(
Math.random(),
Math.random(),
Math.random()
);
fruit.castShadow = true;
crate.add(fruit);
}
}
createProduceCrate(-1.6, 0.35, mats.produceRed);
createProduceCrate(-0.55, 0.35, mats.produceOrange);
createProduceCrate(0.5, 0.35, mats.produceGreen);
createProduceCrate(1.55, 0.35, mats.produceYellow);
// ------------------------------------------------------------
// Historic Market Hall and city context
// ------------------------------------------------------------
const marketHall = new THREE.Group();
contextGroup.add(marketHall);
addBox(
marketHall,
32,
6.25,
6,
0,
3.12,
-32,
mats.brick
);
addBox(
marketHall,
33.2,
0.5,
6.7,
0,
0.25,
-32,
mats.creamTrim
);
addBox(
marketHall,
7.3,
7.25,
1.25,
0,
3.62,
-28.65,
mats.brickLight
);
function archWindow(parent, x, y, z, width, height, mat) {
const shape = new THREE.Shape();
shape.moveTo(-width / 2, 0);
shape.lineTo(-width / 2, height - width / 2);
shape.absarc(
0,
height - width / 2,
width / 2,
Math.PI,
0,
true
);
shape.lineTo(width / 2, 0);
shape.closePath();
const mesh = new THREE.Mesh(
new THREE.ShapeGeometry(shape, 8),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
[-13.4, -9.5, -5.7, 5.7, 9.5, 13.4].forEach((x) => {
archWindow(marketHall, x, 1.65, -28.965, 1.15, 2.55, mats.darkWindow);
addBox(
marketHall,
0.055,
1.75,
0.055,
x,
2.43,
-28.88,
mats.creamTrim
);
});
archWindow(marketHall, -1.65, 0.85, -27.99, 1.7, 3.75, mats.darkWindow);
archWindow(marketHall, 1.65, 0.85, -27.99, 1.7, 3.75, mats.darkWindow);
addBox(
marketHall,
0.07,
2.8,
0.07,
-1.65,
2.15,
-27.9,
mats.creamTrim
);
addBox(
marketHall,
0.07,
2.8,
0.07,
1.65,
2.15,
-27.9,
mats.creamTrim
);
[-2.7, 0, 2.7].forEach((x) => {
addCylinder(
marketHall,
0.25,
0.3,
4.8,
x,
2.65,
-27.78,
mats.creamTrim,
8
);
});
const pedimentShape = new THREE.Shape();
pedimentShape.moveTo(-3.65, 0);
pedimentShape.lineTo(3.65, 0);
pedimentShape.lineTo(0, 2.0);
pedimentShape.closePath();
const pediment = new THREE.Mesh(
new THREE.ShapeGeometry(pedimentShape),
mats.creamTrim
);
pediment.position.set(0, 6.95, -27.72);
pediment.castShadow = true;
marketHall.add(pediment);
// Faceted green roof.
const roofVertices = [];
const roofTriangles = [
[[-16, 6.3, -28.9], [16, 6.3, -28.9], [16, 7.35, -32]],
[[-16, 6.3, -28.9], [16, 7.35, -32], [-16, 7.35, -32]],
[[-16, 7.35, -32], [16, 7.35, -32], [16, 6.3, -35.1]],
[[-16, 7.35, -32], [16, 6.3, -35.1], [-16, 6.3, -35.1]]
];
roofTriangles.forEach((tri) => {
roofVertices.push(...tri[0], ...tri[1], ...tri[2]);
});
const hallRoofGeometry = new THREE.BufferGeometry();
hallRoofGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(roofVertices, 3)
);
hallRoofGeometry.computeVertexNormals();
const hallRoof = new THREE.Mesh(
hallRoofGeometry,
mats.roofGreen
);
hallRoof.castShadow = true;
hallRoof.receiveShadow = true;
marketHall.add(hallRoof);
// Central clock and low-poly cupola.
addBox(
marketHall,
4.3,
2.25,
2.8,
0,
8.15,
-30.2,
mats.brickLight
);
const clockCanvas = document.createElement("canvas");
clockCanvas.width = 256;
clockCanvas.height = 256;
const clockCtx = clockCanvas.getContext("2d");
clockCtx.fillStyle = "#eee4c9";
clockCtx.beginPath();
clockCtx.arc(128, 128, 112, 0, Math.PI * 2);
clockCtx.fill();
clockCtx.strokeStyle = "#33494b";
clockCtx.lineWidth = 12;
clockCtx.stroke();
clockCtx.lineWidth = 8;
clockCtx.beginPath();
clockCtx.moveTo(128, 128);
clockCtx.lineTo(128, 53);
clockCtx.moveTo(128, 128);
clockCtx.lineTo(183, 153);
clockCtx.stroke();
const clockTexture = new THREE.CanvasTexture(clockCanvas);
clockTexture.colorSpace = THREE.SRGBColorSpace;
const clock = new THREE.Mesh(
new THREE.CircleGeometry(0.72, 16),
new THREE.MeshBasicMaterial({
map: clockTexture,
toneMapped: false
})
);
clock.position.set(0, 8.2, -28.76);
marketHall.add(clock);
const dome = new THREE.Mesh(
new THREE.SphereGeometry(
1.45,
8,
4,
0,
Math.PI * 2,
0,
Math.PI / 2
),
mats.roofDark
);
dome.position.set(0, 9.27, -30.2);
dome.castShadow = true;
marketHall.add(dome);
addCylinder(
marketHall,
0.045,
0.07,
1.05,
0,
10.52,
-30.2,
mats.iron,
6
);
// Simplified Helsinki Cathedral in the distant skyline.
const cathedral = new THREE.Group();
cathedral.position.set(-21, 0, -43);
contextGroup.add(cathedral);
addBox(cathedral, 8.2, 5.8, 7, 0, 2.9, 0, mats.plaster);
addBox(cathedral, 3.2, 8.2, 3.2, 0, 4.1, 0, mats.plaster);
const cathedralDome = new THREE.Mesh(
new THREE.SphereGeometry(
1.65,
8,
4,
0,
Math.PI * 2,
0,
Math.PI / 2
),
mats.roofGreen
);
cathedralDome.position.set(0, 8.15, 0);
cathedralDome.castShadow = true;
cathedral.add(cathedralDome);
addCylinder(
cathedral,
0.18,
0.24,
2.5,
0,
11.05,
0,
mats.roofGreen,
7
);
[-4.6, 4.6].forEach((x) => {
addBox(cathedral, 1.65, 7.3, 1.65, x, 3.65, 0.5, mats.plaster);
addCylinder(
cathedral,
0,
0.82,
2.4,
x,
8.45,
0.5,
mats.roofGreen,
6
);
});
// Muted city blocks behind the Market Hall.
const cityColors = [
material(0xb6a89a),
material(0xc5b7a4),
material(0x9da8a6),
material(0xc3b5a1),
material(0xa9927c)
];
const cityBlocks = [
[18, 8, 5, -42],
[24, 11, 6, -43],
[-31, 10, 5, -45],
[31, 7, 4, -39],
[-10, 8, 5, -48]
];
cityBlocks.forEach(([x, height, depth, z], i) => {
addBox(
contextGroup,
6.5,
height,
depth,
x,
height / 2,
z,
cityColors[i % cityColors.length]
);
addBox(
contextGroup,
6.8,
0.38,
depth + 0.25,
x,
height + 0.12,
z,
mats.roofDark
);
});
// Sparse, abstract people establish scale without distracting
// from the temporary/permanent structural distinction.
function createPerson(x, z, coatMaterial, scale = 1) {
const person = new THREE.Group();
person.position.set(x, 0.24, z);
person.scale.setScalar(scale);
contextGroup.add(person);
addCylinder(
person,
0.19,
0.25,
0.68,
0,
1.05,
0,
coatMaterial,
7
);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.17, 7, 5),
mats.skin
);
head.position.y = 1.58;
head.castShadow = true;
person.add(head);
addRod(person, [-0.1, 0.7, 0], [-0.12, 0.08, 0], 0.065, mats.iron, 6);
addRod(person, [0.1, 0.7, 0], [0.13, 0.08, 0], 0.065, mats.iron, 6);
}
createPerson(7.4, -12.2, mats.coatBlue, 0.96);
createPerson(8.25, -12.65, mats.coatRust, 0.88);
createPerson(-9.5, -17.0, mats.coatOchre, 1.02);
createPerson(13.5, -19.0, mats.coatBlue, 0.92);
// ------------------------------------------------------------
// Custom camera controls — no Three.js addons
// ------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(0, 1.3, -4.8),
radius: 27,
theta: 0.55,
phi: 1.02
};
const defaultCamera = {
target: cameraState.target.clone(),
radius: 27,
theta: 0.55,
phi: 1.02
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y +
cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.target.copy(defaultCamera.target);
cameraState.radius = defaultCamera.radius;
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
}
const pointers = new Map();
let interactionMode = "orbit";
let previousPinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
interactionMode =
event.button === 2 || event.shiftKey ? "pan" : "orbit";
}
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(
a.x - b.x,
a.y - b.y
);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
previous.x = event.clientX;
previous.y = event.clientY;
if (pointers.size === 1) {
if (interactionMode === "orbit") {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + dy * 0.005,
0.22,
1.46
);
} else {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3()
.crossVectors(forward, up)
.normalize();
const scale = cameraState.radius * 0.0013;
cameraState.target.addScaledVector(
right,
-dx * scale
);
cameraState.target.addScaledVector(
forward,
dy * scale
);
cameraState.target.x = THREE.MathUtils.clamp(
cameraState.target.x,
-22,
22
);
cameraState.target.z = THREE.MathUtils.clamp(
cameraState.target.z,
-28,
10
);
}
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(
a.x - b.x,
a.y - b.y
);
if (previousPinchDistance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius *
(previousPinchDistance / distance),
8,
55
);
}
previousPinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = 0;
}
renderer.domElement.addEventListener(
"pointerup",
releasePointer
);
renderer.domElement.addEventListener(
"pointercancel",
releasePointer
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
8,
55
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (
event.target instanceof HTMLInputElement ||
event.target instanceof HTMLButtonElement
) {
return;
}
switch (event.key) {
case "ArrowLeft":
cameraState.theta += 0.08;
break;
case "ArrowRight":
cameraState.theta -= 0.08;
break;
case "ArrowUp":
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - 0.06,
0.22,
1.46
);
break;
case "ArrowDown":
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + 0.06,
0.22,
1.46
);
break;
case "+":
case "=":
cameraState.radius = Math.max(
8,
cameraState.radius - 1
);
break;
case "-":
case "_":
cameraState.radius = Math.min(
55,
cameraState.radius + 1
);
break;
case "r":
case "R":
resetCamera();
break;
}
});
document.getElementById("resetView").addEventListener(
"click",
resetCamera
);
document.getElementById("topView").addEventListener(
"click",
() => {
cameraState.phi = 0.28;
cameraState.theta = 0;
cameraState.radius = 31;
cameraState.target.set(0, 0.5, -8);
}
);
document.getElementById("temporaryLayer").addEventListener(
"change",
(event) => {
temporaryGroup.visible = event.target.checked;
}
);
document.getElementById("permanentLayer").addEventListener(
"change",
(event) => {
permanentGroup.visible = event.target.checked;
}
);
document.getElementById("contextLayer").addEventListener(
"change",
(event) => {
contextGroup.visible = event.target.checked;
}
);
let waterMotion = true;
const motionButton = document.getElementById("motionButton");
motionButton.addEventListener("click", () => {
waterMotion = !waterMotion;
motionButton.textContent = waterMotion
? "Pause water"
: "Animate water";
});
// ------------------------------------------------------------
// Projected HTML callouts
// ------------------------------------------------------------
const callouts = [
{
element: document.getElementById("canopyCallout"),
point: new THREE.Vector3(-4.2, 3.75, -3.65),
group: temporaryGroup
},
{
element: document.getElementById("quayCallout"),
point: new THREE.Vector3(9.6, 0.65, 0.45),
group: permanentGroup
},
{
element: document.getElementById("bollardCallout"),
point: new THREE.Vector3(5.2, 1.45, -0.66),
group: permanentGroup
},
{
element: document.getElementById("hallCallout"),
point: new THREE.Vector3(0, 9.7, -29),
group: contextGroup
}
];
const projected = new THREE.Vector3();
function updateCallouts() {
callouts.forEach((callout) => {
if (!callout.group.visible) {
callout.element.style.opacity = "0";
return;
}
projected.copy(callout.point).project(camera);
const onScreen =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.15 &&
projected.x < 1.15 &&
projected.y > -1.15 &&
projected.y < 1.15;
if (!onScreen) {
callout.element.style.opacity = "0";
return;
}
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
callout.element.style.left = `${x}px`;
callout.element.style.top = `${y - 16}px`;
callout.element.style.opacity = "1";
});
}
// ------------------------------------------------------------
// Resize and animation loop
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const animationClock = new THREE.Clock();
let frame = 0;
function animate() {
requestAnimationFrame(animate);
const elapsed = animationClock.getElapsedTime();
frame++;
updateCamera();
updateCallouts();
if (waterMotion) {
const positions = waterGeometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const x = positions.getX(i);
const z = positions.getZ(i);
const baseY = positions.getY(i);
const wave =
Math.sin(x * 0.34 + elapsed * 0.72) * 0.055 +
Math.cos(z * 0.29 - elapsed * 0.53) * 0.04 +
Math.sin((x + z) * 0.17 + elapsed * 0.38) * 0.025;
positions.setY(i, baseY + wave);
}
positions.needsUpdate = true;
if (frame % 2 === 0) {
waterGeometry.computeVertexNormals();
}
}
renderer.render(scene, camera);
}
updateCamera();
renderer.render(scene, camera);
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 450);
});
</script>
</body>
</html>
```