Prompt specification
Build or customize the Three.js 3D scene "Pedestrians passing a bridge shopfront" 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: Pedestrians passing a bridge shopfront
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/pedestrians-passing-a-bridge-shopfront-x2830
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring Ponte Vecchio in Florence. Create a compact Florence bridge vignette with original shop display, central passage, and river glimpse. Keep the walking corridor continuous through the built bridge segment. Voxel style.
Working Three.js Starter (pedestrians-passing-a-bridge-shopfront-x2830):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ponte Vecchio — Voxel Florence</title>
<style>
:root {
color-scheme: light;
--ink: #27343a;
--paper: rgba(255, 250, 238, 0.92);
--accent: #a84732;
--gold: #c99746;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9dce5;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
pointer-events: none;
}
.title-card {
top: 22px;
left: 22px;
width: min(360px, calc(100vw - 44px));
padding: 18px 20px 16px;
border: 1px solid rgba(74, 60, 44, 0.16);
border-radius: 16px;
background: var(--paper);
box-shadow: 0 12px 36px rgba(43, 59, 66, 0.16);
backdrop-filter: blur(10px);
}
.eyebrow {
margin-bottom: 5px;
color: var(--accent);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(29px, 4vw, 42px);
font-weight: 600;
line-height: 1;
letter-spacing: -0.025em;
}
.subtitle {
margin: 9px 0 13px;
color: #667076;
font-size: 12px;
line-height: 1.45;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.chip {
padding: 5px 8px;
border-radius: 999px;
background: rgba(169, 71, 50, 0.09);
color: #7f3d2e;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.035em;
}
.controls {
right: 22px;
bottom: 22px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(66, 54, 42, 0.15);
border-radius: 10px;
padding: 10px 13px;
background: rgba(255, 251, 241, 0.93);
color: var(--ink);
box-shadow: 0 7px 20px rgba(42, 57, 65, 0.12);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition:
transform 120ms ease,
background 120ms ease,
color 120ms ease;
}
button:hover {
transform: translateY(-2px);
background: #fffaf0;
}
button.active {
border-color: transparent;
background: var(--accent);
color: #fff8eb;
}
.hint {
bottom: 24px;
left: 24px;
padding: 8px 11px;
border-radius: 9px;
background: rgba(38, 52, 58, 0.68);
color: rgba(255, 255, 255, 0.88);
font-size: 10px;
line-height: 1.45;
backdrop-filter: blur(8px);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #b9dce5;
color: #31464d;
font: 600 14px system-ui, sans-serif;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 15px;
}
.subtitle {
margin-bottom: 9px;
}
.controls {
right: 12px;
bottom: 12px;
left: 12px;
justify-content: center;
}
button {
padding: 9px 10px;
font-size: 11px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="loading">Building the little Arno…</div>
<section class="panel title-card">
<div class="eyebrow">Voxel Florence</div>
<h1>Ponte Vecchio</h1>
<p class="subtitle">
A compact riverside vignette with three masonry arches, an invented
Bottega del Sole, and an uninterrupted central walking passage.
</p>
<div class="chips">
<span class="chip">Original shop display</span>
<span class="chip">Continuous corridor</span>
<span class="chip">Arno glimpse</span>
</div>
</section>
<nav class="panel controls" aria-label="Scene views">
<button id="overviewButton" class="active">Overview</button>
<button id="walkButton">Walk passage</button>
<button id="riverButton">River glimpse</button>
</nav>
<div class="panel hint">
Drag to orbit · Scroll to zoom<br />
In passage view, drag to look around.
</div>
<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");
// ---------------------------------------------------------------------
// Renderer, scene and lighting
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9dce5);
scene.fog = new THREE.Fog(0xb9dce5, 31, 78);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
140
);
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.08;
document.body.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xe5f7ff, 0x74604b, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedc3, 3.2);
sun.position.set(-12, 24, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -28;
sun.shadow.camera.right = 28;
sun.shadow.camera.top = 28;
sun.shadow.camera.bottom = -28;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00045;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xa9d8ef, 0.8);
fill.position.set(16, 8, -15);
scene.add(fill);
// ---------------------------------------------------------------------
// Materials
// ---------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true,
...options
});
const M = {
stone: material(0xd8bc8b),
stoneLight: material(0xe2c99a),
stoneDark: material(0xb99667),
mortar: material(0x8c7559),
paving: material(0xd6c29d),
pavingLight: material(0xe2d1ae),
pavingDark: material(0xb69c78),
wood: material(0x70452d),
woodLight: material(0x9b6338),
dark: material(0x342f2b),
iron: material(0x394144, { metalness: 0.35, roughness: 0.62 }),
terracotta: material(0xb65337),
terracottaDark: material(0x8e3f2f),
roofBrown: material(0x704431),
water: material(0x68aebc, { roughness: 0.34, metalness: 0.08 }),
bank: material(0xa98e68),
grass: material(0x71885a),
leaf: material(0x3e654a),
leafLight: material(0x587a50),
cream: material(0xeee0bd),
gold: material(0xd5a548, { metalness: 0.22, roughness: 0.45 }),
glass: material(0x9bd3da, {
transparent: true,
opacity: 0.24,
roughness: 0.2,
metalness: 0.05,
depthWrite: false
})
};
function box(parent, w, h, d, mat, x = 0, y = 0, z = 0, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Arno and banks
// ---------------------------------------------------------------------
box(scene, 42, 0.35, 21, M.water, 0, -0.76, 0, false);
for (const side of [-1, 1]) {
box(scene, 42, 0.65, 18, M.bank, 0, 4.78, side * 18.5);
box(scene, 42, 5.6, 0.6, M.stoneDark, 0, 1.72, side * 10.25);
box(scene, 42, 0.18, 1.2, M.pavingLight, 0, 5.12, side * 10.95);
box(scene, 7.5, 0.12, 12, M.paving, 0, 5.19, side * 16.5);
}
const waveMaterial = material(0xa4d5db, {
transparent: true,
opacity: 0.48,
roughness: 0.28
});
const waves = [];
for (let i = 0; i < 44; i++) {
const wave = box(
scene,
0.8 + Math.random() * 1.7,
0.025,
0.08 + Math.random() * 0.12,
waveMaterial,
-20 + Math.random() * 40,
-0.56,
-9.6 + Math.random() * 19.2,
false
);
wave.userData.speed = 0.22 + Math.random() * 0.38;
waves.push(wave);
}
// ---------------------------------------------------------------------
// Voxel masonry bridge: three true openings, built from block cells
// ---------------------------------------------------------------------
const archCenters = [-6, 0, 6];
const archRadius = 2.25;
const archSpring = 1.25;
const blockSize = 0.5;
const bridgeHalfWidth = 3.6;
function isArchOpening(z, y) {
for (const center of archCenters) {
const dz = Math.abs(z - center);
if (dz < archRadius && y <= archSpring) return true;
if (dz < archRadius) {
const archTop =
archSpring + Math.sqrt(archRadius * archRadius - dz * dz);
if (y < archTop) return true;
}
}
return false;
}
const masonryCells = [];
for (let row = 0; row < 10; row++) {
const y = 0.25 + row * blockSize;
for (let column = 0; column < 39; column++) {
const z = -9.5 + column * blockSize;
if (isArchOpening(z, y)) continue;
const touchesArch =
isArchOpening(z - blockSize, y) ||
isArchOpening(z + blockSize, y) ||
isArchOpening(z, y - blockSize) ||
isArchOpening(z, y + blockSize);
for (const x of [-2.4, 0, 2.4]) {
masonryCells.push({ x, y, z, touchesArch });
}
}
}
const masonry = new THREE.InstancedMesh(
new THREE.BoxGeometry(2.38, 0.48, 0.48),
material(0xffffff),
masonryCells.length
);
masonry.castShadow = true;
masonry.receiveShadow = true;
const dummy = new THREE.Object3D();
const stoneColors = [
new THREE.Color(0xd8bc8b),
new THREE.Color(0xe0c596),
new THREE.Color(0xc9a875),
new THREE.Color(0xd6b27e)
];
const archColor = new THREE.Color(0xc99761);
masonryCells.forEach((cell, index) => {
dummy.position.set(cell.x, cell.y, cell.z);
dummy.updateMatrix();
masonry.setMatrixAt(index, dummy.matrix);
masonry.setColorAt(
index,
cell.touchesArch
? archColor
: stoneColors[Math.floor(Math.random() * stoneColors.length)]
);
});
masonry.instanceMatrix.needsUpdate = true;
masonry.instanceColor.needsUpdate = true;
scene.add(masonry);
// The deck is deliberately continuous from bank to bank.
box(scene, 7.5, 0.28, 20.4, M.stoneDark, 0, 5.0, 0);
box(scene, 2.62, 0.09, 20.35, M.pavingLight, 0, 5.19, 0);
// Flush paving joints emphasize the uninterrupted central passage.
for (let z = -9.85; z <= 9.85; z += 0.52) {
box(scene, 2.56, 0.012, 0.025, M.pavingDark, 0, 5.242, z, false);
}
for (const x of [-1.27, 1.27]) {
box(scene, 0.09, 0.045, 20.25, M.paving, x, 5.225, 0, false);
}
// End parapets and a small side viewing bay.
function railing(x, z, length, alongZ = true) {
const postSize = 0.15;
const positions = alongZ
? [z - length / 2, z, z + length / 2]
: [x - length / 2, x, x + length / 2];
for (const p of positions) {
box(
scene,
postSize,
0.9,
postSize,
M.iron,
alongZ ? x : p,
5.64,
alongZ ? p : z
);
}
box(
scene,
alongZ ? 0.12 : length,
0.11,
alongZ ? length : 0.12,
M.iron,
x,
5.92,
z
);
}
for (const side of [-1, 1]) {
for (const end of [-1, 1]) {
railing(side * 3.42, end * 9.2, 1.6);
}
}
box(scene, 1.15, 0.24, 1.15, M.stoneLight, 3.25, 5.08, 3.0);
railing(3.82, 3.0, 1.15);
// ---------------------------------------------------------------------
// Original shop signs, generated locally with Canvas
// ---------------------------------------------------------------------
function createSignTexture(title, subtitle, background, foreground, sun = false) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
context.strokeStyle = foreground;
context.lineWidth = 6;
context.strokeRect(15, 15, 994, 226);
if (sun) {
const cx = 115;
const cy = 125;
context.fillStyle = foreground;
for (let i = 0; i < 8; i++) {
const angle = (Math.PI * 2 * i) / 8;
context.fillRect(
cx + Math.cos(angle) * 48 - 7,
cy + Math.sin(angle) * 48 - 7,
14,
14
);
}
context.beginPath();
context.arc(cx, cy, 35, 0, Math.PI * 2);
context.fill();
}
context.fillStyle = foreground;
context.textAlign = "center";
context.textBaseline = "middle";
context.font = "700 65px Georgia";
context.fillText(title, sun ? 570 : 512, 104);
context.font = "600 26px sans-serif";
context.letterSpacing = "4px";
context.fillText(subtitle, sun ? 570 : 512, 174);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
const shopPalettes = {
ochre: material(0xd6a54f),
coral: material(0xc46f53),
sage: material(0x879978),
rose: material(0xc88f7d),
blue: material(0x718c9b),
cream: material(0xd7c08b)
};
const shops = [
{
side: 1,
z: -6,
wall: shopPalettes.ochre,
title: "BOTTEGA DEL SOLE",
subtitle: "ARGENTI & ORO",
bg: "#783e2f",
fg: "#f3d582",
sun: true,
display: true
},
{
side: 1,
z: 0,
wall: shopPalettes.coral,
title: "FORNO DEL PONTE",
subtitle: "PANE E DOLCI",
bg: "#684537",
fg: "#f4dfb4"
},
{
side: 1,
z: 6,
wall: shopPalettes.sage,
title: "IL MAGAZZINO",
subtitle: "ARTE DI BORGO",
bg: "#354c42",
fg: "#ead9a2"
},
{
side: -1,
z: -6,
wall: shopPalettes.rose,
title: "CASA ROSSA",
subtitle: "TINTORIA",
bg: "#833f3a",
fg: "#f4ddbd"
},
{
side: -1,
z: 0,
wall: shopPalettes.blue,
title: "OFFICINA 24",
subtitle: "LIBRI & CARTE",
bg: "#344d59",
fg: "#f0dfb3"
},
{
side: -1,
z: 6,
wall: shopPalettes.cream,
title: "OLEARIO",
subtitle: "OLIO E VERDURE",
bg: "#655d35",
fg: "#f4e2ae"
}
];
function createShop(spec) {
const group = new THREE.Group();
group.position.set(spec.side * 2.45, 5.24, spec.z);
scene.add(group);
// Floor, end walls and roof.
box(group, 2.08, 0.14, 5.05, M.woodLight, 0, 0.05, 0);
box(group, 2.08, 3.0, 0.18, spec.wall, 0, 1.5, -2.48);
box(group, 2.08, 3.0, 0.18, spec.wall, 0, 1.5, 2.48);
box(group, 2.28, 0.22, 5.35, M.roofBrown, 0, 3.05, 0);
box(group, 1.92, 0.13, 4.95, M.terracotta, 0, 3.2, 0);
box(group, 0.38, 0.85, 0.42, M.stoneDark, -0.35, 3.55, 1.45);
const outerX = spec.side * 1.0;
const innerX = -spec.side * 1.0;
// Exterior wall with a large display window.
box(group, 0.16, 0.82, 5.0, spec.wall, outerX, 0.43, 0);
box(group, 0.16, 0.62, 5.0, spec.wall, outerX, 2.68, 0);
for (const z of [-2.34, 0, 2.34]) {
box(group, 0.18, 1.55, 0.16, M.wood, outerX, 1.55, z);
}
box(group, 0.035, 1.38, 4.48, M.glass, outerX, 1.52, 0, false);
box(group, 0.11, 0.09, 4.58, M.woodLight, outerX + spec.side * 0.06, 0.86, 0);
box(group, 0.11, 0.09, 4.58, M.woodLight, outerX + spec.side * 0.06, 2.18, 0);
// Corridor-facing facade, with an open central doorway.
box(group, 0.16, 0.72, 1.84, spec.wall, innerX, 0.38, -1.57);
box(group, 0.16, 0.72, 1.84, spec.wall, innerX, 0.38, 1.57);
box(group, 0.16, 0.63, 5.0, spec.wall, innerX, 2.68, 0);
box(group, 0.16, 1.9, 0.14, M.wood, innerX, 1.23, -0.68);
box(group, 0.16, 1.9, 0.14, M.wood, innerX, 1.23, 0.68);
box(group, 0.07, 1.83, 1.22, M.dark, innerX + spec.side * 0.07, 1.22, 0);
// Striped voxel awning.
for (let i = 0; i < 7; i++) {
box(
group,
0.68,
0.09,
0.67,
i % 2 === 0 ? M.cream : M.woodLight,
outerX + spec.side * 0.28,
2.27,
-2.1 + i * 0.7
);
}
// Fictitious original sign.
const signTexture = createSignTexture(
spec.title,
spec.subtitle,
spec.bg,
spec.fg,
spec.sun
);
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(4.55, 0.68),
new THREE.MeshBasicMaterial({
map: signTexture,
side: THREE.DoubleSide,
toneMapped: false
})
);
sign.position.set(outerX + spec.side * 0.12, 2.73, 0);
sign.rotation.y = spec.side * Math.PI / 2;
group.add(sign);
// Display shelf and small goods.
box(group, 0.72, 0.10, 3.9, M.wood, outerX - spec.side * 0.33, 0.86, 0);
const productColors = [
M.gold,
M.terracotta,
shopPalettes.blue,
M.cream,
M.leaf
];
for (let i = 0; i < 5; i++) {
const z = -1.5 + i * 0.75;
box(
group,
0.3,
0.22 + (i % 2) * 0.12,
0.3,
productColors[i],
outerX - spec.side * 0.35,
1.02 + (i % 2) * 0.06,
z
);
}
if (spec.display) {
// Original voxel sun-and-diamond display.
box(group, 0.66, 0.66, 0.66, M.cream, outerX - spec.side * 0.28, 1.25, 0.45);
box(group, 0.26, 0.26, 0.26, M.gold, outerX - spec.side * 0.28, 1.7, 0.45);
box(group, 0.13, 0.13, 0.13, M.gold, outerX - spec.side * 0.28, 1.9, 0.45);
box(group, 0.13, 0.13, 0.13, M.gold, outerX - spec.side * 0.28, 1.96, 0.45);
}
// Hanging brackets.
for (const z of [-2.15, 2.15]) {
box(group, 0.09, 0.5, 0.09, M.iron, outerX + spec.side * 0.29, 2.44, z);
}
}
shops.forEach(createShop);
// ---------------------------------------------------------------------
// Distant Florence-like city blocks
// ---------------------------------------------------------------------
const cityMaterials = [
material(0xc99a73),
material(0xd8b17e),
material(0xb77e63),
material(0xc4b88d),
material(0x9caaa0)
];
function createCityBuilding(x, z, width, depth, height, mat, facing) {
const group = new THREE.Group();
group.position.set(x, 5.16, z);
scene.add(group);
box(group, width, height, depth, mat, 0, height / 2, 0);
box(group, width + 0.25, 0.24, depth + 0.25, M.terracottaDark, 0, height + 0.12, 0);
box(group, width * 0.78, 0.3, depth * 0.76, M.terracotta, 0, height + 0.35, 0);
box(group, width * 0.45, 0.28, depth * 0.48, M.terracotta, 0, height + 0.58, 0);
const frontZ = facing * (depth / 2 + 0.025);
const floors = Math.max(2, Math.floor(height / 1.7));
const columns = Math.max(2, Math.floor(width / 1.25));
for (let floor = 0; floor < floors; floor++) {
for (let column = 0; column < columns; column++) {
const wx =
-width / 2 + (width / columns) * (column + 0.5);
const wy = 1.05 + floor * 1.45;
box(group, 0.48, 0.72, 0.05, M.dark, wx, wy, frontZ, false);
box(group, 0.59, 0.09, 0.10, M.cream, wx, wy - 0.38, frontZ, false);
}
}
}
createCityBuilding(-13, -15.5, 4.8, 4.2, 6.5, cityMaterials[0], 1);
createCityBuilding(-7, -16.2, 4.6, 4.1, 7.7, cityMaterials[1], 1);
createCityBuilding(7.7, -15.8, 4.8, 4.0, 6.2, cityMaterials[2], 1);
createCityBuilding(13.4, -16.1, 5.2, 4.4, 7.2, cityMaterials[3], 1);
createCityBuilding(-13, 15.7, 4.8, 4.0, 5.9, cityMaterials[2], -1);
createCityBuilding(10.0, 16.0, 5.1, 4.2, 6.8, cityMaterials[4], -1);
createCityBuilding(15.0, 16.4, 4.5, 4.0, 5.4, cityMaterials[1], -1);
// Voxel Duomo and campanile silhouettes.
const dome = new THREE.Group();
dome.position.set(-8.5, 5.16, -21);
scene.add(dome);
box(dome, 6.8, 3.4, 6.8, M.cream, 0, 1.7, 0);
for (let i = 0; i < 7; i++) {
const size = 6.8 - i * 0.67;
box(
dome,
size,
0.48,
size,
i < 3 ? M.roofBrown : M.terracotta,
0,
3.55 + i * 0.48,
0
);
}
box(dome, 1.0, 1.0, 1.0, M.cream, 0, 7.15, 0);
box(dome, 0.35, 0.7, 0.35, M.gold, 0, 7.85, 0);
const campanile = new THREE.Group();
campanile.position.set(-14, 5.16, -21);
scene.add(campanile);
for (let i = 0; i < 13; i++) {
box(
campanile,
2.1,
0.72,
2.1,
i % 2 === 0 ? M.cream : M.stoneDark,
0,
0.36 + i * 0.72,
0
);
}
box(campanile, 2.5, 0.3, 2.5, M.stoneDark, 0, 9.5, 0);
// ---------------------------------------------------------------------
// Trees, lamps and blocky clouds
// ---------------------------------------------------------------------
function createCypress(x, z) {
box(scene, 0.35, 1.45, 0.35, M.wood, x, 5.85, z);
box(scene, 1.25, 1.4, 1.25, M.leaf, x, 7.2, z);
box(scene, 1.0, 1.25, 1.0, M.leafLight, x, 8.25, z);
box(scene, 0.7, 1.05, 0.7, M.leaf, x, 9.2, z);
box(scene, 0.32, 0.65, 0.32, M.leafLight, x, 9.95, z);
}
[
[-5.7, -12.0],
[5.8, -12.1],
[-8.8, 12.2],
[7.0, 12.4],
[17.0, -11.5]
].forEach(([x, z]) => createCypress(x, z));
function createLamp(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 5.16, z);
group.rotation.y = rotation;
scene.add(group);
box(group, 0.16, 2.9, 0.16, M.iron, 0, 1.45, 0);
box(group, 0.55, 0.62, 0.55, M.gold, 0, 2.95, 0);
box(group, 0.72, 0.12, 0.72, M.iron, 0, 3.3, 0);
}
createLamp(-4.3, -10.7);
createLamp(4.3, 10.7);
createLamp(-4.3, 10.7);
createLamp(4.3, -10.7);
const cloudMaterial = new THREE.MeshBasicMaterial({
color: 0xf6f0df,
transparent: true,
opacity: 0.78,
depthWrite: false
});
[
[-15, 16, -25, 1.2],
[3, 18, -31, 1.5],
[17, 15, -20, 0.9],
[-6, 20, 17, 1.25]
].forEach(([x, y, z, scale]) => {
box(scene, 4.2 * scale, 1.0 * scale, 1.8 * scale, cloudMaterial, x, y, z, false);
box(scene, 2.5 * scale, 1.7 * scale, 1.8 * scale, cloudMaterial, x - 0.8 * scale, y + 0.3 * scale, z, false);
box(scene, 2.0 * scale, 1.3 * scale, 1.8 * scale, cloudMaterial, x + 1.5 * scale, y + 0.15 * scale, z, false);
});
// ---------------------------------------------------------------------
// Custom camera controls — no Three.js examples/addons
// ---------------------------------------------------------------------
const overviewTarget = new THREE.Vector3(0, 3.8, 0);
const orbit = new THREE.Spherical(31, 1.04, 0.74);
camera.position.setFromSpherical(orbit).add(overviewTarget);
camera.lookAt(overviewTarget);
const currentTarget = overviewTarget.clone();
let cameraTween = null;
let mode = "orbit";
let walkZ = 13;
let walkYaw = 0;
let walkPitch = -0.035;
let walkPlaying = false;
let walkGlanceApplied = false;
const overviewButton = document.getElementById("overviewButton");
const walkButton = document.getElementById("walkButton");
const riverButton = document.getElementById("riverButton");
function setActiveButton(button) {
[overviewButton, walkButton, riverButton].forEach((item) => {
item.classList.toggle("active", item === button);
});
}
function flyTo(position, target, duration = 1.1) {
cameraTween = {
fromPosition: camera.position.clone(),
fromTarget: currentTarget.clone(),
toPosition: position.clone(),
toTarget: target.clone(),
elapsed: 0,
duration
};
}
function sphericalPosition(radius, phi, theta, target) {
return new THREE.Vector3().setFromSpherical(
new THREE.Spherical(radius, phi, theta)
).add(target);
}
function showOverview() {
mode = "orbit";
walkPlaying = false;
setActiveButton(overviewButton);
const target = overviewTarget.clone();
const position = sphericalPosition(31, 1.04, 0.74, target);
flyTo(position, target);
}
function showRiver() {
mode = "orbit";
walkPlaying = false;
setActiveButton(riverButton);
const target = new THREE.Vector3(0, 2.4, 0);
const position = sphericalPosition(24, 1.18, 1.03, target);
flyTo(position, target);
}
function startWalk() {
setActiveButton(walkButton);
walkZ = 13;
walkYaw = 0;
walkPitch = -0.035;
walkGlanceApplied = false;
const position = new THREE.Vector3(0, 6.72, walkZ);
const target = new THREE.Vector3(0, 6.42, walkZ - 8);
flyTo(position, target, 1.0);
walkPlaying = true;
}
overviewButton.addEventListener("click", showOverview);
riverButton.addEventListener("click", showRiver);
walkButton.addEventListener("click", () => {
if (mode === "walk" && walkZ > -11) {
walkPlaying = !walkPlaying;
walkButton.textContent = walkPlaying ? "Pause passage" : "Resume passage";
} else {
walkButton.textContent = "Pause passage";
startWalk();
}
});
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || cameraTween) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
if (mode === "walk") {
walkYaw -= dx * 0.0035;
walkPitch = THREE.MathUtils.clamp(walkPitch - dy * 0.003, -0.7, 0.45);
walkGlanceApplied = true;
} else {
const offset = camera.position.clone().sub(currentTarget);
orbit.setFromVector3(offset);
orbit.theta -= dx * 0.005;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - dy * 0.005, 0.35, 1.48);
camera.position.setFromSpherical(orbit).add(currentTarget);
camera.lookAt(currentTarget);
}
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {}
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
if (mode !== "orbit" || cameraTween) return;
const offset = camera.position.clone().sub(currentTarget);
orbit.setFromVector3(offset);
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
8,
58
);
camera.position.setFromSpherical(orbit).add(currentTarget);
camera.lookAt(currentTarget);
},
{ passive: false }
);
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
// Water pixels drift downstream.
for (const wave of waves) {
wave.position.x += wave.userData.speed * delta;
if (wave.position.x > 21) wave.position.x = -21;
}
if (cameraTween) {
cameraTween.elapsed += delta;
const t = Math.min(cameraTween.elapsed / cameraTween.duration, 1);
const eased = 1 - Math.pow(1 - t, 3);
camera.position.lerpVectors(
cameraTween.fromPosition,
cameraTween.toPosition,
eased
);
currentTarget.lerpVectors(
cameraTween.fromTarget,
cameraTween.toTarget,
eased
);
camera.lookAt(currentTarget);
if (t >= 1) {
cameraTween = null;
if (mode === "orbit") {
const offset = camera.position.clone().sub(currentTarget);
orbit.setFromVector3(offset);
}
}
} else if (mode === "walk") {
if (walkPlaying) {
walkZ -= delta * 1.65;
if (walkZ < -12.5) {
walkZ = -12.5;
walkPlaying = false;
walkButton.textContent = "Replay passage";
}
}
// A brief glance toward the viewing bay reveals the Arno.
if (!walkGlanceApplied && walkPlaying) {
const glance = Math.exp(-Math.pow(walkZ - 8.8, 2) / 5.5);
walkYaw = glance * 0.26;
}
const bob = walkPlaying ? Math.sin(elapsed * 7.5) * 0.018 : 0;
camera.position.set(0, 6.72 + bob, walkZ);
const direction = new THREE.Vector3(
Math.sin(walkYaw) * Math.cos(walkPitch),
Math.sin(walkPitch),
-Math.cos(walkYaw) * Math.cos(walkPitch)
);
currentTarget.copy(camera.position).addScaledVector(direction, 8);
camera.lookAt(currentTarget);
}
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
loading.classList.add("hidden");
animate();
</script>
</body>
</html>
```