Prompt specification
Build or customize the Three.js 3D scene "Mercado Modelo waterfront market in Salvador" 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: Mercado Modelo waterfront market in Salvador
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/mercado-modelo-waterfront-market-in-salvador-x2643
Scene Description Prompt:
Create one standalone low-poly HTML scene using Three.js from cdnjs. Show a bounded waterfront market fragment around Mercado Modelo, Salvador, in the former neoclassical customs house at Praça Visconde de Cairu. Use the building silhouette in the IMS historic photograph (https://acervos.ims.com.br/index.php/Detail/objects/47463) and evidence from Bahia SETUR (https://www.ba.gov.br/turismo/noticia/2024-07/3809/mercado-modelo-diversidade-e-historia-atraem-turistas-para-a-primeira-capital-do). Show the rectangular pale masonry facade with repeated arched openings. Include a quay edge, small boats and varied market stalls with clear activities in a bounded schematic arrangement. Cite these two references and distinguish the documented building from illustrative stall and quay placement.
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 (mercado-modelo-waterfront-market-in-salvador-x2643):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mercado Modelo — Waterfront Fragment</title>
<style>
:root {
color-scheme: light;
--ink: #283235;
--muted: #607075;
--paper: rgba(250, 247, 238, 0.94);
--line: rgba(48, 64, 67, 0.18);
--teal: #287b7b;
--orange: #bd6944;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9dde1;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.panel {
background: var(--paper);
border: 1px solid var(--line);
box-shadow: 0 12px 34px rgba(34, 50, 53, 0.15);
backdrop-filter: blur(10px);
}
.title-card {
position: absolute;
top: 18px;
left: 18px;
width: min(410px, calc(100vw - 36px));
padding: 17px 19px 16px;
border-radius: 16px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(40, 123, 123, 0.12);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 3vw, 36px);
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.025em;
}
.subtitle {
margin: 9px 0 0;
max-width: 360px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.controls {
position: absolute;
top: 18px;
right: 18px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 7px;
width: min(390px, calc(100vw - 36px));
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(48, 64, 67, 0.2);
border-radius: 999px;
padding: 9px 13px;
background: rgba(250, 247, 238, 0.94);
color: #344346;
box-shadow: 0 4px 14px rgba(34, 50, 53, 0.1);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
transition: background 140ms ease, transform 140ms ease, border-color 140ms ease;
}
button:hover {
background: #fffdf7;
border-color: rgba(40, 123, 123, 0.52);
transform: translateY(-1px);
}
button:focus-visible {
outline: 3px solid rgba(40, 123, 123, 0.28);
outline-offset: 2px;
}
button[aria-pressed="true"] {
color: white;
background: var(--teal);
border-color: var(--teal);
}
#evidence-panel {
position: absolute;
left: 18px;
bottom: 18px;
width: min(570px, calc(100vw - 36px));
max-height: min(46vh, 430px);
overflow: auto;
padding: 16px 18px;
border-radius: 15px;
transform: translateY(0);
opacity: 1;
transition: opacity 180ms ease, transform 180ms ease;
}
#evidence-panel.closed {
opacity: 0;
transform: translateY(18px);
pointer-events: none;
}
#evidence-panel h2 {
margin: 0 0 8px;
font-family: Georgia, "Times New Roman", serif;
font-size: 19px;
font-weight: 500;
}
#evidence-panel p {
margin: 7px 0;
font-size: 12.5px;
line-height: 1.48;
}
.documented,
.illustrative {
display: inline-block;
width: 9px;
height: 9px;
margin-right: 6px;
border-radius: 2px;
vertical-align: 1px;
}
.documented { background: var(--teal); }
.illustrative { background: var(--orange); }
.references {
margin-top: 11px;
padding-top: 10px;
border-top: 1px solid var(--line);
}
.references p {
margin: 5px 0;
color: #536164;
font-size: 10.5px;
line-height: 1.4;
overflow-wrap: anywhere;
}
.references strong {
color: #334245;
}
.legend {
position: absolute;
right: 18px;
bottom: 18px;
padding: 11px 13px;
border-radius: 12px;
color: #536164;
font-size: 10.5px;
line-height: 1.65;
}
.legend div { white-space: nowrap; }
.interaction-note {
position: absolute;
right: 18px;
bottom: 112px;
padding: 7px 10px;
border-radius: 9px;
background: rgba(250, 247, 238, 0.78);
color: #58676a;
font-size: 10.5px;
}
#labels {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
transition: opacity 160ms ease;
}
#labels.hidden { opacity: 0; }
.scene-label {
position: absolute;
transform: translate(-50%, -100%);
padding: 6px 9px;
border: 1px solid rgba(38, 54, 57, 0.18);
border-radius: 8px;
background: rgba(252, 249, 240, 0.92);
box-shadow: 0 5px 15px rgba(32, 49, 52, 0.12);
color: #34474a;
font-size: 10.5px;
font-weight: 750;
letter-spacing: 0.015em;
white-space: nowrap;
}
.scene-label.documented { border-left: 4px solid var(--teal); }
.scene-label.illustrative { border-left: 4px solid var(--orange); }
#loading {
position: fixed;
inset: 0;
display: grid;
place-items: center;
z-index: 20;
background: #c9dde1;
color: #3f595c;
font-size: 13px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#loading.hidden { display: none; }
@media (max-width: 760px) {
.title-card {
top: 10px;
left: 10px;
width: min(330px, calc(100vw - 20px));
padding: 13px 15px;
}
.subtitle { font-size: 11.5px; }
.controls {
top: auto;
right: 10px;
bottom: 10px;
width: min(360px, calc(100vw - 20px));
}
button { padding: 8px 10px; font-size: 10.5px; }
#evidence-panel {
left: 10px;
bottom: 66px;
width: calc(100vw - 20px);
max-height: 48vh;
}
.legend, .interaction-note { display: none; }
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive low-poly interpretation of Mercado Modelo and its waterfront"></main>
<div class="hud">
<header class="title-card panel">
<div class="eyebrow">Salvador · Bahia · schematic reconstruction</div>
<h1>Mercado Modelo</h1>
<p class="subtitle">
A bounded waterfront fragment at Praça Visconde de Cairu: the documented
neoclassical customs-house shell, with an illustrative market and quay layer.
</p>
</header>
<nav class="controls" aria-label="Scene controls">
<button type="button" data-view="overview" aria-pressed="true">Overview</button>
<button type="button" data-view="facade">Facade</button>
<button type="button" data-view="waterfront">Waterfront</button>
<button type="button" id="toggle-labels" aria-pressed="true">Labels</button>
<button type="button" id="toggle-evidence" aria-expanded="true">Evidence & sources</button>
</nav>
<div id="labels" aria-hidden="true">
<div class="scene-label documented" data-label="building">Documented shell · former customs house</div>
<div class="scene-label illustrative" data-label="stalls">Illustrative stalls and trading</div>
<div class="scene-label illustrative" data-label="quay">Schematic quay edge</div>
<div class="scene-label illustrative" data-label="boats">Illustrative small boats</div>
</div>
<section id="evidence-panel" class="panel" aria-label="Interpretation and references">
<h2>What is documented, and what is illustrative?</h2>
<p>
<span class="documented"></span><strong>Documented shell.</strong>
The long, pale, rectangular neoclassical facade, repeated arched openings,
cornice and central classical pediment are a diagrammatic silhouette study
based on the IMS historic photograph. The building's identity as the former
customs house, its location at Praça Visconde de Cairu, and its historic
market role are supported by Bahia SETUR.
</p>
<p>
<span class="illustrative"></span><strong>Illustrative layer.</strong>
Individual stalls, awnings, produce, fish, vendors, visitors, crates, trees,
boats, mooring points and the exact quay placement are schematic scene
devices. They communicate waterfront commerce and loading activity but are
not a surveyed or claimed reconstruction of the market's present layout.
</p>
<div class="references">
<p>
<strong>[1] IMS historic photograph, object 47463.</strong><br>
https://acervos.ims.com.br/index.php/Detail/objects/47463
</p>
<p>
<strong>[2] Bahia SETUR, “Mercado Modelo: diversidade e história atraem
turistas para a primeira capital do,” July 2024.</strong><br>
https://www.ba.gov.br/turismo/noticia/2024-07/3809/mercado-modelo-diversidade-e-historia-atraem-turistas-para-a-primeira-capital-do
</p>
</div>
</section>
<div class="interaction-note">Drag to orbit · Shift/right-drag to pan · Wheel to zoom</div>
<aside class="legend panel" aria-label="Legend">
<div><span class="documented"></span>Reference-based building shell</div>
<div><span class="illustrative"></span>Schematic activity and waterfront</div>
</aside>
</div>
<div id="loading">Building the waterfront 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 host = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.domElement.setAttribute("aria-label", "Low-poly three-dimensional Mercado Modelo waterfront scene");
renderer.domElement.tabIndex = 0;
host.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc9dde1);
scene.fog = new THREE.Fog(0xc9dde1, 68, 132);
const camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, 0.1, 220);
const hemi = new THREE.HemisphereLight(0xf2fbff, 0x796c5b, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffefd0, 3.25);
sun.position.set(-24, 38, 25);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -42;
sun.shadow.camera.right = 42;
sun.shadow.camera.top = 35;
sun.shadow.camera.bottom = -28;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 110;
sun.shadow.bias = -0.00035;
scene.add(sun);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.86,
metalness: options.metalness ?? 0,
flatShading: options.flatShading ?? true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
side: options.side ?? THREE.FrontSide
});
const M = {
stone: material(0xe5d9c2),
stoneLight: material(0xf3ead7),
stoneShade: material(0xcbbda4),
recess: material(0x4c4943),
window: material(0x354d50, { roughness: 0.48 }),
roof: material(0x777268),
roofLight: material(0x918b7f),
plaza: material(0xd7c8ae),
plazaEdge: material(0xb8a78d),
ground: material(0xbcae94),
water: material(0x4f8e98, { roughness: 0.55 }),
waterDark: material(0x3e7884, { roughness: 0.6 }),
foam: material(0xbdd6d5, { transparent: true, opacity: 0.58 }),
wood: material(0x74513a),
woodLight: material(0xa1744f),
dark: material(0x343b3b),
iron: material(0x455052, { metalness: 0.28, roughness: 0.62 }),
cream: material(0xf4e6cb),
red: material(0xb75b48),
mustard: material(0xd5a641),
green: material(0x668a63),
blue: material(0x4d7e99),
orange: material(0xd17c45),
pink: material(0xc98779),
leaf: material(0x668a61),
leafLight: material(0x86a16b),
trunk: material(0x755640),
skin: material(0xb77f5d),
skinLight: material(0xd09a74),
skinDark: material(0x8c5f45),
silver: material(0xaeb9b7, { roughness: 0.48 }),
fishDark: material(0x617b7d, { roughness: 0.55 })
};
function mesh(geometry, mat, x = 0, y = 0, z = 0, parent = scene) {
const object = new THREE.Mesh(geometry, mat);
object.position.set(x, y, z);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(parent, w, h, d, mat, x = 0, y = 0, z = 0) {
return mesh(new THREE.BoxGeometry(w, h, d), mat, x, y, z, parent);
}
function cylinder(parent, rTop, rBottom, h, mat, x = 0, y = 0, z = 0, segments = 8) {
return mesh(new THREE.CylinderGeometry(rTop, rBottom, h, segments), mat, x, y, z, parent);
}
function ico(parent, radius, mat, x = 0, y = 0, z = 0, detail = 0) {
return mesh(new THREE.IcosahedronGeometry(radius, detail), mat, x, y, z, parent);
}
function rod(parent, a, b, radius, mat, segments = 6) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const middle = start.clone().add(end).multiplyScalar(0.5);
const object = cylinder(parent, radius, radius, direction.length(), mat, middle.x, middle.y, middle.z, segments);
object.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), direction.normalize());
return object;
}
// ---------------------------------------------------------------------
// Bounded land, quay, and low-poly water
// ---------------------------------------------------------------------
box(scene, 54, 0.72, 28, M.ground, 0, -0.36, -6);
box(scene, 51, 0.08, 13.5, M.plaza, 0, 0.045, 0.65);
box(scene, 51.4, 0.12, 0.32, M.plazaEdge, 0, 0.1, 7.55);
const quayWall = box(scene, 54, 1.25, 0.58, M.stoneShade, 0, -0.5, 8.05);
quayWall.receiveShadow = true;
box(scene, 54, 0.18, 0.76, M.stoneLight, 0, 0.1, 8.02);
const waterGeometry = new THREE.PlaneGeometry(54, 10, 18, 7);
const waterPositions = waterGeometry.attributes.position;
for (let i = 0; i < waterPositions.count; i++) {
waterPositions.setZ(i, (Math.sin(i * 2.17) + Math.cos(i * 0.73)) * 0.028);
}
waterGeometry.computeVertexNormals();
const water = mesh(waterGeometry, M.water, 0, -0.78, 13.35);
water.rotation.x = -Math.PI / 2;
water.castShadow = false;
const waterPatches = [];
for (let i = 0; i < 20; i++) {
const patch = box(
scene,
1.1 + (i % 4) * 0.45,
0.018,
0.06,
i % 3 === 0 ? M.waterDark : M.foam,
-25 + i * 2.55,
-0.69,
8.8 + (i * 1.73) % 8.7
);
patch.rotation.y = (i % 2 ? 1 : -1) * 0.16;
patch.castShadow = false;
waterPatches.push(patch);
}
// ---------------------------------------------------------------------
// Mercado Modelo: reference-based neoclassical shell
// ---------------------------------------------------------------------
const building = new THREE.Group();
scene.add(building);
// Main pale masonry mass and long low roof silhouette.
box(building, 42, 8.35, 8.1, M.stone, 0, 4.175, -8.55);
box(building, 42.7, 0.34, 8.65, M.stoneLight, 0, 8.35, -8.55);
box(building, 42.25, 0.17, 8.3, M.stoneShade, 0, 5.13, -8.55);
box(building, 42.25, 0.18, 8.3, M.stoneLight, 0, 8.05, -8.55);
function makeHippedRoof(width, depth, height) {
const w = width / 2;
const d = depth / 2;
const inset = 1.05;
const vertices = new Float32Array([
-w, 0, -d, w, 0, -d, w, 0, d, -w, 0, d,
-w + inset, height, 0, w - inset, height, 0
]);
const indices = [
0, 4, 5, 0, 5, 1,
1, 5, 3, 1, 3, 2,
2, 3, 5,
0, 3, 4,
3, 2, 5,
3, 5, 4
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
mesh(makeHippedRoof(43.2, 8.9, 0.78), M.roof, 0, 8.48, -8.55, building);
box(building, 40.9, 0.12, 0.36, M.roofLight, 0, 9.26, -8.55);
// A perforated ground-floor facade, with eleven true arched openings.
const facadeShape = new THREE.Shape();
facadeShape.moveTo(-21, 0);
facadeShape.lineTo(21, 0);
facadeShape.lineTo(21, 5);
facadeShape.lineTo(-21, 5);
facadeShape.closePath();
const archCenters = [];
for (let i = 0; i < 11; i++) {
const cx = -18 + i * 3.6;
archCenters.push(cx);
const r = 1.12;
const spring = 3.05;
const hole = new THREE.Path();
hole.moveTo(cx + r, 0.22);
hole.lineTo(cx - r, 0.22);
hole.lineTo(cx - r, spring);
hole.absarc(cx, spring, r, Math.PI, 0, true);
hole.lineTo(cx + r, 0.22);
hole.closePath();
facadeShape.holes.push(hole);
}
const facadeGeometry = new THREE.ExtrudeGeometry(facadeShape, {
depth: 0.55,
bevelEnabled: false,
curveSegments: 12
});
mesh(facadeGeometry, M.stoneLight, 0, 0, -4.55, building);
// Dark recessed arch fields and individually modeled low-poly voussoirs.
for (const cx of archCenters) {
const r = 1.055;
const spring = 3.05;
const arch = new THREE.Shape();
arch.moveTo(-r, 0.22);
arch.lineTo(r, 0.22);
arch.lineTo(r, spring);
arch.absarc(0, spring, r, 0, Math.PI, false);
arch.lineTo(-r, 0.22);
arch.closePath();
mesh(new THREE.ShapeGeometry(arch, 12), M.recess, cx, 0, -4.47, building);
for (let j = 0; j <= 10; j++) {
const angle = (j / 10) * Math.PI;
const radius = 1.24;
const block = box(
building,
0.35,
0.22,
0.28,
j % 2 ? M.stone : M.stoneLight,
cx + Math.cos(angle) * radius,
spring + Math.sin(angle) * radius,
-3.84
);
block.rotation.z = angle - Math.PI / 2;
}
box(building, 0.18, 2.88, 0.24, M.stone, cx - 1.18, 1.66, -3.84);
box(building, 0.18, 2.88, 0.24, M.stone, cx + 1.18, 1.66, -3.84);
}
// Upper-level window rhythm.
for (let i = 0; i < 13; i++) {
const x = -18 + i * 3;
box(building, 1.42, 1.78, 0.16, M.window, x, 6.7, -4.43);
box(building, 1.68, 0.13, 0.24, M.stoneLight, x, 5.88, -4.39);
box(building, 1.68, 0.13, 0.24, M.stoneLight, x, 7.55, -4.39);
box(building, 0.12, 1.8, 0.24, M.stoneLight, x - 0.72, 6.7, -4.39);
box(building, 0.12, 1.8, 0.24, M.stoneLight, x + 0.72, 6.7, -4.39);
box(building, 0.07, 1.72, 0.27, M.stoneShade, x, 6.7, -4.35);
box(building, 1.34, 0.07, 0.27, M.stoneShade, x, 6.7, -4.34);
}
// End pilasters and a central doorway.
for (const x of [-20.35, 20.35]) {
box(building, 0.72, 7.9, 0.38, M.stone, x, 4.0, -3.82);
box(building, 0.94, 0.24, 0.54, M.stoneLight, x, 8.03, -3.75);
}
box(building, 2.35, 4.25, 0.17, M.recess, 0, 2.18, -4.38);
// Central portico: six columns, entablature, and triangular pediment.
box(building, 10.7, 0.22, 2.05, M.stoneLight, 0, 0.12, -3.48);
box(building, 9.6, 0.18, 1.45, M.stoneShade, 0, 0.31, -3.34);
for (const x of [-4.2, -2.52, -0.84, 0.84, 2.52, 4.2]) {
cylinder(building, 0.22, 0.27, 7.45, M.stoneLight, x, 4.12, -3.25, 10);
cylinder(building, 0.38, 0.38, 0.2, M.stone, x, 0.5, -3.25, 10);
box(building, 0.65, 0.2, 0.65, M.stoneLight, x, 7.88, -3.25);
}
box(building, 10.55, 0.62, 1.35, M.stoneLight, 0, 8.3, -3.35);
const pedimentShape = new THREE.Shape();
pedimentShape.moveTo(-5.25, 0);
pedimentShape.lineTo(5.25, 0);
pedimentShape.lineTo(0, 2.08);
pedimentShape.closePath();
const pedimentGeometry = new THREE.ExtrudeGeometry(pedimentShape, {
depth: 0.68,
bevelEnabled: false
});
mesh(pedimentGeometry, M.stoneLight, 0, 8.6, -3.72, building);
const tympanumShape = new THREE.Shape();
tympanumShape.moveTo(-4.2, 0.05);
tympanumShape.lineTo(4.2, 0.05);
tympanumShape.lineTo(0, 1.48);
tympanumShape.closePath();
mesh(new THREE.ShapeGeometry(tympanumShape), M.stoneShade, 0, 8.75, -3.015, building);
rod(building, [-4.95, 8.69, -2.98], [0, 10.59, -2.98], 0.09, M.stone, 5);
rod(building, [0, 10.59, -2.98], [4.95, 8.69, -2.98], 0.09, M.stone, 5);
// ---------------------------------------------------------------------
// People and market objects
// ---------------------------------------------------------------------
const shirtMaterials = new Map();
function shirtMaterial(color) {
if (!shirtMaterials.has(color)) shirtMaterials.set(color, material(color));
return shirtMaterials.get(color);
}
function person(x, z, shirtColor, options = {}) {
const group = new THREE.Group();
group.position.set(x, options.y ?? 0.08, z);
group.rotation.y = options.rotation ?? 0;
const scale = options.scale ?? 1;
group.scale.setScalar(scale);
scene.add(group);
const skin = options.skin ?? M.skin;
const shirt = shirtMaterial(shirtColor);
const trousers = options.trousers ?? M.dark;
rod(group, [-0.12, 0.78, 0], [-0.13, 0.12, 0.02], 0.09, trousers);
rod(group, [0.12, 0.78, 0], [0.14, 0.12, -0.03], 0.09, trousers);
box(group, 0.22, 0.12, 0.34, M.dark, -0.14, 0.06, 0.08);
box(group, 0.22, 0.12, 0.34, M.dark, 0.14, 0.06, -0.04);
cylinder(group, 0.23, 0.29, 0.72, shirt, 0, 1.18, 0, 7);
ico(group, 0.25, skin, 0, 1.82, 0, 1);
ico(group, 0.245, M.dark, 0, 1.95, -0.025, 0);
const pose = options.pose ?? "stand";
if (pose === "vendor") {
rod(group, [-0.25, 1.46, 0], [-0.48, 1.0, 0.36], 0.075, shirt);
rod(group, [0.25, 1.46, 0], [0.48, 1.0, 0.36], 0.075, shirt);
ico(group, 0.08, skin, -0.48, 0.98, 0.36, 0);
ico(group, 0.08, skin, 0.48, 0.98, 0.36, 0);
} else if (pose === "carry") {
rod(group, [-0.25, 1.43, 0], [-0.34, 1.0, 0.38], 0.075, shirt);
rod(group, [0.25, 1.43, 0], [0.34, 1.0, 0.38], 0.075, shirt);
} else if (pose === "wave") {
rod(group, [-0.25, 1.44, 0], [-0.42, 1.08, 0.05], 0.075, shirt);
rod(group, [0.25, 1.44, 0], [0.48, 1.88, 0.02], 0.075, shirt);
ico(group, 0.08, skin, 0.49, 1.91, 0.02, 0);
} else {
rod(group, [-0.25, 1.44, 0], [-0.36, 0.98, 0.03], 0.075, shirt);
rod(group, [0.25, 1.44, 0], [0.36, 0.98, -0.03], 0.075, shirt);
ico(group, 0.08, skin, -0.36, 0.95, 0.03, 0);
ico(group, 0.08, skin, 0.36, 0.95, -0.03, 0);
}
return group;
}
function crate(parent, x, y, z, size = 0.72) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
box(group, size, size * 0.68, size, M.wood, 0, size * 0.34, 0);
for (const sx of [-0.34, 0.34]) {
box(group, size * 0.09, size * 0.72, size * 1.03, M.woodLight, sx * size, size * 0.34, 0);
}
for (const sz of [-0.34, 0.34]) {
box(group, size * 1.03, size * 0.72, size * 0.09, M.woodLight, 0, size * 0.34, sz * size);
}
return group;
}
function basket(parent, x, y, z, r = 0.38) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
cylinder(group, r * 0.88, r * 0.67, 0.34, M.woodLight, 0, 0.17, 0, 8);
cylinder(group, r * 0.91, r * 0.91, 0.045, M.wood, 0, 0.35, 0, 8);
return group;
}
function fish(parent, x, y, z, rotation = 0, dark = false) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
parent.add(group);
const body = ico(group, 0.28, dark ? M.fishDark : M.silver, 0, 0, 0, 1);
body.scale.set(1.55, 0.42, 0.56);
const tail = mesh(new THREE.ConeGeometry(0.18, 0.3, 3), dark ? M.fishDark : M.silver, -0.43, 0, 0, group);
tail.rotation.z = Math.PI / 2;
const fin = mesh(new THREE.ConeGeometry(0.1, 0.18, 3), dark ? M.fishDark : M.silver, 0, 0.13, 0, group);
fin.scale.z = 0.5;
ico(group, 0.032, M.dark, 0.19, 0.04, 0.13, 0);
return group;
}
function makeStall(options) {
const { x, z, type, color, accent, rotation = 0 } = options;
const group = new THREE.Group();
group.position.set(x, 0.08, z);
group.rotation.y = rotation;
scene.add(group);
const primary = material(color);
const secondary = material(accent);
// Counter and supports.
box(group, 3.75, 0.18, 1.5, M.woodLight, 0, 0.94, 0.12);
box(group, 3.55, 0.38, 0.1, M.wood, 0, 0.66, 0.78);
for (const sx of [-1.63, 1.63]) {
for (const sz of [-0.55, 0.82]) {
box(group, 0.1, 2.35, 0.1, M.wood, sx, 1.23, sz);
}
}
// Six striped canopy panels, each split into two sloping planes.
for (let i = 0; i < 6; i++) {
const px = -1.75 + i * 0.7;
for (const half of [-1, 1]) {
const roof = box(
group,
0.68,
0.11,
1.33,
i % 2 ? secondary : primary,
px,
2.52,
half * 0.58
);
roof.rotation.x = half * 0.29;
}
}
rod(group, [-1.95, 2.82, 0], [1.95, 2.82, 0], 0.055, M.wood);
for (let i = 0; i < 6; i++) {
box(group, 0.67, 0.28, 0.06, i % 2 ? secondary : primary, -1.75 + i * 0.7, 2.18, 1.12);
}
if (type === "fish") {
box(group, 3.15, 0.08, 1.15, M.silver, 0, 1.07, 0.08);
for (let i = 0; i < 6; i++) {
fish(group, -1.18 + i * 0.45, 1.17, 0.08 + (i % 2) * 0.26, i % 2 ? 0.18 : -0.18, i % 3 === 0);
}
fish(group, -1.1, 1.86, -0.75, Math.PI / 2, true);
fish(group, -0.72, 1.85, -0.76, Math.PI / 2, false);
crate(group, -2.08, 0.1, 0.25, 0.64);
} else if (type === "fruit") {
const colors = [M.red, M.mustard, M.green];
for (let i = 0; i < 3; i++) {
const bx = -1.12 + i * 1.12;
const b = basket(group, bx, 1.04, 0.12, 0.4);
for (let j = 0; j < 5; j++) {
const fruit = ico(b, 0.13, colors[(i + j) % 3], (j % 2 - 0.5) * 0.35, 0.42, (Math.floor(j / 2) - 0.5) * 0.34, 0);
fruit.scale.y = 0.85;
}
}
} else if (type === "produce") {
for (let i = 0; i < 3; i++) {
const c = crate(group, -1.15 + i * 1.15, 1.03, 0.1, 0.78);
for (let j = 0; j < 4; j++) {
ico(c, 0.16, j % 2 ? M.green : M.orange, (j % 2 - 0.5) * 0.3, 0.58, (Math.floor(j / 2) - 0.5) * 0.28, 0);
}
}
} else if (type === "textile") {
for (let i = 0; i < 4; i++) {
const cloth = box(group, 0.48, 1.15, 0.07, i % 2 ? M.blue : M.red, -1.38 + i * 0.9, 1.65, -0.64);
cloth.rotation.z = (i - 1.5) * 0.025;
}
box(group, 1.05, 0.25, 0.6, M.mustard, -0.8, 1.12, 0.1);
box(group, 0.85, 0.22, 0.55, M.blue, 0.85, 1.11, 0.15);
} else if (type === "spice") {
const spiceColors = [M.red, M.mustard, M.orange, M.green];
for (let i = 0; i < 4; i++) {
const b = basket(group, -1.35 + i * 0.9, 1.04, 0.1, 0.34);
const mound = ico(b, 0.29, spiceColors[i], 0, 0.43, 0, 0);
mound.scale.y = 0.4;
}
} else {
for (let i = 0; i < 4; i++) {
const pot = cylinder(group, 0.26, 0.2, 0.38, i % 2 ? M.cream : M.red, -1.25 + i * 0.84, 1.2, 0.1, 8);
ico(group, 0.22, M.green, pot.position.x, 1.46, 0.1, 0);
}
}
const vendor = person(0, -1.04, color, {
pose: type === "textile" ? "stand" : "vendor",
rotation: 0,
skin: iSkin(options.skinIndex)
});
vendor.position.x += x;
vendor.position.z += z;
vendor.position.y = 0.08;
if (options.customer) {
const shopper = person(x + (options.customerOffset ?? 0.55), z + 1.28, options.customerColor ?? M.blue, {
pose: "stand",
rotation: Math.PI,
skin: iSkin((options.skinIndex + 1) % 3)
});
}
return group;
}
function iSkin(index) {
return [M.skin, M.skinLight, M.skinDark][index % 3];
}
makeStall({ x: -15, z: -1.15, type: "fish", color: 0xb75b48, accent: 0xf0dfc5, skinIndex: 0, customer: true, customerColor: 0x4d7e99 });
makeStall({ x: -7, z: -1.05, type: "fruit", color: 0xd5a641, accent: 0xf5ead7, skinIndex: 1, customer: true, customerColor: 0x7a5b67 });
makeStall({ x: 7.1, z: -1.15, type: "textile", color: 0x4d7e99, accent: 0xb75b48, skinIndex: 2, customer: true, customerColor: 0xd17c45 });
makeStall({ x: 15, z: -0.7, type: "flowers", color: 0xc98779, accent: 0xf0dfc5, skinIndex: 0 });
makeStall({ x: -13.2, z: 3.8, type: "produce", color: 0x668a63, accent: 0xf0dfc5, skinIndex: 1, customer: true, customerColor: 0xbd6944 });
makeStall({ x: -5.2, z: 4.15, type: "spice", color: 0xd17c45, accent: 0xf3e5c9, skinIndex: 2, customer: true, customerColor: 0x536d83 });
makeStall({ x: 5.1, z: 4.1, type: "fruit", color: 0xb75b48, accent: 0xe9d9b8, skinIndex: 0, customer: true, customerColor: 0x5f7660 });
makeStall({ x: 13.4, z: 3.7, type: "fish", color: 0x4d7e99, accent: 0xf0dfc5, skinIndex: 1, customer: true, customerColor: 0xd5a641 });
// Additional clear activities: greeting, carrying, and loading.
person(-2.5, 1.25, 0x668a63, { pose: "wave", rotation: 0.25, skin: M.skinLight });
person(1.9, 0.15, 0xbd6944, { pose: "stand", rotation: -0.5, skin: M.skinDark });
person(-9.8, 6.15, 0x4d7e99, { pose: "carry", rotation: 0.25, skin: M.skin });
person(10.8, 6.2, 0xd5a641, { pose: "carry", rotation: Math.PI, skin: M.skinLight });
crate(scene, -9.8, 1.05, 6.58, 0.65);
crate(scene, 10.8, 1.05, 6.55, 0.65);
crate(scene, 17.2, 0.08, 5.9, 0.78);
crate(scene, 17.2, 0.62, 5.9, 0.78);
// ---------------------------------------------------------------------
// Quay furniture, trees, lamps, and small boats
// ---------------------------------------------------------------------
for (const x of [-22, -16, -10, -4, 4, 10, 16, 22]) {
cylinder(scene, 0.13, 0.18, 0.6, M.iron, x, 0.43, 7.76, 8);
ico(scene, 0.19, M.iron, x, 0.75, 7.76, 0);
}
for (const x of [-20, 20]) {
for (let i = 0; i < 4; i++) {
box(scene, 2.4, 0.16, 0.7, M.stoneLight, x, -0.08 - i * 0.18, 8.15 + i * 0.55);
}
}
function tree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.05, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(group, 0.16, 0.23, 2.8, M.trunk, 0, 1.4, 0, 7);
ico(group, 1.25, M.leaf, 0, 3.1, 0, 1);
ico(group, 0.92, M.leafLight, -0.58, 3.65, 0.05, 0);
ico(group, 0.84, M.leaf, 0.64, 3.48, -0.04, 0);
ico(group, 0.72, M.leafLight, 0.12, 4.0, 0.18, 0);
}
tree(-23.1, -0.6, 0.92);
tree(23.1, -0.9, 0.98);
tree(-22.7, 5.8, 0.72);
tree(22.9, 5.7, 0.76);
function lamp(x, z) {
cylinder(scene, 0.08, 0.14, 3.5, M.iron, x, 1.75, z, 8);
ico(scene, 0.23, M.cream, x, 3.64, z, 1);
ico(scene, 0.29, M.iron, x, 3.86, z, 0);
}
lamp(-17.5, 6.75);
lamp(-0.8, 6.8);
lamp(17.5, 6.75);
function makeBoat(x, z, hullColor, rotation = 0, phase = 0) {
const group = new THREE.Group();
group.position.set(x, -0.28, z);
group.rotation.y = rotation;
scene.add(group);
const hullMat = material(hullColor);
const top = [
[-2.15, 0], [-1.32, -0.68], [1.22, -0.68],
[2.02, 0], [1.22, 0.68], [-1.32, 0.68]
];
const vertices = [];
for (const [px, pz] of top) vertices.push(px, 0.27, pz);
for (const [px, pz] of top) vertices.push(px * 0.63, -0.34, pz * 0.55);
const indices = [];
for (let i = 0; i < top.length; i++) {
const j = (i + 1) % top.length;
indices.push(i, j, j + 6, i, j + 6, i + 6);
}
const hullGeometry = new THREE.BufferGeometry();
hullGeometry.setAttribute("position", new THREE.Float32BufferAttribute(vertices, 3));
hullGeometry.setIndex(indices);
hullGeometry.computeVertexNormals();
mesh(hullGeometry, hullMat, 0, 0, 0, group);
const deckVertices = [0, 0.29, 0];
for (const [px, pz] of top) deckVertices.push(px, 0.29, pz);
const deckIndices = [];
for (let i = 0; i < top.length; i++) {
deckIndices.push(0, i + 1, ((i + 1) % top.length) + 1);
}
const deckGeometry = new THREE.BufferGeometry();
deckGeometry.setAttribute("position", new THREE.Float32BufferAttribute(deckVertices, 3));
deckGeometry.setIndex(deckIndices);
deckGeometry.computeVertexNormals();
mesh(deckGeometry, M.woodLight, 0, 0, 0, group);
box(group, 2.6, 0.13, 0.42, M.wood, 0, 0.48, 0);
box(group, 0.16, 1.8, 0.16, M.wood, -0.75, 1.03, 0);
rod(group, [0.25, 0.75, 0.2], [1.55, 0.55, 0.7], 0.04, M.woodLight);
const passenger = person(0.65, 0.05, phase % 2 ? 0xd5a641 : 0x4d7e99, {
pose: phase % 2 ? "stand" : "wave",
rotation: -Math.PI / 2,
scale: 0.82,
skin: phase % 2 ? M.skinDark : M.skinLight,
y: 0.29
});
passenger.position.set(0.65, 0.29, 0.05);
group.add(passenger);
group.remove(passenger);
// A simple oarsman supplies a second readable human activity.
const oarsman = person(-0.65, 0, 0xb75b48, {
pose: "carry",
rotation: -Math.PI / 2,
scale: 0.78,
skin: M.skin,
y: 0.29
});
oarsman.position.set(-0.65, 0.29, 0);
group.add(oarsman);
group.userData.baseY = -0.28;
group.userData.phase = phase;
return group;
}
const boats = [
makeBoat(-10.5, 11.4, 0xb75b48, 0.08, 0.2),
makeBoat(0.8, 13.2, 0x4d7e99, -0.12, 2.1),
makeBoat(12.5, 11.8, 0xd5a641, 0.18, 4.2)
];
function rope(a, b) {
const midpoint = a.clone().lerp(b, 0.5);
midpoint.y -= 0.45;
const curve = new THREE.CatmullRomCurve3([a, midpoint, b]);
mesh(new THREE.TubeGeometry(curve, 18, 0.027, 5, false), M.woodLight);
}
rope(new THREE.Vector3(-16, 0.62, 7.78), new THREE.Vector3(-11.6, -0.02, 11.1));
rope(new THREE.Vector3(-4, 0.62, 7.78), new THREE.Vector3(-0.2, -0.02, 13.0));
rope(new THREE.Vector3(16, 0.62, 7.78), new THREE.Vector3(13.7, -0.02, 11.5));
// Sparse polygonal clouds for depth.
function cloud(x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
scene.add(group);
ico(group, 1.5, M.cream, 0, 0, 0, 1);
ico(group, 1.0, M.cream, -1.25, -0.15, 0, 0);
ico(group, 1.12, M.cream, 1.15, -0.12, 0.1, 0);
ico(group, 0.8, M.cream, 0.25, 0.65, 0, 0);
group.userData.baseX = x;
group.userData.speed = 0.08 + scale * 0.025;
return group;
}
const clouds = [
cloud(-31, 24, -47, 1.5),
cloud(9, 27, -58, 1.8),
cloud(39, 22, -41, 1.15)
];
// ---------------------------------------------------------------------
// Camera controls implemented directly, without Three.js add-ons
// ---------------------------------------------------------------------
const current = {
theta: 0.56,
phi: 1.04,
radius: 56,
target: new THREE.Vector3(0, 2.1, -1.4)
};
const goal = {
theta: current.theta,
phi: current.phi,
radius: current.radius,
target: current.target.clone()
};
function updateCamera() {
current.theta += (goal.theta - current.theta) * 0.1;
current.phi += (goal.phi - current.phi) * 0.1;
current.radius += (goal.radius - current.radius) * 0.1;
current.target.lerp(goal.target, 0.1);
const sinPhi = Math.sin(current.phi);
camera.position.set(
current.target.x + current.radius * sinPhi * Math.sin(current.theta),
current.target.y + current.radius * Math.cos(current.phi),
current.target.z + current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(current.target);
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let pointerButton = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerButton = event.button;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
if (pointerButton === 2 || event.shiftKey) {
const scale = current.radius * 0.0012;
const right = new THREE.Vector3(Math.cos(current.theta), 0, -Math.sin(current.theta));
const forward = new THREE.Vector3(-Math.sin(current.theta), 0, -Math.cos(current.theta));
goal.target.addScaledVector(right, -dx * scale);
goal.target.addScaledVector(forward, dy * scale);
goal.target.x = THREE.MathUtils.clamp(goal.target.x, -23, 23);
goal.target.z = THREE.MathUtils.clamp(goal.target.z, -13, 9);
} else {
goal.theta -= dx * 0.006;
goal.phi = THREE.MathUtils.clamp(goal.phi + dy * 0.005, 0.48, 1.43);
}
});
function endDrag(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
goal.radius = THREE.MathUtils.clamp(goal.radius * Math.exp(event.deltaY * 0.001), 18, 90);
}, { passive: false });
renderer.domElement.style.cursor = "grab";
const views = {
overview: { theta: 0.56, phi: 1.04, radius: 56, target: [0, 2.1, -1.4] },
facade: { theta: 0.02, phi: 1.18, radius: 44, target: [0, 3.8, -3.8] },
waterfront: { theta: 0.24, phi: 1.17, radius: 35, target: [0, 1.2, 3.2] }
};
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => {
const view = views[button.dataset.view];
goal.theta = view.theta;
goal.phi = view.phi;
goal.radius = view.radius;
goal.target.set(...view.target);
document.querySelectorAll("[data-view]").forEach((other) => {
other.setAttribute("aria-pressed", String(other === button));
});
});
});
const labels = document.getElementById("labels");
const labelEnabled = { value: true };
document.getElementById("toggle-labels").addEventListener("click", (event) => {
labelEnabled.value = !labelEnabled.value;
labels.classList.toggle("hidden", !labelEnabled.value);
event.currentTarget.setAttribute("aria-pressed", String(labelEnabled.value));
});
const evidencePanel = document.getElementById("evidence-panel");
document.getElementById("toggle-evidence").addEventListener("click", (event) => {
const closed = evidencePanel.classList.toggle("closed");
event.currentTarget.setAttribute("aria-expanded", String(!closed));
});
// ---------------------------------------------------------------------
// Labels and animation
// ---------------------------------------------------------------------
const labelPositions = {
building: new THREE.Vector3(0, 11.55, -3.25),
stalls: new THREE.Vector3(-8.8, 4.2, 3.75),
quay: new THREE.Vector3(17.6, 1.3, 8),
boats: new THREE.Vector3(1, 1.25, 13.25)
};
const labelElements = {};
document.querySelectorAll("[data-label]").forEach((element) => {
labelElements[element.dataset.label] = element;
});
function updateLabels() {
for (const [key, element] of Object.entries(labelElements)) {
const projected = labelPositions[key].clone().project(camera);
const visible = projected.z > -1 && projected.z < 1 && Math.abs(projected.x) < 1.1 && Math.abs(projected.y) < 1.1;
element.style.display = visible ? "block" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
}
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const t = clock.getElapsedTime();
if (!reduceMotion) {
boats.forEach((boat, i) => {
boat.position.y = boat.userData.baseY + Math.sin(t * 1.15 + boat.userData.phase) * 0.055;
boat.rotation.z = Math.sin(t * 0.82 + boat.userData.phase) * 0.018;
});
waterPatches.forEach((patch, i) => {
patch.material.opacity = 0.42 + (Math.sin(t * 0.8 + i) + 1) * 0.09;
patch.position.x += Math.sin(t * 0.22 + i * 1.7) * 0.0012;
});
clouds.forEach((cloudObject, i) => {
cloudObject.position.x = cloudObject.userData.baseX + Math.sin(t * cloudObject.userData.speed + i) * 2.2;
});
}
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
updateCamera();
renderer.render(scene, camera);
document.getElementById("loading").classList.add("hidden");
animate();
</script>
</body>
</html>
```