Prompt specification
Build or customize the Three.js 3D scene "Pedestrian approaching a Prague bridge tower" 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 approaching a Prague bridge tower
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/pedestrian-approaching-a-prague-bridge-tower-x2858
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring Malá Strana's lanes and bridge approach in Prague. Create a compact referenced street-to-bridge vignette with tower edge, passage, and pedestrians. Show the narrowing route through the gateway without inventing a full medieval interior. Low-poly.
Working Three.js Starter (pedestrian-approaching-a-prague-bridge-tower-x2858):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Malá Strana → Charles Bridge · Low-poly Reference Vignette</title>
<style>
:root{
--ink:#f2ece1; --dim:#c9c0b2; --edge:rgba(242,236,225,.18);
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:#0d1014;overflow:hidden}
body{font-family:"Inter","Helvetica Neue",Arial,sans-serif;color:var(--ink)}
#app{position:fixed;inset:0}
canvas{display:block;touch-action:none}
.vignette{position:fixed;inset:0;pointer-events:none;
background:radial-gradient(120% 90% at 50% 45%,rgba(0,0,0,0) 45%,rgba(0,0,0,.42) 100%)}
.card{position:fixed;left:20px;top:20px;max-width:330px;padding:14px 16px 13px;
background:rgba(16,18,22,.62);backdrop-filter:blur(7px);
border:1px solid var(--edge);border-radius:3px;pointer-events:none}
.card h1{margin:0 0 3px;font-size:14px;letter-spacing:.10em;text-transform:uppercase;font-weight:600}
.card h2{margin:0 0 9px;font-size:11px;letter-spacing:.04em;color:var(--dim);font-weight:400}
.card p{margin:0;font-size:10.5px;line-height:1.55;color:var(--dim)}
.keys{margin-top:10px;padding-top:9px;border-top:1px solid var(--edge);
font-size:10px;letter-spacing:.06em;color:var(--dim);display:flex;gap:12px;flex-wrap:wrap}
.keys b{color:var(--ink);font-weight:600}
.note{position:fixed;right:20px;bottom:18px;max-width:270px;text-align:right;
font-size:10px;line-height:1.5;color:rgba(242,236,225,.5);pointer-events:none}
@media (max-width:620px){.card{max-width:56vw;padding:11px 12px}.card p{display:none}.note{display:none}}
</style>
</head>
<body>
<div id="app"></div>
<div class="vignette"></div>
<div class="card">
<h1>Malá Strana → Charles Bridge</h1>
<h2>Mostecká lane · Lesser Town Bridge Tower (Pražská brána)</h2>
<p>A compact street-to-bridge vignette: the lane narrows toward the gate, threads the
vaulted passage, and spills out onto the bridge deck above the Vltava.</p>
<div class="keys">
<span><b>drag</b> orbit</span><span><b>wheel</b> zoom</span>
<span><b>shift+drag</b> pan</span><span><b>1–4</b> views</span>
</div>
</div>
<div class="note">Stylized low-poly study of the approach sequence — abstracted massing and
silhouette only, not a reconstruction of the historic fabric.</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
/* ------------------------------------------------------------------ *
* renderer / scene basics
* ------------------------------------------------------------------ */
const app = document.getElementById('app');
const renderer = new THREE.WebGLRenderer({ antialias:true, powerPreference:'high-performance' });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.02;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const FOG = new THREE.Color('#c4d3dd');
scene.fog = new THREE.Fog(FOG.getHex(), 38, 168);
const camera = new THREE.PerspectiveCamera(43, innerWidth/innerHeight, 0.1, 900);
/* ------------------------------------------------------------------ *
* deterministic randomness + math helpers
* ------------------------------------------------------------------ */
function mulberry32(a){return function(){a|=0;a=a+0x6D2B79F5|0;let t=Math.imul(a^a>>>15,1|a);
t=t+Math.imul(t^t>>>7,61|t)^t;return ((t^t>>>14)>>>0)/4294967296;};}
const rnd = mulberry32(20240917);
const clamp = THREE.MathUtils.clamp;
const lerp = THREE.MathUtils.lerp;
/* ------------------------------------------------------------------ *
* procedural textures (canvas → THREE.CanvasTexture)
* ------------------------------------------------------------------ */
function cobbleTexture(){
const c = document.createElement('canvas'); c.width = c.height = 256;
const g = c.getContext('2d');
g.fillStyle = '#4e4a44'; g.fillRect(0,0,256,256);
const rows = 8, h = 256/rows;
for(let r=0;r<rows;r++){
const off = (r%2)*16;
for(let x=-20;x<256;x+=32){
const w = 26 + Math.floor(rnd()*6), hh = h-3;
const v = 112 + Math.floor(rnd()*48);
g.fillStyle = `rgb(${v},${v-5},${v-14})`;
g.fillRect(x+off+1.5, r*h+1.5, w, hh);
g.fillStyle = `rgba(255,255,255,${0.03+rnd()*0.05})`;
g.fillRect(x+off+1.5, r*h+1.5, w, 2);
}
}
const t = new THREE.CanvasTexture(c);
t.wrapS = t.wrapT = THREE.RepeatWrapping;
t.colorSpace = THREE.SRGBColorSpace;
t.anisotropy = renderer.capabilities.getMaxAnisotropy();
return t;
}
function stripeTexture(a,b){
const c = document.createElement('canvas'); c.width = 128; c.height = 32;
const g = c.getContext('2d');
g.fillStyle = a; g.fillRect(0,0,128,32);
g.fillStyle = b;
for(let i=0;i<128;i+=32) g.fillRect(i,0,16,32);
const t = new THREE.CanvasTexture(c);
t.wrapS = t.wrapT = THREE.RepeatWrapping;
t.colorSpace = THREE.SRGBColorSpace;
return t;
}
function skyTexture(){
const c = document.createElement('canvas'); c.width = 4; c.height = 256;
const g = c.getContext('2d');
const grd = g.createLinearGradient(0,0,0,256);
grd.addColorStop(0.00,'#4f86c2');
grd.addColorStop(0.42,'#9dc0dd');
grd.addColorStop(0.72,'#d7dfdd');
grd.addColorStop(1.00,'#f2e6cf');
g.fillStyle = grd; g.fillRect(0,0,4,256);
const t = new THREE.CanvasTexture(c);
t.colorSpace = THREE.SRGBColorSpace;
return t;
}
/* ------------------------------------------------------------------ *
* sky + light
* ------------------------------------------------------------------ */
const sky = new THREE.Mesh(
new THREE.SphereGeometry(420, 24, 16),
new THREE.MeshBasicMaterial({ map: skyTexture(), side: THREE.BackSide, fog:false })
);
scene.add(sky);
const hemi = new THREE.HemisphereLight('#bcd6ef', '#6a5b46', 0.72);
scene.add(hemi);
const sun = new THREE.DirectionalLight('#ffe7c2', 2.35);
sun.position.set(62, 74, 34);
sun.target.position.set(0, 2, -26);
sun.castShadow = true;
sun.shadow.mapSize.set(2048,2048);
sun.shadow.camera.left = -48; sun.shadow.camera.right = 48;
sun.shadow.camera.top = 48; sun.shadow.camera.bottom = -48;
sun.shadow.camera.near = 12; sun.shadow.camera.far = 220;
sun.shadow.bias = -0.0012; sun.shadow.normalBias = 0.03;
scene.add(sun, sun.target);
const bounce = new THREE.DirectionalLight('#9fb6cc', 0.35);
bounce.position.set(-40, 20, -60);
scene.add(bounce);
/* ------------------------------------------------------------------ *
* street geometry model — the route narrows toward the gateway
* ------------------------------------------------------------------ */
// [z, half-width] (Malá Strana lane: wide in the foreground, tight at the gate)
const LANE = [[40,7.4],[26,6.6],[12,5.6],[0,4.9],[-12,3.9],[-22,3.1],[-30,2.3],[-38,2.3]];
function laneHalf(z){
if(z >= LANE[0][0]) return LANE[0][1];
for(let i=0;i<LANE.length-1;i++){
const [z0,w0] = LANE[i], [z1,w1] = LANE[i+1];
if(z <= z0 && z >= z1) return lerp(w0, w1, (z0-z)/(z0-z1));
}
return LANE[LANE.length-1][1];
}
const centerX = z => 1.1*Math.sin((z+26)*0.05);
const groundY = z => z > -38 ? 0 : (z > -41 ? -1.2*(-38-z)/3 : -1.2);
const cobble = cobbleTexture();
const matRoad = new THREE.MeshStandardMaterial({ map:cobble, roughness:0.96, metalness:0.0 });
const matWalk = new THREE.MeshStandardMaterial({ color:'#b3ab9c', roughness:0.95 });
const matEarth = new THREE.MeshStandardMaterial({ color:'#6d6a4f', roughness:1.0 });
/* ribbon builder: a quad strip between two edge functions */
function ribbon(zStart, zEnd, segs, edgeL, edgeR, yFn, uScale){
const pos=[], uv=[], idx=[];
for(let i=0;i<=segs;i++){
const z = lerp(zStart, zEnd, i/segs);
const L = edgeL(z), R = edgeR(z), y = yFn(z);
const v = (zStart - z)*uScale;
pos.push(L.x, y, z, R.x, y, z);
uv.push(L.x*uScale, v, R.x*uScale, v);
}
for(let i=0;i<segs;i++){
const a = i*2, b = a+1, c = a+2, d = a+3;
idx.push(a,c,b, b,c,d);
}
const g = new THREE.BufferGeometry();
g.setAttribute('position', new THREE.Float32BufferAttribute(pos,3));
g.setAttribute('uv', new THREE.Float32BufferAttribute(uv,2));
g.setIndex(idx); g.computeVertexNormals();
return g;
}
const road = new THREE.Mesh(
ribbon(40,-38,72,
z=>({x:centerX(z)-laneHalf(z)}),
z=>({x:centerX(z)+laneHalf(z)}),
z=>groundY(z)+0.005, 0.5),
matRoad);
road.receiveShadow = true; scene.add(road);
const walkL = new THREE.Mesh(
ribbon(40,-30,60,
z=>({x:centerX(z)-laneHalf(z)-1.0}),
z=>({x:centerX(z)-laneHalf(z)-0.04}),
()=>0.16, 0.4), matWalk);
const walkR = new THREE.Mesh(
ribbon(40,-30,60,
z=>({x:centerX(z)+laneHalf(z)+0.04}),
z=>({x:centerX(z)+laneHalf(z)+1.0}),
()=>0.16, 0.4), matWalk);
walkL.receiveShadow = walkR.receiveShadow = true; scene.add(walkL, walkR);
const ground = new THREE.Mesh(new THREE.PlaneGeometry(500,500), matEarth);
ground.rotation.x = -Math.PI/2; ground.position.y = -0.03;
ground.receiveShadow = true; scene.add(ground);
/* ------------------------------------------------------------------ *
* low-poly gable roof helper (ridge along Z; rotate for ridge along X)
* ------------------------------------------------------------------ */
function gableGeometry(width, height, depth){
const s = new THREE.Shape();
s.moveTo(-width/2,0); s.lineTo(width/2,0); s.lineTo(0,height); s.closePath();
const g = new THREE.ExtrudeGeometry(s, { depth, bevelEnabled:false });
g.translate(0,0,-depth/2);
return g;
}
function lancetShape(w, h, y0){
const R = w, crown = 0.866*w;
const spring = y0 + h - crown;
const s = new THREE.Shape();
s.moveTo(-w/2, y0);
s.lineTo(-w/2, spring);
s.absarc(w/2, spring, R, Math.PI, Math.PI*2/3, true);
s.absarc(-w/2, spring, R, Math.PI/3, 0, true);
s.lineTo(w/2, y0);
s.closePath();
return s;
}
/* ------------------------------------------------------------------ *
* Malá Strana house rows
* ------------------------------------------------------------------ */
const PLASTER = ['#e7d4b4','#dcc39f','#cbb492','#e3cfa6','#d3c0a4','#c1a98c','#dfc9a8','#cdb89a','#e8d8bb'];
const ROOFS = ['#8a4b3c','#7e4034','#95604e','#6f3b32','#a1664d','#5e4a44','#7a4b3e'];
const SLATE = '#4b535e';
const STONE = '#a39a8b';
const STONE_D= '#847c6f';
const GLASS = new THREE.MeshStandardMaterial({ color:'#3c4654', roughness:0.35, metalness:0.2 });
const GLASS_LIT = new THREE.MeshStandardMaterial({ color:'#e8b169', emissive:'#c8873c', emissiveIntensity:0.75, roughness:0.5 });
const WOOD = new THREE.MeshStandardMaterial({ color:'#5b3f2e', roughness:0.9 });
const TRIM = new THREE.MeshStandardMaterial({ color:'#efe6d4', roughness:0.85 });
const winGeo = new THREE.BoxGeometry(0.08, 1.32, 0.78);
const sillGeo = new THREE.BoxGeometry(0.14, 0.12, 0.94);
const plinthGeo = new THREE.BoxGeometry(1, 0.55, 1);
const corniceGeo = new THREE.BoxGeometry(1, 0.26, 1);
const chimGeo = new THREE.BoxGeometry(0.5, 1.15, 0.46);
function house(side, z, len, depth, height, color, roofColor, litWindows){
const grp = new THREE.Group();
const frontZ = z + len/2; // widest (nearest) end of the row
const x = centerX(frontZ) + side*(laneHalf(frontZ) + 1.0 + depth/2);
grp.position.set(x, 0, z);
const body = new THREE.Mesh(new THREE.BoxGeometry(depth, height, len),
new THREE.MeshStandardMaterial({ color, roughness:0.92 }));
body.position.y = height/2; body.castShadow = body.receiveShadow = true;
grp.add(body);
const plinth = new THREE.Mesh(plinthGeo.clone(), new THREE.MeshStandardMaterial({color:'#a79c8a',roughness:0.95}));
plinth.scale.set(depth+0.1, 1, len+0.1); plinth.position.y = 0.27;
plinth.castShadow = plinth.receiveShadow = true; grp.add(plinth);
const cornice = new THREE.Mesh(corniceGeo.clone(), TRIM);
cornice.scale.set(depth+0.2, 1, len+0.2); cornice.position.y = height - 0.16;
cornice.castShadow = true; grp.add(cornice);
const roofH = depth*0.42 + 1.0;
const roof = new THREE.Mesh(gableGeometry(depth+0.35, roofH, len+0.25),
new THREE.MeshStandardMaterial({ color:roofColor, roughness:0.9 }));
roof.position.y = height; roof.castShadow = roof.receiveShadow = true;
grp.add(roof);
// windows on the street facade
const facadeX = -side*(depth/2 + 0.03);
const floors = Math.max(2, Math.floor((height-1.7)/2.85));
const cols = Math.max(2, Math.floor(len/1.75));
let idx = 0;
for(let f=0; f<floors; f++){
const wy = 1.55 + f*2.85;
if(wy + 0.7 > height - 0.7) break;
for(let c=0; c<cols; c++){
const wz = -len/2 + 0.95 + c*((len-1.9)/Math.max(1,cols-1));
const w = new THREE.Mesh(winGeo, (idx%7===3 && litWindows) ? GLASS_LIT : GLASS);
w.position.set(facadeX, wy, wz);
grp.add(w);
const s = new THREE.Mesh(sillGeo, TRIM);
s.position.set(facadeX - side*0.03, wy-0.74, wz);
grp.add(s);
idx++;
}
}
// doorway
const door = new THREE.Mesh(new THREE.BoxGeometry(0.1, 2.05, 1.05), WOOD);
door.position.set(facadeX, 1.02, (rnd()-0.5)*(len-2.2));
grp.add(door);
const lintel = new THREE.Mesh(new THREE.BoxGeometry(0.16, 0.18, 1.3), TRIM);
lintel.position.set(facadeX - side*0.02, 2.1, door.position.z);
grp.add(lintel);
// chimney
if(rnd() > 0.25){
const ch = new THREE.Mesh(chimGeo, new THREE.MeshStandardMaterial({color:roofColor,roughness:0.9}));
ch.position.set(side*depth*0.22, height + roofH*0.62, (rnd()-0.5)*len*0.6);
ch.castShadow = true; grp.add(ch);
}
// dormer
if(rnd() > 0.62 && len > 7){
const d = new THREE.Mesh(new THREE.BoxGeometry(1.1,1.0,1.0), new THREE.MeshStandardMaterial({color:roofColor,roughness:0.9}));
d.position.set(side*depth*0.22, height+roofH*0.42, (rnd()-0.5)*len*0.5);
d.castShadow = true; grp.add(d);
}
scene.add(grp);
return grp;
}
for(const side of [-1,1]){
let cursor = 26.5;
while(cursor > -27){
const len = 6 + rnd()*5.5;
const depth = 5 + rnd()*2.4;
const height = 9.5 + rnd()*6.5;
const plaster = PLASTER[Math.floor(rnd()*PLASTER.length)];
const roof = rnd() > 0.78 ? SLATE : ROOFS[Math.floor(rnd()*ROOFS.length)];
house(side, cursor - len/2, len, depth, height, plaster, roof, rnd() > 0.45);
cursor -= len + 0.35 + rnd()*1.5; // gaps read as narrow Malá Strana alleys
}
}
/* small café terrace with striped awning */
{
const awn = new THREE.Mesh(new THREE.BoxGeometry(2.4, 0.12, 3.4),
new THREE.MeshStandardMaterial({ map: stripeTexture('#9c3f34','#efe3cf'), roughness:0.9, side:THREE.DoubleSide }));
const az = 10.5, ax = centerX(az)+laneHalf(az)+0.95;
awn.position.set(ax-0.6, 3.0, az); awn.rotation.z = -0.42; awn.castShadow = true;
scene.add(awn);
for(const dz of [-1.1,1.1]){
const t = new THREE.Mesh(new THREE.CylinderGeometry(0.42,0.42,0.07,10), new THREE.MeshStandardMaterial({color:'#8a6a44',roughness:0.8}));
t.position.set(ax-2.1, 0.9, az+dz); t.castShadow = true; scene.add(t);
const stem = new THREE.Mesh(new THREE.CylinderGeometry(0.05,0.05,0.9,6), new THREE.MeshStandardMaterial({color:'#4a4038',roughness:0.8}));
stem.position.set(ax-2.1, 0.45, az+dz); scene.add(stem);
}
}
/* street lamps */
function lamp(z, side){
const x = centerX(z)+side*(laneHalf(z)+1.35);
const g = new THREE.Group(); g.position.set(x,0,z);
const pole = new THREE.Mesh(new THREE.CylinderGeometry(0.07,0.1,3.6,6), new THREE.MeshStandardMaterial({color:'#2f3238',roughness:0.6,metalness:0.4}));
pole.position.y = 1.8; pole.castShadow = true; g.add(pole);
const head = new THREE.Mesh(new THREE.BoxGeometry(0.34,0.46,0.34), new THREE.MeshStandardMaterial({color:'#ffdca0',emissive:'#ffb85c',emissiveIntensity:1.3,roughness:0.5}));
head.position.y = 3.85; g.add(head);
const cap = new THREE.Mesh(new THREE.ConeGeometry(0.3,0.22,4), new THREE.MeshStandardMaterial({color:'#2f3238',roughness:0.6}));
cap.position.y = 4.18; g.add(cap);
scene.add(g);
}
lamp(17,-1); lamp(2,1); lamp(-16,-1);
/* bench + bollards near the forecourt */
{
const b = new THREE.Group();
const seat = new THREE.Mesh(new THREE.BoxGeometry(0.6,0.1,1.9), new THREE.MeshStandardMaterial({color:'#6b4a30',roughness:0.9}));
seat.position.y = 0.55; seat.castShadow = true; b.add(seat);
const back = new THREE.Mesh(new THREE.BoxGeometry(0.1,0.55,1.9), new THREE.MeshStandardMaterial({color:'#6b4a30',roughness:0.9}));
back.position.set(-0.26,0.85,0); b.add(back);
for(const dz of [-0.75,0.75]){
const leg = new THREE.Mesh(new THREE.BoxGeometry(0.5,0.55,0.12), new THREE.MeshStandardMaterial({color:'#33363c',roughness:0.7}));
leg.position.set(0,0.27,dz); b.add(leg);
}
b.position.set(centerX(14)+3.1, 0, 14); b.rotation.y = 0.35; scene.add(b);
}
for(let i=0;i<5;i++){
const bo = new THREE.Mesh(new THREE.CylinderGeometry(0.11,0.13,0.75,6), new THREE.MeshStandardMaterial({color:'#4a4f57',roughness:0.8}));
bo.position.set(centerX(-28)+(-2.6+i*1.3), 0.38, -28.2); bo.castShadow = true; scene.add(bo);
}
/* ------------------------------------------------------------------ *
* Pražská brána — abstracted gate block, vaulted passage, turrets
* ------------------------------------------------------------------ */
const tower = new THREE.Group();
tower.position.set(0,0,-30);
scene.add(tower);
const stoneMat = new THREE.MeshStandardMaterial({ color:'#9d9384', roughness:0.94 });
const stoneDark= new THREE.MeshStandardMaterial({ color:'#7e766a', roughness:0.95 });
const slateMat = new THREE.MeshStandardMaterial({ color:'#3f4751', roughness:0.8, metalness:0.15 });
// main wall with a semicircular gate opening cut clean through
{
const s = new THREE.Shape();
s.moveTo(-7.5,-1.6); s.lineTo(7.5,-1.6); s.lineTo(7.5,15); s.lineTo(-7.5,15); s.closePath();
const R = 2.3, spring = 4.6;
const hole = new THREE.Path();
hole.moveTo(-R,-1.2); hole.lineTo(-R,spring);
hole.absarc(0,spring,R,Math.PI,0,true);
hole.lineTo(R,-1.2); hole.closePath();
s.holes.push(hole);
const geo = new THREE.ExtrudeGeometry(s,{ depth:8, bevelEnabled:false, curveSegments:10 });
geo.translate(0,0,-8);
const wall = new THREE.Mesh(geo, stoneMat);
wall.castShadow = wall.receiveShadow = true; tower.add(wall);
}
// barrel vault inside the passage
{
const v = new THREE.Mesh(new THREE.CylinderGeometry(2.3,2.3,8,14,1,true,0,Math.PI),
new THREE.MeshStandardMaterial({ color:'#6d675c', roughness:1, side:THREE.BackSide }));
v.rotation.x = -Math.PI/2; v.position.set(0,4.6,-4);
v.receiveShadow = true; tower.add(v);
}
// passage floor
{
const f = new THREE.Mesh(new THREE.PlaneGeometry(4.6,8.2), matRoad);
f.rotation.x = -Math.PI/2; f.position.set(0,0.01,-4); f.receiveShadow = true; tower.add(f);
}
// gate cornice + crenellations
{
const cor = new THREE.Mesh(new THREE.BoxGeometry(15.6,0.4,8.5), stoneDark);
cor.position.set(0,15.1,-4); cor.castShadow = true; tower.add(cor);
for(let i=0;i<13;i++){
const m = new THREE.Mesh(new THREE.BoxGeometry(0.85,0.75,0.85), stoneMat);
m.position.set(-6.6+i*1.1,15.7,0.35); m.castShadow = true; tower.add(m);
}
}
// upper stage (chapel level) with a street-facing gable
{
const up = new THREE.Mesh(new THREE.BoxGeometry(10.4,6.2,7.2), stoneMat);
up.position.set(0,18.3,-4); up.castShadow = up.receiveShadow = true; tower.add(up);
const roof = new THREE.Mesh(gableGeometry(7.2,4.6,10.6), slateMat);
roof.rotation.y = Math.PI/2; roof.position.set(0,21.4,-4);
roof.castShadow = true; tower.add(roof);
for(let i=0;i<3;i++){
const w = new THREE.Mesh(new THREE.ShapeGeometry(lancetShape(0.95,2.4,0)),
new THREE.MeshStandardMaterial({ color:'#2c3540', roughness:0.5, metalness:0.2 }));
w.position.set(-2.6+i*2.6, 16.4, -0.42); tower.add(w);
}
for(let i=0;i<9;i++){
const m = new THREE.Mesh(new THREE.BoxGeometry(0.8,0.7,0.8), stoneMat);
m.position.set(-4.6+i*1.15,21.5,0.3); m.castShadow = true; tower.add(m);
}
}
// pointed windows over the gate
{
for(let i=0;i<3;i++){
const w = new THREE.Mesh(new THREE.ShapeGeometry(lancetShape(0.85,2.2,0)),
new THREE.MeshStandardMaterial({ color:'#2c3540', roughness:0.5, metalness:0.2 }));
w.position.set(-2.4+i*2.4, 9.0, 0.03); tower.add(w);
}
}
// flanking turrets
for(const side of [-1,1]){
const t = new THREE.Mesh(new THREE.CylinderGeometry(2.15,2.35,19,8), stoneMat);
t.position.set(side*5.9, 9.5, -0.2); t.castShadow = t.receiveShadow = true; tower.add(t);
const cone = new THREE.Mesh(new THREE.ConeGeometry(2.4,6.6,8), slateMat);
cone.position.set(side*5.9, 22.3, -0.2); cone.castShadow = true; tower.add(cone);
const fin = new THREE.Mesh(new THREE.SphereGeometry(0.24,6,5), slateMat);
fin.position.set(side*5.9, 25.8, -0.2); tower.add(fin);
for(let i=0;i<3;i++){
const sl = new THREE.Mesh(new THREE.BoxGeometry(0.3,0.9,0.5),
new THREE.MeshStandardMaterial({ color:'#2c3540', roughness:0.5 }));
sl.position.set(side*5.9, 12.5+i*2.6, 1.75); tower.add(sl);
}
}
// lantern hung beside the gate + warm light in the vault
{
const lampM = new THREE.Mesh(new THREE.BoxGeometry(0.3,0.44,0.3),
new THREE.MeshStandardMaterial({ color:'#ffd9a0', emissive:'#ffae55', emissiveIntensity:1.6 }));
lampM.position.set(-2.9, 6.4, 0.35); tower.add(lampM);
const pl = new THREE.PointLight('#ffb968', 7, 11, 2);
pl.position.set(-2.9, 6.0, 0.9); tower.add(pl);
const pl2 = new THREE.PointLight('#ffc98a', 9, 14, 2);
pl2.position.set(0, 3.6, -3.6); tower.add(pl2);
}
// embankment mass under the tower
{
const e = new THREE.Mesh(new THREE.BoxGeometry(26,9,11), stoneDark);
e.position.set(0,-4.6,-34); e.castShadow = e.receiveShadow = true; scene.add(e);
}
/* steps down onto the bridge deck */
for(let i=0;i<6;i++){
const s = new THREE.Mesh(new THREE.BoxGeometry(4.6, 0.22, 0.55), stoneMat);
s.position.set(centerX(-38.5-i*0.5)*0.3, -0.11-i*0.2, -38.3-i*0.5);
s.castShadow = s.receiveShadow = true; scene.add(s);
}
/* St. Thomas' spire peeking over the roofs behind the tower */
{
const g = new THREE.Group();
const nave = new THREE.Mesh(new THREE.BoxGeometry(7,9,11), new THREE.MeshStandardMaterial({color:'#8d8477',roughness:0.95}));
nave.position.y = 4.5; g.add(nave);
const spire = new THREE.Mesh(new THREE.ConeGeometry(3.4,17,4), slateMat);
spire.position.y = 17.5; spire.rotation.y = Math.PI/4; g.add(spire);
const tower2 = new THREE.Mesh(new THREE.BoxGeometry(4.2,13,4.2), new THREE.MeshStandardMaterial({color:'#8d8477',roughness:0.95}));
tower2.position.set(2.4, 8, 1); g.add(tower2);
const sp2 = new THREE.Mesh(new THREE.ConeGeometry(2.3,12,4), slateMat);
sp2.position.set(2.4, 20.5, 1); sp2.rotation.y = Math.PI/4; g.add(sp2);
g.position.set(-13.5, 0, -37);
g.traverse(o=>{ if(o.isMesh){o.castShadow=true;} });
scene.add(g);
}
/* ------------------------------------------------------------------ *
* Charles Bridge deck, parapets, statues
* ------------------------------------------------------------------ */
const DECK_Z0 = -41, DECK_Z1 = -96, DECK_LEN = DECK_Z1-DECK_Z0, DECK_HW = 4.6;
{
const deck = new THREE.Mesh(new THREE.BoxGeometry(DECK_HW*2, 0.8, DECK_LEN),
new THREE.MeshStandardMaterial({ color:'#a8a094', roughness:0.95 }));
deck.position.set(0, -1.6, (DECK_Z0+DECK_Z1)/2);
deck.castShadow = deck.receiveShadow = true; scene.add(deck);
// cobbled walking strip
const strip = new THREE.Mesh(new THREE.PlaneGeometry(4.4, DECK_LEN), matRoad);
strip.rotation.x = -Math.PI/2; strip.position.set(0,-1.19,(DECK_Z0+DECK_Z1)/2);
strip.receiveShadow = true; scene.add(strip);
for(const side of [-1,1]){
const p = new THREE.Mesh(new THREE.BoxGeometry(0.55,1.1,DECK_LEN),
new THREE.MeshStandardMaterial({ color:'#a59c8e', roughness:0.95 }));
p.position.set(side*(DECK_HW-0.25), -0.65, (DECK_Z0+DECK_Z1)/2);
p.castShadow = p.receiveShadow = true; scene.add(p);
const cp = new THREE.Mesh(new THREE.BoxGeometry(0.8,0.14,DECK_LEN),
new THREE.MeshStandardMaterial({ color:'#b4ab9c', roughness:0.9 }));
cp.position.set(side*(DECK_HW-0.25), -0.02, (DECK_Z0+DECK_Z1)/2);
cp.castShadow = true; scene.add(cp);
// simplified saint statues on pedestals
for(let z=DECK_Z0-3; z>DECK_Z1+2; z-=4.3){
const ped = new THREE.Mesh(new THREE.BoxGeometry(0.8,1.0,0.8),
new THREE.MeshStandardMaterial({ color:'#8f8779', roughness:0.95 }));
ped.position.set(side*(DECK_HW-0.25), 0.55, z); ped.castShadow = true; scene.add(ped);
const h = 1.2 + rnd()*0.6;
const body = new THREE.Mesh(new THREE.CylinderGeometry(0.2,0.3,h,6),
new THREE.MeshStandardMaterial({ color:'#6f6a60', roughness:0.9 }));
body.position.set(side*(DECK_HW-0.25), 1.05+h/2, z); body.castShadow = true; scene.add(body);
const head = new THREE.Mesh(new THREE.SphereGeometry(0.17,6,5),
new THREE.MeshStandardMaterial({ color:'#6f6a60', roughness:0.9 }));
head.position.set(side*(DECK_HW-0.25), 1.12+h, z); scene.add(head);
if(rnd()>0.5){
const attr = new THREE.Mesh(new THREE.BoxGeometry(0.08,0.9,0.08),
new THREE.MeshStandardMaterial({ color:'#5f5a51', roughness:0.9 }));
attr.position.set(side*(DECK_HW-0.25)+0.16, 1.3+h*0.6, z); attr.rotation.z=0.2; scene.add(attr);
}
}
}
}
/* Vltava + far bank */
{
const river = new THREE.Mesh(new THREE.PlaneGeometry(600,600),
new THREE.MeshStandardMaterial({ color:'#43606c', roughness:0.32, metalness:0.25 }));
river.rotation.x = -Math.PI/2; river.position.y = -9; scene.add(river);
// glints
const glint = new THREE.MeshBasicMaterial({ color:'#b9d3dd', transparent:true, opacity:0.13, fog:false });
for(let i=0;i<26;i++){
const q = new THREE.Mesh(new THREE.PlaneGeometry(1+rnd()*5, 0.25), glint);
q.rotation.x = -Math.PI/2; q.position.set((rnd()-0.5)*180, -8.95, -40-rnd()*120);
scene.add(q);
}
// boats
for(let i=0;i<3;i++){
const s = new THREE.Shape();
s.moveTo(0,-2.4); s.lineTo(0.65,-0.7); s.lineTo(0.72,1.2); s.lineTo(0,2.5);
s.lineTo(-0.72,1.2); s.lineTo(-0.65,-0.7); s.closePath();
const b = new THREE.Mesh(new THREE.ExtrudeGeometry(s,{depth:0.55,bevelEnabled:false}),
new THREE.MeshStandardMaterial({ color: i===0?'#7d4a35':'#3f4f5c', roughness:0.85 }));
b.rotation.x = -Math.PI/2;
b.position.set((i-1)*16 + (rnd()-0.5)*6, -8.7, -52-i*16);
b.rotation.z = (rnd()-0.5)*0.6; b.castShadow = true; scene.add(b);
}
// far bank + Old Town bridge tower silhouette
const bank = new THREE.Mesh(new THREE.BoxGeometry(240,10,44),
new THREE.MeshStandardMaterial({ color:'#8d8577', roughness:0.95 }));
bank.position.set(0,-5, -126); bank.receiveShadow = true; scene.add(bank);
const ot = new THREE.Group();
const ob = new THREE.Mesh(new THREE.BoxGeometry(7,13,7), stoneDark);
ob.position.y = 6.5; ot.add(ob);
const orf = new THREE.Mesh(gableGeometry(7,4,7), slateMat);
orf.position.y = 13; ot.add(orf);
for(const s of [-1,1]){
const tt = new THREE.Mesh(new THREE.CylinderGeometry(1.5,1.6,16,6), stoneDark);
tt.position.set(s*3.6, 8, 0); ot.add(tt);
const cc = new THREE.Mesh(new THREE.ConeGeometry(1.7,5,6), slateMat);
cc.position.set(s*3.6, 18.5, 0); ot.add(cc);
}
ot.position.set(0,0,-106); ot.scale.setScalar(0.85); scene.add(ot);
// far-bank roofs and trees
for(let i=0;i<16;i++){
const w = 6+rnd()*9, h = 7+rnd()*7;
const b = new THREE.Mesh(new THREE.BoxGeometry(w,h,7+rnd()*7),
new THREE.MeshStandardMaterial({ color: PLASTER[Math.floor(rnd()*PLASTER.length)], roughness:0.95 }));
b.position.set(-70+i*9+rnd()*3, h/2-1, -118-rnd()*10); scene.add(b);
const r = new THREE.Mesh(gableGeometry(8,4.5,7),
new THREE.MeshStandardMaterial({ color: ROOFS[Math.floor(rnd()*ROOFS.length)], roughness:0.9 }));
r.position.set(b.position.x, h-1, b.position.z); scene.add(r);
}
for(let i=0;i<26;i++){
const tr = new THREE.Mesh(new THREE.CylinderGeometry(0.18,0.24,1.6,5),
new THREE.MeshStandardMaterial({ color:'#5d4a37', roughness:1 }));
tr.position.set(-100+rnd()*200, -0.2, -108-rnd()*18); scene.add(tr);
for(let k=0;k<2;k++){
const cn = new THREE.Mesh(new THREE.ConeGeometry(1.5-k*0.4, 3.4,6),
new THREE.MeshStandardMaterial({ color:'#4d6242', roughness:1, flatShading:true }));
cn.position.set(tr.position.x, 2.1+k*1.6, tr.position.z); cn.castShadow = true; scene.add(cn);
}
}
}
/* ------------------------------------------------------------------ *
* pedestrians — low-poly figures threading the narrowing route
* ------------------------------------------------------------------ */
const COATS = ['#3f5a7a','#7a3f3a','#485b46','#5f5177','#9a7c42','#83414f','#2f4a55','#6a6f52','#a05a3a'];
const TROUSERS = ['#3a3630','#2f3338','#4a3f35','#38424c'];
const SKINS = ['#e9c6a3','#c98f5e','#a2673c','#7d4b2c','#f0d6b6'];
const legGeo = new THREE.BoxGeometry(0.17,0.66,0.19); legGeo.translate(0,-0.33,0);
const armGeo = new THREE.BoxGeometry(0.12,0.55,0.13); armGeo.translate(0,-0.27,0);
function createPerson(){
const g = new THREE.Group();
const coat = new THREE.MeshStandardMaterial({ color: COATS[Math.floor(rnd()*COATS.length)], roughness:0.9 });
const trou = new THREE.MeshStandardMaterial({ color: TROUSERS[Math.floor(rnd()*TROUSERS.length)], roughness:0.95 });
const skin = new THREE.MeshStandardMaterial({ color: SKINS[Math.floor(rnd()*SKINS.length)], roughness:0.8 });
const hips = new THREE.Group(); hips.position.y = 0.88; g.add(hips);
const legL = new THREE.Group(); legL.position.set(-0.11,0,0); hips.add(legL);
const legR = new THREE.Group(); legR.position.set( 0.11,0,0); hips.add(legR);
legL.add(new THREE.Mesh(legGeo, trou));
legR.add(new THREE.Mesh(legGeo, trou));
const torso = new THREE.Mesh(new THREE.CylinderGeometry(0.27,0.32,0.76,7), coat);
torso.position.y = 0.38; torso.castShadow = true; hips.add(torso);
const neck = new THREE.Mesh(new THREE.CylinderGeometry(0.07,0.08,0.1,6), skin);
neck.position.y = 0.8; hips.add(neck);
const head = new THREE.Mesh(new THREE.SphereGeometry(0.155,7,5), skin);
head.position.y = 0.96; head.castShadow = true; hips.add(head);
const hair = new THREE.Mesh(new THREE.SphereGeometry(0.16,7,5,0,Math.PI*2,0,Math.PI*0.55),
new THREE.MeshStandardMaterial({ color: rnd()>0.5?'#3a2a20':'#6b5340', roughness:0.95 }));
hair.position.y = 0.97; hips.add(hair);
const armL = new THREE.Group(); armL.position.set(-0.3,0.72,0); hips.add(armL);
const armR = new THREE.Group(); armR.position.set( 0.3,0.72,0); hips.add(armR);
armL.add(new THREE.Mesh(armGeo, coat));
armR.add(new THREE.Mesh(armGeo, coat));
g.traverse(o=>{ if(o.isMesh) o.castShadow = true; });
return { g, hips, legL, legR, armL, armR };
}
const walkers = [];
function addWalker(z, opts={}){
const p = createPerson();
const w = {
...p,
z, off: (rnd()-0.5)*1.6,
speed: opts.speed ?? (0.9 + rnd()*0.7),
phase: rnd()*Math.PI*2,
scale: 0.94 + rnd()*0.14,
dir: opts.dir ?? -1
};
p.g.scale.setScalar(w.scale);
scene.add(p.g);
walkers.push(w);
return w;
}
for(let i=0;i<13;i++) addWalker(-88 + i*8.6 + rnd()*4);
for(let i=0;i<5;i++) addWalker(18 + rnd()*10);
// small clusters: people paused in the gate forecourt and mid-lane
const idlers = [];
for(let i=0;i<5;i++){
const p = createPerson();
const z = -24 + rnd()*10;
const side = rnd()>0.5 ? 1 : -1;
const x = centerX(z) + side*(laneHalf(z)-0.9) + (rnd()-0.5)*0.4;
p.g.position.set(x, 0, z);
p.g.rotation.y = Math.atan2(x-centerX(z), 1) + Math.PI + (rnd()-0.5)*1.2;
p.g.scale.setScalar(0.94+rnd()*0.14);
scene.add(p.g); idlers.push({ ...p, phase: rnd()*6 });
}
// one seated on the bench
{
const p = createPerson();
p.g.position.set(centerX(14)+3.1, 0, 14.4);
p.g.rotation.y = Math.PI*0.5;
p.hips.position.y = 0.62; p.legL.rotation.x = -1.45; p.legR.rotation.x = -1.45;
p.armL.rotation.x = -0.5; p.armR.rotation.x = -0.5;
scene.add(p.g);
}
function routeX(z, off){
if(z > -30){
const hw = laneHalf(z)-0.8;
return centerX(z) + clamp(off, -hw, hw);
} else if(z > -38){
return clamp(centerX(z)+off, -1.55, 1.55);
}
return clamp(off*1.6, -2.9, 2.9);
}
function updateWalker(w, dt){
w.z += w.speed*w.dir*dt;
w.phase += dt*w.speed*7.2;
const s = Math.sin(w.phase), c = Math.cos(w.phase);
w.legL.rotation.x = s*0.52;
w.legR.rotation.x = -s*0.52;
w.armL.rotation.x = -s*0.38;
w.armR.rotation.x = s*0.38;
w.hips.position.y = 0.88 + Math.abs(c)*0.035;
w.g.position.set(routeX(w.z, w.off), groundY(w.z), w.z);
w.g.rotation.y = w.dir < 0 ? Math.PI + (w.off*0.05) : (w.off*0.05);
if(w.z > 40 || w.z < DECK_Z1-2){ w.z = w.dir<0 ? 24+rnd()*8 : DECK_Z1-2; }
}
function updateIdler(p, t){
p.hips.position.y = 0.88 + Math.sin(t*1.4 + p.phase)*0.012;
p.g.rotation.y += Math.sin(t*0.7+p.phase)*0.0006;
}
/* ------------------------------------------------------------------ *
* camera rig — hand-written orbit / zoom / pan with damping
* ------------------------------------------------------------------ */
const rig = {
target: new THREE.Vector3(0, 3.6, -26),
az: 0.11, pol: 1.525, dist: 23,
tAz: 0.11, tPol: 1.525, tDist: 23,
tTarget: new THREE.Vector3(0, 3.6, -26)
};
function applyCamera(){
const sp = Math.sin(rig.pol), cp = Math.cos(rig.pol);
camera.position.set(
rig.target.x + rig.dist*sp*Math.sin(rig.az),
Math.max(0.6, rig.target.y + rig.dist*cp),
rig.target.z + rig.dist*sp*Math.cos(rig.az)
);
camera.lookAt(rig.target);
}
const VIEWS = {
'1': { target:[0,3.6,-26], az:0.11, pol:1.525, dist:23 },
'2': { target:[0,4.2,-31], az:0.06, pol:1.50, dist:15 },
'3': { target:[0,0.2,-58], az:0.34, pol:1.22, dist:52 },
'4': { target:[0,11,-33], az:0.62, pol:1.16, dist:38 }
};
function setView(k){
const v = VIEWS[k]; if(!v) return;
rig.tTarget.set(...v.target); rig.tAz = v.az; rig.tPol = v.pol; rig.tDist = v.dist;
}
let dragging=false, panning=false, lastX=0, lastY=0, idle=0;
const el = renderer.domElement;
el.addEventListener('pointerdown', e=>{
dragging = true; panning = e.shiftKey;
lastX = e.clientX; lastY = e.clientY; idle = 0;
el.setPointerCapture(e.pointerId);
});
el.addEventListener('pointermove', e=>{
if(!dragging) return;
const dx = e.clientX-lastX, dy = e.clientY-lastY;
lastX = e.clientX; lastY = e.clientY; idle = 0;
if(panning){
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix,0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix,1);
rig.tTarget.addScaledVector(right, -dx*0.02*rig.dist/23);
rig.tTarget.addScaledVector(up, dy*0.02*rig.dist/23);
rig.tTarget.y = clamp(rig.tTarget.y, -2, 26);
} else {
rig.tAz -= dx*0.0042;
rig.tPol = clamp(rig.tPol + dy*0.0032, 0.30, 1.565);
}
});
const endDrag = e=>{ dragging=false; panning=false; };
el.addEventListener('pointerup', endDrag);
el.addEventListener('pointercancel', endDrag);
el.addEventListener('pointerleave', endDrag);
el.addEventListener('wheel', e=>{
e.preventDefault();
rig.tDist = clamp(rig.tDist * (1 + Math.sign(e.deltaY)*0.09), 7, 95);
idle = 0;
}, { passive:false });
addEventListener('keydown', e=>{ if(VIEWS[e.key]) setView(e.key); idle=0; });
/* ------------------------------------------------------------------ *
* loop
* ------------------------------------------------------------------ */
const clock = new THREE.Clock();
let time = 0;
renderer.setAnimationLoop(()=>{
const dt = Math.min(clock.getDelta(), 0.05);
time += dt;
for(const w of walkers) updateWalker(w, dt);
for(const p of idlers) updateIdler(p, time);
// gentle idle drift
idle += dt;
if(idle > 9 && !dragging) rig.tAz += dt*0.018;
rig.az += (rig.tAz - rig.az) * Math.min(1, dt*5);
rig.pol += (rig.tPol - rig.pol) * Math.min(1, dt*5);
rig.dist += (rig.tDist - rig.dist) * Math.min(1, dt*5);
rig.target.lerp(rig.tTarget, Math.min(1, dt*4));
applyCamera();
renderer.render(scene, camera);
});
addEventListener('resize', ()=>{
camera.aspect = innerWidth/innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
});
</script>
</body>
</html>
```