Prompt specification
Build or customize the Three.js 3D scene "Pedestrian leaving Plaza Independencia through the gateway" 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: Pedestrian leaving Plaza Independencia through the gateway
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/pedestrian-leaving-plaza-independencia-through-the-gat-x2758
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Ciudad Vieja in Montevideo. Create a compact Montevideo vignette with plaza edge, gateway, and street entrance. Animate one clear route and keep the referenced landmark proportionate to a human figure. Low-poly.
Working Three.js Starter (pedestrian-leaving-plaza-independencia-through-the-gat-x2758):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ciudad Vieja — Montevideo</title>
<style>
:root {
color-scheme: light;
--ink: #17383b;
--paper: rgba(250, 247, 236, 0.92);
--accent: #e7a83e;
--route: #26b6ad;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe7e7;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.card {
position: fixed;
z-index: 2;
border: 1px solid rgba(23, 56, 59, 0.13);
border-radius: 16px;
background: var(--paper);
box-shadow: 0 12px 36px rgba(29, 56, 57, 0.13);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
pointer-events: none;
}
.title-card {
top: 24px;
left: 24px;
max-width: min(390px, calc(100vw - 48px));
padding: 18px 20px 16px;
}
.eyebrow {
margin-bottom: 7px;
color: #628083;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 40px);
font-weight: 500;
line-height: 1;
}
.subtitle {
margin: 9px 0 0;
color: #49696c;
font-size: 13px;
line-height: 1.45;
}
.route-card {
top: 24px;
right: 24px;
display: flex;
align-items: center;
gap: 10px;
padding: 11px 14px;
color: var(--ink);
font-size: 12px;
font-weight: 750;
}
.route-dot {
width: 10px;
height: 10px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--route);
box-shadow: 0 0 0 5px rgba(38, 182, 173, 0.14);
}
.help-card {
bottom: 24px;
left: 24px;
padding: 10px 13px;
color: #4f6d70;
font-size: 11px;
letter-spacing: 0.015em;
}
#reset {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 3;
padding: 11px 15px;
border: 1px solid rgba(23, 56, 59, 0.15);
border-radius: 12px;
background: var(--paper);
box-shadow: 0 8px 24px rgba(29, 56, 57, 0.12);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 800;
cursor: pointer;
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#reset:hover {
background: #fffdf5;
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
padding: 30px;
background: #dbe7e7;
color: var(--ink);
text-align: center;
font-size: 14px;
}
@media (max-width: 680px) {
.title-card {
top: 14px;
left: 14px;
padding: 15px 16px;
}
.route-card {
top: auto;
right: 14px;
bottom: 62px;
}
.help-card {
bottom: 14px;
left: 14px;
max-width: calc(100vw - 125px);
}
#reset {
right: 14px;
bottom: 14px;
}
}
</style>
</head>
<body>
<div id="loading">Building the Ciudad Vieja vignette…</div>
<section class="card title-card">
<div class="eyebrow">Montevideo · Uruguay</div>
<h1>Ciudad Vieja</h1>
<p class="subtitle">
A compact low-poly study of a plaza edge, a human-scale masonry gateway,
and the narrow street entrance beyond it.
</p>
</section>
<div class="card route-card">
<span class="route-dot"></span>
<span>One animated route through the gateway</span>
</div>
<div class="card help-card">Drag to orbit · Scroll or pinch to zoom · R to reset</div>
<button id="reset" type="button" aria-label="Reset camera view">Reset view</button>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const loading = document.getElementById("loading");
const canvas = document.createElement("canvas");
canvas.setAttribute("aria-label", "Interactive low-poly Ciudad Vieja diorama");
document.body.prepend(canvas);
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent =
"This vignette requires WebGL. Please try a current browser with hardware acceleration enabled.";
throw error;
}
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;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe7e7);
scene.fog = new THREE.Fog(0xdbe7e7, 39, 72);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
120
);
// Direct camera controls; no addon modules are used.
const controls = {
target: new THREE.Vector3(0, 1.25, 0),
radius: 34,
azimuth: 0.43,
polar: 1.03,
dragging: false,
pointerX: 0,
pointerY: 0
};
const defaultControls = {
radius: controls.radius,
azimuth: controls.azimuth,
polar: controls.polar,
target: controls.target.clone()
};
function updateCamera() {
const sinPolar = Math.sin(controls.polar);
camera.position.set(
controls.target.x +
controls.radius * sinPolar * Math.sin(controls.azimuth),
controls.target.y + controls.radius * Math.cos(controls.polar),
controls.target.z +
controls.radius * sinPolar * Math.cos(controls.azimuth)
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.radius = defaultControls.radius;
controls.azimuth = defaultControls.azimuth;
controls.polar = defaultControls.polar;
controls.target.copy(defaultControls.target);
updateCamera();
}
updateCamera();
canvas.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.pointerX;
const dy = event.clientY - controls.pointerY;
controls.azimuth -= dx * 0.006;
controls.polar = THREE.MathUtils.clamp(
controls.polar - dy * 0.005,
0.48,
1.36
);
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
updateCamera();
});
const endDrag = (event) => {
controls.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
};
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.018,
21,
49
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetCamera();
});
document.getElementById("reset").addEventListener("click", resetCamera);
const hemi = new THREE.HemisphereLight(0xf6fbf6, 0x8e8067, 2.0);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffedcf, 3.0);
sun.position.set(-13, 23, 14);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -27;
sun.shadow.camera.right = 27;
sun.shadow.camera.top = 27;
sun.shadow.camera.bottom = -27;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9bcbd1, 0.65);
fill.position.set(16, 9, -14);
scene.add(fill);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true,
...options
});
}
const M = {
base: material(0x9a8f76),
baseSide: material(0x766f60),
stone: material(0xcbbd9d),
stoneLight: material(0xd9cdb0),
stoneDark: material(0xb7a88a),
curb: material(0xb0aa94),
road: material(0x596568),
roadDark: material(0x4c595c),
wood: material(0x75503a),
woodLight: material(0xa8794c),
roof: material(0xb85f46),
roofDark: material(0x914a3b),
glass: material(0x31565d, { roughness: 0.45 }),
shutter: material(0x456f68),
iron: material(0x304c4e, { roughness: 0.65 }),
leaf: material(0x668b62),
leafLight: material(0x7e9e68),
skin: material(0xc68c68),
shirt: material(0xd5a044),
trousers: material(0x40545b),
route: material(0x26b6ad, {
emissive: 0x0d5e59,
emissiveIntensity: 0.45,
roughness: 0.42
})
};
function box(w, h, d, mat, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(rTop, rBottom, h, segments, mat, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rTop, rBottom, h, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeTextTexture(text, bg = "#23494c", fg = "#f6e8c4") {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 768;
labelCanvas.height = 160;
const ctx = labelCanvas.getContext("2d");
ctx.fillStyle = bg;
ctx.fillRect(0, 0, labelCanvas.width, labelCanvas.height);
ctx.strokeStyle = "rgba(255,255,255,0.18)";
ctx.lineWidth = 8;
ctx.strokeRect(12, 12, 744, 136);
ctx.fillStyle = fg;
ctx.font = "700 66px Georgia";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 384, 83);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(renderer.capabilities.getMaxAnisotropy(), 8);
return texture;
}
// ---------------------------------------------------------------------
// Raised diorama base
// ---------------------------------------------------------------------
box(30, 0.85, 28, M.baseSide, 0, -0.48, 1);
box(29.7, 0.16, 27.7, material(0xb6ad95), 0, -0.02, 1);
// Plaza paving, made from slightly varied square slabs.
const pavingMaterials = [
material(0xc8bea6),
material(0xd1c7af),
material(0xbeb69f),
material(0xd8ceb7)
];
const tileSize = 1.16;
const tileGap = 0.035;
for (let row = 0; row < 11; row++) {
for (let col = 0; col < 17; col++) {
const x = -13.55 + col * tileSize;
const z = 1.28 + row * tileSize;
const mat = pavingMaterials[(row * 3 + col) % pavingMaterials.length];
box(
tileSize - tileGap,
0.09,
tileSize - tileGap,
mat,
x,
0.075,
z
);
}
}
// Narrow cobbled street behind the gateway.
box(4.6, 0.12, 12.7, M.road, 2, 0.055, -5.85);
const cobbleMaterials = [
material(0x596568),
material(0x515d60),
material(0x626d6e),
material(0x485457)
];
for (let row = 0; row < 12; row++) {
for (let col = 0; col < 4; col++) {
box(
1.08,
0.055,
0.99,
cobbleMaterials[(row + col * 2) % cobbleMaterials.length],
0.72 + col * 1.13,
0.135,
-11.35 + row * 1.02
);
}
}
// Plaza curb, interrupted at the street entrance.
for (let x = -13.8; x < -0.2; x += 1.25) {
box(1.16, 0.28, 0.38, M.curb, x, 0.22, 0.55);
}
box(1.2, 0.28, 0.38, M.curb, 4.55, 0.22, 0.55);
// ---------------------------------------------------------------------
// Colonial-style low-poly buildings
// ---------------------------------------------------------------------
function makeRoof(w, d, roofHeight, mat, parent) {
const halfW = w / 2;
const halfD = d / 2;
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-halfW, 0, -halfD,
halfW, 0, -halfD,
0, roofHeight, -halfD,
-halfW, 0, halfD,
halfW, 0, halfD,
0, roofHeight, halfD
], 3)
);
geometry.setIndex([
0, 2, 1,
3, 4, 5,
0, 3, 5,
0, 5, 2,
1, 2, 5,
1, 5, 4,
0, 1, 4,
0, 4, 3
]);
const nonIndexed = geometry.toNonIndexed();
nonIndexed.computeVertexNormals();
const roof = new THREE.Mesh(nonIndexed, mat);
roof.position.y = 0.03;
roof.castShadow = true;
roof.receiveShadow = true;
parent.add(roof);
}
function addWindow(parent, x, y, z, rotationY = 0) {
const unit = new THREE.Group();
unit.position.set(x, y, z);
unit.rotation.y = rotationY;
parent.add(unit);
box(0.78, 1.02, 0.09, M.stoneLight, 0, 0, 0, unit);
box(0.56, 0.80, 0.11, M.glass, 0, 0, 0.065, unit);
box(0.12, 0.82, 0.13, M.shutter, -0.40, 0, 0.10, unit);
box(0.12, 0.82, 0.13, M.shutter, 0.40, 0, 0.10, unit);
box(0.035, 0.82, 0.14, M.wood, 0, 0, 0.13, unit);
}
function createBuilding({
x,
z,
w,
d,
h,
color,
roofColor = M.roof,
innerSide = null,
balcony = false
}) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
scene.add(group);
const wallMat = material(color);
const localRoofMat = material(roofColor);
box(w, h, d, wallMat, 0, h / 2, 0, group);
box(w + 0.12, 0.32, d + 0.12, M.stoneDark, 0, 0.16, 0, group);
makeRoof(w + 0.22, d + 0.22, Math.min(1.5, w * 0.28), localRoofMat, group);
group.children[group.children.length - 1].position.y = h;
const floors = Math.max(2, Math.floor((h - 0.8) / 1.75));
for (let floor = 0; floor < floors; floor++) {
const y = 1.35 + floor * 1.72;
const columns = Math.max(1, Math.floor(w / 1.8));
for (let col = 0; col < columns; col++) {
const wx =
columns === 1
? 0
: -w * 0.27 + (col / (columns - 1)) * w * 0.54;
addWindow(group, wx, y, d / 2 + 0.055, 0);
}
if (innerSide !== null) {
const sideOffset = innerSide * (w / 2 + 0.055);
const rotation = innerSide > 0 ? Math.PI / 2 : -Math.PI / 2;
addWindow(group, sideOffset, y, -d * 0.24, rotation);
addWindow(group, sideOffset, y, d * 0.24, rotation);
}
}
if (balcony) {
box(w * 0.66, 0.12, 0.48, M.stoneLight, 0, 2.55, d / 2 + 0.23, group);
box(w * 0.66, 0.08, 0.08, M.iron, 0, 3.05, d / 2 + 0.43, group);
for (let i = 0; i < 7; i++) {
box(
0.045,
0.52,
0.045,
M.iron,
-w * 0.3 + (i / 6) * w * 0.6,
2.8,
d / 2 + 0.43,
group
);
}
}
box(0.55, 1.05, 0.55, M.stoneDark, w * 0.23, h + 0.62, -d * 0.18, group);
return group;
}
// Buildings framing the narrow street.
createBuilding({
x: -2.05, z: -3.85, w: 3.35, d: 4.45, h: 6.15,
color: 0xc58d73, roofColor: 0xa95643, innerSide: 1, balcony: true
});
createBuilding({
x: -2.05, z: -9.0, w: 3.35, d: 5.1, h: 7.25,
color: 0xd2b875, roofColor: 0xa85b45, innerSide: 1
});
createBuilding({
x: 6.05, z: -3.85, w: 3.35, d: 4.45, h: 6.75,
color: 0x82a7a0, roofColor: 0x8e4c42, innerSide: -1
});
createBuilding({
x: 6.05, z: -9.0, w: 3.35, d: 5.1, h: 7.55,
color: 0x7997a7, roofColor: 0x984e42, innerSide: -1, balcony: true
});
// Plaza-edge buildings.
createBuilding({
x: -10.25, z: -1.6, w: 4.1, d: 5.4, h: 6.7,
color: 0xd0a55d, roofColor: 0x9c4d40, balcony: true
});
createBuilding({
x: -10.1, z: -8.0, w: 4.15, d: 5.6, h: 8.15,
color: 0xb87869, roofColor: 0x93493e
});
createBuilding({
x: 9.8, z: -8.7, w: 5.0, d: 5.4, h: 7.25,
color: 0xc8b474, roofColor: 0x9b5143
});
// ---------------------------------------------------------------------
// Human-scale gateway
// ---------------------------------------------------------------------
const gateway = new THREE.Group();
gateway.position.z = 0.2;
scene.add(gateway);
const innerRadius = 1.55;
const outerRadius = 2.12;
const springHeight = 2.52;
const archSegments = 12;
// Side piers.
box(0.57, springHeight, 1.2, M.stone, 2 - 1.835, springHeight / 2, 0, gateway);
box(0.57, springHeight, 1.2, M.stone, 2 + 1.835, springHeight / 2, 0, gateway);
box(0.73, 0.36, 1.38, M.stoneDark, 2 - 1.835, 0.27, 0, gateway);
box(0.73, 0.36, 1.38, M.stoneDark, 2 + 1.835, 0.27, 0, gateway);
// Faceted masonry arch.
for (let i = 0; i < archSegments; i++) {
const a0 = (i / archSegments) * Math.PI + 0.008;
const a1 = ((i + 1) / archSegments) * Math.PI - 0.008;
const shape = new THREE.Shape();
shape.moveTo(
Math.cos(a0) * innerRadius,
Math.sin(a0) * innerRadius
);
shape.lineTo(
Math.cos(a0) * outerRadius,
Math.sin(a0) * outerRadius
);
shape.lineTo(
Math.cos(a1) * outerRadius,
Math.sin(a1) * outerRadius
);
shape.lineTo(
Math.cos(a1) * innerRadius,
Math.sin(a1) * innerRadius
);
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: 1.2,
bevelEnabled: false,
steps: 1
});
geometry.translate(0, 0, -0.6);
const archMat = i % 2 === 0 ? M.stoneLight : M.stone;
const block = new THREE.Mesh(geometry, archMat);
block.position.set(2, springHeight, 0);
block.castShadow = true;
block.receiveShadow = true;
gateway.add(block);
}
// Cap and sign.
box(4.72, 0.27, 1.48, M.stoneLight, 2, 4.86, 0, gateway);
box(3.3, 0.56, 0.13, M.iron, 2, 5.24, 0.68, gateway);
const gatewaySign = new THREE.Mesh(
new THREE.PlaneGeometry(3.05, 0.42),
new THREE.MeshBasicMaterial({
map: makeTextTexture("CIUDAD VIEJA"),
toneMapped: false
})
);
gatewaySign.position.set(2, 5.24, 0.755);
gateway.add(gatewaySign);
// A modest keystone emphasizes the human-scale civic entrance.
box(0.34, 0.48, 1.36, M.stoneDark, 2, 4.69, 0, gateway);
// ---------------------------------------------------------------------
// Street and plaza furniture
// ---------------------------------------------------------------------
function createTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
group.scale.setScalar(scale);
scene.add(group);
box(1.9, 0.28, 1.9, M.stoneDark, 0, 0.14, 0, group);
box(1.62, 0.12, 1.62, M.stone, 0, 0.31, 0, group);
cylinder(0.17, 0.25, 1.7, 6, M.wood, 0, 1.05, 0, group);
const crown = new THREE.Mesh(
new THREE.IcosahedronGeometry(1.32, 0),
M.leaf
);
crown.position.y = 2.38;
crown.scale.set(1, 1.12, 0.92);
crown.castShadow = true;
group.add(crown);
const crownTop = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.8, 0),
M.leafLight
);
crownTop.position.set(0.28, 3.13, -0.08);
crownTop.castShadow = true;
group.add(crownTop);
}
createTree(-11.8, 9.0, 0.95);
createTree(-6.4, 11.2, 0.72);
function createBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.12, z);
group.rotation.y = rotation;
scene.add(group);
box(1.95, 0.12, 0.48, M.woodLight, 0, 0.48, 0, group);
box(1.95, 0.38, 0.10, M.woodLight, 0, 0.78, -0.22, group);
for (const side of [-0.72, 0.72]) {
box(0.12, 0.48, 0.38, M.iron, side, 0.24, 0, group);
}
}
createBench(-9.7, 3.0, 0.08);
createBench(-4.7, 10.7, Math.PI);
function createLamp(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
scene.add(group);
cylinder(0.07, 0.11, 2.35, 6, M.iron, 0, 1.17, 0, group);
box(0.34, 0.42, 0.34, material(0xf2dfa5, {
emissive: 0x8f6b25,
emissiveIntensity: 0.25
}), 0, 2.46, 0, group);
const cap = new THREE.Mesh(
new THREE.ConeGeometry(0.31, 0.22, 4),
M.iron
);
cap.position.y = 2.78;
cap.rotation.y = Math.PI / 4;
cap.castShadow = true;
group.add(cap);
}
createLamp(-3.4, 0.95);
createLamp(6.8, 0.95);
for (let i = 0; i < 6; i++) {
const x = -12.8 + i * 1.85;
cylinder(0.10, 0.14, 0.68, 6, M.iron, x, 0.45, 0.9);
const top = new THREE.Mesh(
new THREE.SphereGeometry(0.13, 6, 4),
M.iron
);
top.position.set(x, 0.83, 0.9);
top.castShadow = true;
scene.add(top);
}
// 1.75 m human figure provides an explicit scale reference.
function createPerson(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.13, z);
group.rotation.y = -0.35;
scene.add(group);
cylinder(0.115, 0.13, 0.69, 6, M.trousers, -0.13, 0.35, 0, group);
cylinder(0.115, 0.13, 0.69, 6, M.trousers, 0.13, 0.35, 0, group);
box(0.46, 0.64, 0.27, M.shirt, 0, 0.99, 0, group);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.16, 7, 5),
M.skin
);
head.position.y = 1.53;
head.castShadow = true;
group.add(head);
const hat = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.19, 0.07, 8),
M.wood
);
hat.position.y = 1.69;
hat.castShadow = true;
group.add(hat);
cylinder(0.085, 0.09, 0.53, 6, M.shirt, -0.29, 1.0, 0, group);
cylinder(0.085, 0.09, 0.53, 6, M.shirt, 0.29, 1.0, 0, group);
box(0.17, 0.11, 0.31, M.wood, -0.13, 0.045, 0.05, group);
box(0.17, 0.11, 0.31, M.wood, 0.13, 0.045, 0.05, group);
}
createPerson(-0.72, 1.62);
// Ground plaque identifying the plaza edge.
const plaqueTexture = makeTextTexture("PLAZA EDGE", "#d6c8a9", "#315457");
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(3.25, 0.68),
new THREE.MeshBasicMaterial({
map: plaqueTexture,
transparent: true,
toneMapped: false,
opacity: 0.88
})
);
plaque.rotation.x = -Math.PI / 2;
plaque.position.set(-8.7, 0.145, 12.65);
scene.add(plaque);
// ---------------------------------------------------------------------
// One animated route: plaza edge → gateway → street
// ---------------------------------------------------------------------
const routePoints = [
new THREE.Vector3(-9.0, 0.18, 10.8),
new THREE.Vector3(-6.8, 0.18, 9.3),
new THREE.Vector3(-4.0, 0.18, 6.8),
new THREE.Vector3(-0.8, 0.18, 4.8),
new THREE.Vector3( 1.2, 0.18, 3.2),
new THREE.Vector3( 2.0, 0.18, 1.2),
new THREE.Vector3( 2.0, 0.18, -1.0),
new THREE.Vector3( 2.0, 0.18, -4.5),
new THREE.Vector3( 2.0, 0.18, -8.5),
new THREE.Vector3( 2.0, 0.18, -10.7)
];
const routeCurve = new THREE.CatmullRomCurve3(
routePoints,
false,
"centripetal"
);
const routeTube = new THREE.Mesh(
new THREE.TubeGeometry(routeCurve, 96, 0.075, 6, false),
M.route
);
routeTube.castShadow = false;
routeTube.receiveShadow = true;
scene.add(routeTube);
// Moving arrows establish the direction of travel.
const arrows = [];
const arrowCount = 13;
const up = new THREE.Vector3(0, 1, 0);
for (let i = 0; i < arrowCount; i++) {
const arrowMaterial = new THREE.MeshBasicMaterial({
color: 0xf7bd4d,
transparent: true,
opacity: 0.55,
depthWrite: false,
toneMapped: false
});
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.19, 0.52, 3),
arrowMaterial
);
arrow.renderOrder = 3;
scene.add(arrow);
arrows.push(arrow);
}
// Bright traveling marker.
const routeMarker = new THREE.Group();
scene.add(routeMarker);
const marker = new THREE.Mesh(
new THREE.SphereGeometry(0.23, 10, 7),
new THREE.MeshBasicMaterial({
color: 0xffd36c,
toneMapped: false
})
);
marker.position.y = 0.27;
marker.castShadow = true;
routeMarker.add(marker);
const markerHalo = new THREE.Mesh(
new THREE.RingGeometry(0.31, 0.42, 18),
new THREE.MeshBasicMaterial({
color: 0xfff0b0,
transparent: true,
opacity: 0.82,
side: THREE.DoubleSide,
depthWrite: false,
toneMapped: false
})
);
markerHalo.rotation.x = -Math.PI / 2;
markerHalo.position.y = 0.025;
routeMarker.add(markerHalo);
const markerLight = new THREE.PointLight(0xffc45a, 1.4, 5.0, 2);
markerLight.position.y = 0.4;
routeMarker.add(markerLight);
// Start marker.
const startRing = new THREE.Mesh(
new THREE.TorusGeometry(0.43, 0.065, 6, 20),
new THREE.MeshBasicMaterial({
color: 0x26b6ad,
toneMapped: false
})
);
startRing.rotation.x = Math.PI / 2;
startRing.position.copy(routePoints[0]);
startRing.position.y = 0.17;
scene.add(startRing);
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
const routeSpeed = reducedMotion ? 0.025 : 0.075;
const progress = (elapsed * routeSpeed) % 1;
routeMarker.position.copy(routeCurve.getPointAt(progress));
routeMarker.position.y += 0.02;
const haloScale = 1 + Math.sin(elapsed * 4.2) * 0.12;
markerHalo.scale.setScalar(haloScale);
markerLight.intensity = 1.15 + Math.sin(elapsed * 4.2) * 0.25;
for (let i = 0; i < arrows.length; i++) {
const arrowProgress = (i / arrows.length + elapsed * 0.045) % 1;
const point = routeCurve.getPointAt(arrowProgress);
const tangent = routeCurve.getTangentAt(arrowProgress).normalize();
arrows[i].position.copy(point);
arrows[i].position.y += 0.035;
arrows[i].quaternion.setFromUnitVectors(up, tangent);
const pulse = ((elapsed * 0.23 - i / arrows.length) % 1 + 1) % 1;
const pulseStrength = pulse < 0.2 ? 1 - pulse / 0.2 : 0;
arrows[i].material.opacity = 0.28 + pulseStrength * 0.72;
}
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
loading.remove();
</script>
</body>
</html>
```