Prompt specification
Build or customize the Three.js 3D scene "Borough Market rail-viaduct urban slice" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Borough Market rail-viaduct urban slice
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/borough-market-rail-viaduct-urban-slice-x2843
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: Borough Market rail-viaduct urban slice. Build a bounded voxel scene with referenced market roofs, partial railway viaduct, narrow streets, and stalls. Use original shop signage and avoid compressing unrelated London landmarks together. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (borough-market-rail-viaduct-urban-slice-x2843):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Borough Market — Voxel Urban Slice</title>
<style>
:root {
color-scheme: light;
--ink: #24332f;
--paper: rgba(250, 247, 238, 0.92);
--accent: #315b4d;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8d2c4;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
canvas.dragging {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 20px;
left: 20px;
z-index: 10;
width: min(360px, calc(100vw - 40px));
padding: 17px 19px 16px;
color: var(--ink);
background: var(--paper);
border: 1px solid rgba(36, 51, 47, 0.18);
border-radius: 13px;
box-shadow: 0 12px 35px rgba(42, 45, 39, 0.14);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 5px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
color: #7c725e;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(24px, 4vw, 34px);
font-weight: 600;
line-height: 1.02;
letter-spacing: -0.035em;
}
.subtitle {
margin: 8px 0 0;
color: #657069;
font-size: 12px;
line-height: 1.45;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 13px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 8px;
border: 1px solid rgba(36, 51, 47, 0.12);
border-radius: 999px;
background: rgba(255, 255, 255, 0.48);
color: #536058;
font-size: 10px;
font-weight: 700;
}
.legend i {
width: 8px;
height: 8px;
border-radius: 2px;
}
.controls {
position: fixed;
right: 18px;
bottom: 18px;
z-index: 10;
display: flex;
align-items: center;
gap: 10px;
padding: 9px 10px 9px 13px;
color: #f7f3e9;
background: rgba(31, 43, 39, 0.9);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 11px;
box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
font-size: 11px;
backdrop-filter: blur(10px);
}
.controls span {
opacity: 0.78;
}
.controls button {
appearance: none;
border: 0;
border-radius: 7px;
padding: 7px 10px;
color: #263a32;
background: #e6d9b9;
font: inherit;
font-size: 11px;
font-weight: 800;
cursor: pointer;
}
.controls button:hover {
background: #f1e6ca;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
color: #354b42;
background: #d8d2c4;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 0.45s ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 640px) {
.title-card {
top: 12px;
left: 12px;
padding: 13px 15px;
}
.subtitle,
.legend {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
.controls span {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<section class="title-card">
<div class="eyebrow">Voxel Urban Study · South London</div>
<h1>Borough Market</h1>
<p class="subtitle">
A bounded market-hall streetscape with a stepped green roof, narrow lanes,
open-air stalls, and the adjoining brick railway viaduct.
</p>
<div class="legend">
<span><i style="background:#315b4d"></i>Market ironwork</span>
<span><i style="background:#aa6d4f"></i>Stall awnings</span>
<span><i style="background:#8b5a43"></i>Rail viaduct</span>
</div>
</section>
<div class="controls">
<span>Drag to orbit · Shift/right-drag to pan · Scroll to zoom</span>
<button id="reset" type="button">Reset view</button>
</div>
<div id="loading" class="loading">Building the market slice…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene and renderer
// -------------------------------------------------------------------------
const mount = document.getElementById("scene");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d8d2c4");
scene.fog = new THREE.Fog("#d8d2c4", 58, 105);
const camera = new THREE.PerspectiveCamera(39, innerWidth / innerHeight, 0.1, 180);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
mount.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight("#e9eddf", "#675d52", 2.05);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff1cf", 3.35);
sun.position.set(-24, 38, 24);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -36;
sun.shadow.camera.right = 36;
sun.shadow.camera.top = 32;
sun.shadow.camera.bottom = -32;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 90;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#9fb9ba", 0.72);
fill.position.set(22, 14, -28);
scene.add(fill);
// -------------------------------------------------------------------------
// Shared geometry, materials, and helpers
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
if (color && color.isMaterial) return color;
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0.02
})
);
}
return materialCache.get(color);
}
function box(parent, x, y, z, w, h, d, color, castShadow = true) {
const mesh = new THREE.Mesh(unitBox, material(color));
mesh.position.set(x, y, z);
mesh.scale.set(w, h, d);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const glass = new THREE.MeshStandardMaterial({
color: "#49666a",
roughness: 0.24,
metalness: 0.22,
emissive: "#203a3b",
emissiveIntensity: 0.22
});
const skylight = new THREE.MeshStandardMaterial({
color: "#9fc5bd",
roughness: 0.35,
metalness: 0.08,
emissive: "#73998f",
emissiveIntensity: 0.18
});
const warmGlass = new THREE.MeshStandardMaterial({
color: "#f1c979",
roughness: 0.42,
emissive: "#e89d45",
emissiveIntensity: 0.42
});
function signTexture(text, background = "#26483e", foreground = "#f1e6c8") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 192;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = foreground;
ctx.globalAlpha = 0.42;
ctx.lineWidth = 5;
ctx.strokeRect(13, 13, canvas.width - 26, canvas.height - 26);
ctx.globalAlpha = 1;
let fontSize = 92;
const family = '"Trebuchet MS", Arial, sans-serif';
ctx.font = `800 ${fontSize}px ${family}`;
while (ctx.measureText(text).width > 940 && fontSize > 30) {
fontSize -= 2;
ctx.font = `800 ${fontSize}px ${family}`;
}
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function sign(parent, text, x, y, z, w, h, background = "#26483e", foreground = "#f1e6c8") {
box(parent, x, y, z, w, h, 0.12, background, false);
const texture = signTexture(text, background, foreground);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(w * 0.96, h * 0.9),
new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false
})
);
face.position.set(x, y, z + 0.067);
parent.add(face);
return face;
}
function voxelArch(parent, centerX, springY, radius, z, color, depth = 0.46, steps = 15) {
const block = radius > 3 ? 0.58 : 0.38;
for (let i = 0; i <= steps; i++) {
const angle = (i / steps) * Math.PI;
const x = centerX + Math.cos(angle) * radius;
const y = springY + Math.sin(angle) * radius;
box(parent, x, y, z, block, block, depth, color);
}
}
let seed = 73821;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function choose(list) {
return list[Math.floor(random() * list.length)];
}
// -------------------------------------------------------------------------
// Bounded diorama base and streets
// -------------------------------------------------------------------------
const world = new THREE.Group();
scene.add(world);
box(world, 0, -0.92, 0, 46, 1.8, 36, "#4a4b45");
box(world, 0, 0.05, 0, 45.2, 0.22, 35.2, "#8b8070");
box(world, 0, 0.18, 0, 44.7, 0.16, 34.7, "#a59a87");
// Raised boundary rails make the model read as a finite urban slice.
box(world, -22.65, 0.42, 0, 0.35, 0.6, 35, "#59605a");
box(world, 22.65, 0.42, 0, 0.35, 0.6, 35, "#59605a");
box(world, 0, 0.42, -17.65, 45.4, 0.6, 0.35, "#59605a");
box(world, 0, 0.42, 17.65, 45.4, 0.6, 0.35, "#59605a");
// Main lane and the two narrow side lanes.
box(world, 0, 0.25, 9.45, 44.2, 0.13, 3.65, "#4b4b48", false);
box(world, -16.65, 0.25, 1.4, 3.2, 0.13, 26.7, "#4d4d49", false);
box(world, 15.1, 0.25, 5.25, 2.25, 0.13, 17.3, "#50504c", false);
// Pavement bands.
box(world, 0, 0.31, 7.2, 44.2, 0.22, 1.15, "#b8ad98", false);
box(world, 0, 0.31, 11.75, 44.2, 0.22, 0.85, "#b8ad98", false);
box(world, -18.7, 0.31, 0.5, 1.15, 0.22, 29, "#b8ad98", false);
box(world, -14.55, 0.31, 0.5, 0.95, 0.22, 29, "#b8ad98", false);
box(world, 13.55, 0.31, 5.1, 0.8, 0.22, 17.5, "#b8ad98", false);
box(world, 16.6, 0.31, 5.1, 0.8, 0.22, 17.5, "#b8ad98", false);
// Instanced voxel cobbles.
const cobblePositions = [];
for (let x = -21.7; x <= 21.8; x += 0.92) {
for (let z = 8.0; z <= 11.0; z += 0.68) {
cobblePositions.push([x, z]);
}
}
for (let x = -18.1; x <= -15.2; x += 0.7) {
for (let z = -10.5; z <= 13.8; z += 0.83) {
cobblePositions.push([x, z]);
}
}
const cobbleMaterial = new THREE.MeshStandardMaterial({
color: "#ffffff",
roughness: 1
});
const cobbles = new THREE.InstancedMesh(unitBox, cobbleMaterial, cobblePositions.length);
cobbles.receiveShadow = true;
const dummy = new THREE.Object3D();
const cobbleColors = ["#686862", "#73736d", "#5e605c", "#7d7b73", "#696a65"];
cobblePositions.forEach(([x, z], index) => {
dummy.position.set(x, 0.35 + random() * 0.015, z + (random() - 0.5) * 0.08);
dummy.rotation.set(0, (random() - 0.5) * 0.05, 0);
dummy.scale.set(0.7 + random() * 0.13, 0.075, 0.5 + random() * 0.08);
dummy.updateMatrix();
cobbles.setMatrixAt(index, dummy.matrix);
cobbles.setColorAt(index, new THREE.Color(choose(cobbleColors)));
});
cobbles.instanceMatrix.needsUpdate = true;
if (cobbles.instanceColor) cobbles.instanceColor.needsUpdate = true;
world.add(cobbles);
// Drain strips and curb stones.
for (let x = -20; x <= 20; x += 2.5) {
box(world, x, 0.39, 8.12, 1.25, 0.08, 0.18, "#3f4542", false);
}
for (let z = -9; z <= 13; z += 2.2) {
box(world, -15.12, 0.39, z, 0.18, 0.08, 1.25, "#3f4542", false);
}
// -------------------------------------------------------------------------
// Brick railway viaduct, cropped by the edge of the slice
// -------------------------------------------------------------------------
const viaduct = new THREE.Group();
world.add(viaduct);
const brick = "#8c5843";
const brickLight = "#a36b50";
const brickDark = "#6d4438";
const pierEdges = [-8, 0, 8, 16, 23.8];
pierEdges.forEach((x) => {
box(viaduct, x, 3.85, -12.1, 1.05, 7.35, 4.8, brick);
box(viaduct, x, 0.52, -12.1, 1.35, 0.7, 5.05, brickDark);
box(viaduct, x, 7.0, -12.1, 1.3, 0.5, 5.0, brickLight);
});
[-4, 4, 12, 20].forEach((center) => {
voxelArch(viaduct, center, 3.5, 3.45, -9.75, brickLight, 0.52, 19);
voxelArch(viaduct, center, 3.5, 3.45, -14.45, brick, 0.52, 19);
});
box(viaduct, 7.8, 7.65, -12.1, 32.0, 1.05, 5.55, brick);
box(viaduct, 7.8, 8.22, -9.55, 32.0, 0.72, 0.38, brickLight);
box(viaduct, 7.8, 8.22, -14.65, 32.0, 0.72, 0.38, brickDark);
// Sparse brick course accents.
for (let x = -7; x < 23; x += 1.8) {
box(viaduct, x, 6.85, -9.47, 0.7, 0.12, 0.08, brickDark, false);
}
// Ballast, sleepers, and rails.
box(viaduct, 7.8, 8.28, -12.1, 31.7, 0.22, 3.45, "#55524b", false);
for (let x = -7.6; x < 23.5; x += 0.82) {
box(viaduct, x, 8.44, -12.1, 0.28, 0.13, 2.85, "#4a3830", false);
}
box(viaduct, 7.8, 8.58, -12.75, 31.8, 0.13, 0.13, "#a9aaa4", false);
box(viaduct, 7.8, 8.58, -11.45, 31.8, 0.13, 0.13, "#a9aaa4", false);
// Small rail-side lamp posts.
for (const x of [-6.5, 3.2, 13.8, 22.2]) {
box(viaduct, x, 9.2, -10.0, 0.12, 1.8, 0.12, "#35443e");
box(viaduct, x, 10.1, -10.0, 0.38, 0.38, 0.38, warmGlass);
}
// -------------------------------------------------------------------------
// Market hall: open iron arcade and stepped green market roof
// -------------------------------------------------------------------------
const hall = new THREE.Group();
world.add(hall);
const iron = "#315b4d";
const ironLight = "#648879";
const cream = "#d8c9a6";
box(hall, 0, 0.38, -4.7, 28.7, 0.28, 9.5, "#827761");
box(hall, 0, 2.82, -9.15, 28.2, 5.15, 0.36, "#765a47");
box(hall, -14.05, 2.82, -4.7, 0.38, 5.15, 8.95, "#765a47");
box(hall, 13.95, 2.82, -4.7, 0.38, 5.15, 8.95, "#765a47");
box(hall, 0, 1.0, 0.0, 28.0, 1.45, 0.34, "#82604a");
// Arcade columns and capitals.
const columnXs = [-14, -10, -6, -2, 2, 6, 10, 14];
columnXs.forEach((x) => {
box(hall, x, 3.08, 0.12, 0.43, 5.6, 0.48, iron);
box(hall, x, 0.58, 0.12, 0.75, 0.68, 0.78, "#49675b");
box(hall, x, 5.82, 0.12, 0.76, 0.32, 0.78, ironLight);
});
// Voxel arch rings between columns.
for (let i = 0; i < columnXs.length - 1; i++) {
const center = (columnXs[i] + columnXs[i + 1]) / 2;
voxelArch(hall, center, 3.68, 1.73, 0.23, ironLight, 0.42, 13);
}
box(hall, 0, 5.98, -4.7, 29.0, 0.32, 9.7, iron);
box(hall, 0, 6.16, 0.05, 29.1, 0.24, 0.28, ironLight);
box(hall, 0, 6.16, -9.45, 29.1, 0.24, 0.28, ironLight);
// Interior counters and warm lamps.
const interiorStallXs = [-10.5, -5.2, 0.2, 5.6, 10.5];
interiorStallXs.forEach((x, index) => {
box(hall, x, 0.95, -3.5, 2.9, 1.35, 1.25, "#9c7149");
box(hall, x, 1.68, -3.5, 3.1, 0.16, 1.4, "#c7a46e");
box(hall, x, 2.72, -3.9, 3.0, 0.18, 1.25, index % 2 ? "#b65f49" : "#507a66");
box(hall, x, 2.35, -3.18, 2.5, 0.42, 0.1, cream);
box(hall, x, 4.3, -2.9, 0.07, 1.6, 0.07, "#353d38");
box(hall, x, 4.05, -2.9, 0.42, 0.22, 0.42, warmGlass);
});
const interiorLight = new THREE.PointLight("#ffc56e", 16, 15, 2);
interiorLight.position.set(0, 4.3, -3.2);
hall.add(interiorLight);
// Stepped voxel roof: broad green bands form the shallow gabled profile.
const roofColors = ["#315b4d", "#3d6b58", "#294f44", "#477562"];
for (let k = 0; k <= 12; k++) {
const offset = (k - 6) * 0.76;
const z = -4.7 + offset;
const y = 6.27 + (1 - Math.abs(offset) / 4.56) * 1.43;
box(hall, 0, y + 0.16, z, 29.2, 0.32, 0.84, roofColors[k % roofColors.length]);
// Repeated cream ribs articulate the market's iron roof.
for (let x = -13.5; x <= 13.5; x += 2.7) {
box(hall, x, y + 0.36, z, 0.095, 0.10, 0.87, cream, false);
}
}
// Raised glazed ridge lantern.
box(hall, 0, 7.98, -4.7, 27.8, 0.28, 1.65, cream);
for (let x = -13.1; x <= 13.1; x += 1.55) {
box(hall, x, 8.17, -4.7, 1.16, 0.13, 1.27, skylight, false);
box(hall, x + 0.61, 8.26, -4.7, 0.08, 0.12, 1.4, iron, false);
}
box(hall, 0, 8.31, -4.7, 27.6, 0.15, 0.15, ironLight, false);
// Small projecting entrance canopy.
for (let k = 0; k < 6; k++) {
const z = 0.12 + k * 0.36;
const y = 5.58 - k * 0.085;
box(hall, 0, y, z, 7.4, 0.16, 0.42, k % 2 ? cream : iron);
}
box(hall, -3.45, 2.77, 1.78, 0.14, 5.3, 0.14, iron);
box(hall, 3.45, 2.77, 1.78, 0.14, 5.3, 0.14, iron);
sign(hall, "BOROUGH MARKET", 0, 4.93, 0.28, 6.1, 0.72, "#26483e", "#f2e4bd");
// -------------------------------------------------------------------------
// Shop row builder
// -------------------------------------------------------------------------
function makeShop(options) {
const {
x,
z,
rotation = 0,
width = 7.2,
depth = 5.2,
height = 8.5,
brickColor = "#80604c",
facadeColor = "#34584e",
shopName,
signColor = "#25473e",
awning = false
} = options;
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
world.add(group);
box(group, 0, height / 2 + 0.28, 0, width, height, depth, brickColor);
box(group, 0, 0.38, 0, width + 0.18, 0.5, depth + 0.18, "#5e5b51");
box(group, 0, 1.85, depth / 2 + 0.055, width, 2.75, 0.12, facadeColor);
box(group, 0, height + 0.28, 0, width + 0.3, 0.35, depth + 0.3, "#5f5144");
// Shopfront windows.
for (const wx of [-width * 0.31, width * 0.31]) {
box(group, wx, 1.65, depth / 2 + 0.14, 1.62, 1.95, 0.12, cream);
box(group, wx, 1.65, depth / 2 + 0.22, 1.34, 1.68, 0.07, glass);
box(group, wx, 1.65, depth / 2 + 0.27, 0.07, 1.68, 0.06, "#b8a783", false);
}
// Central door.
box(group, 0, 1.55, depth / 2 + 0.17, 1.08, 2.35, 0.13, "#35473f");
box(group, 0.31, 1.55, depth / 2 + 0.25, 0.06, 2.05, 0.05, warmGlass, false);
box(group, 0.34, 1.45, depth / 2 + 0.31, 0.07, 0.07, 0.08, cream, false);
sign(group, shopName, 0, 3.05, depth / 2 + 0.22, Math.min(width - 0.65, 5.8), 0.67, signColor, "#f4e7c7");
// Upper storey windows.
const upperY = height - 1.45;
const columns = Math.max(2, Math.floor(width / 2.2));
for (let i = 0; i < columns; i++) {
const wx = -width / 2 + (width / columns) * (i + 0.5);
box(group, wx, upperY, depth / 2 + 0.09, 1.18, 1.5, 0.12, cream);
box(group, wx, upperY, depth / 2 + 0.17, 0.88, 1.2, 0.07, glass);
box(group, wx, upperY, depth / 2 + 0.22, 0.07, 1.2, 0.05, "#b8a783", false);
}
// Roofline details.
box(group, width * 0.28, height + 0.86, -depth * 0.18, 0.75, 1.0, 0.8, "#765947");
box(group, -width * 0.23, height + 0.55, depth * 0.18, 1.2, 0.42, 0.95, "#70736a");
if (awning) {
for (let i = 0; i < 7; i++) {
box(
group,
0,
3.66 - i * 0.07,
depth / 2 + 0.36 + i * 0.2,
width - 0.8,
0.13,
0.26,
i % 2 ? "#b05f4d" : "#e4d5b5"
);
}
}
return group;
}
// Right-hand row faces the narrow service lane.
makeShop({
x: 19.15,
z: -5.75,
rotation: -Math.PI / 2,
width: 7.3,
depth: 5.3,
height: 8.4,
brickColor: "#8d624c",
facadeColor: "#31574c",
shopName: "RIVER & RYE",
signColor: "#25483e"
});
makeShop({
x: 19.15,
z: 2.0,
rotation: -Math.PI / 2,
width: 7.25,
depth: 5.3,
height: 10.3,
brickColor: "#76564a",
facadeColor: "#934f3f",
shopName: "SALT + SAGE",
signColor: "#733e35"
});
makeShop({
x: 19.15,
z: 9.8,
rotation: -Math.PI / 2,
width: 7.25,
depth: 5.3,
height: 8.5,
brickColor: "#8a705c",
facadeColor: "#3f5963",
shopName: "BRAMBLE BUTTER",
signColor: "#314953",
awning: true
});
// Left-hand row faces the other narrow lane.
makeShop({
x: -19.75,
z: 2.25,
rotation: Math.PI / 2,
width: 8.1,
depth: 5.4,
height: 9.1,
brickColor: "#805746",
facadeColor: "#6a583e",
shopName: "FOX & FEN",
signColor: "#50402f"
});
makeShop({
x: -19.75,
z: 10.9,
rotation: Math.PI / 2,
width: 7.7,
depth: 5.4,
height: 10.4,
brickColor: "#95664f",
facadeColor: "#765443",
shopName: "MORROW BAKEHOUSE",
signColor: "#5d4134",
awning: true
});
// -------------------------------------------------------------------------
// Market stalls, crates, produce, and original signage
// -------------------------------------------------------------------------
const produceColors = ["#d64f37", "#e4aa32", "#76913d", "#b84c62", "#d98d32", "#7d4c81"];
function makeCrate(parent, x, z, color = "#986b43", produceColor = null) {
box(parent, x, 0.57, z, 1.08, 0.7, 0.8, color);
box(parent, x, 0.89, z, 1.12, 0.09, 0.84, "#b88a58");
for (let i = 0; i < 3; i++) {
box(parent, x - 0.35 + i * 0.35, 0.57, z + 0.43, 0.08, 0.58, 0.05, "#634731", false);
}
if (produceColor) {
for (let i = 0; i < 6; i++) {
box(
parent,
x - 0.34 + (i % 3) * 0.32 + random() * 0.06,
1.04 + Math.floor(i / 3) * 0.16,
z - 0.18 + Math.floor(i / 3) * 0.3,
0.24,
0.24,
0.24,
i % 3 === 0 ? produceColor : choose(produceColors)
);
}
}
}
function makeStall(options) {
const {
x,
z,
width = 2.85,
name,
awningA = "#a75742",
awningB = "#e2d3ad",
accent = "#426b59",
rotation = 0
} = options;
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
world.add(group);
// Counter and legs.
box(group, 0, 1.03, 0, width, 1.4, 1.45, "#966a43");
box(group, 0, 1.79, 0, width + 0.16, 0.16, 1.58, "#c39b62");
box(group, -width / 2 + 0.15, 1.85, -0.6, 0.13, 3.55, 0.13, accent);
box(group, width / 2 - 0.15, 1.85, -0.6, 0.13, 3.55, 0.13, accent);
// Stepped striped canopy.
for (let i = 0; i < 6; i++) {
const localZ = -0.78 + i * 0.31;
const localY = 3.3 - Math.abs(localZ) * 0.19;
box(
group,
0,
localY,
localZ,
width + 0.25,
0.16,
0.37,
i % 2 ? awningA : awningB
);
}
box(group, 0, 3.48, 0, width + 0.3, 0.14, 0.14, accent);
sign(group, name, 0, 2.35, 0.79, width - 0.08, 0.47, accent, "#f4e5bd");
// Produce and bread on the counter.
for (let i = 0; i < 8; i++) {
box(
group,
-width * 0.38 + random() * width * 0.76,
2.0,
-0.38 + random() * 0.66,
0.25,
0.25,
0.25,
choose(produceColors)
);
}
makeCrate(group, -width / 2 - 0.2, 0.56, "#85603f", choose(produceColors));
makeCrate(group, width / 2 + 0.08, 0.4, "#9b7048", choose(produceColors));
return group;
}
const stallNames = [
"TURNIP & THISTLE",
"MORROW BAKES",
"RYE & RIVER",
"CITRUS CART",
"FIELD & FLINT",
"EMBER ROOT"
];
[-10.8, -6.7, -2.6, 1.5, 5.6, 9.7].forEach((x, index) => {
makeStall({
x,
z: 2.75,
name: stallNames[index],
awningA: index % 2 ? "#3d7460" : "#a75742",
awningB: "#e4d4ad",
accent: index % 2 ? "#315b4d" : "#744a38"
});
});
// A second, smaller cart keeps the front pavement lively without blocking the lane.
makeStall({
x: -8.9,
z: 6.1,
width: 2.35,
name: "MINT & MOSS",
awningA: "#3d7460",
awningB: "#dfcfa8",
accent: "#315b4d"
});
// -------------------------------------------------------------------------
// Street furniture and planting
// -------------------------------------------------------------------------
function streetLamp(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
world.add(group);
box(group, 0, 2.45, 0, 0.13, 4.6, 0.13, "#36463f");
box(group, 0, 0.38, 0, 0.42, 0.5, 0.42, "#36463f");
box(group, 0.33, 4.72, 0, 0.78, 0.12, 0.12, "#36463f");
box(group, 0.7, 4.56, 0, 0.32, 0.38, 0.32, warmGlass);
box(group, 0.7, 4.78, 0, 0.48, 0.12, 0.42, "#36463f");
}
streetLamp(-14.25, 6.55, Math.PI / 2);
streetLamp(13.25, 6.55, -Math.PI / 2);
streetLamp(-13.95, -7.9, Math.PI / 2);
streetLamp(13.25, -1.6, -Math.PI / 2);
function planter(x, z, size = 1) {
box(world, x, 0.52, z, 1.25 * size, 0.75, 1.25 * size, "#82745f");
box(world, x, 0.93, z, 1.05 * size, 0.1, 1.05 * size, "#4a4437");
box(world, x, 1.65 * size, z, 0.24 * size, 2.0 * size, 0.24 * size, "#68513d");
box(world, x - 0.42 * size, 2.45 * size, z, 0.95 * size, 0.95 * size, 0.95 * size, "#647842");
box(world, x + 0.42 * size, 2.72 * size, z, 0.9 * size, 1.05 * size, 0.9 * size, "#71854a");
box(world, x, 3.02 * size, z - 0.18 * size, 0.85 * size, 0.8 * size, 0.85 * size, "#819452");
}
planter(13.95, 3.8, 0.85);
planter(13.95, 11.8, 0.95);
planter(-13.95, 11.9, 0.85);
planter(-18.85, -7.7, 0.8);
// Bollards.
for (const x of [-12, -8, -4, 0, 4, 8, 12]) {
box(world, x, 0.69, 7.03, 0.18, 0.78, 0.18, "#3e4943");
box(world, x, 1.05, 7.03, 0.26, 0.13, 0.26, "#718077", false);
}
// Waste bins and stacked delivery crates.
for (const [x, z] of [[12.8, 5.8], [-14.3, 5.8], [-14.1, -5.6]]) {
box(world, x, 0.83, z, 0.78, 1.15, 0.72, "#40574d");
box(world, x, 1.46, z, 0.86, 0.12, 0.8, "#2d3d36");
for (let i = 0; i < 3; i++) {
box(world, x, 0.67 + i * 0.19, z + 0.38, 0.52, 0.05, 0.04, "#253a33", false);
}
}
// -------------------------------------------------------------------------
// Voxel pedestrians
// -------------------------------------------------------------------------
function makePerson(x, z, shirtColor, rotation = 0, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
world.add(group);
const trousers = choose(["#35444b", "#5b4d42", "#3d4d3e", "#555565"]);
const skin = choose(["#c88f68", "#9b664c", "#e0ad83", "#6f4939"]);
const hair = choose(["#2e2925", "#4a3326", "#70523c", "#202321"]);
box(group, -0.16, 0.42, 0, 0.22, 0.72, 0.26, trousers);
box(group, 0.16, 0.42, 0, 0.22, 0.72, 0.26, trousers);
box(group, -0.16, 0.08, 0.06, 0.26, 0.16, 0.4, "#2a2b29");
box(group, 0.16, 0.08, 0.06, 0.26, 0.16, 0.4, "#2a2b29");
box(group, 0, 1.13, 0, 0.68, 0.77, 0.38, shirtColor);
box(group, -0.48, 1.13, 0, 0.19, 0.66, 0.24, shirtColor);
box(group, 0.48, 1.13, 0, 0.19, 0.66, 0.24, shirtColor);
box(group, 0, 1.73, 0, 0.4, 0.4, 0.4, skin);
box(group, 0, 1.94, -0.015, 0.43, 0.12, 0.42, hair);
}
const people = [
[-12.5, 8.7, "#c46a4f", 0.2],
[-10.2, 9.6, "#466c69", -0.7],
[-7.4, 8.45, "#d0a74c", 1.2],
[-4.9, 9.75, "#5a526f", -0.4],
[-1.5, 8.8, "#788754", 0.8],
[2.4, 9.55, "#a24e4e", -1.1],
[5.8, 8.6, "#4d6d87", 0.4],
[9.2, 9.8, "#c58a58", -0.8],
[12.1, 8.75, "#6a7651", 1.1],
[-17.2, -7.4, "#5f657b", 0.6],
[-16.1, -3.4, "#b4674f", -0.6],
[-16.4, 4.8, "#62806e", 1.0],
[15.1, -4.1, "#b2904c", 0.1],
[15.0, 2.7, "#4d6971", -0.7],
[14.9, 10.5, "#9e554c", 0.6],
[-8.4, 5.9, "#d2b071", 0.2],
[7.2, 5.7, "#6c586e", -0.9],
[0.1, 1.2, "#3f6f61", 1.0],
[11.2, 1.25, "#c78252", -0.4]
];
people.forEach(([x, z, color, rotation], index) => {
makePerson(x, z, color, rotation, index % 5 === 0 ? 1.06 : 0.94 + random() * 0.12);
});
// -------------------------------------------------------------------------
// Base plaque and small foreground details
// -------------------------------------------------------------------------
sign(world, "BOROUGH MARKET · RAIL VIADUCT", 0, -0.53, 18.08, 15.0, 0.86, "#2e493f", "#ead9ae");
// A few loose paving accents and leaves keep the model from feeling sterile.
const leafColors = ["#a16a35", "#b47c3e", "#7e713d"];
for (let i = 0; i < 28; i++) {
const x = random() * 41 - 20.5;
const z = random() > 0.5 ? 7.65 + random() * 0.35 : 11.35 + random() * 0.25;
box(world, x, 0.42, z, 0.12, 0.025, 0.18, choose(leafColors), false);
}
// -------------------------------------------------------------------------
// Custom orbit, pan, zoom, and keyboard controls
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 2.3, -0.7),
theta: 0.82,
phi: 0.91,
radius: 49
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
function resetView() {
controls.target.set(0, 2.3, -0.7);
controls.theta = 0.82;
controls.phi = 0.91;
controls.radius = innerWidth < 650 ? 57 : 49;
updateCamera();
}
const canvas = renderer.domElement;
let dragging = false;
let panning = false;
let lastX = 0;
let lastY = 0;
let pointerId = null;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
if (pointerId !== null) return;
pointerId = event.pointerId;
dragging = true;
panning = event.button === 2 || event.shiftKey;
lastX = event.clientX;
lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", event => {
if (!dragging || event.pointerId !== pointerId) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
if (panning) {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3(forward.z, 0, -forward.x);
const scale = controls.radius * 0.00145;
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(forward, -dy * scale);
controls.target.x = THREE.MathUtils.clamp(controls.target.x, -17, 17);
controls.target.z = THREE.MathUtils.clamp(controls.target.z, -14, 14);
} else {
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(controls.phi - dy * 0.005, 0.38, 1.34);
}
updateCamera();
});
function endDrag(event) {
if (event.pointerId !== pointerId) return;
dragging = false;
panning = false;
pointerId = null;
canvas.classList.remove("dragging");
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
27,
78
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
document.getElementById("reset").addEventListener("click", resetView);
addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetView();
});
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
resetView();
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 500);
});
</script>
</body>
</html>
```