Prompt specification
Build or customize the Three.js 3D scene "Schedule stall deliveries around ferry arrivals" 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: Schedule stall deliveries around ferry arrivals
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/schedule-stall-deliveries-around-ferry-arrivals-x2836
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts Helsinki's waterfront Market Square. Let users compare fictional delivery windows with ferry passenger pulses. Show route overlap at the square edge without claiming to reproduce actual local transport schedules. Voxel style.
Working Three.js Starter (schedule-stall-deliveries-around-ferry-arrivals-x2836):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Helsinki Market Square — Fictional Flow Study</title>
<style>
:root {
color-scheme: light;
--ink: #173247;
--muted: #557083;
--panel: rgba(248, 252, 253, 0.91);
--line: rgba(23, 50, 71, 0.14);
--orange: #ed7d32;
--teal: #00a8a0;
--amber: #f3b61f;
--blue: #2878bd;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background: #b9dce8;
}
button, select, input { font: inherit; }
#app {
position: relative;
width: 100%;
height: 100%;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene.dragging { cursor: grabbing; }
.panel {
position: absolute;
z-index: 10;
border: 1px solid rgba(255,255,255,.72);
background: var(--panel);
box-shadow:
0 14px 40px rgba(27, 67, 86, .14),
0 2px 8px rgba(27, 67, 86, .08);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
border-radius: 16px;
}
.brand {
top: 20px;
left: 20px;
width: 330px;
padding: 17px 18px 15px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
color: var(--teal);
font-size: 10px;
font-weight: 850;
letter-spacing: .16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(0,168,160,.13);
}
h1 {
margin: 0;
font-size: 25px;
line-height: 1.08;
letter-spacing: -.035em;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.controls {
top: 157px;
left: 20px;
width: 330px;
padding: 15px 17px 16px;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 0 9px;
font-size: 11px;
font-weight: 850;
letter-spacing: .1em;
text-transform: uppercase;
}
.section-title span {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: .04em;
}
.control-row {
margin-bottom: 12px;
}
.control-row label {
display: block;
margin-bottom: 5px;
color: var(--muted);
font-size: 11px;
font-weight: 700;
}
select {
width: 100%;
padding: 9px 30px 9px 10px;
border: 1px solid var(--line);
border-radius: 9px;
color: var(--ink);
background: rgba(255,255,255,.78);
font-size: 12px;
outline: none;
}
select:focus {
border-color: rgba(0,168,160,.55);
box-shadow: 0 0 0 3px rgba(0,168,160,.1);
}
.slider-label {
display: flex;
justify-content: space-between;
margin-bottom: 4px;
color: var(--muted);
font-size: 11px;
font-weight: 700;
}
.slider-label output {
color: var(--ink);
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
accent-color: var(--teal);
cursor: pointer;
}
#deliveryMultiplier { accent-color: var(--orange); }
.divider {
height: 1px;
margin: 14px 0 12px;
background: var(--line);
}
.check-row {
display: flex;
align-items: center;
justify-content: space-between;
margin: 8px 0;
color: var(--muted);
font-size: 12px;
font-weight: 650;
}
.switch {
position: relative;
width: 36px;
height: 20px;
}
.switch input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.switch-track {
position: absolute;
inset: 0;
border-radius: 20px;
background: #b9c7ce;
transition: .18s ease;
}
.switch-track::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 14px;
height: 14px;
border-radius: 50%;
background: white;
box-shadow: 0 1px 3px rgba(0,0,0,.2);
transition: .18s ease;
}
.switch input:checked + .switch-track {
background: var(--teal);
}
.switch input:checked + .switch-track::after {
transform: translateX(16px);
}
.camera-buttons {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
margin-top: 13px;
}
.camera-buttons button,
.play-button {
border: 1px solid var(--line);
border-radius: 9px;
padding: 8px 7px;
color: var(--ink);
background: rgba(255,255,255,.8);
font-size: 10px;
font-weight: 800;
cursor: pointer;
transition: transform .15s ease, background .15s ease;
}
.camera-buttons button:hover,
.play-button:hover {
transform: translateY(-1px);
background: white;
}
.compare {
top: 20px;
right: 20px;
width: 318px;
padding: 16px;
}
.compare-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
margin-bottom: 13px;
}
.compare-heading h2 {
margin: 0;
font-size: 15px;
letter-spacing: -.02em;
}
.compare-heading p {
margin: 4px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.fictional-badge {
flex: 0 0 auto;
padding: 5px 7px;
border-radius: 7px;
color: #855b0c;
background: rgba(243,182,31,.19);
font-size: 8px;
font-weight: 900;
letter-spacing: .09em;
text-transform: uppercase;
}
.metric {
margin-top: 12px;
}
.metric-head {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-bottom: 6px;
font-size: 11px;
font-weight: 800;
}
.metric-head output {
font-size: 19px;
letter-spacing: -.04em;
font-variant-numeric: tabular-nums;
}
.meter {
height: 9px;
overflow: hidden;
border-radius: 20px;
background: #dce6e9;
}
.meter > div {
width: 0;
height: 100%;
border-radius: inherit;
transition: width .2s ease;
}
#deliveryBar { background: var(--orange); }
#ferryBar { background: var(--teal); }
#overlapBar {
background: linear-gradient(90deg, var(--orange), var(--amber), var(--teal));
}
.overlap-card {
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
gap: 12px;
margin-top: 15px;
padding: 11px 12px;
border: 1px solid rgba(243,182,31,.25);
border-radius: 11px;
background: rgba(243,182,31,.08);
}
.overlap-card strong {
display: block;
margin-bottom: 3px;
font-size: 11px;
}
.overlap-card p {
margin: 0;
color: var(--muted);
font-size: 9px;
line-height: 1.35;
}
#overlapValue {
color: #95640a;
font-size: 23px;
font-weight: 900;
letter-spacing: -.05em;
}
.compare-note {
min-height: 31px;
margin: 10px 1px 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 10px 14px;
margin-top: 12px;
padding-top: 11px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 9px;
font-weight: 750;
}
.legend-item {
display: flex;
align-items: center;
gap: 5px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 2px;
}
.timeline {
bottom: 38px;
left: 50%;
width: min(720px, calc(100% - 400px));
min-width: 480px;
padding: 12px 15px 13px;
transform: translateX(-50%);
}
.timeline-top {
display: flex;
align-items: center;
gap: 12px;
}
.play-button {
flex: 0 0 auto;
width: 68px;
padding: 8px;
}
.time-readout {
flex: 0 0 64px;
font-size: 19px;
font-weight: 850;
letter-spacing: -.04em;
font-variant-numeric: tabular-nums;
}
.timeline-track {
position: relative;
flex: 1;
}
#timeSlider {
display: block;
margin: 0;
}
.schedule-key {
display: flex;
justify-content: space-between;
margin-top: 4px;
color: var(--muted);
font-size: 8px;
font-weight: 700;
}
.disclaimer {
position: absolute;
z-index: 10;
right: 18px;
bottom: 9px;
max-width: 520px;
color: rgba(23,50,71,.78);
font-size: 9px;
line-height: 1.35;
text-align: right;
text-shadow: 0 1px 2px rgba(255,255,255,.8);
}
.loading {
position: absolute;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
color: var(--ink);
background: #b9dce8;
font-size: 12px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
transition: opacity .35s ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
.brand {
width: 290px;
}
.controls {
width: 290px;
}
.compare {
width: 285px;
}
.timeline {
left: 18px;
right: 18px;
width: auto;
min-width: 0;
transform: none;
}
.disclaimer {
max-width: 350px;
}
}
@media (max-width: 680px) {
.brand {
top: 10px;
left: 10px;
width: calc(100% - 20px);
padding: 12px 14px;
}
h1 { font-size: 20px; }
.subtitle { display: none; }
.compare {
top: 104px;
right: 10px;
width: 245px;
padding: 12px;
}
.controls {
top: auto;
bottom: 108px;
left: 10px;
width: 245px;
max-height: 45vh;
overflow: auto;
padding: 12px;
}
.controls .section-title,
.controls .divider,
.controls .control-row:nth-child(3),
.controls .control-row:nth-child(4),
.camera-buttons {
display: none;
}
.timeline {
bottom: 35px;
left: 10px;
right: 10px;
}
.disclaimer {
left: 10px;
right: 10px;
bottom: 7px;
max-width: none;
text-align: center;
font-size: 8px;
}
}
</style>
</head>
<body>
<main id="app">
<canvas id="scene" aria-label="Interactive voxel model of Helsinki's Market Square"></canvas>
<header class="panel brand">
<div class="eyebrow">Illustrative waterfront flow</div>
<h1>Market Square / Helsinki</h1>
<p class="subtitle">
Compare imagined delivery windows with ferry passenger pulses at the
waterfront edge of the square.
</p>
</header>
<section class="panel controls" aria-label="Scenario controls">
<div class="section-title">
Fictional comparison
<span>Not live data</span>
</div>
<div class="control-row">
<label for="deliveryWindow">Delivery window</label>
<select id="deliveryWindow"></select>
</div>
<div class="control-row">
<label for="ferryWindow">Ferry passenger pulse</label>
<select id="ferryWindow"></select>
</div>
<div class="control-row">
<label class="slider-label" for="deliveryMultiplier">
<span>Delivery intensity</span>
<output id="deliveryMultiplierValue">100%</output>
</label>
<input id="deliveryMultiplier" type="range" min="0" max="150" value="100" />
</div>
<div class="control-row">
<label class="slider-label" for="ferryMultiplier">
<span>Ferry pulse intensity</span>
<output id="ferryMultiplierValue">100%</output>
</label>
<input id="ferryMultiplier" type="range" min="0" max="150" value="100" />
</div>
<div class="divider"></div>
<div class="check-row">
<span>Illustrative routes</span>
<label class="switch">
<input id="routesToggle" type="checkbox" checked />
<span class="switch-track"></span>
</label>
</div>
<div class="check-row">
<span>Shared-edge overlap</span>
<label class="switch">
<input id="overlapToggle" type="checkbox" checked />
<span class="switch-track"></span>
</label>
</div>
<div class="camera-buttons" aria-label="Camera views">
<button id="resetView" type="button">Reset</button>
<button id="topView" type="button">Top view</button>
<button id="waterView" type="button">Waterfront</button>
</div>
</section>
<section class="panel compare" aria-label="Scenario comparison">
<div class="compare-heading">
<div>
<h2>Flow comparison</h2>
<p>Selected fictional scenario at the comparison time</p>
</div>
<span class="fictional-badge">Fictional</span>
</div>
<div class="metric">
<div class="metric-head">
<span>Delivery activity</span>
<output id="deliveryValue">0%</output>
</div>
<div class="meter"><div id="deliveryBar"></div></div>
</div>
<div class="metric">
<div class="metric-head">
<span>Ferry passenger pulse</span>
<output id="ferryValue">0%</output>
</div>
<div class="meter"><div id="ferryBar"></div></div>
</div>
<div class="metric">
<div class="metric-head">
<span>Shared-edge exposure</span>
<output id="edgeValue">0%</output>
</div>
<div class="meter"><div id="overlapBar"></div></div>
</div>
<div class="overlap-card">
<div>
<strong>Waterfront edge crossing</strong>
<p>Illustrative overlap between delivery and walking flows</p>
</div>
<span id="overlapValue">0%</span>
</div>
<p id="compareNote" class="compare-note"></p>
<div class="legend" aria-label="Legend">
<span class="legend-item">
<i class="swatch" style="background:#ed7d32"></i>Delivery
</span>
<span class="legend-item">
<i class="swatch" style="background:#00a8a0"></i>Ferry walk
</span>
<span class="legend-item">
<i class="swatch" style="background:#f3b61f"></i>Shared zone
</span>
</div>
</section>
<section class="panel timeline" aria-label="Fictional timeline">
<div class="timeline-top">
<button id="playButton" class="play-button" type="button">▶ Play</button>
<output id="timeReadout" class="time-readout">08:15</output>
<div class="timeline-track">
<input
id="timeSlider"
type="range"
min="420"
max="1080"
step="1"
value="495"
aria-label="Fictional comparison time"
/>
<div class="schedule-key">
<span>07:00</span>
<span>10:00</span>
<span>13:00</span>
<span>16:00</span>
<span>18:00</span>
</div>
</div>
</div>
</section>
<footer class="disclaimer">
Simulation only. All windows, passenger volumes, delivery volumes, and route
traces are fictional and do not reproduce actual local transport schedules or
operational routes.
</footer>
<div id="loading" class="loading">Building the waterfront…</div>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (selector) => document.querySelector(selector);
const canvas = $("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9dce8);
scene.fog = new THREE.Fog(0xb9dce8, 47, 92);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
150
);
const hemi = new THREE.HemisphereLight(0xe9f8ff, 0x7b8c76, 2.2);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1cf, 3.1);
sun.position.set(-18, 30, 20);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -34;
sun.shadow.camera.right = 34;
sun.shadow.camera.top = 32;
sun.shadow.camera.bottom = -32;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 80;
sun.shadow.bias = -0.0003;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9ed8ef, 0.9);
fill.position.set(20, 12, -18);
scene.add(fill);
const materialCache = new Map();
function material(color, options = {}) {
const key = `${color}-${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
...options
})
);
}
return materialCache.get(key);
}
function box(
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0,
parent = scene,
options = {}
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
options.material || material(color, options.materialOptions)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function labelSprite(text, color = "#173247", width = 6.4) {
const c = document.createElement("canvas");
c.width = 640;
c.height = 128;
const ctx = c.getContext("2d");
ctx.fillStyle = "rgba(248,252,253,0.94)";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = color;
ctx.fillRect(0, 0, 15, c.height);
ctx.fillStyle = "#173247";
ctx.font = "800 37px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, c.width / 2 + 7, c.height / 2);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.scale.set(width, width * 0.2, 1);
return sprite;
}
function seededRandom(seed) {
let value = seed >>> 0;
return () => {
value = (value * 1664525 + 1013904223) >>> 0;
return value / 4294967296;
};
}
const random = seededRandom(7142024);
// Water and land.
box(
100,
0.5,
80,
0x5fa9c4,
0,
-0.55,
30,
scene,
{ materialOptions: { roughness: 0.38, metalness: 0.08 } }
);
box(36, 0.9, 28, 0xa7a58f, 0, 0, -2);
box(30, 0.42, 20, 0xc2bda8, 0, 0.53, 0);
box(36, 0.75, 0.6, 0x747b78, 0, 0.18, 11.72);
// Small voxel wave marks.
const waveGeometry = new THREE.BoxGeometry(1.4, 0.05, 0.16);
const waveMaterial = new THREE.MeshBasicMaterial({
color: 0xa7d9e7,
transparent: true,
opacity: 0.52
});
for (let i = 0; i < 72; i++) {
const wave = new THREE.Mesh(waveGeometry, waveMaterial);
wave.position.set(
-33 + random() * 66,
-0.27,
13 + random() * 32
);
wave.rotation.y = random() < 0.5 ? 0 : Math.PI / 2;
wave.scale.x = 0.5 + random() * 2.3;
scene.add(wave);
}
// Cobblestone plaza using instanced voxel tiles.
const tileCount = 30 * 20;
const cobbleGeometry = new THREE.BoxGeometry(0.94, 0.08, 0.94);
const cobbleMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96
});
const cobbles = new THREE.InstancedMesh(
cobbleGeometry,
cobbleMaterial,
tileCount
);
cobbles.castShadow = false;
cobbles.receiveShadow = true;
const matrix = new THREE.Matrix4();
const tileColor = new THREE.Color();
let tileIndex = 0;
for (let ix = 0; ix < 30; ix++) {
for (let iz = 0; iz < 20; iz++) {
matrix.makeTranslation(-14.5 + ix, 0.79, -9.5 + iz);
cobbles.setMatrixAt(tileIndex, matrix);
const variation = 0.9 + random() * 0.16;
tileColor.setHSL(
0.11,
0.08 + random() * 0.05,
0.62 * variation
);
cobbles.setColorAt(tileIndex, tileColor);
tileIndex++;
}
}
scene.add(cobbles);
// Market stalls.
const stallColors = [0xd95845, 0xe8b83f, 0x2d9d96, 0xe47b35];
const stallPositions = [
[-7, -4], [-3.4, -4], [0.2, -4], [3.8, -4],
[-7, 0], [-3.4, 0], [0.2, 0],
[-7, 4], [-3.4, 4], [0.2, 4], [3.8, 4]
];
stallPositions.forEach(([x, z], index) => {
const group = new THREE.Group();
group.position.set(x, 0.83, z);
scene.add(group);
const color = stallColors[index % stallColors.length];
box(2.65, 0.22, 1.95, color, 0, 1.78, 0, group);
box(2.9, 0.22, 0.24, 0xf5f0dd, 0, 1.92, 0.76, group);
box(2.4, 0.85, 1.25, 0xf0e8cf, 0, 0.56, 0, group);
box(2.75, 0.16, 1.5, 0x8a6247, 0, 1.04, 0, group);
[-1.18, 1.18].forEach((px) => {
[-0.78, 0.78].forEach((pz) => {
box(0.12, 1.85, 0.12, 0x725947, px, 0.91, pz, group);
});
});
for (let crateIndex = 0; crateIndex < 3; crateIndex++) {
box(
0.35,
0.27,
0.35,
crateIndex % 2 ? 0xd9a64a : 0xb87c43,
-0.65 + crateIndex * 0.48,
1.25,
0.05,
group
);
}
});
// Yellow Market Hall on the western side.
const hall = new THREE.Group();
hall.position.set(-12, 0.82, -2.8);
scene.add(hall);
box(4.5, 3.65, 10.5, 0xe6b843, 0, 1.85, 0, hall);
box(5.0, 0.45, 11.2, 0x526b70, 0, 3.85, 0, hall);
box(4.7, 0.22, 10.7, 0xf4dc82, 0, 4.08, 0, hall);
for (let i = 0; i < 7; i++) {
box(0.95, 1.25, 0.08, 0x416875, 0, 2.05, 5.29, hall);
box(0.08, 1.25, 0.95, 0x416875, 2.29, 2.05, -4 + i * 1.35, hall);
}
const hallLabel = labelSprite("MARKET HALL", "#9b7111", 4.4);
hallLabel.position.set(-12, 5.25, -2.8);
scene.add(hallLabel);
// Voxel Helsinki Cathedral-inspired background landmark.
const cathedral = new THREE.Group();
cathedral.position.set(2, 0.85, -12);
scene.add(cathedral);
box(11, 0.55, 5.5, 0x9b9b91, 0, 0.28, 0, cathedral);
box(8.4, 3.8, 3.8, 0xe6e5dc, 0, 2.4, 0, cathedral);
box(8.8, 0.35, 4.2, 0x597b73, 0, 4.45, 0, cathedral);
box(8.2, 1.8, 0.35, 0xe9e8df, 0, 2.3, 2.02, cathedral);
[-3.7, 3.7].forEach((x) => {
box(2.05, 5.8, 2.05, 0xe8e7dd, x, 3.2, 1.05, cathedral);
box(2.35, 0.35, 2.35, 0x56756e, x, 6.25, 1.05, cathedral);
box(1.25, 1.65, 1.25, 0xe8e7dd, x, 7.15, 1.05, cathedral);
box(1.48, 0.25, 1.48, 0x56756e, x, 8.05, 1.05, cathedral);
});
box(2.2, 6.6, 2.2, 0xe9e8df, 0, 3.6, 1.5, cathedral);
box(2.5, 0.35, 2.5, 0x56756e, 0, 7.05, 1.5, cathedral);
box(1.4, 1.8, 1.4, 0xe9e8df, 0, 8.05, 1.5, cathedral);
box(1.62, 0.25, 1.62, 0x56756e, 0, 9.05, 1.5, cathedral);
for (const x of [-1.7, 0, 1.7]) {
box(0.58, 1.25, 0.09, 0x55717a, x, 2.55, 2.24, cathedral);
}
// Trees along the square edge.
function addTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.83, z);
group.scale.setScalar(scale);
scene.add(group);
box(0.32, 1.6, 0.32, 0x795b40, 0, 0.8, 0, group);
box(1.35, 1.25, 1.35, 0x4d8b58, 0, 1.75, 0, group);
box(0.95, 0.85, 0.95, 0x65a167, 0.42, 2.35, 0.05, group);
box(0.9, 0.8, 0.9, 0x39784b, -0.35, 2.25, -0.15, group);
}
[
[-14, -8], [-14, -4], [-14, 1], [-14, 6],
[14, -8], [14, -4], [14, 0], [14, 5],
[-9.5, 10.3], [-5, 10.3], [11.5, 10.3], [14, 9]
].forEach(([x, z], i) => addTree(x, z, 0.82 + (i % 3) * 0.08));
// Crates and freight on the edge.
for (let i = 0; i < 8; i++) {
box(
0.8,
0.7,
0.8,
i % 2 ? 0xb67c43 : 0xd6a24f,
11.2 + (i % 2) * 0.9,
1.18 + Math.floor(i / 4) * 0.72,
9.4 - Math.floor(i / 4) * 0.85
);
}
// Pier and ferry.
box(2.8, 0.45, 6.3, 0x8c8f84, 7, 0.57, 14.4);
for (let i = 0; i < 4; i++) {
box(0.28, 2.8, 0.28, 0x596966, 5.85, 1.4, 12 + i * 1.8);
box(0.28, 2.8, 0.28, 0x596966, 8.15, 1.4, 12 + i * 1.8);
}
const ferry = new THREE.Group();
ferry.position.set(7, -0.05, 20);
scene.add(ferry);
box(8.3, 1.25, 3.25, 0x17475c, 0, 0.65, 0, ferry);
box(7.8, 1.35, 2.95, 0xf1f0e7, 0, 1.8, 0, ferry);
box(7.95, 0.24, 3.02, 0xf1bc3c, 0, 1.25, 0, ferry);
box(5.8, 1.15, 2.55, 0xf7f5eb, -0.4, 2.95, 0, ferry);
box(6.05, 0.25, 2.7, 0x2b7f9d, -0.4, 3.6, 0, ferry);
box(1.3, 1.6, 1.35, 0xe8e8df, 2.65, 2.2, 0, ferry);
for (let i = 0; i < 6; i++) {
box(0.75, 0.55, 0.08, 0x244e60, -2.65 + i * 1.05, 2.05, 1.51, ferry);
}
for (let i = 0; i < 4; i++) {
box(0.08, 0.5, 0.7, 0x244e60, -3.94, 2.05, -0.9 + i * 0.65, ferry);
box(0.08, 0.5, 0.7, 0x244e60, 3.14, 2.05, -0.9 + i * 0.65, ferry);
}
const ferryLabel = labelSprite("FERRY PULSE", "#007d78", 4.8);
ferryLabel.position.set(7, 5.1, 20);
scene.add(ferryLabel);
// Illustrative route geometry.
const deliveryPath = [
new THREE.Vector3(-13, 0.91, 8.4),
new THREE.Vector3(-8, 0.91, 8.4),
new THREE.Vector3(-2, 0.91, 8.4),
new THREE.Vector3(5, 0.91, 8.4),
new THREE.Vector3(10, 0.91, 8.4),
new THREE.Vector3(10, 0.91, 4),
new THREE.Vector3(10, 0.91, -5),
new THREE.Vector3(5, 0.91, -5)
];
const ferryPath = [
new THREE.Vector3(7, 0.94, 18),
new THREE.Vector3(7, 0.94, 12),
new THREE.Vector3(7, 0.94, 8.4),
new THREE.Vector3(4, 0.94, 8.4),
new THREE.Vector3(0, 0.94, 8.4),
new THREE.Vector3(0, 0.94, 2)
];
function pathLength(path) {
let length = 0;
for (let i = 1; i < path.length; i++) {
length += path[i].distanceTo(path[i - 1]);
}
return length;
}
function samplePath(path, t, target = new THREE.Vector3()) {
const length = pathLength(path);
let distance = ((t % 1) + 1) % 1 * length;
for (let i = 1; i < path.length; i++) {
const segment = path[i].distanceTo(path[i - 1]);
if (distance <= segment || i === path.length - 1) {
const f = segment === 0 ? 0 : distance / segment;
target.lerpVectors(path[i - 1], path[i], f);
const tangent = path[i].clone().sub(path[i - 1]).normalize();
return { position: target, tangent };
}
distance -= segment;
}
target.copy(path[0]);
return { position: target, tangent: new THREE.Vector3(0, 0, 1) };
}
function makeRoute(path, color, spacing = 0.62) {
const group = new THREE.Group();
const length = pathLength(path);
const count = Math.floor(length / spacing);
const geometry = new THREE.BoxGeometry(0.31, 0.08, 0.31);
const routeMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.93
});
const route = new THREE.InstancedMesh(geometry, routeMaterial, count);
const routeMatrix = new THREE.Matrix4();
const p = new THREE.Vector3();
for (let i = 0; i < count; i++) {
samplePath(path, (i / count), p);
routeMatrix.makeTranslation(p.x, p.y, p.z);
route.setMatrixAt(i, routeMatrix);
}
route.instanceMatrix.needsUpdate = true;
group.add(route);
scene.add(group);
return group;
}
const deliveryRoute = makeRoute(deliveryPath, 0xed7d32);
const ferryRoute = makeRoute(ferryPath, 0x00a8a0);
const deliveryLabel = labelSprite("DELIVERY · ILLUSTRATIVE", "#b5531f", 6.6);
deliveryLabel.position.set(-7.6, 2.4, 8.4);
scene.add(deliveryLabel);
const ferryRouteLabel = labelSprite("FERRY WALK · ILLUSTRATIVE", "#007d78", 6.8);
ferryRouteLabel.position.set(2.4, 2.65, 6.2);
scene.add(ferryRouteLabel);
// Shared-edge highlight at the square waterfront.
const overlapGroup = new THREE.Group();
scene.add(overlapGroup);
const overlapPad = new THREE.Mesh(
new THREE.BoxGeometry(3.6, 0.025, 2.15),
new THREE.MeshBasicMaterial({
color: 0xf3b61f,
transparent: true,
opacity: 0.19
})
);
overlapPad.position.set(7, 1.01, 8.4);
overlapGroup.add(overlapPad);
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const marker = box(
0.28,
0.18,
0.28,
0xf3b61f,
7 + Math.cos(angle) * 1.65,
1.06,
8.4 + Math.sin(angle) * 0.95,
overlapGroup,
{ castShadow: false }
);
marker.rotation.y = angle;
}
const overlapLabel = labelSprite("SHARED EDGE", "#95640a", 4.2);
overlapLabel.position.set(7, 2.55, 8.4);
overlapGroup.add(overlapLabel);
// Delivery vehicles.
const vans = [];
const vanColors = [0xf0f1e9, 0xe6b63c, 0xe17736];
for (let i = 0; i < 5; i++) {
const group = new THREE.Group();
scene.add(group);
box(1.35, 0.8, 2.1, vanColors[i % vanColors.length], 0, 0.52, 0, group);
box(1.25, 0.72, 0.82, vanColors[i % vanColors.length], 0, 0.95, 0.82, group);
box(1.08, 0.4, 0.08, 0x305366, 0, 1.02, 1.25, group);
box(1.42, 0.15, 2.18, 0xf7f5eb, 0, 1.03, -0.05, group);
[-0.67, 0.67].forEach((x) => {
box(0.23, 0.42, 0.42, 0x293238, x, 0.26, 0.64, group);
box(0.23, 0.42, 0.42, 0x293238, x, 0.26, -0.66, group);
});
group.visible = false;
vans.push(group);
}
// Passenger voxels.
const people = [];
const personColors = [
0xed7d32, 0x00a8a0, 0xf0c13d, 0x345f82,
0xd95e5e, 0x765993, 0xf1eee0, 0x4b8d57
];
for (let i = 0; i < 36; i++) {
const group = new THREE.Group();
scene.add(group);
box(
0.34,
0.63,
0.28,
personColors[i % personColors.length],
0,
0.32,
0,
group
);
box(
0.29,
0.3,
0.27,
0xe4b18b,
0,
0.79,
0,
group
);
box(
0.12,
0.25,
0.13,
0x273b48,
-0.1,
0.12,
0,
group
);
box(
0.12,
0.25,
0.13,
0x273b48,
0.1,
0.12,
0,
group
);
group.visible = false;
people.push(group);
}
// Fictional scenario definitions.
const deliveryWindows = [
{
label: "Morning loading · 07:30–09:00",
short: "Morning loading",
start: 450,
end: 540
},
{
label: "Midday replenishment · 10:00–11:30",
short: "Midday replenishment",
start: 600,
end: 690
},
{
label: "Afternoon consolidation · 13:30–15:30",
short: "Afternoon consolidation",
start: 810,
end: 930
}
];
const ferryWindows = [
{
label: "Pulse A · 08:00–08:30",
short: "Pulse A",
start: 480,
end: 510
},
{
label: "Pulse B · 11:30–12:00",
short: "Pulse B",
start: 690,
end: 720
},
{
label: "Pulse C · 15:30–16:15",
short: "Pulse C",
start: 930,
end: 975
}
];
const deliverySelect = $("#deliveryWindow");
const ferrySelect = $("#ferryWindow");
deliveryWindows.forEach((item, index) => {
const option = document.createElement("option");
option.value = index;
option.textContent = item.label;
deliverySelect.appendChild(option);
});
ferryWindows.forEach((item, index) => {
const option = document.createElement("option");
option.value = index;
option.textContent = item.label;
ferrySelect.appendChild(option);
});
deliverySelect.value = "0";
ferrySelect.value = "0";
let simTime = 495;
let deliveryMultiplier = 1;
let ferryMultiplier = 1;
let playing = false;
const timeSlider = $("#timeSlider");
const timeReadout = $("#timeReadout");
function clamp(value, min, max) {
return Math.min(max, Math.max(min, value));
}
function smoothstep(edge0, edge1, value) {
const t = clamp((value - edge0) / (edge1 - edge0), 0, 1);
return t * t * (3 - 2 * t);
}
function profileAt(time, start, end) {
const ramp = Math.min(14, (end - start) * 0.28);
const rise = smoothstep(start - ramp, start + ramp, time);
const fall = 1 - smoothstep(end - ramp, end + ramp, time);
return rise * fall;
}
function formatTime(minutes) {
const rounded = Math.round(minutes);
const hour = Math.floor(rounded / 60);
const minute = rounded % 60;
return `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
}
function updateComparison() {
const delivery = deliveryWindows[Number(deliverySelect.value)];
const ferry = ferryWindows[Number(ferrySelect.value)];
const deliveryLoad = Math.round(
profileAt(simTime, delivery.start, delivery.end) *
deliveryMultiplier *
100
);
const ferryLoad = Math.round(
profileAt(simTime, ferry.start, ferry.end) *
ferryMultiplier *
100
);
const overlap = Math.min(deliveryLoad, ferryLoad);
$("#deliveryValue").textContent = `${deliveryLoad}%`;
$("#ferryValue").textContent = `${ferryLoad}%`;
$("#edgeValue").textContent = `${overlap}%`;
$("#overlapValue").textContent = `${overlap}%`;
$("#deliveryBar").style.width = `${deliveryLoad}%`;
$("#ferryBar").style.width = `${ferryLoad}%`;
$("#overlapBar").style.width = `${overlap}%`;
timeReadout.textContent = formatTime(simTime);
timeSlider.value = simTime;
let note;
if (overlap >= 60) {
note = "Dense shared-edge moment in this fictional comparison.";
} else if (overlap >= 25) {
note = "A brief shared-edge crossing appears in the fictional scenario.";
} else if (deliveryLoad > ferryLoad) {
note = "Delivery activity leads while the ferry pulse remains light.";
} else if (ferryLoad > deliveryLoad) {
note = "The ferry pulse leads while delivery activity remains light.";
} else {
note = "Both fictional flows are quiet at the selected comparison time.";
}
$("#compareNote").textContent = note;
return { deliveryLoad, ferryLoad, overlap };
}
deliverySelect.addEventListener("change", () => {
const selected = deliveryWindows[Number(deliverySelect.value)];
simTime = (selected.start + selected.end) / 2;
updateComparison();
});
ferrySelect.addEventListener("change", () => {
const selected = ferryWindows[Number(ferrySelect.value)];
simTime = (selected.start + selected.end) / 2;
updateComparison();
});
$("#deliveryMultiplier").addEventListener("input", (event) => {
deliveryMultiplier = Number(event.target.value) / 100;
$("#deliveryMultiplierValue").textContent = `${event.target.value}%`;
updateComparison();
});
$("#ferryMultiplier").addEventListener("input", (event) => {
ferryMultiplier = Number(event.target.value) / 100;
$("#ferryMultiplierValue").textContent = `${event.target.value}%`;
updateComparison();
});
timeSlider.addEventListener("input", (event) => {
simTime = Number(event.target.value);
updateComparison();
});
$("#playButton").addEventListener("click", () => {
playing = !playing;
$("#playButton").textContent = playing ? "❚❚ Pause" : "▶ Play";
});
$("#routesToggle").addEventListener("change", (event) => {
const visible = event.target.checked;
deliveryRoute.visible = visible;
ferryRoute.visible = visible;
deliveryLabel.visible = visible;
ferryRouteLabel.visible = visible;
});
$("#overlapToggle").addEventListener("change", (event) => {
overlapGroup.visible = event.target.checked;
});
// Direct orbit-style camera controls, implemented without addons.
const cameraState = {
theta: 0.72,
phi: 1.02,
radius: 45,
target: new THREE.Vector3(0, 2.1, 1.0)
};
function updateCamera() {
const { theta, phi, radius, target } = cameraState;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
}
function setCamera(theta, phi, radius, target = [0, 2.1, 1]) {
cameraState.theta = theta;
cameraState.phi = phi;
cameraState.radius = radius;
cameraState.target.set(...target);
updateCamera();
}
$("#resetView").addEventListener("click", () => {
setCamera(0.72, 1.02, 45, [0, 2.1, 1]);
});
$("#topView").addEventListener("click", () => {
setCamera(0.001, 0.22, 49, [0, 0.8, 0]);
});
$("#waterView").addEventListener("click", () => {
setCamera(0.08, 1.18, 39, [1, 2.4, 3]);
});
let dragging = false;
let previousX = 0;
let previousY = 0;
let pointerId = null;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerId = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== pointerId) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = clamp(
cameraState.phi - dy * 0.005,
0.16,
1.38
);
if (event.shiftKey) {
const panScale = cameraState.radius * 0.0013;
cameraState.target.x -= dx * panScale;
cameraState.target.z -= dy * panScale;
cameraState.target.x = clamp(cameraState.target.x, -13, 13);
cameraState.target.z = clamp(cameraState.target.z, -12, 16);
}
updateCamera();
});
function endDrag(event) {
if (event.pointerId !== pointerId) return;
dragging = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(pointerId)) {
canvas.releasePointerCapture(pointerId);
}
pointerId = null;
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
20,
68
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateCamera();
updateComparison();
const clock = new THREE.Clock();
const sample = new THREE.Vector3();
const tangent = new THREE.Vector3();
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (playing) {
simTime += delta * 4;
if (simTime > 1080) simTime = 420;
}
const loads = updateComparison();
const vanCount = Math.min(
vans.length,
Math.ceil(loads.deliveryLoad / 22)
);
vans.forEach((van, index) => {
van.visible = index < vanCount;
if (!van.visible) return;
const phase = (elapsed * 0.026 + index * 0.19) % 1;
const result = samplePath(deliveryPath, phase, sample);
van.position.copy(result.position);
van.position.y = 0.83;
van.rotation.y = Math.atan2(result.tangent.x, result.tangent.z);
});
const personCount = Math.min(
people.length,
Math.round(loads.ferryLoad * 0.34)
);
people.forEach((person, index) => {
person.visible = index < personCount;
if (!person.visible) return;
const phase = (elapsed * 0.018 + index / Math.max(1, personCount)) % 1;
const result = samplePath(ferryPath, phase, sample);
person.position.copy(result.position);
person.position.y = 0.86;
person.rotation.y = Math.atan2(result.tangent.x, result.tangent.z);
person.position.y += Math.sin(elapsed * 7 + index) * 0.025;
});
const overlapScale = 1 + Math.sin(elapsed * 2.7) * 0.08;
overlapPad.scale.set(overlapScale, 1, overlapScale);
overlapLabel.position.y = 2.55 + Math.sin(elapsed * 2.7) * 0.08;
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
$("#loading").classList.add("hidden");
});
</script>
</body>
</html>
```