Prompt specification
Build or customize the Three.js 3D scene "Bergen Fish Market at the Vågen waterfront" 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: Bergen Fish Market at the Vågen waterfront
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/bergen-fish-market-at-the-v-gen-waterfront-x2835
Scene Description Prompt:
Create one standalone voxel HTML scene using Three.js from cdnjs. Build a bounded fragment of Bergen’s outdoor Fish Market at Torget by Vågen in Norway. Use the official Visit Norway record (https://www.visitnorway.com/listings/fish-market-in-bergen/15340/) and Visit Bergen description (https://en.visitbergen.com/things-to-do/fish-market). Place market canopies and fish and produce stalls on land beside the identifiable harbor edge, with a compact row of selected urban facades and a simple distant silhouette. Show workers and shoppers and one or two boats as schematic foreground cues. Cite the two references. Avoid invented block dimensions and label exact stall positions as illustrative.
Return a single complete HTML document. It must work in a sandbox that allows scripts, with the cdnjs Three.js r160 module and inline CSS. Use procedural geometry and local button handlers; no native form submission, pointer lock, remote assets, or runtime network requests besides Three.js.
Working Three.js Starter (bergen-fish-market-at-the-v-gen-waterfront-x2835):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#102a31">
<title>Fish Market in Bergen — Torget at Vågen</title>
<link rel="icon" href="data:,">
<style>
:root {
color-scheme: dark;
--ink: #f4f1e8;
--muted: #c4d1ce;
--panel: rgba(12, 31, 37, 0.88);
--panel-line: rgba(228, 240, 235, 0.16);
--accent: #f0b35a;
--accent-2: #db5b4b;
--sea: #8fc4c6;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b8d0d2;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
a {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.panel {
background: var(--panel);
border: 1px solid var(--panel-line);
box-shadow: 0 18px 50px rgba(4, 20, 24, 0.22);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.intro {
position: absolute;
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 20px 21px 18px;
border-radius: 18px;
pointer-events: auto;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: #b9d5d4;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 2px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
color: var(--ink);
font-size: clamp(25px, 3vw, 38px);
font-weight: 760;
letter-spacing: -0.035em;
line-height: 1.02;
}
.subtitle {
margin: 8px 0 14px;
color: #d9e3de;
font-size: 14px;
font-weight: 650;
}
.selection {
padding-top: 13px;
border-top: 1px solid var(--panel-line);
}
.selection strong {
display: block;
margin-bottom: 5px;
color: var(--accent);
font-size: 13px;
letter-spacing: 0.01em;
}
.selection p {
margin: 0;
color: var(--muted);
font-size: 12.5px;
line-height: 1.5;
}
.illustrative {
display: inline-flex;
align-items: center;
margin-top: 12px;
padding: 5px 8px;
border: 1px solid rgba(240, 179, 90, 0.38);
border-radius: 999px;
color: #ffd99c;
background: rgba(240, 179, 90, 0.08);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.sources {
position: absolute;
top: 22px;
right: 22px;
width: min(330px, calc(100vw - 44px));
padding: 17px 18px;
border-radius: 16px;
pointer-events: auto;
}
.sources h2 {
margin: 0 0 9px;
color: var(--ink);
font-size: 13px;
letter-spacing: 0.02em;
}
.sources p {
margin: 0 0 11px;
color: var(--muted);
font-size: 12px;
line-height: 1.48;
}
.sources ol {
display: grid;
gap: 7px;
margin: 0;
padding-left: 20px;
color: var(--muted);
font-size: 11.5px;
line-height: 1.4;
}
.sources a {
color: #9ed5dc;
text-decoration-color: rgba(158, 213, 220, 0.45);
text-underline-offset: 3px;
}
.sources a:hover {
color: #d8f7fa;
}
.controls {
position: absolute;
bottom: 20px;
left: 50%;
display: flex;
gap: 6px;
max-width: calc(100vw - 28px);
padding: 7px;
overflow-x: auto;
border-radius: 14px;
transform: translateX(-50%);
pointer-events: auto;
scrollbar-width: none;
}
.controls::-webkit-scrollbar {
display: none;
}
.controls button {
flex: 0 0 auto;
padding: 9px 13px;
border: 1px solid transparent;
border-radius: 9px;
color: #dce8e4;
background: transparent;
cursor: pointer;
font-size: 12px;
font-weight: 720;
white-space: nowrap;
transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.controls button:hover {
color: #ffffff;
background: rgba(255, 255, 255, 0.08);
}
.controls button.active {
color: #173038;
background: var(--accent);
border-color: rgba(255, 255, 255, 0.25);
}
.controls .divider {
width: 1px;
flex: 0 0 auto;
margin: 4px 2px;
background: var(--panel-line);
}
.hint {
position: absolute;
bottom: 24px;
left: 22px;
padding: 8px 10px;
border-radius: 9px;
color: rgba(244, 249, 246, 0.76);
background: rgba(12, 31, 37, 0.66);
font-size: 10.5px;
letter-spacing: 0.02em;
backdrop-filter: blur(8px);
}
#labels {
position: fixed;
inset: 0;
z-index: 1;
overflow: hidden;
pointer-events: none;
}
.scene-label {
position: absolute;
min-width: 125px;
padding: 7px 9px 7px 11px;
border: 1px solid rgba(255, 255, 255, 0.28);
border-left: 3px solid var(--accent);
border-radius: 8px;
color: #fff;
background: rgba(12, 31, 37, 0.82);
box-shadow: 0 8px 24px rgba(5, 21, 25, 0.18);
transform: translate(-50%, -100%);
transition: opacity 150ms ease;
backdrop-filter: blur(7px);
}
.scene-label::after {
position: absolute;
bottom: -17px;
left: 50%;
width: 1px;
height: 16px;
content: "";
background: rgba(255, 255, 255, 0.58);
}
.scene-label b {
display: block;
font-size: 11px;
line-height: 1.2;
}
.scene-label span {
display: block;
margin-top: 2px;
color: #b9ceca;
font-size: 9.5px;
line-height: 1.2;
}
#loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
color: #eaf2ef;
background: #16343b;
font-size: 13px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.intro {
top: 12px;
left: 12px;
width: min(340px, calc(100vw - 24px));
padding: 15px 16px;
}
.sources {
top: auto;
right: 12px;
bottom: 78px;
width: min(300px, calc(100vw - 24px));
padding: 12px 14px;
}
.sources p,
.sources h2 {
display: none;
}
.sources ol {
font-size: 10px;
}
.hint {
display: none;
}
.controls {
bottom: 12px;
}
.controls button {
padding: 8px 10px;
font-size: 11px;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive schematic voxel scene of Bergen's Fish Market at Torget beside Vågen harbor"></main>
<div id="labels" aria-hidden="true"></div>
<div class="hud">
<section class="intro panel" aria-label="Scene description">
<div class="eyebrow">Bergen · Vågen</div>
<h1>Fish Market in Bergen</h1>
<div class="subtitle">A bounded voxel fragment of Fisketorget / Torget</div>
<div class="selection" aria-live="polite">
<strong id="selection-title">Torget at the harbor</strong>
<p id="selection-copy">Outdoor canopies, fish and produce counters, people, quay details, and small working boats establish the market setting.</p>
</div>
<span class="illustrative">Schematic interpretation · not a survey</span>
</section>
<aside class="sources panel" aria-label="References">
<h2>About this interpretation</h2>
<p>The identity and harbor-side market setting follow the official Visit Norway listing and Visit Bergen’s visitor description. Facades, boats, backdrop, proportions, and stall positions are intentionally selective.</p>
<ol>
<li><a href="https://www.visitnorway.com/listings/fish-market-in-bergen/15340/" target="_blank" rel="noopener">Visit Norway — Fish Market in Bergen</a></li>
<li><a href="https://en.visitbergen.com/things-to-do/fish-market" target="_blank" rel="noopener">Visit Bergen — Fish Market</a></li>
</ol>
</aside>
<div class="hint">Drag to orbit · Scroll or pinch to zoom · Select a stall for context</div>
<nav class="controls panel" aria-label="Camera and display controls">
<button type="button" data-view="overview" class="active">Overview</button>
<button type="button" data-view="market">Market</button>
<button type="button" data-view="harbor">Harbor</button>
<button type="button" data-view="facades">Facades</button>
<span class="divider" aria-hidden="true"></span>
<button type="button" id="toggle-labels">Labels on</button>
</nav>
</div>
<div id="loading">Building the harbor fragment…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneRoot = document.getElementById("scene");
const labelRoot = document.getElementById("labels");
const loading = document.getElementById("loading");
const selectionTitle = document.getElementById("selection-title");
const selectionCopy = document.getElementById("selection-copy");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xbfd4d5);
scene.fog = new THREE.Fog(0xbfd4d5, 34, 72);
const camera = new THREE.PerspectiveCamera(43, innerWidth / innerHeight, 0.1, 150);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, 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", "Schematic three-dimensional view of the Fish Market in Bergen");
renderer.domElement.tabIndex = 0;
sceneRoot.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xe4f3ef, 0x5c5145, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedcf, 3.2);
sun.position.set(-13, 24, 17);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 28;
sun.shadow.camera.bottom = -28;
sun.shadow.camera.near = 2;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.00035;
scene.add(sun);
const seaFill = new THREE.DirectionalLight(0x8bcbd5, 1.05);
seaFill.position.set(18, 8, -12);
scene.add(seaFill);
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
const sphereGeometry = new THREE.SphereGeometry(1, 10, 7);
const materialCache = new Map();
const clickables = [];
const animatedPeople = [];
const boats = [];
function solid(color, roughness = 0.8, metalness = 0) {
const key = `${color}-${roughness}-${metalness}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness,
metalness
}));
}
return materialCache.get(key);
}
function block(parent, size, position, color, rotationY = 0) {
const mesh = new THREE.Mesh(cubeGeometry, solid(color));
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.y = rotationY;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function ball(parent, size, position, color) {
const mesh = new THREE.Mesh(sphereGeometry, solid(color, 0.64));
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, radiusTop, radiusBottom, height, position, color, segments = 10) {
const geometry = new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments);
const mesh = new THREE.Mesh(geometry, solid(color));
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeGableRoof(width, depth, height, color) {
const w = width / 2;
const d = depth / 2;
const vertices = new Float32Array([
-w, 0, -d, w, 0, -d, 0, height, -d,
-w, 0, d, w, 0, d, 0, height, d
]);
const indices = [
0, 2, 1,
3, 4, 5,
0, 3, 5, 0, 5, 2,
1, 2, 5, 1, 5, 4,
0, 1, 4, 0, 4, 3
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
const roof = new THREE.Mesh(geometry, solid(color));
roof.castShadow = true;
roof.receiveShadow = true;
return roof;
}
function makeSign(text, width, height, background = "#9f302c", foreground = "#fff8e8") {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
context.strokeStyle = "rgba(255,255,255,.45)";
context.lineWidth = 8;
context.strokeRect(10, 10, canvas.width - 20, canvas.height - 20);
context.fillStyle = foreground;
context.textAlign = "center";
context.textBaseline = "middle";
context.font = "700 66px system-ui, sans-serif";
context.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(4, renderer.capabilities.getMaxAnisotropy());
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture, side: THREE.DoubleSide })
);
return mesh;
}
// Bounded diorama base.
block(scene, [35, 1.05, 24], [0.5, -1.28, 0], 0x526661);
block(scene, [23, 1.2, 24], [-5.5, -0.58, 0], 0x8b8170);
block(scene, [12, 0.8, 24], [12, -0.92, 0], 0x496d70);
// A quiet paved square, built from offset voxel stones.
const cobbleMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.94,
vertexColors: true
});
const cobbleGeometry = new THREE.BoxGeometry(1, 1, 1);
const cobbleRows = 17;
const cobbleColumns = 21;
const cobbles = new THREE.InstancedMesh(cobbleGeometry, cobbleMaterial, cobbleRows * cobbleColumns);
const dummy = new THREE.Object3D();
const stonePalette = [0x9b9385, 0xa49b8b, 0x8f8a7e, 0xb0a494, 0x969183];
let cobbleIndex = 0;
for (let row = 0; row < cobbleRows; row++) {
for (let column = 0; column < cobbleColumns; column++) {
const x = -16.25 + column * 1.04 + (row % 2) * 0.24;
const z = -7.35 + row * 1.04;
dummy.position.set(x, 0.025 + ((row + column) % 3) * 0.006, z);
dummy.rotation.set(0, (((row * 13 + column * 7) % 9) - 4) * 0.012, 0);
dummy.scale.set(0.95, 0.08, 0.88);
dummy.updateMatrix();
cobbles.setMatrixAt(cobbleIndex, dummy.matrix);
cobbles.setColorAt(cobbleIndex, new THREE.Color(stonePalette[(row * 3 + column) % stonePalette.length]));
cobbleIndex++;
}
}
cobbles.instanceMatrix.needsUpdate = true;
cobbles.instanceColor.needsUpdate = true;
cobbles.receiveShadow = true;
scene.add(cobbles);
// Harbor water.
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x4b9da8,
roughness: 0.28,
metalness: 0.08,
transparent: true,
opacity: 0.94
});
const water = new THREE.Mesh(new THREE.PlaneGeometry(12, 24), waterMaterial);
water.rotation.x = -Math.PI / 2;
water.position.set(12, -0.69, 0);
water.receiveShadow = true;
scene.add(water);
const waveVertices = [];
for (let i = 0; i < 58; i++) {
const x = 6.45 + ((i * 1.731) % 11.2);
const z = -11.2 + ((i * 2.417) % 22.1);
const length = 0.35 + ((i * 0.37) % 0.65);
waveVertices.push(x, -0.665, z, x + length, -0.665, z + 0.025);
}
const waveGeometry = new THREE.BufferGeometry();
waveGeometry.setAttribute("position", new THREE.Float32BufferAttribute(waveVertices, 3));
const waves = new THREE.LineSegments(
waveGeometry,
new THREE.LineBasicMaterial({ color: 0xb8e2df, transparent: true, opacity: 0.45 })
);
scene.add(waves);
// A clearly legible quay wall, edge stones, bollards, ropes, and steps.
block(scene, [0.48, 0.9, 23.8], [6.04, -0.4, 0], 0x656e67);
for (let i = 0; i < 16; i++) {
block(
scene,
[0.24, 0.52 + (i % 3) * 0.055, 1.34],
[5.83, -0.28 + (i % 2) * 0.025, -11.1 + i * 1.48],
i % 3 === 0 ? 0x81877b : 0x737b73
);
}
const bollardZ = [-8.5, -3.4, 1.7, 6.8, 10.5];
bollardZ.forEach((z) => {
cylinder(scene, 0.17, 0.24, 0.62, [5.56, 0.28, z], 0x28383a, 8);
block(scene, [0.48, 0.12, 0.28], [5.56, 0.59, z], 0x28383a);
});
for (let i = 0; i < bollardZ.length - 1; i++) {
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(5.56, 0.47, bollardZ[i]),
new THREE.Vector3(5.42, 0.2, (bollardZ[i] + bollardZ[i + 1]) / 2),
new THREE.Vector3(5.56, 0.47, bollardZ[i + 1])
]);
const rope = new THREE.Mesh(
new THREE.TubeGeometry(curve, 12, 0.035, 5, false),
solid(0xb8a77d)
);
scene.add(rope);
}
for (let i = 0; i < 4; i++) {
block(scene, [0.7, 0.24, 2.5], [6.28 + i * 0.37, -0.14 - i * 0.2, 2.2], 0x858a7f);
}
// Compact selected row of colorful Bergen-style wooden facades.
function makeBuilding(x, z, width, height, depth, facadeColor, roofColor) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
block(group, [width, height, depth], [0, height / 2, 0], facadeColor);
block(group, [width + 0.08, 0.22, depth + 0.08], [0, 0.16, 0], 0x565b55);
block(group, [width + 0.12, 0.16, depth + 0.1], [0, height - 0.2, 0], 0xe5dfcf);
const roof = makeGableRoof(width + 0.34, depth + 0.38, Math.min(1.8, width * 0.42), roofColor);
roof.position.y = height;
group.add(roof);
const front = depth / 2 + 0.025;
const levels = Math.max(2, Math.floor((height - 1.2) / 2.2));
const columns = width > 3.5 ? 3 : 2;
for (let level = 0; level < levels; level++) {
const y = 2.05 + level * 2.15;
for (let column = 0; column < columns; column++) {
const wx = columns === 3 ? (column - 1) * 1.08 : (column - 0.5) * 1.18;
block(group, [0.72, 1.08, 0.075], [wx, y, front], 0xe8e2d4);
block(group, [0.54, 0.88, 0.08], [wx, y, front + 0.045], 0x355a61);
block(group, [0.045, 0.9, 0.09], [wx, y, front + 0.09], 0xb8c6bd);
block(group, [0.56, 0.045, 0.09], [wx, y, front + 0.09], 0xb8c6bd);
}
}
block(group, [0.72, 1.45, 0.08], [0, 0.86, front + 0.035], 0x314d4e);
block(group, [0.8, 0.14, 0.12], [0, 1.62, front + 0.07], 0xe8e2d4);
const cornerXs = [-width / 2 + 0.12, width / 2 - 0.12];
cornerXs.forEach((cornerX) => {
block(group, [0.12, height, 0.1], [cornerX, height / 2, front + 0.07], 0xe2dccc);
});
}
makeBuilding(-13.7, -9.35, 3.6, 8.0, 2.35, 0x9d4f43, 0x39474b);
makeBuilding(-9.9, -9.45, 3.7, 9.5, 2.45, 0xd0a85d, 0x39474b);
makeBuilding(-6.0, -9.4, 3.7, 8.6, 2.35, 0x6e9290, 0x39474b);
makeBuilding(-2.1, -9.45, 3.7, 10.0, 2.45, 0xb56d48, 0x39474b);
makeBuilding(1.8, -9.4, 3.5, 7.8, 2.35, 0xc4b49b, 0x39474b);
// Small market square details.
function makeLamp(x, z) {
cylinder(scene, 0.055, 0.085, 3.3, [x, 1.65, z], 0x293b3d, 8);
block(scene, [0.34, 0.12, 0.34], [x, 3.33, z], 0x293b3d);
block(scene, [0.25, 0.34, 0.25], [x, 3.52, z], 0xf2d69a);
cylinder(scene, 0.1, 0.14, 0.18, [x, 0.08, z], 0x293b3d, 8);
}
makeLamp(-7.7, 1.2);
makeLamp(-0.5, -6.6);
function makeBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
block(group, [2.1, 0.13, 0.52], [0, 0.57, 0], 0x8b5a3f);
block(group, [2.1, 0.46, 0.11], [0, 0.91, -0.23], 0x8b5a3f);
block(group, [0.12, 0.55, 0.45], [-0.78, 0.28, 0], 0x34413e);
block(group, [0.12, 0.55, 0.45], [0.78, 0.28, 0], 0x34413e);
}
makeBench(-9.0, 6.0, -0.08);
makeBench(-4.6, -5.5, 0.03);
// Outdoor market canopies.
function makeCrate(parent, x, y, z, color = 0x9a7048) {
block(parent, [0.72, 0.08, 0.62], [x, y, z], color);
block(parent, [0.72, 0.35, 0.07], [x, y + 0.17, z + 0.28], color);
block(parent, [0.72, 0.35, 0.07], [x, y + 0.17, z - 0.28], color);
block(parent, [0.07, 0.35, 0.62], [x - 0.33, y + 0.17, z], color);
block(parent, [0.07, 0.35, 0.62], [x + 0.33, y + 0.17, z], color);
}
function makeStall(x, z, type) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
const isFish = type === "fish";
const stripeColor = isFish ? 0xa43d37 : 0xb56b36;
const labelText = isFish ? "FISK" : "FRUKT & GRØNT";
const description = isFish
? "Outdoor fish counter with a striped canopy, ice tray, and simplified fish. The canopy position is illustrative."
: "Produce stall with open crates, fruit, and vegetables. The canopy position is illustrative.";
const roofMeshes = [];
for (const px of [-1.55, 1.55]) {
for (const pz of [-1.25, 1.25]) {
block(group, [0.14, 3.0, 0.14], [px, 1.5, pz], 0x745039);
}
}
block(group, [3.25, 0.2, 1.12], [0, 1.06, 0.86], 0xa8794d);
block(group, [3.25, 0.68, 0.1], [0, 0.72, 1.36], 0x7f5539);
for (let i = 0; i < 7; i++) {
block(group, [0.42, 0.55, 0.11], [-1.38 + i * 0.46, 0.75, 1.37], 0x966442);
}
block(group, [3.25, 0.12, 0.65], [0, 1.58, -0.9], 0x76503a);
for (let i = 0; i < 6; i++) {
const roof = block(
group,
[0.58, 0.12, 3.35],
[-1.45 + i * 0.58, 3.04, 0],
i % 2 === 0 ? stripeColor : 0xf0e6d1
);
roof.rotation.x = -0.075;
roof.userData = {
title: isFish ? "Outdoor fish stall" : "Outdoor produce stall",
copy: description
};
clickables.push(roof);
roofMeshes.push(roof);
block(group, [0.58, 0.3, 0.09], [-1.45 + i * 0.58, 2.83, 1.65], i % 2 === 0 ? stripeColor : 0xf0e6d1);
}
block(group, [3.45, 0.12, 0.12], [0, 2.88, -1.58], 0x5f4837);
block(group, [3.45, 0.12, 0.12], [0, 2.88, 1.58], 0x5f4837);
const sign = makeSign(labelText, 2.2, 0.52, isFish ? "#9d302c" : "#76513a");
sign.position.set(0, 2.48, 1.46);
group.add(sign);
if (isFish) {
block(group, [2.8, 0.1, 0.76], [0, 1.21, 0.85], 0xdbe7df);
for (let i = 0; i < 10; i++) {
const fish = ball(
group,
[0.31, 0.075, 0.095],
[-1.15 + (i % 5) * 0.52, 1.31, 0.61 + Math.floor(i / 5) * 0.28],
i % 3 === 0 ? 0x6f9698 : 0xb8c8c7
);
fish.rotation.y = (i % 2 ? 1 : -1) * 0.25;
const tail = block(group, [0.12, 0.055, 0.14], [fish.position.x + (i % 2 ? 0.3 : -0.3), 1.31, fish.position.z], 0x8ba8aa);
tail.rotation.y = fish.rotation.y;
}
} else {
const produceColors = [0xd84e35, 0xe2b632, 0x6f983e, 0xe77e2d, 0x9a5b42];
for (let crateIndex = 0; crateIndex < 3; crateIndex++) {
const crateX = -1.05 + crateIndex * 1.05;
makeCrate(group, crateX, 1.17, 0.85, 0xa6754e);
for (let i = 0; i < 5; i++) {
ball(
group,
[0.14, 0.14, 0.14],
[crateX - 0.22 + (i % 3) * 0.2, 1.42, 0.7 + Math.floor(i / 3) * 0.18],
produceColors[(crateIndex * 2 + i) % produceColors.length]
);
}
}
}
makeCrate(group, -1.0, 0.08, -0.75, 0x8c633e);
makeCrate(group, -0.2, 0.08, -0.75, 0x8c633e);
makeCrate(group, 0.6, 0.08, -0.75, 0x8c633e);
}
makeStall(3.25, -3.1, "fish");
makeStall(3.25, 3.55, "fish");
makeStall(-2.65, 4.75, "produce");
makeStall(-0.55, 4.75, "produce");
// Voxel workers and shoppers.
function makePerson(x, z, options = {}) {
const {
shirt = 0x426b78,
trousers = 0x35424a,
skin = 0xd9a17d,
worker = false,
shopper = false,
rotation = 0,
phase = Math.random() * Math.PI * 2
} = options;
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
block(group, [0.22, 0.62, 0.25], [-0.17, 0.31, 0], trousers);
block(group, [0.22, 0.62, 0.25], [0.17, 0.31, 0], trousers);
block(group, [0.18, 0.12, 0.34], [-0.17, 0.08, 0.07], 0x273033);
block(group, [0.18, 0.12, 0.34], [0.17, 0.08, 0.07], 0x273033);
block(group, [0.58, 0.72, 0.34], [0, 1.0, 0], shirt);
block(group, [0.17, 0.62, 0.2], [-0.39, 0.97, 0], shirt, -0.1);
block(group, [0.17, 0.62, 0.2], [0.39, 0.97, 0], shirt, 0.1);
block(group, [0.16, 0.13, 0.17], [-0.39, 0.63, 0], skin);
block(group, [0.16, 0.13, 0.17], [0.39, 0.63, 0], skin);
block(group, [0.42, 0.43, 0.4], [0, 1.59, 0], skin);
block(group, [0.44, 0.13, 0.42], [0, 1.82, 0], worker ? 0xf0eadb : 0x453a32);
if (worker) {
block(group, [0.46, 0.62, 0.07], [0, 0.98, 0.2], 0xf2eee1);
block(group, [0.5, 0.14, 0.48], [0, 1.91, 0], 0xf4efe1);
block(group, [0.5, 0.08, 0.23], [0, 1.84, 0.2], 0xf4efe1);
}
if (shopper) {
block(group, [0.32, 0.38, 0.18], [0.48, 0.45, 0.08], 0xd8a448);
block(group, [0.17, 0.18, 0.06], [0.48, 0.72, 0.08], 0xd8a448);
}
group.userData.phase = phase;
group.userData.baseY = 0;
animatedPeople.push(group);
return group;
}
makePerson(3.25, -3.52, { shirt: 0x426b78, worker: true, phase: 0.2 });
makePerson(3.67, -3.48, { shirt: 0x7f9d80, worker: true, phase: 1.3 });
makePerson(3.28, 3.12, { shirt: 0x426b78, worker: true, phase: 2.1 });
makePerson(-2.66, 4.34, { shirt: 0x66885e, worker: true, phase: 2.8 });
makePerson(-0.58, 4.34, { shirt: 0xb35c46, worker: true, phase: 3.6 });
makePerson(1.05, 2.15, { shirt: 0xd39b3d, shopper: true, rotation: 0.35, phase: 0.7 });
makePerson(1.82, 4.9, { shirt: 0x4d6f9a, shopper: true, rotation: -0.5, phase: 1.8 });
makePerson(-3.8, 3.15, { shirt: 0x9f5c62, shopper: true, rotation: 0.15, phase: 4.2 });
makePerson(-6.1, 1.15, { shirt: 0x465d72, shopper: true, rotation: -0.4, phase: 5.1 });
makePerson(4.65, 0.05, { shirt: 0xc18b48, shopper: true, rotation: -0.9, phase: 2.4 });
// Schematic fishing boats in the foreground water.
function makeHullGeometry() {
const vertices = new Float32Array([
-0.72, 0.35, -2.05,
0.72, 0.35, -2.05,
0.72, 0.35, 1.35,
-0.72, 0.35, 1.35,
-0.28,-0.43, -1.5,
0.28,-0.43, -1.5,
0.28,-0.43, 0.82,
-0.28,-0.43, 0.82
]);
const indices = [
0,3,2, 0,2,1,
0,1,5, 0,5,4,
1,2,6, 1,6,5,
2,3,7, 2,7,6,
3,0,4, 3,4,7,
4,5,6, 4,6,7
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const hullGeometry = makeHullGeometry();
function makeBoat(x, z, rotation, hullColor, accentColor, scale = 1) {
const group = new THREE.Group();
group.position.set(x, -0.27, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
const hull = new THREE.Mesh(hullGeometry, solid(hullColor, 0.7));
hull.castShadow = true;
hull.receiveShadow = true;
group.add(hull);
block(group, [1.32, 0.11, 3.25], [0, 0.39, -0.3], 0xc6b690);
block(group, [1.08, 0.78, 1.05], [0, 0.82, -0.8], 0xe7e1cf);
block(group, [1.16, 0.12, 1.16], [0, 1.25, -0.8], accentColor);
block(group, [0.72, 0.34, 0.06], [0, 0.95, -0.255], 0x41666b);
block(group, [0.05, 0.34, 0.5], [-0.55, 0.95, -0.8], 0x41666b);
block(group, [0.05, 0.34, 0.5], [0.55, 0.95, -0.8], 0x41666b);
cylinder(group, 0.035, 0.045, 2.4, [0, 1.95, 0.75], 0x6e573c, 6);
block(group, [1.3, 0.08, 0.08], [0, 2.48, 0.75], 0x6e573c);
block(group, [0.9, 0.32, 0.75], [0, 0.58, 1.02], 0xb9a671);
for (let i = 0; i < 3; i++) {
ball(group, [0.13, 0.1, 0.25], [-0.24 + i * 0.24, 0.79, 1.03], 0x9fb9b5);
}
group.userData.baseY = group.position.y;
group.userData.phase = Math.random() * Math.PI * 2;
boats.push(group);
}
makeBoat(10.2, 5.1, -0.28, 0xa53e36, 0xe3d6b7, 1.03);
makeBoat(13.45, -0.8, 0.2, 0x356f7c, 0xdbc278, 0.82);
// A simple distant shore and mountain silhouette across Vågen.
block(scene, [12, 0.75, 1.1], [12, -0.32, -11.7], 0x617879);
const mountainMaterial = new THREE.MeshStandardMaterial({
color: 0x607b80,
roughness: 1,
flatShading: true
});
[
[8.9, 5.8, 6.4, 0.8],
[12.0, 7.8, 7.2, 1.0],
[15.5, 5.2, 6.0, 0.72]
].forEach(([x, height, radius, zShift]) => {
const mountain = new THREE.Mesh(new THREE.ConeGeometry(radius, height, 5), mountainMaterial);
mountain.position.set(x, 2.8, -13.2 + zShift);
mountain.rotation.y = x * 0.17;
mountain.castShadow = true;
scene.add(mountain);
});
for (let i = 0; i < 6; i++) {
block(scene, [1.25, 0.7 + (i % 3) * 0.35, 0.7], [7.1 + i * 1.65, 0.35, -11.6], i % 2 ? 0x718586 : 0x627779);
}
// Screen-space labels for the principal visual cues.
const labels = [];
function addLabel(title, subtitle, position) {
const element = document.createElement("div");
element.className = "scene-label";
const strong = document.createElement("b");
strong.textContent = title;
const small = document.createElement("span");
small.textContent = subtitle;
element.append(strong, small);
labelRoot.appendChild(element);
labels.push({ element, position: new THREE.Vector3(...position) });
}
addLabel("Outdoor fish stalls", "illustrative position", [3.25, 4.05, -2.6]);
addLabel("Produce stalls", "illustrative position", [-1.6, 3.85, 4.75]);
addLabel("Vågen harbor edge", "quay, bollards and steps", [6.05, 1.15, 0.1]);
addLabel("Selected urban facades", "compact illustrative backdrop", [-6.0, 10.4, -8.1]);
let labelsVisible = true;
// Custom camera controls; no examples or addons are used.
const goalTarget = new THREE.Vector3(0, 1.3, 0);
const currentTarget = goalTarget.clone();
const goalSpherical = new THREE.Spherical(43, 1.0, 0.73);
const currentSpherical = goalSpherical.clone();
const views = {
overview: { target: [0, 1.3, 0], radius: 43, phi: 1.0, theta: 0.73 },
market: { target: [0.6, 1.15, 1.4], radius: 27, phi: 1.13, theta: 0.51 },
harbor: { target: [7.0, 0.1, 2.0], radius: 23, phi: 1.14, theta: 1.03 },
facades: { target: [-4.0, 3.1, -2.8], radius: 29, phi: 1.05, theta: 0.32 }
};
function setView(name) {
const view = views[name];
goalTarget.set(...view.target);
goalSpherical.radius = view.radius;
goalSpherical.phi = view.phi;
goalSpherical.theta = view.theta;
document.querySelectorAll("[data-view]").forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
document.getElementById("toggle-labels").addEventListener("click", (event) => {
labelsVisible = !labelsVisible;
event.currentTarget.textContent = labelsVisible ? "Labels on" : "Labels off";
event.currentTarget.classList.toggle("active", labelsVisible);
});
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let dragDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
dragDistance = 0;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
dragDistance += Math.abs(dx) + Math.abs(dy);
goalSpherical.theta -= dx * 0.006;
goalSpherical.phi = THREE.MathUtils.clamp(goalSpherical.phi - dy * 0.005, 0.36, 1.38);
document.querySelectorAll("[data-view]").forEach((button) => button.classList.remove("active"));
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (dragDistance < 5) selectAt(event.clientX, event.clientY);
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
goalSpherical.radius = THREE.MathUtils.clamp(goalSpherical.radius * Math.exp(event.deltaY * 0.001), 13, 61);
}, { passive: false });
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function selectAt(clientX, clientY) {
const bounds = renderer.domElement.getBoundingClientRect();
pointer.x = ((clientX - bounds.left) / bounds.width) * 2 - 1;
pointer.y = -((clientY - bounds.top) / bounds.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(clickables, false)[0];
if (hit && hit.object.userData.title) {
selectionTitle.textContent = hit.object.userData.title;
selectionCopy.textContent = hit.object.userData.copy;
}
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
addEventListener("resize", resize);
const projected = new THREE.Vector3();
function updateLabels() {
for (const label of labels) {
if (!labelsVisible) {
label.element.style.opacity = "0";
continue;
}
projected.copy(label.position).project(camera);
const visible = projected.z > -1 && projected.z < 1 && Math.abs(projected.x) < 1.08 && Math.abs(projected.y) < 1.08;
label.element.style.opacity = visible ? "1" : "0";
label.element.style.left = `${(projected.x * 0.5 + 0.5) * innerWidth}px`;
label.element.style.top = `${(-projected.y * 0.5 + 0.5) * innerHeight}px`;
}
}
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
currentTarget.lerp(goalTarget, 0.075);
currentSpherical.radius = THREE.MathUtils.lerp(currentSpherical.radius, goalSpherical.radius, 0.08);
currentSpherical.phi = THREE.MathUtils.lerp(currentSpherical.phi, goalSpherical.phi, 0.08);
currentSpherical.theta = THREE.MathUtils.lerp(currentSpherical.theta, goalSpherical.theta, 0.08);
camera.position.setFromSpherical(currentSpherical).add(currentTarget);
camera.lookAt(currentTarget);
camera.updateMatrixWorld();
animatedPeople.forEach((person) => {
person.position.y = person.userData.baseY + Math.sin(elapsed * 1.7 + person.userData.phase) * 0.012;
});
boats.forEach((boat) => {
boat.position.y = boat.userData.baseY + Math.sin(elapsed * 0.85 + boat.userData.phase) * 0.045;
boat.rotation.z = Math.sin(elapsed * 0.65 + boat.userData.phase) * 0.008;
});
waterMaterial.color.setHSL(
0.515,
0.38,
0.37 + Math.sin(elapsed * 0.45) * 0.012
);
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
renderer.render(scene, camera);
animate();
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
</script>
</body>
</html>
```