Prompt specification
Build or customize the Three.js 3D scene "Cannaregio: pedestrian and boat to the Misericordia" 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: Cannaregio: pedestrian and boat to the Misericordia
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/cannaregio-pedestrian-and-boat-to-the-misericordia-x2876
Scene Description Prompt:
Create one standalone voxel Three.js scene of a documented Cannaregio landmark and a schematic two-route comparison. Use the Scuola Grande della Misericordia at the end of Fondamenta della Misericordia, documented by La Biennale (https://www.labiennale.org/en/noticeboard/438) and the Venetian visitor authority (https://www.veneziaunica.it/en/things-to-do-in-venice/itineraries/cannaregio-authenticity-and-traditions). Show a recognizable brick institutional facade and an adjacent canal. Draw a continuous pedestrian path using a footbridge and a separate continuous canal-only boat journey, both to two schematic entrances of the same building. Label the model routes, graph and landing as fictional training aids, not actual public access. Keep all other named geography out of the model. Show both arrivals and verify every graph endpoint.
Return one complete HTML document. Use procedural geometry and the cdnjs Three.js r160 module; runtime network requests, native form submissions and pointer lock are unavailable in the gallery.
Working Three.js Starter (cannaregio-pedestrian-and-boat-to-the-misericordia-x2876):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="description" content="A procedural voxel Three.js study of the Scuola Grande della Misericordia with a fictional pedestrian and canal-only route comparison.">
<title>Scuola Grande della Misericordia — Fictional Two-Route Voxel Study</title>
<style>
:root {
--ink: #17313a;
--ink-2: #294751;
--paper: #f7f3e9;
--paper-2: #ece5d6;
--ped: #f1a84d;
--boat: #52d6d8;
--ok: #8be3a7;
--warn: #ffcf80;
--line: rgba(255,255,255,.14);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cad8d2;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, a { -webkit-tap-highlight-color: transparent; }
#sceneCanvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
cursor: grab;
}
#sceneCanvas:active { cursor: grabbing; }
.glass {
background: rgba(19, 44, 52, .91);
color: #f7f4eb;
border: 1px solid rgba(255,255,255,.13);
box-shadow: 0 18px 52px rgba(13, 33, 39, .19);
backdrop-filter: blur(14px) saturate(115%);
-webkit-backdrop-filter: blur(14px) saturate(115%);
}
.title-card {
position: fixed;
top: 20px;
left: 20px;
width: min(520px, calc(100vw - 430px));
padding: 20px 22px 18px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
display: block;
margin-bottom: 8px;
color: #a9c8c7;
font-size: 10px;
font-weight: 800;
letter-spacing: .18em;
text-transform: uppercase;
}
h1 {
margin: 0;
max-width: 480px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 43px);
font-weight: 500;
line-height: .98;
letter-spacing: -.035em;
}
.location {
margin: 11px 0 0;
color: #d9e6e1;
font-size: 13px;
line-height: 1.45;
}
.model-warning {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 14px;
padding: 8px 10px;
border: 1px solid rgba(255,207,128,.35);
border-radius: 9px;
background: rgba(255,207,128,.08);
color: var(--warn);
font-size: 10px;
font-weight: 800;
letter-spacing: .07em;
line-height: 1.35;
text-transform: uppercase;
}
.model-warning::before {
content: "!";
display: grid;
width: 17px;
height: 17px;
place-items: center;
flex: 0 0 auto;
border-radius: 50%;
background: var(--warn);
color: #49351e;
font-size: 11px;
}
.panel {
position: fixed;
top: 20px;
right: 20px;
bottom: 20px;
width: 382px;
overflow: auto;
padding: 19px;
border-radius: 18px;
scrollbar-width: thin;
scrollbar-color: #638087 transparent;
}
.panel h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 25px;
font-weight: 500;
line-height: 1.05;
letter-spacing: -.02em;
}
.panel-intro {
margin: 9px 0 15px;
color: #bdd0d0;
font-size: 11.5px;
line-height: 1.5;
}
.route-card {
position: relative;
margin-top: 9px;
overflow: hidden;
padding: 12px 13px 11px 15px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255,255,255,.045);
}
.route-card::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 4px;
background: var(--route-color);
}
.route-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
}
.route-name {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
font-weight: 800;
}
.route-dot {
width: 9px;
height: 9px;
flex: 0 0 auto;
border-radius: 2px;
background: var(--route-color);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--route-color) 18%, transparent);
}
.route-status {
padding: 4px 6px;
border: 1px solid rgba(139,227,167,.3);
border-radius: 5px;
background: rgba(139,227,167,.09);
color: var(--ok);
font-size: 8px;
font-weight: 900;
letter-spacing: .08em;
white-space: nowrap;
}
.route-stats {
margin-top: 7px;
color: #bed0d1;
font-size: 10px;
line-height: 1.45;
}
.route-endpoint {
margin-top: 4px;
color: #f6f1e6;
font-size: 10.5px;
font-weight: 700;
}
.section-title {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin: 18px 0 8px;
color: #f8f4e9;
font-size: 11px;
font-weight: 900;
letter-spacing: .1em;
text-transform: uppercase;
}
.section-title small {
color: #9fb9ba;
font-size: 8px;
font-weight: 700;
letter-spacing: .04em;
text-transform: none;
}
.graph-card {
padding: 9px 9px 6px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(5,22,28,.28);
}
.graph-label {
margin: 0 2px 3px;
color: #a9c0c1;
font-size: 8.5px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
}
.graph-card svg {
display: block;
width: 100%;
height: auto;
overflow: visible;
}
.graph-edge {
fill: none;
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
opacity: .82;
}
.graph-node {
stroke: var(--ok);
stroke-width: 2.5;
}
.graph-text {
fill: #dbe8e5;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
font-weight: 700;
text-anchor: middle;
}
.graph-end-label {
fill: #9fb7b8;
font-family: ui-sans-serif, system-ui, sans-serif;
font-size: 7px;
font-weight: 700;
text-anchor: middle;
}
.audit-summary {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-bottom: 8px;
}
.audit-stat {
padding: 8px 9px;
border: 1px solid rgba(139,227,167,.2);
border-radius: 9px;
background: rgba(139,227,167,.06);
}
.audit-stat strong {
display: block;
color: var(--ok);
font-size: 13px;
line-height: 1.1;
}
.audit-stat span {
display: block;
margin-top: 3px;
color: #a9c0c1;
font-size: 8px;
font-weight: 700;
line-height: 1.3;
}
.audit-list {
overflow: hidden;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(0,0,0,.1);
}
.audit-line {
display: grid;
grid-template-columns: 18px 67px 1fr;
align-items: center;
min-height: 23px;
padding: 3px 8px;
border-bottom: 1px solid rgba(255,255,255,.07);
color: #bed0d0;
font-size: 8.5px;
}
.audit-line:last-child { border-bottom: 0; }
.audit-line.binding {
grid-template-columns: 18px 1fr;
background: rgba(139,227,167,.045);
}
.audit-check {
color: var(--ok);
font-size: 11px;
font-weight: 900;
}
.audit-code {
color: #eef4ef;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-weight: 800;
}
.audit-detail {
overflow: hidden;
color: #95b0b1;
text-overflow: ellipsis;
white-space: nowrap;
}
.controls-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 15px;
}
.button {
min-height: 34px;
border: 1px solid rgba(255,255,255,.15);
border-radius: 9px;
background: rgba(255,255,255,.075);
color: #f7f3e9;
cursor: pointer;
font: inherit;
font-size: 9.5px;
font-weight: 800;
letter-spacing: .03em;
transition: background .15s ease, transform .15s ease;
}
.button:hover { background: rgba(255,255,255,.13); }
.button:active { transform: translateY(1px); }
.button[aria-pressed="true"] {
border-color: rgba(139,227,167,.35);
background: rgba(139,227,167,.1);
color: var(--ok);
}
.docs {
margin-top: 15px;
padding-top: 13px;
border-top: 1px solid var(--line);
}
.docs p {
margin: 0 0 8px;
color: #a9bfc0;
font-size: 9.5px;
line-height: 1.55;
}
.source-links {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.source-links a {
display: inline-block;
padding: 6px 8px;
border: 1px solid rgba(255,255,255,.13);
border-radius: 7px;
color: #e8f0ea;
font-size: 8.5px;
font-weight: 800;
text-decoration: none;
}
.source-links a:hover {
border-color: rgba(139,227,167,.4);
background: rgba(139,227,167,.07);
}
.footer-hint {
position: fixed;
left: 20px;
bottom: 20px;
display: flex;
align-items: center;
gap: 12px;
max-width: calc(100vw - 440px);
padding: 10px 13px;
border-radius: 12px;
color: #dbe8e4;
font-size: 9.5px;
line-height: 1.4;
pointer-events: none;
}
.legend {
display: flex;
flex: 0 0 auto;
gap: 10px;
}
.legend-item {
display: flex;
align-items: center;
gap: 5px;
white-space: nowrap;
}
.legend-swatch {
width: 16px;
height: 4px;
border-radius: 3px;
background: var(--c);
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #d3dfda;
color: var(--ink);
font-size: 13px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
transition: opacity .35s ease;
}
.loading.gone {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
max-width: 510px;
padding: 15px 17px;
}
h1 { font-size: 29px; }
.location { font-size: 11px; }
.model-warning { margin-top: 10px; font-size: 8.5px; }
.panel {
top: auto;
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
height: 43vh;
min-height: 300px;
padding: 15px;
border-radius: 15px;
}
.footer-hint {
top: 178px;
bottom: auto;
left: 12px;
max-width: calc(100vw - 24px);
padding: 7px 9px;
font-size: 8px;
}
}
@media (max-width: 520px) {
.title-card { width: calc(100vw - 24px); }
.eyebrow { font-size: 8px; }
h1 { font-size: 25px; }
.location { margin-top: 7px; }
.model-warning { padding: 6px 8px; }
.footer-hint { top: 166px; }
.legend { display: none; }
}
</style>
</head>
<body>
<canvas id="sceneCanvas" tabindex="0" aria-label="Interactive voxel model of the Scuola Grande della Misericordia with fictional pedestrian and canal-only routes"></canvas>
<header class="title-card glass">
<span class="eyebrow">Documented Cannaregio landmark · procedural voxel study</span>
<h1>Scuola Grande della Misericordia</h1>
<p class="location">At the end of Fondamenta della Misericordia, beside an adjacent canal.</p>
<div class="model-warning">Routes, graph and landing are fictional training aids — not actual public access.</div>
</header>
<aside class="panel glass" aria-label="Schematic route comparison and graph verification">
<span class="eyebrow">Schematic two-route comparison</span>
<h2>Two routes, one landmark</h2>
<p class="panel-intro">A pedestrian model route uses a footbridge and reaches Entrance A. A separate canal-only boat route reaches Entrance B. Both are fictional training aids, not navigation or access instructions.</p>
<article class="route-card" style="--route-color: var(--ped)">
<div class="route-top">
<div class="route-name"><span class="route-dot"></span>Pedestrian model route</div>
<span class="route-status" id="pedStatus">VERIFYING</span>
</div>
<div class="route-stats" id="pedStats"></div>
<div class="route-endpoint">Endpoint: Entrance A · building-side quay</div>
</article>
<article class="route-card" style="--route-color: var(--boat)">
<div class="route-top">
<div class="route-name"><span class="route-dot"></span>Canal-only boat model route</div>
<span class="route-status" id="boatStatus">VERIFYING</span>
</div>
<div class="route-stats" id="boatStats"></div>
<div class="route-endpoint">Endpoint: Entrance B · fictional model landing edge</div>
</article>
<div class="section-title">
<span>Schematic graph</span>
<small>fictional training aid · not public access</small>
</div>
<div class="graph-card">
<p class="graph-label">Pedestrian graph · footbridge leg P2 → P3</p>
<svg id="pedGraph" viewBox="0 0 320 82" role="img" aria-label="Verified pedestrian route graph"></svg>
<p class="graph-label">Canal-only graph · all legs remain canal-side</p>
<svg id="boatGraph" viewBox="0 0 320 82" role="img" aria-label="Verified canal-only route graph"></svg>
</div>
<div class="section-title">
<span>Endpoint verification</span>
<small id="auditCount">checking every reference</small>
</div>
<div class="audit-summary">
<div class="audit-stat">
<strong id="endpointStat">—</strong>
<span>graph edge endpoint references resolved</span>
</div>
<div class="audit-stat">
<strong id="arrivalStat">—</strong>
<span>arrivals mapped and simultaneously visible</span>
</div>
</div>
<div class="audit-list" id="auditList" aria-live="polite"></div>
<div class="controls-row">
<button class="button" id="showArrivals" type="button" aria-pressed="false">Show both arrivals</button>
<button class="button" id="replayRoutes" type="button">Replay both routes</button>
</div>
<section class="docs">
<p>The brick institutional massing, lower arcade, upper arched windows and pale stone bands are a stylized procedural interpretation for training, not a surveyed reconstruction. No live map, routing service or access status is used.</p>
<div class="source-links">
<a href="https://www.labiennale.org/en/noticeboard/438" target="_blank" rel="noopener noreferrer">La Biennale notice</a>
<a href="https://www.veneziaunica.it/en/things-to-do-in-venice/itineraries/cannaregio-authenticity-and-traditions" target="_blank" rel="noopener noreferrer">Venezia Unica itinerary</a>
</div>
</section>
</aside>
<div class="footer-hint glass">
<div class="legend">
<span class="legend-item"><span class="legend-swatch" style="--c: var(--ped)"></span>Pedestrian</span>
<span class="legend-item"><span class="legend-swatch" style="--c: var(--boat)"></span>Canal-only</span>
</div>
<span>Drag to orbit · wheel or pinch to zoom · arrow keys to orbit · double-click to reset · no pointer lock</span>
</div>
<div class="loading" id="loading">Loading voxel study…</div>
<script type="module">
const THREE_URL = "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
let THREE;
try {
THREE = await import(THREE_URL);
} catch (error) {
document.getElementById("loading").textContent = "The Three.js core module could not be loaded.";
throw error;
}
const canvas = document.getElementById("sceneCanvas");
const loading = document.getElementById("loading");
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "WebGL is unavailable in this gallery.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.8));
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(0xcbd9d3);
scene.fog = new THREE.Fog(0xcbd9d3, 58, 105);
const camera = new THREE.OrthographicCamera(-25, 25, 16, -16, 0.1, 180);
const cameraTarget = new THREE.Vector3(0, 2.1, 4.0);
let cameraTheta = 0.59;
let cameraPhi = 0.94;
let cameraRadius = 43;
let viewHeight = 31;
let cameraDirty = true;
const hemi = new THREE.HemisphereLight(0xfff3d7, 0x52616a, 1.7);
scene.add(hemi);
const ambient = new THREE.AmbientLight(0xffffff, 0.3);
scene.add(ambient);
const sun = new THREE.DirectionalLight(0xffe8c1, 3.1);
sun.position.set(-13, 24, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -28;
sun.shadow.camera.right = 28;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9ed7db, 0.75);
fill.position.set(18, 9, -12);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const palette = {
brick: 0xa84d39,
brickDark: 0x76372f,
brickLight: 0xc2694d,
stone: 0xded0b4,
stoneLight: 0xf0e5ca,
stoneDark: 0xbba98d,
roof: 0x854a39,
wood: 0x78583d,
woodLight: 0x9b744e,
dark: 0x253a3e,
glass: 0x31545a,
water: 0x4f9ca0,
cobble: 0xb9ae98,
amber: 0xf1a84d,
cyan: 0x52d6d8,
green: 0x8be3a7
};
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.82,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
side: options.side ?? THREE.FrontSide
});
}
const mats = {
brick: material(palette.brick, { roughness: 0.92 }),
brickDark: material(palette.brickDark, { roughness: 0.95 }),
stone: material(palette.stone, { roughness: 0.88 }),
stoneLight: material(palette.stoneLight, { roughness: 0.86 }),
stoneDark: material(palette.stoneDark, { roughness: 0.9 }),
roof: material(palette.roof, { roughness: 0.93 }),
wood: material(palette.wood, { roughness: 0.92 }),
woodLight: material(palette.woodLight, { roughness: 0.88 }),
dark: material(palette.dark, { roughness: 0.78 }),
glass: material(palette.glass, { roughness: 0.3, metalness: 0.08 }),
cobble: material(palette.cobble, { roughness: 0.97 }),
amber: material(palette.amber, { roughness: 0.5, emissive: 0x7d3510, emissiveIntensity: 0.38 }),
cyan: material(palette.cyan, { roughness: 0.42, emissive: 0x0a6468, emissiveIntensity: 0.45 }),
green: material(palette.green, { roughness: 0.45, emissive: 0x1b6333, emissiveIntensity: 0.6 })
};
function box(parent, width, height, depth, mat, x = 0, y = 0, z = 0, cast = true) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function segment(parent, a, b, width, height, mat, cast = true) {
const direction = b.clone().sub(a);
const length = direction.length();
const mesh = box(parent, width, height, length, mat, 0, 0, 0, cast);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(new THREE.Vector3(0, 0, 1), direction.normalize());
return mesh;
}
let randomSeed = 82471;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
const groundPlane = new THREE.Mesh(
new THREE.PlaneGeometry(180, 180),
material(0xb8c8c1, { roughness: 1 })
);
groundPlane.rotation.x = -Math.PI / 2;
groundPlane.position.y = -0.72;
groundPlane.receiveShadow = true;
scene.add(groundPlane);
box(scene, 43, 0.42, 27.5, material(0x71807c), 0, -0.45, 4.4);
const northBank = box(scene, 42, 0.6, 9.3, material(0xb9ad96), 0, 0, -3.45);
northBank.receiveShadow = true;
const southBank = box(scene, 42, 0.6, 4.2, material(0xb9ad96), 0, 0, 15.4);
southBank.receiveShadow = true;
box(scene, 42, 0.28, 12.1, material(0x244f53), 0, -0.18, 7.3);
const waterMat = material(palette.water, {
roughness: 0.3,
metalness: 0.08,
transparent: true,
opacity: 0.9
});
const water = box(scene, 42, 0.12, 12.05, waterMat, 0, 0.03, 7.3, false);
water.receiveShadow = true;
for (const [x, width] of [[-16, 10], [6, 30]]) {
box(scene, width, 0.42, 0.28, mats.stoneDark, x, 0.03, 1.27, false);
box(scene, width, 0.42, 0.28, mats.stoneDark, x, 0.03, 13.33, false);
}
const cobbleGeometry = new THREE.BoxGeometry(0.9, 0.035, 0.9);
const cobbles = new THREE.InstancedMesh(cobbleGeometry, material(0xffffff, { roughness: 1 }), 520);
const dummy = new THREE.Object3D();
let cobbleIndex = 0;
for (let x = -20; x <= 20; x += 1.12) {
for (let z = -7.2; z <= 0.72; z += 1.05) {
dummy.position.set(x + (random() - 0.5) * 0.12, 0.315, z + (random() - 0.5) * 0.1);
dummy.rotation.y = (random() - 0.5) * 0.08;
dummy.scale.set(0.9 + random() * 0.08, 1, 0.9 + random() * 0.08);
dummy.updateMatrix();
cobbles.setMatrixAt(cobbleIndex, dummy.matrix);
cobbles.setColorAt(cobbleIndex, new THREE.Color().setHSL(0.1, 0.12, 0.57 + random() * 0.13));
cobbleIndex++;
}
}
for (let x = -20; x <= 20; x += 1.12) {
for (let z = 13.8; z <= 17.0; z += 1.05) {
dummy.position.set(x + (random() - 0.5) * 0.12, 0.315, z + (random() - 0.5) * 0.1);
dummy.rotation.y = (random() - 0.5) * 0.08;
dummy.scale.set(0.9 + random() * 0.08, 1, 0.9 + random() * 0.08);
dummy.updateMatrix();
cobbles.setMatrixAt(cobbleIndex, dummy.matrix);
cobbles.setColorAt(cobbleIndex, new THREE.Color().setHSL(0.1, 0.12, 0.56 + random() * 0.13));
cobbleIndex++;
}
}
cobbles.count = cobbleIndex;
cobbles.receiveShadow = true;
cobbles.instanceMatrix.needsUpdate = true;
if (cobbles.instanceColor) cobbles.instanceColor.needsUpdate = true;
scene.add(cobbles);
function addVoxelArch(cx, base, width, height, frameMat, fillMat, z, inset = 0.18) {
const radius = width / 2;
const spring = base + height * 0.58;
box(scene, width - inset * 2, spring - base, 0.12, fillMat, cx, (base + spring) / 2, z, false);
const halfCircle = new THREE.Mesh(
new THREE.CircleGeometry(radius - inset, 28, 0, Math.PI),
fillMat
);
halfCircle.position.set(cx, spring, z);
scene.add(halfCircle);
box(scene, 0.28, spring - base + 0.12, 0.25, frameMat, cx - radius + 0.02, (base + spring) / 2, z + 0.03);
box(scene, 0.28, spring - base + 0.12, 0.25, frameMat, cx + radius - 0.02, (base + spring) / 2, z + 0.03);
box(scene, width + 0.28, 0.2, 0.28, frameMat, cx, base + 0.02, z + 0.04);
const arcBlockGeometry = new THREE.BoxGeometry(0.34, 0.24, 0.28);
for (let i = 0; i < 13; i++) {
const theta = (i / 12) * Math.PI;
const block = new THREE.Mesh(arcBlockGeometry, frameMat);
block.position.set(
cx + Math.cos(theta) * (radius - 0.07),
spring + Math.sin(theta) * (radius - 0.07),
z + 0.055
);
block.rotation.z = theta + Math.PI / 2;
block.castShadow = true;
block.receiveShadow = true;
scene.add(block);
}
}
const building = new THREE.Group();
scene.add(building);
box(building, 15.4, 0.44, 6.35, mats.stoneDark, 0, 0.52, -3);
box(building, 15, 7.22, 6, mats.brick, 0, 4.0, -3);
box(building, 15.55, 0.25, 6.45, mats.stone, 0, 3.66, -2.98);
box(building, 15.7, 0.3, 6.55, mats.stoneLight, 0, 7.55, -3);
box(building, 15.45, 0.56, 6.45, mats.roof, 0, 7.92, -3.03);
for (let i = 0; i < 4; i++) {
box(building, 4.4 - i * 0.82, 0.23, 0.52, mats.stone, 0, 7.72 + i * 0.23, 0.24);
}
const frontBrickGeometry = new THREE.BoxGeometry(0.68, 0.38, 0.08);
const frontBricks = new THREE.InstancedMesh(frontBrickGeometry, material(0xffffff, { roughness: 0.94 }), 400);
let brickIndex = 0;
for (let row = 0; row < 16; row++) {
const y = 0.67 + row * 0.43;
for (let col = 0; col < 22; col++) {
const x = -7.14 + col * 0.72 + (row % 2 ? 0.36 : 0);
if (x > 7.12 || y > 7.3) continue;
dummy.position.set(x, y, 0.045);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
frontBricks.setMatrixAt(brickIndex, dummy.matrix);
frontBricks.setColorAt(
brickIndex,
new THREE.Color().setHSL(0.025 + random() * 0.018, 0.42 + random() * 0.16, 0.34 + random() * 0.13)
);
brickIndex++;
}
}
frontBricks.count = brickIndex;
frontBricks.receiveShadow = true;
frontBricks.instanceMatrix.needsUpdate = true;
if (frontBricks.instanceColor) frontBricks.instanceColor.needsUpdate = true;
building.add(frontBricks);
const sideBrickGeometry = new THREE.BoxGeometry(0.08, 0.38, 0.68);
const sideBricks = new THREE.InstancedMesh(sideBrickGeometry, material(0xffffff, { roughness: 0.94 }), 240);
brickIndex = 0;
for (let row = 0; row < 16; row++) {
const y = 0.67 + row * 0.43;
for (let col = 0; col < 9; col++) {
const z = -5.67 + col * 0.72 + (row % 2 ? 0.36 : 0);
if (z > -0.04 || y > 7.3) continue;
dummy.position.set(7.54, y, z);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
sideBricks.setMatrixAt(brickIndex, dummy.matrix);
sideBricks.setColorAt(
brickIndex,
new THREE.Color().setHSL(0.025 + random() * 0.018, 0.42 + random() * 0.16, 0.33 + random() * 0.13)
);
brickIndex++;
}
}
sideBricks.count = brickIndex;
sideBricks.receiveShadow = true;
sideBricks.instanceMatrix.needsUpdate = true;
if (sideBricks.instanceColor) sideBricks.instanceColor.needsUpdate = true;
building.add(sideBricks);
const arcadeCenters = [-6, -4, -2, 0, 2, 4, 6];
arcadeCenters.forEach((x) => addVoxelArch(x, 0.65, 1.62, 2.95, mats.stone, mats.dark, 0.17));
for (const x of [-7.12, -5, -3, -1, 1, 3, 5, 7.12]) {
box(building, 0.26, 3.15, 0.34, mats.stoneLight, x, 2.13, 0.17);
}
addVoxelArch(-4.2, 4.02, 2.35, 2.62, mats.stoneLight, mats.glass, 0.17, 0.2);
addVoxelArch(0, 4.02, 2.35, 2.62, mats.stoneLight, mats.glass, 0.17, 0.2);
addVoxelArch(4.2, 4.02, 2.35, 2.62, mats.stoneLight, mats.glass, 0.17, 0.2);
box(building, 0.78, 0.78, 0.2, mats.stoneLight, 0, 7.03, 0.18);
box(building, 0.42, 0.42, 0.22, mats.brickDark, 0, 7.03, 0.3);
for (const z of [-5.0, -3.0, -1.0]) {
box(building, 0.1, 1.42, 0.72, mats.dark, 7.61, 5.08, z);
box(building, 0.15, 0.14, 0.92, mats.stone, 7.65, 5.88, z);
box(building, 0.15, 0.14, 0.92, mats.stone, 7.65, 4.28, z);
}
const doorA = material(0xb96d35, { roughness: 0.7, emissive: 0x4a1d08, emissiveIntensity: 0.16 });
const doorB = material(0x2d7d7f, { roughness: 0.58, emissive: 0x073c3e, emissiveIntensity: 0.24 });
box(building, 1.08, 2.08, 0.12, doorA, -2, 1.42, 0.25);
box(building, 0.08, 2.1, 0.15, mats.stoneLight, -2.58, 1.45, 0.29);
box(building, 0.08, 2.1, 0.15, mats.stoneLight, -1.42, 1.45, 0.29);
box(building, 1.22, 0.11, 0.16, mats.stoneLight, -2, 2.49, 0.29);
box(building, 1.08, 2.08, 0.12, doorB, 4, 1.42, 0.25);
box(building, 0.08, 2.1, 0.15, mats.stoneLight, 3.42, 1.45, 0.29);
box(building, 0.08, 2.1, 0.15, mats.stoneLight, 4.58, 1.45, 0.29);
box(building, 1.22, 0.11, 0.16, mats.stoneLight, 4, 2.49, 0.29);
box(scene, 2.25, 0.3, 1.75, mats.stoneDark, 4, 0.22, 0.95);
box(scene, 2.0, 0.12, 1.5, mats.stone, 4, 0.4, 0.96);
box(scene, 0.18, 0.7, 0.18, mats.wood, 2.9, 0.72, 1.45);
box(scene, 0.18, 0.7, 0.18, mats.wood, 5.1, 0.72, 1.45);
function addLamp(x, z) {
box(scene, 0.44, 0.16, 0.44, mats.stoneDark, x, 0.4, z);
box(scene, 0.13, 2.15, 0.13, mats.wood, x, 1.52, z);
box(scene, 0.43, 0.13, 0.43, mats.wood, x, 2.62, z);
const lampMat = material(0xffd990, { roughness: 0.4, emissive: 0x9e6021, emissiveIntensity: 0.7 });
box(scene, 0.3, 0.4, 0.3, lampMat, x, 2.9, z);
box(scene, 0.48, 0.12, 0.48, mats.wood, x, 3.16, z);
}
addLamp(-16.2, 14.7);
addLamp(12.7, 0.72);
addLamp(-16.6, 0.72);
for (let x = -18; x <= 18; x += 4.2) {
if (Math.abs(x + 10) < 1.2) continue;
box(scene, 0.18, 0.52, 0.18, mats.wood, x, 0.55, 13.03);
}
const P = {
P0: new THREE.Vector3(-16, 0.42, 15.2),
P1: new THREE.Vector3(-10, 0.42, 15.2),
P2: new THREE.Vector3(-10, 0.48, 12.9),
P3: new THREE.Vector3(-10, 0.48, 1.45),
P4: new THREE.Vector3(-10, 0.42, 0.75),
P5: new THREE.Vector3(-4, 0.42, 0.75),
P6: new THREE.Vector3(-2, 0.42, 0.48)
};
const B = {
B0: new THREE.Vector3(16, 0.18, 10.7),
B1: new THREE.Vector3(12, 0.18, 8.6),
B2: new THREE.Vector3(8, 0.18, 5.5),
B3: new THREE.Vector3(5, 0.18, 2.8),
B4: new THREE.Vector3(4, 0.18, 1.55)
};
const bridgeCurve = [];
for (let i = 0; i <= 12; i++) {
const t = i / 12;
const point = P.P2.clone().lerp(P.P3, t);
point.y = 0.48 + Math.sin(Math.PI * t) * 0.67;
bridgeCurve.push(point);
}
const pedPhysical = [P.P0, P.P1, ...bridgeCurve, P.P4, P.P5, P.P6];
const boatPhysical = [B.B0, B.B1, B.B2, B.B3, B.B4];
const graph = {
nodes: new Map([
["P0", { id: "P0", position: P.P0.clone(), label: "Quay start" }],
["P1", { id: "P1", position: P.P1.clone(), label: "Bridge approach" }],
["P2", { id: "P2", position: P.P2.clone(), label: "Footbridge south" }],
["P3", { id: "P3", position: P.P3.clone(), label: "Footbridge north" }],
["P4", { id: "P4", position: P.P4.clone(), label: "Building-side quay" }],
["P5", { id: "P5", position: P.P5.clone(), label: "Facade walk" }],
["P6", { id: "P6", position: P.P6.clone(), label: "Entrance A" }],
["B0", { id: "B0", position: B.B0.clone(), label: "Canal start" }],
["B1", { id: "B1", position: B.B1.clone(), label: "Canal bend" }],
["B2", { id: "B2", position: B.B2.clone(), label: "Canal approach" }],
["B3", { id: "B3", position: B.B3.clone(), label: "Landing approach" }],
["B4", { id: "B4", position: B.B4.clone(), label: "Entrance B" }]
]),
edges: [
{ id: "P0-P1", from: "P0", to: "P1", points: [P.P0, P.P1] },
{ id: "P1-P2", from: "P1", to: "P2", points: [P.P1, P.P2] },
{ id: "P2-P3", from: "P2", to: "P3", points: bridgeCurve },
{ id: "P3-P4", from: "P3", to: "P4", points: [P.P3, P.P4] },
{ id: "P4-P5", from: "P4", to: "P5", points: [P.P4, P.P5] },
{ id: "P5-P6", from: "P5", to: "P6", points: [P.P5, P.P6] },
{ id: "B0-B1", from: "B0", to: "B1", points: [B.B0, B.B1] },
{ id: "B1-B2", from: "B1", to: "B2", points: [B.B1, B.B2] },
{ id: "B2-B3", from: "B2", to: "B3", points: [B.B2, B.B3] },
{ id: "B3-B4", from: "B3", to: "B4", points: [B.B3, B.B4] }
],
routes: [
{
id: "pedestrian",
name: "Pedestrian",
start: "P0",
end: "P6",
nodeIds: ["P0", "P1", "P2", "P3", "P4", "P5", "P6"],
edgeIds: ["P0-P1", "P1-P2", "P2-P3", "P3-P4", "P4-P5", "P5-P6"],
physicalPath: pedPhysical,
color: palette.amber
},
{
id: "boat",
name: "Canal-only",
start: "B0",
end: "B4",
nodeIds: ["B0", "B1", "B2", "B3", "B4"],
edgeIds: ["B0-B1", "B1-B2", "B2-B3", "B3-B4"],
physicalPath: boatPhysical,
color: palette.cyan
}
]
};
function addBridge() {
for (let i = 0; i < bridgeCurve.length - 1; i++) {
const a = bridgeCurve[i].clone();
const b = bridgeCurve[i + 1].clone();
a.y -= 0.11;
b.y -= 0.11;
segment(scene, a, b, 1.5, 0.18, mats.woodLight);
for (const side of [-0.7, 0.7]) {
const pa = bridgeCurve[i].clone();
const pb = bridgeCurve[i + 1].clone();
pa.x += side;
pb.x += side;
pa.y += 0.93;
pb.y += 0.93;
segment(scene, pa, pb, 0.09, 0.09, mats.wood, false);
const post = bridgeCurve[i].clone();
post.x += side;
post.y += 0.53;
box(scene, 0.11, 0.92, 0.11, mats.wood, post.x, post.y, post.z);
}
}
for (const t of [0.28, 0.5, 0.72]) {
const i = Math.round(t * (bridgeCurve.length - 1));
const point = bridgeCurve[i];
box(scene, 0.22, 1.45, 0.22, mats.stoneDark, point.x, -0.05, point.z);
}
}
addBridge();
function addRibbon(points, color, width, thickness, opacity = 1) {
const routeMat = material(color, {
roughness: 0.45,
emissive: color,
emissiveIntensity: 0.32,
transparent: opacity < 1,
opacity
});
for (let i = 0; i < points.length - 1; i++) {
segment(scene, points[i], points[i + 1], width, thickness, routeMat, false);
}
return routeMat;
}
addRibbon(pedPhysical, palette.amber, 0.48, 0.07);
addRibbon(boatPhysical, palette.cyan, 0.34, 0.065);
for (const [id, node] of graph.nodes) {
const markerMat = id.startsWith("P") ? mats.amber : mats.cyan;
const isEnd = id === "P6" || id === "B4" || id === "P0" || id === "B0";
box(
scene,
isEnd ? 0.24 : 0.16,
isEnd ? 0.24 : 0.16,
isEnd ? 0.24 : 0.16,
markerMat,
node.position.x,
node.position.y + 0.11,
node.position.z,
false
);
}
const rippleMeshes = [];
const rippleMat = material(0xb9eeee, {
roughness: 0.28,
transparent: true,
opacity: 0.28,
emissive: 0x376d70,
emissiveIntensity: 0.15
});
for (let i = 0; i < 34; i++) {
const ripple = box(
scene,
0.7 + random() * 1.5,
0.025,
0.08,
rippleMat,
-20 + random() * 40,
0.115,
1.55 + random() * 11.5,
false
);
rippleMeshes.push({ mesh: ripple, speed: 0.16 + random() * 0.28 });
}
function roundedRectPath(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabel(title, subtitle, accent, worldWidth = 8) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 1024;
labelCanvas.height = 240;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 240);
roundedRectPath(ctx, 8, 8, 1008, 224, 24);
ctx.fillStyle = "rgba(15, 39, 46, 0.92)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 4;
ctx.stroke();
ctx.fillStyle = accent;
roundedRectPath(ctx, 24, 27, 13, 186, 6);
ctx.fill();
let titleSize = 48;
ctx.font = `800 ${titleSize}px system-ui, sans-serif`;
while (ctx.measureText(title).width > 920 && titleSize > 27) {
titleSize -= 1;
ctx.font = `800 ${titleSize}px system-ui, sans-serif`;
}
ctx.fillStyle = "#f8f5eb";
ctx.fillText(title, 60, 93);
let subtitleSize = 29;
ctx.font = `700 ${subtitleSize}px system-ui, sans-serif`;
while (ctx.measureText(subtitle).width > 920 && subtitleSize > 17) {
subtitleSize -= 1;
ctx.font = `700 ${subtitleSize}px system-ui, sans-serif`;
}
ctx.fillStyle = "#b9d0cf";
ctx.fillText(subtitle, 60, 154);
ctx.fillStyle = accent;
ctx.font = `800 19px system-ui, sans-serif`;
ctx.fillText("FICTIONAL TRAINING AID · NOT ACTUAL PUBLIC ACCESS", 60, 202);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
}));
sprite.scale.set(worldWidth, worldWidth * 240 / 1024, 1);
sprite.renderOrder = 50;
return sprite;
}
const landmarkLabel = makeLabel(
"SCUOLA GRANDE DELLA MISERICORDIA",
"PROCEDURAL BRICK FACADE · LANDMARK STUDY",
"#e8d3a9",
10.6
);
landmarkLabel.position.set(0, 9.85, -0.2);
scene.add(landmarkLabel);
const pedestrianLabel = makeLabel(
"PEDESTRIAN MODEL ROUTE",
"FOOTBRIDGE · TO ENTRANCE A",
"#f1a84d",
7.8
);
pedestrianLabel.position.set(-14.4, 2.8, 14.7);
scene.add(pedestrianLabel);
const boatLabel = makeLabel(
"CANAL-ONLY MODEL ROUTE",
"BOAT JOURNEY · TO ENTRANCE B",
"#52d6d8",
7.8
);
boatLabel.position.set(11.3, 2.65, 8.6);
scene.add(boatLabel);
const quayLabel = makeLabel(
"FONDAMENTA DELLA MISERICORDIA",
"DOCUMENTED SETTING · SCHEMATIC CONTEXT",
"#c5b89a",
8.0
);
quayLabel.position.set(-11.7, 1.65, -1.55);
scene.add(quayLabel);
const landingLabel = makeLabel(
"MODEL LANDING",
"ENTRANCE B APPROACH",
"#52d6d8",
7.3
);
landingLabel.position.set(9.4, 3.8, 2.2);
scene.add(landingLabel);
function makeBeacon(position, color, title, subtitle) {
const group = new THREE.Group();
group.position.copy(position);
const ring = new THREE.Group();
const ringMat = material(color, {
roughness: 0.4,
emissive: color,
emissiveIntensity: 0.9
});
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const piece = box(
ring,
0.24,
0.09,
0.12,
ringMat,
Math.cos(angle) * 0.52,
0.03,
Math.sin(angle) * 0.52,
false
);
piece.rotation.y = -angle;
}
group.add(ring);
const beamMat = material(color, {
roughness: 0.25,
emissive: color,
emissiveIntensity: 0.75,
transparent: true,
opacity: 0.34,
side: THREE.DoubleSide
});
const beam = new THREE.Mesh(new THREE.CylinderGeometry(0.06, 0.19, 1.9, 8), beamMat);
beam.position.y = 1.0;
beam.renderOrder = 4;
group.add(beam);
box(group, 0.26, 0.26, 0.26, ringMat, 0, 1.95, 0, false);
const label = makeLabel(title, subtitle, color, 6.1);
label.position.set(0, 2.65, 0);
group.add(label);
scene.add(group);
return { group, ring, beam, position: position.clone() };
}
const arrivalA = makeBeacon(
P.P6,
palette.amber,
"ARRIVAL A · PEDESTRIAN",
"FICTIONAL ENTRANCE ARRIVAL"
);
const arrivalB = makeBeacon(
B.B4,
palette.cyan,
"ARRIVAL B · CANAL-ONLY",
"FICTIONAL ENTRANCE ARRIVAL"
);
function pathLength(points) {
let total = 0;
for (let i = 0; i < points.length - 1; i++) total += points[i].distanceTo(points[i + 1]);
return total;
}
function samplePath(points, t) {
const lengths = [];
let total = 0;
for (let i = 0; i < points.length - 1; i++) {
const length = points[i].distanceTo(points[i + 1]);
lengths.push(length);
total += length;
}
const target = THREE.MathUtils.clamp(t, 0, 1) * total;
let traversed = 0;
for (let i = 0; i < lengths.length; i++) {
if (target <= traversed + lengths[i] || i === lengths.length - 1) {
const local = lengths[i] === 0 ? 0 : (target - traversed) / lengths[i];
const position = points[i].clone().lerp(points[i + 1], THREE.MathUtils.clamp(local, 0, 1));
const direction = points[i + 1].clone().sub(points[i]).normalize();
return { position, direction };
}
traversed += lengths[i];
}
return { position: points[points.length - 1].clone(), direction: new THREE.Vector3(0, 0, 1) };
}
function createWalker() {
const group = new THREE.Group();
const coat = material(palette.amber, { roughness: 0.65, emissive: 0x5b2b0c, emissiveIntensity: 0.2 });
const skin = material(0xe0b28e, { roughness: 0.9 });
const trousers = material(0x30434a, { roughness: 0.9 });
box(group, 0.36, 0.58, 0.25, coat, 0, 0.82, 0);
box(group, 0.27, 0.28, 0.26, skin, 0, 1.27, 0);
box(group, 0.31, 0.09, 0.29, material(0x654b35), 0, 1.43, 0);
const legL = new THREE.Group();
const legR = new THREE.Group();
legL.position.set(-0.1, 0.54, 0);
legR.position.set(0.1, 0.54, 0);
box(legL, 0.13, 0.48, 0.14, trousers, 0, -0.24, 0);
box(legR, 0.13, 0.48, 0.14, trousers, 0, -0.24, 0);
group.add(legL, legR);
box(group, 0.11, 0.45, 0.13, coat, -0.25, 0.83, 0);
box(group, 0.11, 0.45, 0.13, coat, 0.25, 0.83, 0);
scene.add(group);
return { group, legL, legR };
}
function createBoat() {
const group = new THREE.Group();
const hull = material(0x754833, { roughness: 0.86 });
const hullLight = material(0xa56e42, { roughness: 0.82 });
const cabin = material(0xe8dfc9, { roughness: 0.74 });
const trim = material(palette.cyan, { roughness: 0.5, emissive: 0x07585b, emissiveIntensity: 0.25 });
box(group, 1.18, 0.25, 2.05, hull, 0, 0, 0);
box(group, 0.78, 0.24, 0.45, hullLight, 0, 0.01, 1.14);
box(group, 0.88, 0.12, 1.5, hullLight, 0, 0.16, -0.04);
box(group, 0.72, 0.62, 0.86, cabin, 0, 0.52, -0.25);
box(group, 0.86, 0.13, 1.02, trim, 0, 0.89, -0.25);
box(group, 0.54, 0.22, 0.05, material(0x2d5359), 0, 0.57, 0.2);
const person = box(group, 0.22, 0.45, 0.2, trim, 0, 1.12, -0.27);
person.castShadow = true;
scene.add(group);
return group;
}
const walker = createWalker();
const boat = createBoat();
let holdArrivals = reducedMotion;
let journeyEpoch = 0;
const showArrivalsButton = document.getElementById("showArrivals");
const replayButton = document.getElementById("replayRoutes");
function updateArrivalButton() {
showArrivalsButton.setAttribute("aria-pressed", String(holdArrivals));
showArrivalsButton.textContent = holdArrivals ? "Both arrivals held" : "Show both arrivals";
}
showArrivalsButton.addEventListener("click", () => {
holdArrivals = true;
updateArrivalButton();
});
replayButton.addEventListener("click", () => {
holdArrivals = false;
journeyEpoch = clock.getElapsedTime();
updateArrivalButton();
});
updateArrivalButton();
function validateGraph() {
const edgeChecks = graph.edges.map((edge) => {
const from = graph.nodes.get(edge.from);
const to = graph.nodes.get(edge.to);
const physicalStart = Boolean(from) && edge.points[0].distanceTo(from.position) < 0.0001;
const physicalEnd = Boolean(to) && edge.points[edge.points.length - 1].distanceTo(to.position) < 0.0001;
let continuous = edge.points.length >= 2;
for (let i = 0; i < edge.points.length - 1; i++) {
if (edge.points[i].distanceTo(edge.points[i + 1]) < 0.0001) continuous = false;
}
return {
edge,
fromExists: Boolean(from),
toExists: Boolean(to),
physicalStart,
physicalEnd,
continuous,
valid: Boolean(from && to && physicalStart && physicalEnd && continuous)
};
});
const endpointReferences = edgeChecks.length * 2;
const resolvedEndpointReferences = edgeChecks.reduce((count, check) => count + Number(check.fromExists) + Number(check.toExists), 0);
const routeChecks = graph.routes.map((route) => {
const edgeMap = new Map(graph.edges.map((edge) => [edge.id, edge]));
let chainValid = route.edgeIds.length === route.nodeIds.length - 1;
for (let i = 0; i < route.edgeIds.length; i++) {
const edge = edgeMap.get(route.edgeIds[i]);
if (!edge || edge.from !== route.nodeIds[i] || edge.to !== route.nodeIds[i + 1]) chainValid = false;
}
const startValid = route.edgeIds[0] && edgeMap.get(route.edgeIds[0]).from === route.start;
const endValid = route.edgeIds[route.edgeIds.length - 1] && edgeMap.get(route.edgeIds[route.edgeIds.length - 1]).to === route.end;
return { route, valid: chainValid && startValid && endValid, chainValid, startValid, endValid };
});
const bindings = [
{ nodeId: "P6", beacon: arrivalA, entrance: "Entrance A" },
{ nodeId: "B4", beacon: arrivalB, entrance: "Entrance B" }
].map((binding) => {
const node = graph.nodes.get(binding.nodeId);
const positionMatches = node.position.distanceTo(binding.beacon.position) < 0.0001;
const visible = binding.beacon.group.visible;
return { ...binding, valid: positionMatches && visible, positionMatches, visible };
});
return {
edgeChecks,
endpointReferences,
resolvedEndpointReferences,
routeChecks,
bindings,
allValid:
edgeChecks.every((check) => check.valid) &&
routeChecks.every((check) => check.valid) &&
bindings.every((binding) => binding.valid)
};
}
const validation = validateGraph();
function graphSvg(routeId, svgId, layouts) {
const route = graph.routes.find((candidate) => candidate.id === routeId);
const svg = document.getElementById(svgId);
const color = routeId === "pedestrian" ? "#f1a84d" : "#52d6d8";
const edgeMap = new Map(graph.edges.map((edge) => [edge.id, edge]));
let markup = "";
route.edgeIds.forEach((edgeId) => {
const edge = edgeMap.get(edgeId);
const from = layouts[edge.from];
const to = layouts[edge.to];
markup += `<line class="graph-edge" x1="${from.x}" y1="${from.y}" x2="${to.x}" y2="${to.y}" stroke="${color}"></line>`;
});
route.nodeIds.forEach((nodeId, index) => {
const point = layouts[nodeId];
const isEnd = index === 0 || index === route.nodeIds.length - 1;
markup += `<circle class="graph-node" cx="${point.x}" cy="${point.y}" r="${isEnd ? 7.5 : 6}" fill="${color}"></circle>`;
markup += `<text class="graph-text" x="${point.x}" y="${point.y + 17}">${nodeId}</text>`;
if (isEnd) {
const endText = index === 0 ? "START" : (routeId === "pedestrian" ? "ENTRANCE A" : "ENTRANCE B");
markup += `<text class="graph-end-label" x="${point.x}" y="${point.y - 12}">${endText}</text>`;
}
});
svg.innerHTML = markup;
}
graphSvg("pedestrian", "pedGraph", {
P0: { x: 20, y: 50 }, P1: { x: 66, y: 24 }, P2: { x: 112, y: 50 },
P3: { x: 158, y: 24 }, P4: { x: 204, y: 50 }, P5: { x: 250, y: 24 },
P6: { x: 298, y: 50 }
});
graphSvg("boat", "boatGraph", {
B0: { x: 22, y: 28 }, B1: { x: 91, y: 56 }, B2: { x: 160, y: 28 },
B3: { x: 229, y: 56 }, B4: { x: 298, y: 28 }
});
const auditList = document.getElementById("auditList");
let auditMarkup = "";
for (const check of validation.edgeChecks) {
auditMarkup += `
<div class="audit-line">
<span class="audit-check">✓</span>
<span class="audit-code">${check.edge.from} → ${check.edge.to}</span>
<span class="audit-detail">both endpoints resolved</span>
</div>`;
}
for (const binding of validation.bindings) {
auditMarkup += `
<div class="audit-line binding">
<span class="audit-check">✓</span>
<span class="audit-detail"><span class="audit-code">${binding.nodeId}</span> maps to ${binding.entrance}; arrival is visible</span>
</div>`;
}
auditList.innerHTML = auditMarkup;
document.getElementById("endpointStat").textContent = `${validation.resolvedEndpointReferences}/${validation.endpointReferences}`;
document.getElementById("arrivalStat").textContent = `${validation.bindings.filter((binding) => binding.valid).length}/2`;
document.getElementById("auditCount").textContent = `${validation.resolvedEndpointReferences}/${validation.endpointReferences} endpoint references resolved`;
const pedRoute = graph.routes.find((route) => route.id === "pedestrian");
const boatRoute = graph.routes.find((route) => route.id === "boat");
document.getElementById("pedStats").textContent = `${pedRoute.edgeIds.length} graph legs · ${pathLength(pedRoute.physicalPath).toFixed(1)} model units · footbridge included`;
document.getElementById("boatStats").textContent = `${boatRoute.edgeIds.length} graph legs · ${pathLength(boatRoute.physicalPath).toFixed(1)} model units · canal-only`;
document.getElementById("pedStatus").textContent = validation.routeChecks[0].valid ? "ENDPOINTS VERIFIED" : "CHECK FAILED";
document.getElementById("boatStatus").textContent = validation.routeChecks[1].valid ? "ENDPOINTS VERIFIED" : "CHECK FAILED";
function updateCamera() {
if (!cameraDirty) return;
cameraDirty = false;
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const effectiveHeight = Math.max(viewHeight, 42 / aspect);
camera.left = -effectiveHeight * aspect / 2;
camera.right = effectiveHeight * aspect / 2;
camera.top = effectiveHeight / 2;
camera.bottom = -effectiveHeight / 2;
camera.updateProjectionMatrix();
const offset = new THREE.Vector3().setFromSpherical(
new THREE.Spherical(cameraRadius, cameraPhi, cameraTheta)
);
camera.position.copy(cameraTarget).add(offset);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraTheta = 0.59;
cameraPhi = 0.94;
cameraRadius = 43;
viewHeight = 31;
cameraDirty = true;
}
const activePointers = new Map();
let pinchDistance = 0;
canvas.addEventListener("pointerdown", (event) => {
canvas.focus({ preventScroll: true });
activePointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
canvas.setPointerCapture(event.pointerId);
if (activePointers.size === 2) {
const points = [...activePointers.values()];
pinchDistance = Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!activePointers.has(event.pointerId)) return;
const previous = activePointers.get(event.pointerId);
if (activePointers.size === 1) {
cameraTheta -= (event.clientX - previous.x) * 0.006;
cameraPhi = THREE.MathUtils.clamp(cameraPhi + (event.clientY - previous.y) * 0.005, 0.34, 1.38);
cameraDirty = true;
} else if (activePointers.size === 2) {
const points = [...activePointers.values()];
const distance = Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y);
if (pinchDistance > 0 && distance > 0) {
viewHeight = THREE.MathUtils.clamp(viewHeight * (pinchDistance / distance), 18, 54);
cameraDirty = true;
}
pinchDistance = distance;
}
activePointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
});
function endPointer(event) {
activePointers.delete(event.pointerId);
pinchDistance = 0;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
viewHeight = THREE.MathUtils.clamp(viewHeight * Math.exp(event.deltaY * 0.001), 18, 54);
cameraDirty = true;
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
let handled = true;
if (event.key === "ArrowLeft") cameraTheta += 0.09;
else if (event.key === "ArrowRight") cameraTheta -= 0.09;
else if (event.key === "ArrowUp") cameraPhi = Math.max(0.34, cameraPhi - 0.07);
else if (event.key === "ArrowDown") cameraPhi = Math.min(1.38, cameraPhi + 0.07);
else if (event.key === "+" || event.key === "=") viewHeight = Math.max(18, viewHeight - 2);
else if (event.key === "-" || event.key === "_") viewHeight = Math.min(54, viewHeight + 2);
else if (event.key.toLowerCase() === "r") resetCamera();
else handled = false;
if (handled) {
event.preventDefault();
cameraDirty = true;
}
});
function resize() {
renderer.setSize(window.innerWidth, window.innerHeight, false);
cameraDirty = true;
}
window.addEventListener("resize", resize);
resize();
updateCamera();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
const sinceStart = Math.max(0, elapsed - journeyEpoch);
const pedestrianProgress = holdArrivals ? 1 : (sinceStart * 0.052) % 1;
const boatProgress = holdArrivals ? 1 : (sinceStart * 0.039) % 1;
const pedestrianSample = samplePath(pedPhysical, pedestrianProgress);
walker.group.position.copy(pedestrianSample.position);
walker.group.rotation.y = Math.atan2(pedestrianSample.direction.x, pedestrianSample.direction.z);
const walking = !holdArrivals && pedestrianProgress < 0.96;
walker.legL.rotation.x = walking ? Math.sin(elapsed * 9) * 0.42 : 0;
walker.legR.rotation.x = walking ? -Math.sin(elapsed * 9) * 0.42 : 0;
walker.group.position.y += walking ? Math.abs(Math.sin(elapsed * 9)) * 0.035 : 0;
const boatSample = samplePath(boatPhysical, boatProgress);
boat.position.copy(boatSample.position);
boat.rotation.y = Math.atan2(boatSample.direction.x, boatSample.direction.z);
boat.position.y += holdArrivals ? 0 : Math.sin(elapsed * 2.1) * 0.018;
for (const ripple of rippleMeshes) {
ripple.mesh.position.x += ripple.speed * 0.016;
if (ripple.mesh.position.x > 20.5) ripple.mesh.position.x = -20.5;
}
const pulse = 1 + Math.sin(elapsed * 3.2) * 0.12;
arrivalA.ring.scale.setScalar(pulse);
arrivalB.ring.scale.setScalar(1 + Math.sin(elapsed * 3.2 + 1.1) * 0.12);
arrivalA.beam.material.opacity = 0.27 + Math.sin(elapsed * 2.5) * 0.07;
arrivalB.beam.material.opacity = 0.27 + Math.sin(elapsed * 2.5 + 1.4) * 0.07;
updateCamera();
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => loading.classList.add("gone"));
</script>
</body>
</html>
```