Prompt specification
Build or customize the Three.js 3D scene "Neighborhood Cycling Route Diorama" 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: Neighborhood Cycling Route Diorama
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/neighborhood-cycling-route-diorama-x2091
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing connected cycling routes through junctions. Build a bounded original neighborhood with homes, school, park, and connected cycle links. Show actual crossings and intersections rather than an uninterrupted decorative ribbon. Voxel style.
Working Three.js Starter (neighborhood-cycling-route-diorama-x2091):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Juniper Commons — Voxel Cycling Network</title>
<style>
:root {
--ink: #173d3a;
--muted: #627b76;
--paper: rgba(250, 249, 239, 0.94);
--line: rgba(23, 61, 58, 0.13);
--teal: #18a995;
--coral: #f06b4f;
--gold: #f2b84b;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dfe9e5;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.glass {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.72);
box-shadow:
0 14px 40px rgba(29, 65, 59, 0.12),
0 2px 8px rgba(29, 65, 59, 0.06);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.brand {
position: fixed;
top: 22px;
left: 24px;
z-index: 10;
max-width: min(440px, calc(100vw - 48px));
padding: 17px 19px 16px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--coral);
box-shadow: 14px 0 0 var(--teal);
margin-right: 14px;
content: "";
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 36px);
font-weight: 820;
letter-spacing: -0.045em;
line-height: 1;
}
.subtitle {
max-width: 390px;
margin: 9px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.legend {
position: fixed;
left: 24px;
bottom: 24px;
z-index: 10;
width: 242px;
padding: 15px 16px;
border-radius: 16px;
}
.legend-title,
.controls-title {
margin-bottom: 11px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 28px 1fr;
align-items: center;
gap: 10px;
margin: 9px 0;
font-size: 12px;
}
.swatch {
position: relative;
height: 7px;
border-radius: 2px;
background: var(--teal);
box-shadow: 0 0 0 1px rgba(23, 61, 58, 0.08);
}
.swatch.coral {
background: var(--coral);
}
.swatch.crossing {
height: 12px;
border: 2px solid var(--gold);
background: repeating-linear-gradient(
90deg,
transparent 0,
transparent 4px,
rgba(255, 255, 255, 0.9) 4px,
rgba(255, 255, 255, 0.9) 7px
);
}
.legend-note {
margin: 12px 0 0;
padding-top: 11px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.controls {
position: fixed;
top: 22px;
right: 24px;
z-index: 20;
width: 218px;
padding: 15px;
border-radius: 16px;
}
.toggle {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 10px 0;
color: #365651;
font-size: 11px;
font-weight: 650;
cursor: pointer;
user-select: none;
}
.toggle input {
width: 30px;
height: 17px;
margin: 0;
accent-color: var(--teal);
cursor: pointer;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 13px;
}
.button-row.three {
grid-template-columns: repeat(3, 1fr);
}
button {
min-height: 34px;
padding: 8px 9px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.75);
color: var(--ink);
font-size: 10px;
font-weight: 750;
cursor: pointer;
transition:
transform 0.15s ease,
background 0.15s ease,
border-color 0.15s ease;
}
button:hover {
transform: translateY(-1px);
border-color: rgba(23, 61, 58, 0.25);
background: white;
}
button:active {
transform: translateY(0);
}
.hint {
margin: 11px 0 0;
color: var(--muted);
font-size: 9px;
line-height: 1.5;
}
.selection {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 10;
width: min(310px, calc(100vw - 48px));
padding: 15px 16px;
border-radius: 16px;
pointer-events: none;
}
#selection-kicker {
margin-bottom: 5px;
color: var(--coral);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#selection-title {
margin: 0 0 6px;
font-size: 16px;
font-weight: 800;
letter-spacing: -0.02em;
}
#selection-text {
margin: 0;
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
#tooltip {
position: fixed;
z-index: 50;
max-width: 230px;
padding: 9px 11px;
border-radius: 9px;
background: rgba(20, 49, 46, 0.94);
color: white;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
font-size: 10px;
line-height: 1.45;
pointer-events: none;
}
#tooltip strong {
display: block;
margin-bottom: 2px;
color: #fff4c9;
font-size: 11px;
}
#loader {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #dfe9e5;
transition: opacity 0.45s ease;
}
#loader.hide {
opacity: 0;
pointer-events: none;
}
.loader-card {
text-align: center;
}
.loader-blocks {
display: flex;
justify-content: center;
gap: 5px;
margin-bottom: 15px;
}
.loader-blocks i {
width: 15px;
height: 15px;
border-radius: 3px;
background: var(--teal);
animation: pulse 0.9s infinite alternate;
}
.loader-blocks i:nth-child(2) {
background: var(--gold);
animation-delay: 0.15s;
}
.loader-blocks i:nth-child(3) {
background: var(--coral);
animation-delay: 0.3s;
}
@keyframes pulse {
to {
transform: translateY(-7px);
}
}
@media (max-width: 760px) {
.brand {
top: 12px;
left: 12px;
padding: 13px 14px;
}
.subtitle,
.legend-note,
.selection {
display: none;
}
.controls {
top: 12px;
right: 12px;
width: 160px;
padding: 11px;
}
.controls-title,
.hint {
display: none;
}
.toggle {
margin: 8px 0;
font-size: 10px;
}
.legend {
left: 12px;
bottom: 12px;
width: 180px;
padding: 11px 13px;
}
.legend-title {
display: none;
}
.legend-row {
grid-template-columns: 22px 1fr;
gap: 8px;
margin: 7px 0;
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="brand glass">
<div class="eyebrow">Voxel cycling atlas</div>
<h1>Juniper Commons</h1>
<p class="subtitle">
A bounded neighborhood where protected cycle links meet at real street
crossings, raised junction pads, school entrances, and neighborhood hubs.
</p>
</header>
<aside class="legend glass">
<div class="legend-title">Network key</div>
<div class="legend-row">
<span class="swatch"></span>
<span>Willow Loop</span>
</div>
<div class="legend-row">
<span class="swatch coral"></span>
<span>Cedar Spine + school link</span>
</div>
<div class="legend-row">
<span class="swatch crossing"></span>
<span>Marked street crossing</span>
</div>
<p class="legend-note">
Gaps in the colored lanes are occupied by physical crossing decks and
junction pads—not by a decorative continuous ribbon.
</p>
</aside>
<aside class="controls glass">
<div class="controls-title">Map controls</div>
<label class="toggle">
Cycle links
<input id="toggle-routes" type="checkbox" checked />
</label>
<label class="toggle">
Crossing markings
<input id="toggle-crossings" type="checkbox" checked />
</label>
<label class="toggle">
Place labels
<input id="toggle-labels" type="checkbox" checked />
</label>
<div class="button-row">
<button id="view-iso">Isometric</button>
<button id="view-plan">Plan</button>
</div>
<div class="button-row three">
<button data-focus="school">School</button>
<button data-focus="park">Park</button>
<button id="reset">Reset</button>
</div>
<p class="hint">
Drag: orbit · Shift/right-drag: pan · Wheel: zoom · R: reset
</p>
</aside>
<aside class="selection glass">
<div id="selection-kicker">Network overview</div>
<h2 id="selection-title">Streets, crossings, and places</h2>
<p id="selection-text">
Select a home, school, park, or colored junction to inspect the neighborhood.
</p>
</aside>
<div id="tooltip" hidden></div>
<div id="loader">
<div class="loader-card">
<div class="loader-blocks"><i></i><i></i><i></i></div>
<strong>Building Juniper Commons…</strong>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const tooltip = document.getElementById("tooltip");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdfe9e5);
scene.fog = new THREE.Fog(0xdfe9e5, 82, 145);
const camera = new THREE.OrthographicCamera(-35, 35, 25, -25, 0.1, 220);
const hemi = new THREE.HemisphereLight(0xf8fff8, 0x87958b, 2.05);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff4dc, 3.1);
sun.position.set(-28, 48, 24);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -45;
sun.shadow.camera.right = 45;
sun.shadow.camera.top = 40;
sun.shadow.camera.bottom = -40;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 110;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const routeGroup = new THREE.Group();
const crossingGroup = new THREE.Group();
const labelsGroup = new THREE.Group();
scene.add(routeGroup, crossingGroup, labelsGroup);
const pickables = [];
const cyclists = [];
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
...options
});
const M = {
soil: material(0x8f7961),
grass: material(0x9fc48d),
grassLight: material(0xb2d29f),
grassDark: material(0x7fa878),
sidewalk: material(0xd8d4c4),
sidewalkEdge: material(0xb9b4a5),
asphalt: material(0x596366),
asphaltDark: material(0x4d5759),
paint: material(0xf3eedb),
yellow: material(0xf2b84b),
teal: material(0x18a995, {
emissive: 0x063b34,
emissiveIntensity: 0.12
}),
coral: material(0xf06b4f, {
emissive: 0x4e160b,
emissiveIntensity: 0.1
}),
junction: material(0xf7df86),
cream: material(0xf7f0d7),
dark: material(0x263f3d),
window: material(0x91cbd1, {
emissive: 0x23525a,
emissiveIntensity: 0.18,
roughness: 0.4
}),
roof: material(0x9d5f4d),
roofBlue: material(0x4f7473),
roofGreen: material(0x66866d),
trunk: material(0x76513a),
leaves: material(0x5f9866),
leavesLight: material(0x82b277),
leavesDark: material(0x467858),
water: material(0x70b9bd, {
roughness: 0.3,
metalness: 0.05
}),
white: material(0xfaf8ed),
black: material(0x253130),
school: material(0xe5b861),
schoolRoof: material(0x2f7772),
schoolGlass: material(0x7fc5c7),
fence: material(0x8e755b),
wall: material(0xc8c0aa),
coralBike: material(0xf06b4f),
tealBike: material(0x18a995),
goldBike: material(0xf2b84b)
};
function box(w, h, d, x, y, z, mat, parent = scene, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function groupAt(x, y, z, parent = scene) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
return group;
}
function addInfo(object, kicker, title, text) {
object.userData.info = { kicker, title, text };
pickables.push(object);
return object;
}
function infoFromObject(object) {
let current = object;
while (current) {
if (current.userData && current.userData.info) {
return current.userData.info;
}
current = current.parent;
}
return null;
}
// ---------------------------------------------------------------------
// Ground and bounded neighborhood edge
// ---------------------------------------------------------------------
box(60, 1.3, 48, 0, -0.65, 0, M.soil, scene, false);
box(59.5, 0.12, 47.5, 0, 0.06, 0, M.grass, scene, false);
// Low perimeter walls, with a civic entrance gap on the south side.
box(0.48, 0.72, 46.8, -29.35, 0.47, 0, M.wall);
box(0.48, 0.72, 46.8, 29.35, 0.47, 0, M.wall);
box(58.2, 0.72, 0.48, 0, 0.47, -23.35, M.wall);
box(22, 0.72, 0.48, -18, 0.47, 23.35, M.wall);
box(22, 0.72, 0.48, 18, 0.47, 23.35, M.wall);
for (const x of [-29.35, 29.35]) {
for (const z of [-23.35, 23.35]) {
box(1.15, 1.25, 1.15, x, 0.75, z, M.sidewalkEdge);
box(0.85, 0.28, 0.85, x, 1.48, z, M.teal);
}
}
// ---------------------------------------------------------------------
// Street grid. Segments stop at intersection squares.
// ---------------------------------------------------------------------
const roadX = [-21, -7, 7, 21];
const roadZ = [-15, 0, 15];
const roadHalf = 1.7;
const walkHalf = 2.4;
function dashedHorizontal(x1, x2, z) {
for (let x = x1 + 1; x < x2 - 1; x += 2.4) {
box(0.95, 0.025, 0.12, x, 0.355, z, M.yellow, scene, false);
}
}
function dashedVertical(z1, z2, x) {
for (let z = z1 + 1; z < z2 - 1; z += 2.4) {
box(0.12, 0.025, 0.95, x, 0.355, z, M.yellow, scene, false);
}
}
function buildRoads() {
for (let i = 0; i < roadX.length - 1; i++) {
const x1 = roadX[i];
const x2 = roadX[i + 1];
const length = x2 - x1 - walkHalf * 2;
const center = (x1 + x2) * 0.5;
box(length, 0.14, walkHalf * 2, center, 0.17, 0, M.sidewalk);
box(length + 0.02, 0.08, roadHalf * 2, center, 0.28, 0, M.asphalt);
dashedHorizontal(x1 + walkHalf, x2 - walkHalf, 0);
}
for (let i = 0; i < roadZ.length - 1; i++) {
const z1 = roadZ[i];
const z2 = roadZ[i + 1];
const length = z2 - z1 - walkHalf * 2;
const center = (z1 + z2) * 0.5;
box(walkHalf * 2, 0.14, length, 0, 0.17, center, M.sidewalk);
box(roadHalf * 2, 0.08, length + 0.02, 0, 0.28, center, M.asphalt);
dashedVertical(z1 + walkHalf, z2 - walkHalf, 0);
}
// Sidewalk junctions and asphalt intersection decks.
for (const x of roadX) {
for (const z of roadZ) {
box(walkHalf * 2, 0.14, walkHalf * 2, x, 0.17, z, M.sidewalk);
box(roadHalf * 2, 0.08, roadHalf * 2, x, 0.285, z, M.asphaltDark);
// Small corner blocks make each intersection read as a real node.
const corner = 0.55;
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
box(
corner,
0.025,
0.08,
x + sx * 1.31,
0.35,
z + sz * 1.34,
M.paint,
scene,
false
);
}
}
}
}
}
buildRoads();
// ---------------------------------------------------------------------
// Voxel vegetation
// ---------------------------------------------------------------------
function makeTree(x, z, scale = 1, light = false) {
const tree = groupAt(x, 0.12, z);
tree.scale.setScalar(scale);
box(0.42, 1.55, 0.42, 0, 0.78, 0, M.trunk, tree);
box(2.05, 1.05, 2.05, 0, 1.95, 0, light ? M.leavesLight : M.leaves, tree);
box(1.55, 0.9, 1.55, 0.15, 2.85, -0.08, light ? M.leaves : M.leavesDark, tree);
box(0.9, 0.55, 0.9, -0.2, 3.42, 0.1, M.leavesLight, tree);
return tree;
}
const random = (() => {
let seed = 9137;
return () => {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
};
})();
// ---------------------------------------------------------------------
// Homes
// ---------------------------------------------------------------------
const wallColors = [
material(0xe4c8a4),
material(0xd9b895),
material(0xb8c8b0),
material(0xd9d3bd),
material(0xc8b7c2)
];
const roofColors = [
M.roof,
M.roofBlue,
M.roofGreen,
material(0x86675d)
];
function makeHouse(x, z, w, d, h, index, name) {
const group = groupAt(x, 0, z);
const wallMat = wallColors[index % wallColors.length];
const roofMat = roofColors[index % roofColors.length];
box(w + 0.25, 0.15, d + 0.25, 0, 0.195, 0, M.sidewalkEdge, group);
box(w, h, d, 0, 0.27 + h * 0.5, 0, wallMat, group);
// Stepped, entirely block-built roof.
box(w + 0.35, 0.42, d + 0.35, 0, 0.27 + h + 0.21, 0, roofMat, group);
box(
Math.max(0.8, w - 0.65),
0.34,
Math.max(0.8, d - 0.65),
0,
0.27 + h + 0.59,
0,
roofMat,
group
);
const windowY = 0.27 + h * 0.56;
for (const wx of [-w * 0.28, w * 0.28]) {
box(0.72, 0.72, 0.07, wx, windowY, d * 0.5 + 0.035, M.window, group);
box(0.82, 0.09, 0.11, wx, windowY, d * 0.5 + 0.075, M.cream, group);
}
box(0.78, 1.35, 0.09, 0, 0.945, d * 0.5 + 0.05, index % 3 === 0 ? M.teal : M.coral, group);
box(0.18, 1.8, 0.18, w * 0.3, 0.27 + h + 0.8, -d * 0.2, M.sidewalkEdge, group);
// Small front path and planting.
box(0.7, 0.045, 1.35, 0, 0.145, d * 0.5 + 0.65, M.sidewalk, group, false);
box(1.15, 0.18, 0.8, -w * 0.43, 0.24, d * 0.5 + 0.65, M.grassDark, group);
addInfo(
group,
"Residential",
name,
"A compact voxel home within Juniper Commons. Click nearby streets to inspect how the cycle network connects to the block."
);
return group;
}
const homes = [
[-14, -20.2, 3.5, 3.2, 2.5],
[-7, -20.5, 3.4, 3.0, 2.8],
[2, -20.2, 3.7, 3.3, 2.5],
[23.7, -20.1, 3.2, 3.0, 2.6],
[-25, -7, 3.4, 3.5, 2.5],
[-25, 8, 3.5, 3.4, 2.7],
[25, -8, 3.4, 3.5, 2.5],
[25, 8.5, 3.4, 3.3, 2.7],
[-15.5, -8.2, 3.8, 3.4, 2.6],
[-10.6, -9.4, 3.3, 3.2, 2.8],
[-2.2, -8.0, 3.6, 3.4, 2.5],
[2.1, -10.1, 3.3, 3.2, 2.7],
[11.2, 7.4, 3.5, 3.3, 2.5],
[16.3, 6.3, 3.7, 3.5, 2.8],
[13.2, 11.2, 3.3, 3.2, 2.4],
[-15.2, 20.1, 3.5, 3.3, 2.6],
[-7.2, 20.4, 3.6, 3.2, 2.8],
[3.8, 20.2, 3.4, 3.3, 2.5],
[12.0, 20.3, 3.7, 3.4, 2.7],
[25.0, 19.4, 3.2, 3.1, 2.5],
[-25.1, 19.5, 3.3, 3.1, 2.6]
];
homes.forEach((home, index) => {
makeHouse(
...home,
index,
[
"Willow Cottage",
"Juniper House",
"Cedar Corner",
"Mossbank Home",
"Linden Row",
"The Teal Door",
"Orchard Cottage",
"Maple Steps"
][index % 8]
);
});
// ---------------------------------------------------------------------
// School
// ---------------------------------------------------------------------
const school = groupAt(13, 0, -8);
box(10.5, 0.16, 6.2, 0, 0.2, 0, M.sidewalkEdge, school);
box(8.4, 3.0, 4.7, -0.7, 1.88, 0, M.school, school);
box(3.3, 2.35, 3.6, 3.0, 1.55, 0.25, M.cream, school);
box(9.0, 0.42, 5.2, -0.7, 3.58, 0, M.schoolRoof, school);
box(7.3, 0.38, 4.2, -0.7, 3.98, 0, M.schoolRoof, school);
box(3.7, 0.4, 3.9, 3.0, 2.93, 0.25, M.schoolRoof, school);
for (let i = 0; i < 5; i++) {
box(0.9, 0.95, 0.07, -3.55 + i * 1.42, 2.15, 2.39, M.schoolGlass, school);
box(0.98, 0.08, 0.1, -3.55 + i * 1.42, 2.15, 2.45, M.cream, school);
}
box(1.35, 1.65, 0.09, 0.7, 1.08, 2.4, M.teal, school);
box(0.55, 0.55, 0.09, 0.7, 2.25, 2.45, M.schoolGlass, school);
// School yard and a compact marked court.
box(7.6, 0.055, 2.0, -0.2, 0.16, 3.8, M.grassLight, school, false);
box(4.4, 0.055, 2.7, 1.5, 0.16, -4.15, M.asphaltDark, school, false);
for (const x of [-0.7, 3.7]) {
box(0.08, 0.03, 2.45, x, 0.21, -4.15, M.paint, school, false);
}
box(4.15, 0.03, 0.08, 1.5, 0.21, -4.15, M.paint, school, false);
// Flag pole.
box(0.12, 4.2, 0.12, -5.0, 2.2, 0.3, M.cream, school);
box(1.2, 0.65, 0.06, -4.4, 3.65, 0.3, M.coral, school);
addInfo(
school,
"Civic destination",
"Juniper Primary School",
"The Cedar Spine reaches the school through a marked crossing over Juniper Street. The raised deck, edge markings, ramps, and bollards identify a genuine street crossing."
);
// ---------------------------------------------------------------------
// Park
// ---------------------------------------------------------------------
const park = groupAt(-14, 0, 7.5);
box(10.3, 0.09, 10.3, 0, 0.155, 0, M.grassLight, park, false);
box(1.25, 0.07, 10.0, 0, 0.225, 0, M.sidewalk, park, false);
box(9.8, 0.07, 1.15, 0, 0.225, 0, M.sidewalk, park, false);
// Pond with a voxel border.
box(3.35, 0.13, 2.65, -2.55, 0.25, -1.35, M.sidewalkEdge, park);
box(2.95, 0.15, 2.25, -2.55, 0.31, -1.35, M.water, park);
// Play structure.
box(2.2, 0.25, 1.8, 2.45, 0.3, 2.1, M.teal, park);
box(0.25, 1.75, 0.25, 1.65, 1.18, 2.1, M.yellow, park);
box(0.25, 1.75, 0.25, 3.25, 1.18, 2.1, M.yellow, park);
box(1.9, 0.22, 0.25, 2.45, 1.98, 2.1, M.coral, park);
box(1.1, 0.2, 1.6, 2.45, 0.47, 2.05, M.coral, park);
// Swing set.
for (const x of [-0.3, 2.0]) {
box(0.16, 1.8, 0.16, x, 1.12, -2.7, M.dark, park);
}
box(2.55, 0.16, 0.16, 0.85, 1.95, -2.7, M.dark, park);
for (const x of [0.55, 1.25]) {
box(0.05, 1.15, 0.05, x, 1.38, -2.7, M.cream, park);
box(0.55, 0.12, 0.28, x, 0.83, -2.7, M.coral, park);
}
const parkTrees = [
[-4.15, -3.8, 1.0],
[-3.8, 3.7, 0.85],
[-0.2, 3.9, 1.05],
[3.9, 3.5, 0.92],
[4.1, -3.2, 1.1],
[3.3, -0.2, 0.72]
];
parkTrees.forEach(([x, z, s], index) => {
const tree = makeTree(x, z, s, index % 2 === 0);
park.add(tree);
});
addInfo(
park,
"Public green space",
"Oak Pocket Park",
"A shaded neighborhood park with a pond, play structure, swings, and a direct connection to the Cedar Spine. The cycle access enters from the south edge of the block."
);
// ---------------------------------------------------------------------
// Small cycle hub / community pavilion
// ---------------------------------------------------------------------
const cycleHub = groupAt(0.2, 0, 8.2);
box(5.2, 0.15, 4.1, 0, 0.21, 0, M.sidewalkEdge, cycleHub);
box(4.4, 2.35, 3.4, 0, 1.52, 0, M.cream, cycleHub);
box(4.9, 0.4, 3.9, 0, 2.9, 0, M.coral, cycleHub);
box(3.7, 0.34, 2.9, 0, 3.25, 0, M.coral, cycleHub);
box(1.1, 1.45, 0.08, -0.7, 0.98, 1.74, M.teal, cycleHub);
box(0.75, 0.72, 0.08, 1.1, 1.83, 1.74, M.window, cycleHub);
// Voxel bike racks.
for (let i = 0; i < 4; i++) {
const x = -1.8 + i * 1.05;
box(0.09, 0.85, 0.09, x, 0.66, 2.35, M.dark, cycleHub);
box(0.09, 0.85, 0.09, x, 0.66, 2.7, M.dark, cycleHub);
box(0.09, 0.09, 0.44, x, 1.05, 2.52, M.dark, cycleHub);
}
addInfo(
cycleHub,
"Cycle facility",
"Juniper Cycle Hub",
"A neighborhood workshop and covered bike rack beside the central cycle junction. It anchors the southern part of the Cedar Spine."
);
// ---------------------------------------------------------------------
// Street trees, lamps, fences, and small block details
// ---------------------------------------------------------------------
const streetTreePositions = [
[-23.7, -10], [-23.7, 4], [-23.7, 11],
[23.7, -4], [23.7, 3], [23.7, 12],
[-18, -18], [-11, -18], [-3, -18], [4, -18], [11, -18],
[-17, 18], [-10, 18], [4, 18], [17, 18],
[-18.7, -3.2], [-18.7, 3.3],
[18.7, -4.2], [18.7, 4.4], [18.7, 10]
];
streetTreePositions.forEach(([x, z], index) => {
makeTree(x, z, 0.62 + (index % 3) * 0.08, index % 2 === 0);
});
function makeStreetLamp(x, z, rotation = 0) {
const lamp = groupAt(x, 0.12, z);
lamp.rotation.y = rotation;
box(0.13, 3.1, 0.13, 0, 1.55, 0, M.dark, lamp);
box(0.85, 0.13, 0.13, 0.35, 3.0, 0, M.dark, lamp);
box(0.5, 0.15, 0.38, 0.72, 2.88, 0, M.yellow, lamp);
}
[
[-23, -12.5, 0],
[-18.7, -2.3, Math.PI / 2],
[-9.2, 3, 0],
[5.2, 3, 0],
[9.2, -3.3, Math.PI / 2],
[18.7, 3.3, Math.PI / 2],
[23.5, -10.5, 0],
[-14, 17, 0],
[15, 17, 0]
].forEach(([x, z, r]) => makeStreetLamp(x, z, r));
function fenceSegment(x, z, w, d) {
box(w, 0.08, 0.08, x, 0.75, z, M.fence);
box(w, 0.08, 0.08, x, 0.35, z, M.fence);
const count = Math.max(2, Math.ceil(Math.max(w, d) / 0.8));
for (let i = 0; i <= count; i++) {
const t = i / count - 0.5;
box(0.09, 0.85, 0.09, x + (w > d ? t * w : 0), 0.53, z + (d > w ? t * d : 0), M.fence);
}
}
fenceSegment(13, -3.0, 8.8, 0);
fenceSegment(13, 6.8, 7.4, 0);
fenceSegment(17.2, 4.9, 0, 3.8);
// Small planted community garden.
box(4.6, 0.1, 3.2, -0.5, 0.19, 4.9, M.grassDark, scene, false);
for (let row = 0; row < 3; row++) {
box(3.7, 0.18, 0.48, -0.5, 0.29, 3.9 + row * 0.82, M.trunk);
box(3.4, 0.12, 0.28, -0.5, 0.44, 3.9 + row * 0.82, M.grassLight);
}
// ---------------------------------------------------------------------
// Cycling network
// ---------------------------------------------------------------------
function routeSegmentX(x1, x2, z, colorMat) {
const length = x2 - x1;
if (length <= 0) return;
box(length, 0.055, 0.9, (x1 + x2) * 0.5, 0.375, z, colorMat, routeGroup);
for (let x = x1 + 1; x < x2 - 0.4; x += 2.6) {
box(0.38, 0.022, 0.07, x, 0.415, z, M.cream, routeGroup, false);
}
}
function routeSegmentZ(z1, z2, x, colorMat) {
const length = z2 - z1;
if (length <= 0) return;
box(0.9, 0.055, length, x, 0.375, (z1 + z2) * 0.5, colorMat, routeGroup);
for (let z = z1 + 1; z < z2 - 0.4; z += 2.6) {
box(0.07, 0.022, 0.38, x, 0.415, z, M.cream, routeGroup, false);
}
}
function makeJunction(x, z, colorMat, title, text) {
const junction = box(1.55, 0.085, 1.55, x, 0.45, z, colorMat, routeGroup);
box(0.55, 0.09, 0.55, x, 0.5, z, M.junction, routeGroup, false);
// Four small pale corner blocks visually define the junction pad.
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
box(
0.24,
0.025,
0.08,
x + sx * 0.55,
0.505,
z + sz * 0.55,
M.cream,
routeGroup,
false
);
}
}
addInfo(
junction,
"Cycle junction",
title,
text
);
return junction;
}
function addCrossing(travelAxis, roadCenter, pathCoordinate, colorMat) {
if (travelAxis === "x") {
// Travel east-west over a north-south street.
box(3.4, 0.06, 0.94, roadCenter, 0.415, pathCoordinate, colorMat, routeGroup);
for (const side of [-1, 1]) {
box(
3.15,
0.028,
0.055,
roadCenter,
0.46,
pathCoordinate + side * 0.37,
M.cream,
crossingGroup,
false
);
}
// Small raised curb ramps.
for (const side of [-1, 1]) {
box(
0.52,
0.12,
1.12,
roadCenter + side * 1.88,
0.3,
pathCoordinate,
M.sidewalk,
routeGroup
);
}
// Direction markers made from small white blocks.
for (const offset of [-0.85, 0.85]) {
box(0.08, 0.025, 0.28, roadCenter + offset, 0.465, pathCoordinate, M.white, crossingGroup, false);
}
} else {
// Travel north-south over an east-west street.
box(0.94, 0.06, 3.4, pathCoordinate, 0.415, roadCenter, colorMat, routeGroup);
for (const side of [-1, 1]) {
box(
0.055,
0.028,
3.15,
pathCoordinate + side * 0.37,
0.46,
roadCenter,
M.cream,
crossingGroup,
false
);
}
for (const side of [-1, 1]) {
box(
1.12,
0.12,
0.52,
pathCoordinate,
0.3,
roadCenter + side * 1.88,
M.sidewalk,
routeGroup
);
}
for (const offset of [-0.85, 0.85]) {
box(0.28, 0.025, 0.08, pathCoordinate, 0.465, roadCenter + offset, M.white, crossingGroup, false);
}
}
// Crossing bollards.
if (travelAxis === "x") {
for (const side of [-1, 1]) {
for (const edge of [-1, 1]) {
box(
0.13,
0.75,
0.13,
roadCenter + side * 1.85,
0.64,
pathCoordinate + edge * 0.58,
M.cream,
routeGroup
);
}
}
} else {
for (const side of [-1, 1]) {
for (const edge of [-1, 1]) {
box(
0.13,
0.75,
0.13,
pathCoordinate + edge * 0.58,
0.64,
roadCenter + side * 1.85,
M.cream,
routeGroup
);
}
}
}
}
// Willow Loop: four broken sides with explicit street-crossing decks.
routeSegmentX(-19.2, -8.7, -13.35, M.teal);
routeSegmentX(-5.3, 5.3, -13.35, M.teal);
routeSegmentX(8.7, 19.2, -13.35, M.teal);
routeSegmentX(-19.2, -8.7, 13.35, M.teal);
routeSegmentX(-5.3, 5.3, 13.35, M.teal);
routeSegmentX(8.7, 19.2, 13.35, M.teal);
routeSegmentZ(-13.35, -1.7, -19.2, M.teal);
routeSegmentZ(1.7, 13.35, -19.2, M.teal);
routeSegmentZ(-13.35, -1.7, 19.2, M.teal);
routeSegmentZ(1.7, 13.35, 19.2, M.teal);
// Cedar Spine: vertical and horizontal connected chords.
routeSegmentZ(-13.35, -1.7, 4.2, M.coral);
routeSegmentZ(1.7, 13.35, 4.2, M.coral);
routeSegmentX(-19.2, -8.7, 1.35, M.coral);
routeSegmentX(-5.3, 5.3, 1.35, M.coral);
routeSegmentX(8.7, 19.2, 1.35, M.coral);
// Physical street crossings.
addCrossing("x", -7, -13.35, M.teal);
addCrossing("x", 7, -13.35, M.teal);
addCrossing("x", -7, 13.35, M.teal);
addCrossing("x", 7, 13.35, M.teal);
addCrossing("z", 0, -19.2, M.teal);
addCrossing("z", 0, 19.2, M.teal);
addCrossing("z", 0, 4.2, M.coral);
addCrossing("x", -7, 1.35, M.coral);
addCrossing("x", 7, 1.35, M.coral);
// School branch: the colored lane is interrupted by a real street crossing.
routeSegmentX(4.2, 5.3, -9.0, M.coral);
addCrossing("x", 7, -9.0, M.coral);
routeSegmentX(8.7, 9.55, -9.0, M.coral);
makeJunction(
4.2,
-9.0,
M.coral,
"School access junction",
"The Cedar Spine turns east here. Its approach stops at the curb ramp, crosses Juniper Street on a marked raised deck, and continues to the school gate."
);
// Park access from the Cedar Spine.
routeSegmentZ(1.35, 2.75, -14.0, M.coral);
box(1.25, 0.045, 1.15, -14, 0.42, 2.6, M.coral, routeGroup, false);
// Explicit cycle junctions where routes meet.
const junctionData = [
[-19.2, -13.35, M.teal, "Willow Loop corner", "A square junction pad turns the protected link around the neighborhood block."],
[19.2, -13.35, M.teal, "Willow Loop corner", "A square junction pad turns the protected link around the neighborhood block."],
[-19.2, 13.35, M.teal, "Willow Loop corner", "A square junction pad turns the protected link around the neighborhood block."],
[19.2, 13.35, M.teal, "Willow Loop corner", "A square junction pad turns the protected link around the neighborhood block."],
[4.2, -13.35, M.coral, "North route junction", "The Cedar Spine joins the Willow Loop here. Both colored links meet on a shared raised junction pad."],
[4.2, 13.35, M.coral, "South route junction", "The Cedar Spine joins the Willow Loop here. Both colored links meet on a shared raised junction pad."],
[-19.2, 1.35, M.coral, "West route junction", "The Cedar Spine joins the western side of the Willow Loop at a marked junction."],
[19.2, 1.35, M.coral, "East route junction", "The Cedar Spine joins the eastern side of the Willow Loop at a marked junction."],
[4.2, 1.35, M.coral, "Central cycle junction", "Two Cedar Spine links meet beside the central intersection. The gold center marks the conflict area for turning cyclists."]
];
junctionData.forEach(([x, z, mat, title, text]) => {
makeJunction(x, z, mat, title, text);
});
// ---------------------------------------------------------------------
// 3D labels made with canvas textures
// ---------------------------------------------------------------------
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
function makeLabel(text, x, y, z, background = "#173d3a") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = background;
roundedRect(ctx, 8, 8, 496, 112, 18);
ctx.fill();
ctx.strokeStyle = "rgba(255,255,255,0.72)";
ctx.lineWidth = 4;
roundedRect(ctx, 10, 10, 492, 108, 16);
ctx.stroke();
ctx.fillStyle = "#fff8df";
ctx.font = "800 42px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 66);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.position.set(x, y, z);
sprite.scale.set(7.4, 1.85, 1);
sprite.renderOrder = 20;
labelsGroup.add(sprite);
return sprite;
}
makeLabel("JUNIPER PRIMARY", 13, 5.5, -8, "#2f7772");
makeLabel("OAK POCKET PARK", -14, 3.3, 7.5, "#547d57");
makeLabel("CYCLE HUB", 0.2, 4.65, 8.2, "#b55742");
// ---------------------------------------------------------------------
// Animated voxel cyclists
// ---------------------------------------------------------------------
function createCyclist(path, colorMat, speed, offset, closed = false) {
const cyclist = groupAt(0, 0.46, 0);
// Local forward direction is +Z.
box(0.24, 0.24, 0.13, 0, 0.16, 0.48, M.black, cyclist);
box(0.24, 0.24, 0.13, 0, 0.16, -0.48, M.black, cyclist);
box(0.16, 0.16, 0.55, 0, 0.38, 0, M.dark, cyclist);
box(0.36, 0.42, 0.28, 0, 0.68, -0.02, colorMat, cyclist);
box(0.29, 0.29, 0.29, 0, 1.02, 0.02, M.cream, cyclist);
box(0.33, 0.13, 0.35, 0, 1.19, 0.02, colorMat, cyclist);
box(0.12, 0.12, 0.5, 0, 0.82, 0.3, M.cream, cyclist);
scene.add(cyclist);
const segments = [];
let total = 0;
for (let i = 0; i < path.length - 1; i++) {
const [x1, z1] = path[i];
const [x2, z2] = path[i + 1];
const length = Math.hypot(x2 - x1, z2 - z1);
segments.push({ x1, z1, x2, z2, length, start: total });
total += length;
}
cyclists.push({
object: cyclist,
path,
segments,
total,
speed,
distance: offset,
closed
});
}
createCyclist(
[
[-19.2, -13.35],
[19.2, -13.35],
[19.2, 13.35],
[-19.2, 13.35]
],
M.tealBike,
1.55,
0,
true
);
createCyclist(
[
[4.2, -13.35],
[4.2, 13.35]
],
M.coralBike,
1.25,
3.5
);
createCyclist(
[
[-19.2, 1.35],
[19.2, 1.35]
],
M.goldBike,
1.05,
8
);
function updateCyclists(delta) {
for (const cyclist of cyclists) {
cyclist.distance += cyclist.speed * delta;
let d;
if (cyclist.closed) {
d = cyclist.distance % cyclist.total;
} else {
const period = cyclist.total * 2;
const p = cyclist.distance % period;
d = p <= cyclist.total ? p : period - p;
}
let segment = cyclist.segments[cyclist.segments.length - 1];
for (const candidate of cyclist.segments) {
if (d <= candidate.start + candidate.length) {
segment = candidate;
break;
}
}
const local = Math.max(0, Math.min(1, (d - segment.start) / segment.length));
const x = THREE.MathUtils.lerp(segment.x1, segment.x2, local);
const z = THREE.MathUtils.lerp(segment.z1, segment.z2, local);
cyclist.object.position.set(x, 0.46, z);
cyclist.object.rotation.y = Math.atan2(
segment.x2 - segment.x1,
segment.z2 - segment.z1
);
}
}
// ---------------------------------------------------------------------
// Direct camera controls: orbit, pan, zoom, keyboard
// ---------------------------------------------------------------------
const target = new THREE.Vector3(0, 0, 0);
let cameraTheta = 0.72;
let cameraPhi = 0.70;
let cameraZoom = 1;
let cameraSpan = 43;
function updateCamera() {
const radius = 68;
camera.position.set(
target.x + radius * Math.sin(cameraPhi) * Math.sin(cameraTheta),
target.y + radius * Math.cos(cameraPhi),
target.z + radius * Math.sin(cameraPhi) * Math.cos(cameraTheta)
);
camera.lookAt(target);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
cameraSpan = Math.max(43, 66 / aspect);
camera.left = (-cameraSpan * aspect) / 2;
camera.right = (cameraSpan * aspect) / 2;
camera.top = cameraSpan / 2;
camera.bottom = -cameraSpan / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", resize);
resize();
let drag = null;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function setPointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pick(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickables, true);
return hits.length ? infoFromObject(hits[0].object) : null;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
drag = {
x: event.clientX,
y: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
moved: false,
pan: event.shiftKey || event.button === 2
};
tooltip.hidden = true;
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (drag) {
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
if (Math.abs(event.clientX - drag.x) + Math.abs(event.clientY - drag.y) > 4) {
drag.moved = true;
}
if (drag.pan) {
const scale = cameraSpan / (cameraZoom * window.innerHeight);
const right = new THREE.Vector3(
Math.cos(cameraTheta),
0,
-Math.sin(cameraTheta)
);
const forward = new THREE.Vector3(
-Math.sin(cameraTheta),
0,
-Math.cos(cameraTheta)
);
target.addScaledVector(right, -dx * scale);
target.addScaledVector(forward, dy * scale);
target.x = THREE.MathUtils.clamp(target.x, -23, 23);
target.z = THREE.MathUtils.clamp(target.z, -20, 20);
} else {
cameraTheta -= dx * 0.006;
cameraPhi = THREE.MathUtils.clamp(cameraPhi + dy * 0.005, 0.12, 1.32);
}
drag.lastX = event.clientX;
drag.lastY = event.clientY;
updateCamera();
return;
}
if (event.pointerType === "touch") return;
const info = pick(event);
if (info) {
tooltip.innerHTML = `<strong>${info.title}</strong>${info.kicker}`;
tooltip.style.left = `${Math.min(event.clientX + 15, window.innerWidth - 245)}px`;
tooltip.style.top = `${Math.max(12, event.clientY - 52)}px`;
tooltip.hidden = false;
renderer.domElement.style.cursor = "pointer";
} else {
tooltip.hidden = true;
renderer.domElement.style.cursor = "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (drag && !drag.moved) {
const info = pick(event);
if (info) {
document.getElementById("selection-kicker").textContent = info.kicker;
document.getElementById("selection-title").textContent = info.title;
document.getElementById("selection-text").textContent = info.text;
}
}
drag = null;
});
renderer.domElement.addEventListener("pointercancel", () => {
drag = null;
});
renderer.domElement.addEventListener("pointerleave", () => {
if (!drag) tooltip.hidden = true;
});
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.001),
0.62,
2.45
);
updateCamera();
},
{ passive: false }
);
function resetView() {
target.set(0, 0, 0);
cameraTheta = 0.72;
cameraPhi = 0.70;
cameraZoom = 1;
updateCamera();
}
function focusOn(place) {
if (place === "school") {
target.set(12, 0, -7);
cameraTheta = 0.84;
cameraPhi = 0.64;
cameraZoom = 1.65;
} else if (place === "park") {
target.set(-14, 0, 7.5);
cameraTheta = 0.55;
cameraPhi = 0.66;
cameraZoom = 1.65;
}
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetView);
document.getElementById("view-iso").addEventListener("click", resetView);
document.getElementById("view-plan").addEventListener("click", () => {
target.set(0, 0, 0);
cameraTheta = 0;
cameraPhi = 0.06;
cameraZoom = 1;
updateCamera();
});
document.querySelectorAll("[data-focus]").forEach((button) => {
button.addEventListener("click", () => focusOn(button.dataset.focus));
});
document.getElementById("toggle-routes").addEventListener("change", (event) => {
routeGroup.visible = event.target.checked;
});
document.getElementById("toggle-crossings").addEventListener("change", (event) => {
crossingGroup.visible = event.target.checked;
});
document.getElementById("toggle-labels").addEventListener("change", (event) => {
labelsGroup.visible = event.target.checked;
});
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetView();
if (event.key.toLowerCase() === "t") {
target.set(0, 0, 0);
cameraTheta = 0;
cameraPhi = 0.06;
cameraZoom = 1;
updateCamera();
}
if (event.key === "+" || event.key === "=") {
cameraZoom = Math.min(2.45, cameraZoom * 1.12);
updateCamera();
}
if (event.key === "-") {
cameraZoom = Math.max(0.62, cameraZoom / 1.12);
updateCamera();
}
});
// ---------------------------------------------------------------------
// Render loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
let firstFrame = true;
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
updateCyclists(delta);
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
document.getElementById("loader").classList.add("hide");
}
});
</script>
</body>
</html>
```