Prompt specification
Build or customize the Three.js 3D scene "Agora corner with market and meeting space" 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: Agora corner with market and meeting space
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/agora-corner-with-market-and-meeting-space-x2271
Scene Description Prompt:
Use Three.js from cdnjs to build a referenced agora-inspired corner with shaded colonnade, vendor area, and open meeting ground. Preserve distinct circulation routes between commercial and civic activities. Deliver one self-contained HTML file with low-poly forms.
Working Three.js Starter (agora-corner-with-market-and-meeting-space-x2271):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Agora Corner — Civic and Market Studies</title>
<style>
:root {
--ink: #263333;
--paper: rgba(250, 247, 238, 0.91);
--market: #b95f3b;
--civic: #d6aa54;
--line: rgba(38, 51, 51, 0.15);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce7e7;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.info {
position: fixed;
z-index: 5;
top: 22px;
left: 22px;
width: min(360px, calc(100vw - 44px));
padding: 18px 19px 16px;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 16px;
background: var(--paper);
box-shadow: 0 12px 36px rgba(39, 54, 54, 0.15);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: #748181;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0 0 7px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 38px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.intro {
margin: 0 0 15px;
color: #5f6b6b;
font-size: 12px;
line-height: 1.5;
}
.legend {
display: grid;
gap: 8px;
padding-top: 12px;
border-top: 1px solid var(--line);
}
.legend-item {
display: grid;
grid-template-columns: 30px 1fr;
align-items: center;
gap: 9px;
font-size: 11px;
}
.swatch {
height: 7px;
border-radius: 10px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.swatch.market {
background: var(--market);
}
.swatch.civic {
background: var(--civic);
}
.swatch.shade {
background: #62716e;
}
.controls {
position: fixed;
z-index: 6;
right: 20px;
bottom: 20px;
display: flex;
gap: 8px;
}
button {
appearance: none;
border: 1px solid rgba(38, 51, 51, 0.13);
border-radius: 11px;
padding: 10px 13px;
color: var(--ink);
background: rgba(250, 247, 238, 0.91);
box-shadow: 0 8px 22px rgba(39, 54, 54, 0.12);
font: 700 11px/1 inherit;
letter-spacing: 0.02em;
cursor: pointer;
backdrop-filter: blur(10px);
}
button:hover {
background: #fffdf7;
transform: translateY(-1px);
}
.hint {
position: fixed;
z-index: 5;
left: 22px;
bottom: 22px;
padding: 8px 11px;
border-radius: 9px;
color: rgba(38, 51, 51, 0.7);
background: rgba(250, 247, 238, 0.72);
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(8px);
}
.compass {
position: fixed;
z-index: 5;
top: 22px;
right: 22px;
width: 58px;
height: 58px;
display: grid;
place-items: center;
border: 1px solid rgba(38, 51, 51, 0.14);
border-radius: 50%;
color: #485958;
background: rgba(250, 247, 238, 0.78);
box-shadow: 0 8px 22px rgba(39, 54, 54, 0.1);
pointer-events: none;
}
.compass::before {
content: "";
width: 0;
height: 0;
border-right: 6px solid transparent;
border-bottom: 23px solid #bd6141;
border-left: 6px solid transparent;
transform: translateY(-4px);
}
.compass span {
position: absolute;
top: 3px;
font-size: 8px;
font-weight: 900;
}
@media (max-width: 650px) {
.info {
top: 12px;
left: 12px;
width: calc(100vw - 84px);
padding: 14px;
}
.intro {
display: none;
}
.legend {
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.legend-item {
grid-template-columns: 20px 1fr;
gap: 5px;
font-size: 9px;
}
.compass {
top: 12px;
right: 12px;
}
.controls {
right: 12px;
bottom: 12px;
}
.hint {
left: 12px;
bottom: 12px;
max-width: 150px;
line-height: 1.4;
}
}
</style>
</head>
<body>
<canvas
id="scene"
aria-label="Interactive low-poly agora with a shaded colonnade, vendor area, civic meeting ground, and separate circulation routes"
></canvas>
<section class="info">
<div class="eyebrow">Urban threshold study</div>
<h1>Agora Corner</h1>
<p class="intro">
A shaded civic colonnade frames an open meeting ground, while a distinct
market lane serves vendors along the western edge.
</p>
<div class="legend">
<div class="legend-item">
<span class="swatch market"></span>
<span>Commercial route / vendor row</span>
</div>
<div class="legend-item">
<span class="swatch civic"></span>
<span>Civic route / meeting approach</span>
</div>
<div class="legend-item">
<span class="swatch shade"></span>
<span>Shaded colonnade walk</span>
</div>
</div>
</section>
<div class="compass"><span>N</span></div>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<div class="controls">
<button id="routesButton" type="button">Hide routes</button>
<button id="labelsButton" type="button">Hide labels</button>
<button id="resetButton" type="button">Reset view</button>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce7e7);
scene.fog = new THREE.Fog(0xdce7e7, 45, 92);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
160
);
const controls = {
target: new THREE.Vector3(0, 0.8, -0.5),
yaw: 0.72,
pitch: 0.72,
radius: 48
};
function updateCamera() {
const { target, yaw, pitch, radius } = controls;
camera.position.set(
target.x + radius * Math.sin(pitch) * Math.sin(yaw),
target.y + radius * Math.cos(pitch),
target.z + radius * Math.sin(pitch) * Math.cos(yaw)
);
camera.lookAt(target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xe8f4f5, 0x95785a, 2.0);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d2, 3.1);
sun.position.set(-18, 32, 22);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -42;
sun.shadow.camera.right = 42;
sun.shadow.camera.top = 38;
sun.shadow.camera.bottom = -38;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 95;
sun.shadow.bias = -0.00025;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const routeGroup = new THREE.Group();
const labelGroup = new THREE.Group();
scene.add(routeGroup, labelGroup);
const materials = {
plaza: new THREE.MeshStandardMaterial({
color: 0xd8c9aa,
roughness: 0.98,
flatShading: true
}),
plazaEdge: new THREE.MeshStandardMaterial({
color: 0xb7aa8e,
roughness: 1,
flatShading: true
}),
road: new THREE.MeshStandardMaterial({
color: 0x5d6969,
roughness: 1,
flatShading: true
}),
roadMark: new THREE.MeshStandardMaterial({
color: 0xe9e3cf,
roughness: 1
}),
marketRoute: new THREE.MeshStandardMaterial({
color: 0xb95f3b,
roughness: 0.95,
flatShading: true
}),
civicRoute: new THREE.MeshStandardMaterial({
color: 0xd6aa54,
roughness: 0.95,
flatShading: true
}),
routeEdge: new THREE.MeshStandardMaterial({
color: 0x8f8068,
roughness: 1
}),
stone: new THREE.MeshStandardMaterial({
color: 0xe7dcc3,
roughness: 0.96,
flatShading: true
}),
stoneDark: new THREE.MeshStandardMaterial({
color: 0xc7b99a,
roughness: 1,
flatShading: true
}),
column: new THREE.MeshStandardMaterial({
color: 0xeee5d0,
roughness: 0.9,
flatShading: true
}),
timber: new THREE.MeshStandardMaterial({
color: 0x79543b,
roughness: 0.95,
flatShading: true
}),
timberLight: new THREE.MeshStandardMaterial({
color: 0xa47b4d,
roughness: 1,
flatShading: true
}),
roof: new THREE.MeshStandardMaterial({
color: 0x8b6d51,
roughness: 1,
flatShading: true
}),
wall: new THREE.MeshStandardMaterial({
color: 0xcdbd9f,
roughness: 1,
flatShading: true
}),
wallLight: new THREE.MeshStandardMaterial({
color: 0xe1d4b8,
roughness: 1,
flatShading: true
}),
glass: new THREE.MeshStandardMaterial({
color: 0x4d6667,
roughness: 0.45,
metalness: 0.08
}),
foliage: new THREE.MeshStandardMaterial({
color: 0x647c52,
roughness: 1,
flatShading: true
}),
foliageLight: new THREE.MeshStandardMaterial({
color: 0x82935d,
roughness: 1,
flatShading: true
}),
soil: new THREE.MeshStandardMaterial({
color: 0x75614a,
roughness: 1
}),
terracotta: new THREE.MeshStandardMaterial({
color: 0xb76342,
roughness: 1,
flatShading: true
}),
cream: new THREE.MeshStandardMaterial({
color: 0xf1e4c7,
roughness: 1,
flatShading: true
}),
teal: new THREE.MeshStandardMaterial({
color: 0x537f78,
roughness: 1,
flatShading: true
}),
metal: new THREE.MeshStandardMaterial({
color: 0x596463,
roughness: 0.65,
metalness: 0.35,
flatShading: true
}),
skin: new THREE.MeshStandardMaterial({
color: 0xc98962,
roughness: 1,
flatShading: true
})
};
function mesh(geometry, material, x = 0, y = 0, z = 0, parent = scene) {
const object = new THREE.Mesh(geometry, material);
object.position.set(x, y, z);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(w, h, d, x, y, z, material, parent = scene) {
return mesh(new THREE.BoxGeometry(w, h, d), material, x, y, z, parent);
}
function cylinder(rt, rb, h, segments, x, y, z, material, parent = scene) {
return mesh(
new THREE.CylinderGeometry(rt, rb, h, segments),
material,
x,
y,
z,
parent
);
}
function segmentBox(a, b, width, height, y, material, parent) {
const dx = b.x - a.x;
const dz = b.z - a.z;
const length = Math.hypot(dx, dz);
const object = box(
width,
height,
length,
(a.x + b.x) / 2,
y,
(a.z + b.z) / 2,
material,
parent
);
object.rotation.y = Math.atan2(dx, dz);
return object;
}
function ribbon(points, width, material, parent = routeGroup, edge = true) {
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
segmentBox(a, b, width, 0.09, 0.075, material, parent);
if (edge) {
const dx = b.x - a.x;
const dz = b.z - a.z;
const length = Math.hypot(dx, dz);
const nx = dz / length;
const nz = -dx / length;
for (const side of [-1, 1]) {
const offset = (width / 2 - 0.06) * side;
segmentBox(
{ x: a.x + nx * offset, z: a.z + nz * offset },
{ x: b.x + nx * offset, z: b.z + nz * offset },
0.075,
0.105,
0.09,
materials.routeEdge,
parent
);
}
}
}
for (const p of points) {
cylinder(
width / 2,
width / 2,
0.09,
18,
p.x,
0.075,
p.z,
material,
parent
);
}
}
function chevron(x, z, angle, material, parent = routeGroup) {
const group = new THREE.Group();
group.position.set(x, 0.14, z);
group.rotation.y = angle;
parent.add(group);
box(0.11, 0.025, 0.95, -0.27, 0, 0, material, group).rotation.y = -0.68;
box(0.11, 0.025, 0.95, 0.27, 0, 0, material, group).rotation.y = 0.68;
}
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabel(text, accent) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 1024;
labelCanvas.height = 220;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 220);
roundedRect(ctx, 12, 12, 1000, 196, 28);
ctx.fillStyle = "rgba(250,247,238,0.94)";
ctx.fill();
ctx.strokeStyle = "rgba(38,51,51,0.16)";
ctx.lineWidth = 4;
ctx.stroke();
ctx.fillStyle = accent;
roundedRect(ctx, 34, 39, 18, 142, 9);
ctx.fill();
ctx.fillStyle = "#2d3b3b";
ctx.font = "600 56px Arial, sans-serif";
ctx.textBaseline = "middle";
ctx.fillText(text, 78, 108);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.scale.set(8.6, 1.85, 1);
labelGroup.add(sprite);
return sprite;
}
// Urban ground, streets, and curb edges.
box(42, 0.5, 28, 1, -0.25, 0, materials.plaza);
box(54, 0.18, 8, 0, -0.15, 18.5, materials.road);
box(8, 0.18, 39, -25, -0.15, 0, materials.road);
box(42.5, 0.28, 0.35, 1, 0.02, 14.15, materials.plazaEdge);
box(0.35, 0.28, 28.3, -20.15, 0.02, 0, materials.plazaEdge);
box(8.2, 0.2, 0.3, -25, -0.02, 13.6, materials.plazaEdge);
box(8.2, 0.2, 0.3, -25, -0.02, -13.6, materials.plazaEdge);
for (let x = -18; x < 22; x += 5) {
box(2.2, 0.025, 0.14, x, -0.045, 18.5, materials.roadMark);
}
for (let z = -13; z < 14; z += 5) {
box(0.14, 0.025, 2.2, -25, -0.045, z, materials.roadMark);
}
// Zebra crossings mark the separate commercial and civic street entries.
for (let i = 0; i < 6; i++) {
box(0.42, 0.025, 1.7, -23.6 + i * 0.68, -0.035, 10.5, materials.roadMark);
box(1.7, 0.025, 0.42, 17.5, -0.035, 15.6 + i * 0.68, materials.roadMark);
}
// Market district paving.
box(13.6, 0.055, 16.4, -13.2, 0.015, 1.2,
new THREE.MeshStandardMaterial({
color: 0xc9a887,
roughness: 1,
flatShading: true
})
);
// Open civic meeting ground.
cylinder(7.15, 7.15, 0.085, 32, 7.1, 0.045, 0.7, materials.stone);
const meetingRing = mesh(
new THREE.RingGeometry(6.35, 6.65, 32),
materials.stoneDark,
7.1,
0.095,
0.7,
scene
);
meetingRing.rotation.x = -Math.PI / 2;
for (let i = 0; i < 20; i++) {
const angle = (i / 20) * Math.PI * 2;
const radius = 4.3;
const joint = box(
0.025,
0.016,
4.15,
7.1 + Math.cos(angle) * radius,
0.098,
0.7 + Math.sin(angle) * radius,
materials.stoneDark
);
joint.rotation.y = Math.PI / 2 - angle;
}
// Distinct circulation systems.
const marketRoute = [
{ x: -25, z: 10.5 },
{ x: -18.1, z: 10.5 },
{ x: -18.1, z: 3.2 },
{ x: -12.0, z: 3.2 }
];
const marketSpine = [
{ x: -12.0, z: -4.8 },
{ x: -12.0, z: 9.1 }
];
const civicApproach = [
{ x: 17.5, z: 19.6 },
{ x: 17.5, z: 8.1 },
{ x: 14.0, z: 4.2 },
{ x: 8.0, z: 2.0 }
];
const civicColonnade = [
{ x: 8.0, z: 2.0 },
{ x: 7.0, z: -9.7 },
{ x: 19.0, z: -9.7 },
{ x: 19.0, z: 5.7 }
];
ribbon(marketRoute, 2.15, materials.marketRoute);
ribbon(marketSpine, 1.65, materials.marketRoute);
ribbon(civicApproach, 2.35, materials.civicRoute);
ribbon(civicColonnade, 2.25, materials.civicRoute);
chevron(-21.8, 10.5, Math.PI / 2, materials.cream);
chevron(-18.1, 7.0, Math.PI, materials.cream);
chevron(-14.4, 3.2, -Math.PI / 2, materials.cream);
chevron(17.5, 12.0, Math.PI, materials.cream);
chevron(15.7, 6.0, 2.5, materials.cream);
chevron(10.9, 2.7, -2.7, materials.cream);
chevron(11.8, -9.7, Math.PI / 2, materials.cream);
chevron(19.0, -2.0, 0, materials.cream);
// Low planting wall separates the commercial and civic territories.
for (const z of [-5.8, -1.0, 3.8]) {
box(1.35, 0.65, 3.6, -2.15, 0.33, z, materials.stoneDark);
box(1.16, 0.08, 3.38, -2.15, 0.69, z, materials.soil);
for (let i = 0; i < 3; i++) {
const shrub = mesh(
new THREE.DodecahedronGeometry(0.65, 0),
i % 2 ? materials.foliage : materials.foliageLight,
-2.15 + (i - 1) * 0.25,
1.15,
z - 1.05 + i * 1.05
);
shrub.scale.set(1, 0.85, 1);
}
}
// North civic building behind the colonnade.
box(25.5, 6.4, 4.8, 8.7, 3.2, -16.3, materials.wall);
box(26.2, 0.38, 5.2, 8.7, 6.52, -16.3, materials.stone);
box(26.4, 0.22, 5.35, 8.7, 6.82, -16.3, materials.stoneDark);
box(3.3, 3.5, 0.18, 8.4, 1.75, -13.82, materials.timber);
box(4.4, 0.22, 0.8, 8.4, 0.12, -13.45, materials.stone);
for (let x = -1; x <= 19; x += 4.4) {
box(1.35, 2.2, 0.12, x, 3.65, -13.82, materials.glass);
box(1.65, 0.16, 0.2, x, 4.85, -13.72, materials.stone);
}
// Eastern urban edge.
box(4.5, 7.2, 10.5, 24.5, 3.6, -4.0, materials.wallLight);
box(4.9, 0.3, 11.0, 24.5, 7.3, -4.0, materials.stoneDark);
for (let z = -8; z <= 0; z += 3.2) {
box(0.12, 1.65, 1.15, 22.18, 4.25, z, materials.glass);
}
function makeColumn(x, z) {
box(0.92, 0.24, 0.92, x, 0.12, z, materials.stoneDark);
cylinder(0.31, 0.37, 3.65, 8, x, 2.06, z, materials.column);
cylinder(0.39, 0.32, 0.22, 8, x, 3.98, z, materials.column);
box(0.82, 0.26, 0.82, x, 4.22, z, materials.stone);
}
// North colonnade and its deep, shadow-casting roof.
const northXs = [];
for (let x = -1.5; x <= 20.5; x += 2.75) {
northXs.push(x);
makeColumn(x, -11.25);
}
box(25.0, 0.42, 0.72, 9.5, 4.55, -11.25, materials.stone);
box(25.8, 0.28, 3.55, 9.5, 4.91, -11.25, materials.roof);
for (let x = -2.5; x <= 21.5; x += 1.65) {
box(0.13, 0.25, 3.25, x, 4.70, -11.25, materials.timber);
}
box(25.6, 0.18, 0.24, 9.5, 4.72, -9.72, materials.timber);
// East colonnade turn.
for (let z = -9.7; z <= 5.6; z += 2.75) {
makeColumn(19.65, z);
}
box(0.72, 0.42, 17.0, 19.65, 4.55, -2.05, materials.stone);
box(3.55, 0.28, 17.8, 19.65, 4.91, -2.05, materials.roof);
for (let z = -10.5; z <= 6.5; z += 1.65) {
box(3.25, 0.25, 0.13, 19.65, 4.70, z, materials.timber);
}
// Vendor stalls.
const awningColors = [
[materials.terracotta, materials.cream],
[materials.teal, materials.cream],
[materials.civicRoute, materials.cream]
];
function makeStall(x, z, colorIndex, facing = 0) {
const stall = new THREE.Group();
stall.position.set(x, 0, z);
stall.rotation.y = facing;
scene.add(stall);
const colors = awningColors[colorIndex % awningColors.length];
box(3.35, 0.16, 1.45, 0, 1.12, 0, materials.timberLight, stall);
for (const px of [-1.45, 1.45]) {
for (const pz of [-0.72, 0.72]) {
box(0.12, 2.75, 0.12, px, 1.38, pz, materials.timber, stall);
}
}
const panelWidth = 0.425;
for (let side = 0; side < 2; side++) {
for (let i = 0; i < 4; i++) {
const sign = side === 0 ? -1 : 1;
const offset = (i + 0.5) * panelWidth;
const panel = box(
panelWidth + 0.025,
0.12,
2.1,
sign * offset,
2.89,
0,
i % 2 === 0 ? colors[0] : colors[1],
stall
);
panel.rotation.z = side === 0 ? 0.25 : -0.25;
}
}
box(3.55, 0.2, 0.14, 0, 2.53, -1.02, colors[0], stall);
box(0.72, 0.28, 0.65, 1.05, 1.37, 0.05, materials.stoneDark, stall);
const produceMaterials = [
new THREE.MeshStandardMaterial({ color: 0xc85d36, roughness: 1, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0xe0a83e, roughness: 1, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0x6f8c4c, roughness: 1, flatShading: true })
];
for (let row = 0; row < 2; row++) {
for (let i = 0; i < 7; i++) {
const produce = mesh(
new THREE.IcosahedronGeometry(0.13 + (i % 3) * 0.025, 0),
produceMaterials[(i + row + colorIndex) % 3],
-1.05 + i * 0.34,
1.29,
-0.35 + row * 0.64,
stall
);
produce.scale.y = 0.85;
}
}
box(1.35, 0.52, 0.72, -1.15, 0.3, 0.45, materials.timber, stall);
for (let i = 0; i < 3; i++) {
box(0.37, 0.1, 0.68, -1.55 + i * 0.39, 0.62, 0.45,
materials.timberLight, stall);
}
}
makeStall(-15.0, -4.7, 0, 0);
makeStall(-9.0, -4.7, 1, 0);
makeStall(-15.0, 1.7, 2, 0);
makeStall(-9.0, 1.7, 0, 0);
makeStall(-15.0, 8.0, 1, 0);
// A low wall defines the market's western edge.
box(0.45, 1.45, 15.7, -19.45, 0.73, 1.2, materials.wall);
box(0.65, 0.18, 16.0, -19.45, 1.53, 1.2, materials.stone);
// Sparse benches retain the center as an open meeting ground.
function bench(x, z, angle) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = angle;
scene.add(group);
box(1.55, 0.16, 0.46, 0, 0.62, 0, materials.timber, group);
box(0.14, 0.62, 0.38, -0.58, 0.3, 0, materials.metal, group);
box(0.14, 0.62, 0.38, 0.58, 0.3, 0, materials.metal, group);
}
for (let i = 0; i < 7; i++) {
const angle = Math.PI + 0.16 + (i / 6) * (Math.PI - 0.32);
const radius = 5.95;
bench(
7.1 + Math.cos(angle) * radius,
0.7 + Math.sin(angle) * radius,
Math.PI / 2 - angle
);
}
// Speaker podium at the edge rather than the center of the assembly space.
cylinder(0.75, 0.88, 0.28, 10, 7.1, 0.23, -0.55, materials.stoneDark);
box(0.9, 0.12, 0.55, 7.1, 0.48, -0.55, materials.timber);
cylinder(0.045, 0.045, 1.1, 6, 7.1, 0.76, -0.55, materials.metal);
box(0.5, 0.06, 0.3, 7.1, 1.31, -0.55, materials.metal);
// Street furniture and trees.
function tree(x, z, scale = 1) {
cylinder(0.20 * scale, 0.28 * scale, 2.7 * scale, 7,
x, 1.35 * scale, z, materials.timber);
const crown = mesh(
new THREE.DodecahedronGeometry(1.35 * scale, 0),
materials.foliage,
x,
3.0 * scale,
z
);
crown.scale.set(1, 1.12, 0.95);
const crown2 = mesh(
new THREE.IcosahedronGeometry(0.95 * scale, 0),
materials.foliageLight,
x + 0.55 * scale,
3.35 * scale,
z - 0.1
);
crown2.scale.set(1, 0.8, 1);
}
for (const p of [
[-18.6, -7.4],
[-6.4, -8.2],
[16.8, 8.8],
[11.7, -11.9],
[-17.2, 11.4]
]) {
box(1.8, 0.55, 1.8, p[0], 0.28, p[1], materials.stoneDark);
box(1.55, 0.08, 1.55, p[0], 0.59, p[1], materials.soil);
tree(p[0], p[1], p[0] === 16.8 ? 1.05 : 0.92);
}
function lamp(x, z) {
cylinder(0.11, 0.16, 3.7, 8, x, 1.85, z, materials.metal);
box(0.48, 0.18, 0.48, x, 3.78, z, materials.metal);
box(0.36, 0.05, 0.36, x, 3.67, z,
new THREE.MeshStandardMaterial({
color: 0xf3d895,
emissive: 0xc29a46,
emissiveIntensity: 0.45,
roughness: 0.7
})
);
}
lamp(-19.0, 12.2);
lamp(18.7, 11.4);
lamp(20.8, -8.0);
// Low-poly people provide scale without obstructing the open ground.
function person(x, z, shirtMaterial, scale = 1, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
box(0.14, 0.56, 0.15, -0.11, 0.28, 0, materials.metal, group);
box(0.14, 0.56, 0.15, 0.11, 0.28, 0, materials.metal, group);
cylinder(0.22, 0.28, 0.63, 6, 0, 0.88, 0, shirtMaterial, group);
mesh(new THREE.IcosahedronGeometry(0.18, 1), materials.skin,
0, 1.38, 0, group);
}
const shirtMaterials = [
materials.teal,
materials.terracotta,
materials.civicRoute,
materials.cream,
new THREE.MeshStandardMaterial({
color: 0x536b78,
roughness: 1,
flatShading: true
})
];
const people = [
[-16.2, -3.2, 0, 0.97, 0.3],
[-14.7, -3.0, 1, 1.02, -0.4],
[-10.6, -3.1, 2, 0.94, 0.7],
[-14.0, 2.9, 1, 1.04, -0.8],
[-8.2, 2.7, 0, 0.91, 2.5],
[-15.4, 9.0, 2, 0.98, 0.2],
[-17.6, 7.6, 0, 0.92, -1.2],
[16.9, 6.8, 1, 1.02, 1.4],
[15.1, 3.4, 3, 0.96, -1.0],
[11.5, 1.4, 0, 1.05, 2.0],
[9.7, 2.5, 1, 0.92, -0.6],
[6.2, -3.2, 2, 0.98, 0.2],
[3.5, -2.2, 3, 1.02, -1.8],
[9.1, -4.4, 0, 0.95, 1.1],
[14.9, -9.3, 1, 1.0, -1.4],
[10.4, -9.1, 3, 0.92, 0.6],
[18.7, -5.3, 2, 1.0, 1.2],
[18.3, 2.9, 0, 0.97, -0.4]
];
people.forEach((p, i) => person(
p[0], p[1], shirtMaterials[i % shirtMaterials.length], p[2], p[3]
));
// Wayfinding posts reinforce the route separation.
function signpost(x, z, color, text) {
box(0.13, 2.0, 0.13, x, 1.0, z, materials.metal);
const sign = box(2.45, 0.58, 0.12, x + 0.95, 1.82, z, color);
sign.rotation.y = 0;
box(2.1, 0.1, 0.14, x + 0.95, 1.82, z - 0.02, materials.cream);
}
signpost(-19.0, 8.9, materials.marketRoute);
signpost(18.2, 10.2, materials.civicRoute);
signpost(18.8, -7.7, materials.civicRoute);
// Spatial labels.
const vendorLabel = makeLabel("VENDOR ROW", "#b95f3b");
vendorLabel.position.set(-13.2, 5.0, 5.7);
const marketLabel = makeLabel("MARKET WALK", "#b95f3b");
marketLabel.position.set(-18.1, 3.35, 12.0);
const meetingLabel = makeLabel("MEETING GROUND", "#d6aa54");
meetingLabel.position.set(7.0, 5.25, 5.8);
const civicLabel = makeLabel("CIVIC WALK", "#d6aa54");
civicLabel.position.set(17.8, 5.6, -8.6);
// Direct, dependency-free camera controls.
const pointers = new Map();
let pinchDistance = 0;
function resetView() {
controls.target.set(0, 0.8, -0.5);
controls.yaw = 0.72;
controls.pitch = 0.72;
controls.radius = 48;
updateCamera();
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
controls.yaw -= dx * 0.005;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.004,
0.28,
1.28
);
updateCamera();
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (pinchDistance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (pinchDistance / Math.max(distance, 1)),
20,
76
);
updateCamera();
}
pinchDistance = distance;
}
});
function removePointer(event) {
pointers.delete(event.pointerId);
pinchDistance = 0;
}
canvas.addEventListener("pointerup", removePointer);
canvas.addEventListener("pointercancel", removePointer);
canvas.addEventListener("pointerleave", (event) => {
if (event.buttons === 0) removePointer(event);
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
20,
76
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
document.getElementById("resetButton").addEventListener("click", resetView);
let routesVisible = true;
let labelsVisible = true;
document.getElementById("routesButton").addEventListener("click", (event) => {
routesVisible = !routesVisible;
routeGroup.visible = routesVisible;
event.currentTarget.textContent = routesVisible ? "Hide routes" : "Show routes";
});
document.getElementById("labelsButton").addEventListener("click", (event) => {
labelsVisible = !labelsVisible;
labelGroup.visible = labelsVisible;
event.currentTarget.textContent = labelsVisible ? "Hide labels" : "Show labels";
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
</script>
</body>
</html>
```