Prompt specification
Build or customize the Three.js 3D scene "Addis Ababa arcade shopfront and curb tile" 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: Addis Ababa arcade shopfront and curb tile
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/addis-ababa-arcade-shopfront-and-curb-tile-x2885
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows the Piazza district of Addis Ababa. Build a referenced Piazza-area shopfront fragment with arcade, threshold, and curb. Keep the covered pedestrian space readable and use original business signage. Low-poly.
Working Three.js Starter (addis-ababa-arcade-shopfront-and-curb-tile-x2885):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Piazza District — Addis Ababa</title>
<style>
:root {
--ink: #f5f0e4;
--muted: #bdc8bf;
--accent: #e2b45b;
--panel: rgba(18, 28, 25, 0.86);
--line: rgba(255, 255, 255, 0.16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cbd8d3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app, canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
canvas {
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.hud {
position: fixed;
z-index: 3;
pointer-events: none;
}
.title-card {
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 19px 21px 18px;
border: 1px solid var(--line);
border-left: 4px solid var(--accent);
background: var(--panel);
backdrop-filter: blur(12px);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
.eyebrow {
margin: 0 0 7px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 39px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.025em;
}
.subtitle {
margin: 11px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.viewbar {
bottom: 24px;
left: 50%;
display: flex;
gap: 4px;
padding: 5px;
transform: translateX(-50%);
border: 1px solid var(--line);
border-radius: 999px;
background: var(--panel);
backdrop-filter: blur(12px);
pointer-events: auto;
box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
}
.viewbar button {
min-width: 92px;
padding: 9px 14px;
border: 0;
border-radius: 999px;
color: var(--muted);
background: transparent;
font: inherit;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.04em;
cursor: pointer;
transition: 160ms ease;
}
.viewbar button:hover,
.viewbar button.active {
color: #17221e;
background: var(--accent);
}
.detail-card {
right: 24px;
bottom: 24px;
width: 260px;
padding: 16px 17px;
border: 1px solid var(--line);
background: var(--panel);
backdrop-filter: blur(12px);
box-shadow: 0 14px 38px rgba(0, 0, 0, 0.17);
}
.detail-card strong {
display: block;
margin-bottom: 7px;
color: var(--accent);
font-size: 10px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.detail-card p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 13px;
margin-top: 12px;
color: #e8e5dc;
font-size: 9px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.legend span::before {
content: "";
display: inline-block;
width: 7px;
height: 7px;
margin-right: 6px;
border-radius: 50%;
background: var(--swatch);
}
.hint {
top: 25px;
right: 25px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 5px;
color: #26352f;
background: rgba(247, 244, 231, 0.84);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#loading {
position: fixed;
z-index: 10;
inset: 0;
display: grid;
place-items: center;
color: #20302a;
background: #dbe3dc;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.title-card {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
.subtitle { display: none; }
.hint { display: none; }
.detail-card { display: none; }
.viewbar {
bottom: 13px;
width: calc(100vw - 24px);
justify-content: center;
}
.viewbar button {
min-width: 0;
flex: 1;
padding: 9px 8px;
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="app"></div>
<header class="hud title-card">
<p class="eyebrow">Addis Ababa · Ethiopia</p>
<h1>Piazza District</h1>
<p class="subtitle">
A low-poly street study of arcaded shopfronts, shaded thresholds,
civic paving, and the cathedral skyline.
</p>
</header>
<div class="hud hint">Drag to orbit · Scroll to zoom</div>
<nav class="hud viewbar" aria-label="Camera views">
<button class="active" data-view="district">District</button>
<button data-view="shopfront">Shopfront</button>
<button data-view="plan">Plan</button>
</nav>
<aside class="hud detail-card">
<strong>Focal fragment</strong>
<p>
A recessed café bay behind a continuous arcade, with a raised shop
threshold, stone curb, and sheltered pedestrian paving.
</p>
<div class="legend">
<span style="--swatch:#c98c46">Arcade</span>
<span style="--swatch:#e4d3ae">Threshold</span>
<span style="--swatch:#718176">Curb</span>
</div>
</aside>
<div id="loading">Constructing Piazza…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const loading = document.getElementById("loading");
// ---------------------------------------------------------------------
// Renderer, scene, and camera
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd5e0db);
scene.fog = new THREE.Fog(0xd5e0db, 27, 66);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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;
app.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
120
);
const orbit = {
target: new THREE.Vector3(0, 2.1, -2.3),
desiredTarget: new THREE.Vector3(0, 2.1, -2.3),
radius: 24,
desiredRadius: 24,
theta: 0.08,
desiredTheta: 0.08,
phi: 1.12,
desiredPhi: 1.12
};
function updateCamera(dt) {
const smoothing = 1 - Math.exp(-dt * 7.5);
orbit.target.lerp(orbit.desiredTarget, smoothing);
orbit.radius += (orbit.desiredRadius - orbit.radius) * smoothing;
orbit.theta += (orbit.desiredTheta - orbit.theta) * smoothing;
orbit.phi += (orbit.desiredPhi - orbit.phi) * smoothing;
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xeaf3ef, 0x776b56, 2.15));
const sun = new THREE.DirectionalLight(0xffe6bc, 3.25);
sun.position.set(-12, 19, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -22;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 58;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const coolFill = new THREE.DirectionalLight(0xb7d7dd, 0.62);
coolFill.position.set(12, 9, -12);
scene.add(coolFill);
// ---------------------------------------------------------------------
// Materials and geometry helpers
// ---------------------------------------------------------------------
const standard = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...options
});
const M = {
ground: standard(0xb9ad91),
plaza: standard(0xcac0a7),
asphalt: standard(0x5d625e),
gutter: standard(0x444a46),
sidewalk: standard(0xc7bea7),
joint: standard(0xa79d86),
curb: standard(0x90978b),
ochre: standard(0xc78345),
cream: standard(0xe5d8b9),
paleGreen: standard(0x98aa91),
terracotta: standard(0xa9563f),
dustyRose: standard(0xc48772),
greenTrim: standard(0x456b59),
darkGreen: standard(0x28483b),
blue: standard(0x3b6974),
dark: standard(0x25322f),
window: standard(0x203f45, { roughness: 0.36 }),
warmLight: standard(0xe9bd6c),
metal: standard(0x59635f, { metalness: 0.2, roughness: 0.6 }),
trunk: standard(0x6d4e34),
leaf: standard(0x4f7650),
leafLight: standard(0x708c55),
flower: standard(0xbb5d4a),
yellow: standard(0xe0a52c),
white: standard(0xede9d9),
roadPaint: standard(0xd8d0ae),
water: standard(0x6ca9a8, { roughness: 0.25 }),
skinA: standard(0x6f4633),
skinB: standard(0x9a6848),
skinC: standard(0x4f3328),
shirtRed: standard(0xa9443c),
shirtBlue: standard(0x385c72),
shirtCream: standard(0xd8cdb5),
shirtGreen: standard(0x506b4d)
};
function box(w, h, d, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
radiusTop,
radiusBottom,
height,
segments,
material,
x,
y,
z,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function lowPolySphere(radius, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.DodecahedronGeometry(radius, 0),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
function makeSignMaterial(title, subtitle, background, foreground, accent) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 18, canvas.height);
ctx.fillRect(0, canvas.height - 15, canvas.width, 15);
ctx.strokeStyle = accent;
ctx.lineWidth = 3;
ctx.strokeRect(31, 23, 962, 210);
let size = 72;
ctx.font = `800 ${size}px Arial, sans-serif`;
while (ctx.measureText(title).width > 875 && size > 30) {
size -= 2;
ctx.font = `800 ${size}px Arial, sans-serif`;
}
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(title, 522, 108);
ctx.fillStyle = accent;
ctx.font = "700 27px Arial, sans-serif";
ctx.fillText(subtitle, 522, 183);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide
});
}
function signPlane(
width,
height,
material,
x,
y,
z,
side,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
material
);
mesh.position.set(x, y, z);
mesh.rotation.y = side < 0 ? Math.PI / 2 : -Math.PI / 2;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Ground, road, curb, threshold, and pedestrian paving
// ---------------------------------------------------------------------
box(38, 0.18, 54, M.ground, 0, -0.16, -7);
box(20, 0.08, 12, M.plaza, 0, -0.035, -12.5);
// Main road.
box(5.72, 0.08, 25.5, M.asphalt, 0, 0.015, 2.6);
for (let z = -9.3; z < 15; z += 2.1) {
box(0.09, 0.025, 0.92, M.roadPaint, 0, 0.068, z);
}
// Pedestrian crossings.
for (let z = 9.55; z < 11.75; z += 0.46) {
box(5.55, 0.024, 0.25, M.roadPaint, 0, 0.073, z);
}
for (const side of [-1, 1]) {
// Raised sidewalks.
box(1.93, 0.18, 25.7, M.sidewalk, side * 3.86, 0.09, 2.6);
// Continuous stone curb and dark gutter.
box(0.25, 0.24, 25.7, M.curb, side * 2.79, 0.12, 2.6);
box(0.2, 0.03, 25.6, M.gutter, side * 2.61, 0.066, 2.6);
// Paving joints emphasize the arcade's sheltered ground plane.
for (let z = -9.8; z <= 15; z += 1.35) {
box(1.76, 0.012, 0.025, M.joint, side * 3.86, 0.186, z);
}
box(0.025, 0.012, 25.3, M.joint, side * 3.86, 0.188, 2.6);
}
// ---------------------------------------------------------------------
// Arcaded shopfront blocks
// ---------------------------------------------------------------------
function createArcadeBlock(
side,
startZ,
length,
bays,
facadeMaterial,
shopData,
canopyMaterial
) {
const endZ = startZ + length;
const centerZ = startZ + length / 2;
const bayWidth = length / bays;
const wallX = side * 7.04;
// Main upper mass.
box(
4.38,
7.05,
length,
facadeMaterial,
wallX,
3.54,
centerZ
);
// Ground plinth and upper cornice.
box(4.55, 0.48, length + 0.08, M.cream, wallX, 0.25, centerZ);
box(4.58, 0.22, length + 0.18, M.cream, wallX, 7.13, centerZ);
box(4.7, 0.16, length + 0.30, M.terracotta, wallX, 7.31, centerZ);
// Flat roof and small roof projections.
box(4.32, 0.12, length - 0.12, M.terracotta, wallX, 7.44, centerZ);
for (let i = 0; i < 3; i++) {
box(
0.38,
0.74,
0.42,
facadeMaterial,
side * 7.35,
7.82,
startZ + length * (0.22 + i * 0.28)
);
}
// Arcade canopy.
box(
1.94,
0.18,
length,
canopyMaterial,
side * 3.91,
3.25,
centerZ
);
// Outer fascia emphasizes the covered edge.
box(
0.16,
0.48,
length,
canopyMaterial,
side * 2.98,
3.02,
centerZ
);
// Continuous stone sill at the shop threshold.
box(
0.28,
0.14,
length,
M.cream,
side * 4.59,
0.27,
centerZ
);
for (let i = 0; i <= bays; i++) {
const z = startZ + i * bayWidth;
// Column shaft, base, and capital.
cylinder(0.14, 0.17, 2.72, 8, M.cream, side * 3.03, 1.67, z);
cylinder(0.24, 0.27, 0.18, 8, M.cream, side * 3.03, 0.39, z);
cylinder(0.24, 0.18, 0.18, 8, M.cream, side * 3.03, 3.03, z);
// Small brackets.
box(0.38, 0.12, 0.28, M.cream, side * 3.23, 2.92, z);
}
for (let i = 0; i < bays; i++) {
const z = startZ + (i + 0.5) * bayWidth;
const data = shopData[i % shopData.length];
// Dark recessed shop volume.
box(
0.13,
2.42,
bayWidth - 0.24,
M.dark,
side * 4.80,
1.52,
z
);
// Door and narrow glazed side panel.
box(
0.10,
2.18,
0.88,
M.greenTrim,
side * 4.69,
1.34,
z - 0.68
);
box(
0.11,
1.32,
0.82,
M.warmLight,
side * 4.68,
1.54,
z + 0.66
);
box(
0.13,
0.055,
0.82,
M.darkGreen,
side * 4.62,
1.55,
z + 0.66
);
box(
0.13,
1.35,
0.055,
M.darkGreen,
side * 4.62,
1.54,
z + 0.66
);
// Raised sill at the recessed entrance.
box(
0.38,
0.13,
bayWidth - 0.20,
M.cream,
side * 4.52,
0.24,
z
);
// Original business sign.
const signMaterial = makeSignMaterial(
data.title,
data.subtitle,
data.bg,
data.fg,
data.accent
);
signPlane(
bayWidth - 0.30,
0.60,
signMaterial,
side * 4.61,
2.82,
z,
side
);
// Upper-storey window.
box(
0.12,
1.35,
1.05,
M.window,
side * 4.78,
4.77,
z
);
box(
0.17,
0.10,
1.20,
M.cream,
side * 4.71,
5.48,
z
);
// Painted shutters.
box(
0.16,
1.42,
0.34,
M.greenTrim,
side * 4.70,
4.76,
z - 0.70
);
box(
0.16,
1.42,
0.34,
M.greenTrim,
side * 4.70,
4.76,
z + 0.70
);
// Narrow balcony rail.
for (let n = 0; n < 5; n++) {
box(
0.06,
0.54,
0.045,
M.darkGreen,
side * 4.37,
3.87,
z - 0.56 + n * 0.28
);
}
box(
0.07,
0.055,
1.26,
M.darkGreen,
side * 4.37,
4.13,
z
);
}
// Warm lights make the covered pedestrian strip legible.
const lightCount = Math.max(2, Math.round(length / 5));
for (let i = 0; i < lightCount; i++) {
const z = startZ + length * ((i + 0.5) / lightCount);
const lamp = new THREE.PointLight(0xffc879, 0.48, 5.2, 2);
lamp.position.set(side * 3.65, 2.9, z);
scene.add(lamp);
cylinder(
0.10,
0.16,
0.12,
8,
M.warmLight,
side * 3.67,
3.03,
z
);
}
}
createArcadeBlock(
-1,
-7.1,
14.0,
4,
M.ochre,
[
{
title: "TAYTU COFFEE",
subtitle: "ROASTED IN ADDIS",
bg: "#23473e",
fg: "#f5e8c9",
accent: "#d8a34c"
},
{
title: "ADDAS PAPER & PRESS",
subtitle: "BOOKS · PRINTS · PAPER",
bg: "#f0e4c8",
fg: "#2e443e",
accent: "#a94b3f"
},
{
title: "MESKEL SPICE",
subtitle: "BERBERE · TEFF · SMOKE",
bg: "#743d30",
fg: "#f5dfb0",
accent: "#d6a345"
},
{
title: "SELAM BEADS",
subtitle: "HAND-STRUNG · SMALL GIFTS",
bg: "#e3c783",
fg: "#253f39",
accent: "#8b493a"
}
],
M.terracotta
);
createArcadeBlock(
1,
-8.0,
13.2,
4,
M.dustyRose,
[
{
title: "HABESHA STUDIO",
subtitle: "LEATHER · TEXTILES",
bg: "#f1dfb9",
fg: "#743d31",
accent: "#315c4b"
},
{
title: "WUBA NOON",
subtitle: "FRESH JUICE · SALADS",
bg: "#335d4e",
fg: "#f5e6c5",
accent: "#e0a93e"
},
{
title: "PIAZZA POST",
subtitle: "POSTCARDS · STAMPS",
bg: "#d9b65a",
fg: "#263f3a",
accent: "#9c4438"
},
{
title: "LUCY'S LATTES",
subtitle: "ESPRESSO · SODA · TEA",
bg: "#8b4d3d",
fg: "#f7e7c5",
accent: "#e4bc63"
}
],
M.greenTrim
);
// ---------------------------------------------------------------------
// Piazza landmark: a stylized St. George's Cathedral
// ---------------------------------------------------------------------
const cathedral = new THREE.Group();
cathedral.position.set(0, 0, -15.6);
scene.add(cathedral);
box(9.6, 0.42, 9.0, M.cream, 0, 0.21, 0, cathedral);
box(8.7, 0.22, 8.1, M.terracotta, 0, 0.52, 0, cathedral);
cylinder(3.82, 4.05, 3.65, 8, M.dustyRose, 0, 2.42, 0, cathedral);
cylinder(3.34, 3.82, 0.72, 8, M.cream, 0, 4.57, 0, cathedral);
const dome = new THREE.Mesh(
new THREE.SphereGeometry(3.34, 8, 4, 0, Math.PI * 2, 0, Math.PI / 2),
M.darkGreen
);
dome.position.y = 4.92;
dome.castShadow = true;
cathedral.add(dome);
cylinder(0.58, 0.72, 1.25, 8, M.cream, 0, 7.62, 0, cathedral);
const cap = new THREE.Mesh(
new THREE.ConeGeometry(0.88, 1.12, 8),
M.darkGreen
);
cap.position.y = 8.78;
cap.castShadow = true;
cathedral.add(cap);
// Cross.
box(0.12, 1.18, 0.12, M.metal, 0, 9.68, 0, cathedral);
box(0.62, 0.12, 0.12, M.metal, 0, 9.77, 0, cathedral);
// Entrance toward the square.
box(2.5, 2.55, 0.30, M.cream, 0, 1.85, 3.88, cathedral);
box(1.65, 2.15, 0.18, M.darkGreen, 0, 1.67, 4.08, cathedral);
const arch = new THREE.Mesh(
new THREE.CircleGeometry(0.84, 12, 0, Math.PI),
M.darkGreen
);
arch.position.set(0, 2.73, 4.19);
cathedral.add(arch);
// Octagonal buttresses.
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2 + Math.PI / 8;
const buttress = box(
0.55,
3.2,
0.72,
M.cream,
Math.sin(angle) * 3.75,
2.15,
Math.cos(angle) * 3.75,
cathedral
);
buttress.rotation.y = angle;
}
// Square bell tower.
box(2.25, 8.2, 2.25, M.cream, 4.55, 4.55, -0.3, cathedral);
box(2.48, 0.24, 2.48, M.dustyRose, 4.55, 8.75, -0.3, cathedral);
for (const y of [5.9, 7.35]) {
box(0.12, 1.05, 0.70, M.dark, 3.86, y, -0.3, cathedral);
}
const towerRoof = new THREE.Mesh(
new THREE.ConeGeometry(1.72, 1.65, 4),
M.terracotta
);
towerRoof.position.set(4.55, 9.63, -0.3);
towerRoof.rotation.y = Math.PI / 4;
towerRoof.castShadow = true;
cathedral.add(towerRoof);
// Landmark label.
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 1024;
labelCanvas.height = 128;
const labelContext = labelCanvas.getContext("2d");
labelContext.fillStyle = "rgba(28, 43, 38, 0.84)";
labelContext.fillRect(0, 0, 1024, 128);
labelContext.fillStyle = "#e7c879";
labelContext.textAlign = "center";
labelContext.textBaseline = "middle";
labelContext.font = "700 35px Arial";
labelContext.fillText("ST. GEORGE'S CATHEDRAL", 512, 64);
const labelTexture = new THREE.CanvasTexture(labelCanvas);
labelTexture.colorSpace = THREE.SRGBColorSpace;
const label = new THREE.Sprite(
new THREE.SpriteMaterial({
map: labelTexture,
transparent: true,
depthWrite: false
})
);
label.position.set(0, 9.45, -15.5);
label.scale.set(5.2, 0.65, 1);
scene.add(label);
// ---------------------------------------------------------------------
// Trees, planters, lamps, and street furniture
// ---------------------------------------------------------------------
function createTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(0.18, 0.26, 2.4, 7, M.trunk, 0, 1.2, 0, group);
lowPolySphere(1.15, M.leaf, 0, 2.8, 0, group);
lowPolySphere(0.80, M.leafLight, 0.62, 3.15, 0.12, group);
lowPolySphere(0.75, M.leaf, -0.55, 3.0, -0.18, group);
box(1.65, 0.28, 1.65, M.cream, 0, 0.14, 0, group);
box(1.44, 0.08, 1.44, M.dark, 0, 0.31, 0, group);
}
[
[-7.4, -10.8, 1.05],
[7.4, -10.8, 1.1],
[-7.0, 5.0, 0.83],
[7.0, 5.0, 0.86],
[-5.4, -6.8, 0.7],
[5.4, -6.8, 0.72]
].forEach((p) => createTree(...p));
function createLamp(side, z) {
const x = side * 3.14;
cylinder(0.065, 0.09, 3.65, 8, M.darkGreen, x, 1.84, z);
box(0.65, 0.08, 0.08, M.darkGreen, x - side * 0.25, 3.64, z);
box(0.37, 0.13, 0.25, M.warmLight, x - side * 0.52, 3.54, z);
}
[-7, -1, 5, 11].forEach((z) => {
createLamp(-1, z);
createLamp(1, z);
});
for (const side of [-1, 1]) {
for (let z = -5; z <= 9; z += 2.8) {
cylinder(
0.09,
0.11,
0.62,
8,
M.darkGreen,
side * 2.93,
0.52,
z
);
}
}
// Cafe seating under the right-hand arcade.
function createCafeTable(x, z) {
cylinder(0.48, 0.48, 0.08, 12, M.cream, x, 0.93, z);
cylinder(0.065, 0.09, 0.82, 8, M.metal, x, 0.47, z);
for (const dz of [-0.68, 0.68]) {
box(0.40, 0.07, 0.40, M.greenTrim, x, 0.48, z + dz);
box(0.40, 0.48, 0.07, M.greenTrim, x, 0.73, z + dz + 0.16);
for (const dx of [-0.15, 0.15]) {
box(0.045, 0.45, 0.045, M.metal, x + dx, 0.25, z + dz);
}
}
}
createCafeTable(3.76, 2.1);
createCafeTable(3.76, 4.1);
createCafeTable(-3.76, -0.7);
// ---------------------------------------------------------------------
// Low-poly people
// ---------------------------------------------------------------------
const animatedPeople = [];
function createPerson(x, z, options = {}) {
const group = new THREE.Group();
group.position.set(x, 0.2, z);
const skin = options.skin || M.skinA;
const shirt = options.shirt || M.shirtRed;
const scale = options.scale || 1;
group.scale.setScalar(scale);
const torso = new THREE.Mesh(
new THREE.CylinderGeometry(0.20, 0.27, 0.70, 7),
shirt
);
torso.position.y = 1.15;
torso.castShadow = true;
group.add(torso);
lowPolySphere(0.17, skin, 0, 1.69, 0, group);
const hair = lowPolySphere(
0.175,
options.hair || M.dark,
0,
1.76,
-0.025,
group
);
hair.scale.y = 0.62;
const leftLeg = box(
0.12,
0.72,
0.14,
M.dark,
-0.12,
0.48,
0,
group
);
const rightLeg = box(
0.12,
0.72,
0.14,
M.dark,
0.12,
0.48,
0,
group
);
box(0.10, 0.58, 0.12, skin, -0.28, 1.10, 0, group);
box(0.10, 0.58, 0.12, skin, 0.28, 1.10, 0, group);
if (options.bag) {
box(0.28, 0.35, 0.16, M.terracotta, 0.35, 0.75, 0, group);
}
scene.add(group);
if (options.animate) {
animatedPeople.push({
group,
leftLeg,
rightLeg,
baseX: x,
baseZ: z,
phase: Math.random() * Math.PI * 2
});
}
}
createPerson(-3.70, -5.0, { skin: M.skinB, shirt: M.shirtCream, animate: true });
createPerson(-4.12, -4.55, { skin: M.skinA, shirt: M.shirtGreen, bag: true });
createPerson(3.72, 3.55, { skin: M.skinC, shirt: M.shirtBlue });
createPerson(3.95, 4.55, { skin: M.skinB, shirt: M.shirtRed, animate: true });
createPerson(-3.82, 1.9, { skin: M.skinA, shirt: M.shirtBlue });
createPerson(1.45, 5.8, { skin: M.skinB, shirt: M.shirtGreen, animate: true });
createPerson(-1.15, -4.8, { skin: M.skinC, shirt: M.shirtCream, animate: true });
createPerson(0.8, -8.7, { skin: M.skinA, shirt: M.shirtRed, animate: true });
createPerson(-2.1, -9.5, { skin: M.skinB, shirt: M.shirtBlue });
createPerson(2.1, -9.3, { skin: M.skinC, shirt: M.shirtGreen });
// ---------------------------------------------------------------------
// Small city vehicles
// ---------------------------------------------------------------------
function createTaxi(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.08, z);
group.rotation.y = rotation;
scene.add(group);
box(1.36, 0.48, 2.85, M.yellow, 0, 0.55, 0, group);
box(1.20, 0.58, 1.53, M.white, 0, 1.05, -0.17, group);
box(1.10, 0.42, 0.06, M.window, 0, 1.10, 0.62, group);
box(0.06, 0.42, 1.25, M.window, -0.61, 1.10, -0.17, group);
box(0.06, 0.42, 1.25, M.window, 0.61, 1.10, -0.17, group);
box(0.58, 0.18, 0.24, M.dark, 0, 1.44, -0.17, group);
for (const dx of [-0.68, 0.68]) {
for (const dz of [-0.92, 0.92]) {
const wheel = cylinder(
0.28,
0.28,
0.16,
10,
M.dark,
dx,
0.32,
dz,
group
);
wheel.rotation.z = Math.PI / 2;
}
}
}
createTaxi(1.47, 5.9, 0);
createTaxi(-1.45, -2.6, Math.PI);
function createMinibus(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.08, z);
group.rotation.y = rotation;
scene.add(group);
box(1.65, 1.72, 3.85, M.blue, 0, 1.12, 0, group);
box(1.48, 0.64, 0.08, M.window, 0, 1.43, 1.95, group);
box(0.08, 0.58, 1.05, M.window, 0.84, 1.42, -0.72, group);
box(0.08, 0.58, 1.05, M.window, -0.84, 1.42, -0.72, group);
box(1.69, 0.18, 3.65, M.cream, 0, 0.43, 0, group);
for (const dx of [-0.84, 0.84]) {
for (const dz of [-1.25, 1.25]) {
const wheel = cylinder(
0.34,
0.34,
0.18,
10,
M.dark,
dx,
0.38,
dz,
group
);
wheel.rotation.z = Math.PI / 2;
}
}
}
createMinibus(1.63, -6.6, Math.PI);
// ---------------------------------------------------------------------
// Bunting across the street
// ---------------------------------------------------------------------
function createBunting(z, colorOffset = 0) {
const points = [];
const colors = [
0xc95b48,
0xd8a63f,
0x3d6c5a,
0xe0d4b1,
0x3e7180
];
for (let i = 0; i <= 20; i++) {
const x = -4.75 + (9.5 * i) / 20;
const y = 6.25 - 0.85 * (1 - Math.pow(x / 4.75, 2));
points.push(new THREE.Vector3(x, y, z));
}
const lineGeometry = new THREE.BufferGeometry().setFromPoints(points);
scene.add(
new THREE.Line(
lineGeometry,
new THREE.LineBasicMaterial({ color: 0x39443d })
)
);
for (let i = 0; i < 14; i++) {
const x = -4.45 + (8.9 * i) / 13;
const y = 6.25 - 0.85 * (1 - Math.pow(x / 4.75, 2));
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(
[-0.19, 0, 0, 0.19, 0, 0, 0, -0.42, 0],
3
)
);
geometry.computeVertexNormals();
const flag = new THREE.Mesh(
geometry,
new THREE.MeshBasicMaterial({
color: colors[(i + colorOffset) % colors.length],
side: THREE.DoubleSide
})
);
flag.position.set(x, y - 0.02, z);
scene.add(flag);
}
}
createBunting(3.2, 0);
createBunting(-3.6, 2);
// ---------------------------------------------------------------------
// Custom camera controls
// ---------------------------------------------------------------------
let dragging = false;
let lastX = 0;
let lastY = 0;
let activePointer = null;
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
activePointer = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointer) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
orbit.desiredTheta -= dx * 0.005;
orbit.desiredPhi = THREE.MathUtils.clamp(
orbit.desiredPhi - dy * 0.004,
0.38,
1.46
);
});
function endDrag(event) {
if (event.pointerId !== activePointer) return;
dragging = false;
activePointer = null;
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.desiredRadius = THREE.MathUtils.clamp(
orbit.desiredRadius + event.deltaY * 0.012,
5.5,
42
);
},
{ passive: false }
);
const views = {
district: {
target: [0, 2.1, -2.3],
radius: 24,
theta: 0.08,
phi: 1.12
},
shopfront: {
target: [-4.05, 1.55, -5.05],
radius: 9.2,
theta: 0.56,
phi: 1.16
},
plan: {
target: [0, 0.4, -2.0],
radius: 27,
theta: 0,
phi: 0.53
}
};
const buttons = [...document.querySelectorAll("[data-view]")];
function setView(name) {
const view = views[name];
orbit.desiredTarget.set(...view.target);
orbit.desiredRadius = view.radius;
orbit.desiredTheta = view.theta;
orbit.desiredPhi = view.phi;
buttons.forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
buttons.forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
window.addEventListener("keydown", (event) => {
if (event.key === "1") setView("district");
if (event.key === "2") setView("shopfront");
if (event.key === "3") setView("plan");
if (event.key === "ArrowLeft") orbit.desiredTheta -= 0.12;
if (event.key === "ArrowRight") orbit.desiredTheta += 0.12;
if (event.key === "ArrowUp") orbit.desiredPhi -= 0.08;
if (event.key === "ArrowDown") orbit.desiredPhi += 0.08;
});
// ---------------------------------------------------------------------
// Resize and animation
// ---------------------------------------------------------------------
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 clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
updateCamera(dt);
animatedPeople.forEach((person, index) => {
const movement = Math.sin(elapsed * 0.62 + person.phase);
person.group.position.z = person.baseZ + movement * 0.42;
person.leftLeg.rotation.x = movement * 0.26;
person.rightLeg.rotation.x = -movement * 0.26;
person.group.position.y =
0.2 + Math.abs(Math.sin(elapsed * 1.24 + person.phase)) * 0.018;
});
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updateCamera(1);
animate();
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```