Prompt specification
Build or customize the Three.js 3D scene "Comuna 13 hillside access slice" 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: Comuna 13 hillside access slice
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/comuna-13-hillside-access-slice-x2751
Scene Description Prompt:
I'd like to see this as a low-poly Three.js scene: Comuna 13 hillside access slice. Build a bounded low-poly scene with referenced stacked housing, public circulation links, and original mural surfaces. Keep the terrain and access network legible beneath the architectural density. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (comuna-13-hillside-access-slice-x2751):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Comuna 13 — Hillside Access Slice</title>
<style>
:root {
--ink: #183334;
--paper: rgba(250, 248, 239, 0.92);
--line: rgba(24, 51, 52, 0.16);
--accent: #e75f42;
--gold: #efbd3b;
--teal: #238b82;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7e9e2;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 5;
background: var(--paper);
border: 1px solid rgba(255,255,255,0.75);
box-shadow: 0 12px 35px rgba(31, 49, 48, 0.12);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.title-panel {
top: 22px;
left: 22px;
width: min(380px, calc(100vw - 44px));
padding: 19px 21px 17px;
border-radius: 4px 20px 4px 4px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 24px;
height: 3px;
background: var(--accent);
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 40px);
line-height: 0.98;
letter-spacing: -0.055em;
text-transform: uppercase;
}
.subtitle {
max-width: 320px;
margin: 11px 0 0;
color: rgba(24, 51, 52, 0.72);
font-size: 12px;
line-height: 1.5;
}
.view-panel {
top: 22px;
right: 22px;
padding: 7px;
border-radius: 14px 4px 4px 14px;
}
.view-label {
padding: 5px 8px 7px;
color: rgba(24, 51, 52, 0.58);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.views {
display: flex;
gap: 4px;
}
.views button {
border: 0;
border-radius: 8px;
padding: 9px 11px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.views button:hover {
background: rgba(35, 139, 130, 0.09);
transform: translateY(-1px);
}
.views button.active {
background: var(--ink);
color: #fffaf0;
}
.legend {
right: 22px;
bottom: 22px;
min-width: 205px;
padding: 14px 16px 13px;
border-radius: 4px 4px 14px 4px;
}
.legend-title {
margin-bottom: 10px;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 12px 1fr;
align-items: center;
gap: 9px;
margin: 8px 0;
color: rgba(24, 51, 52, 0.76);
font-size: 11px;
}
.swatch {
width: 11px;
height: 11px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.help {
left: 22px;
bottom: 22px;
max-width: 330px;
padding: 11px 14px;
border-radius: 4px 12px 4px 4px;
color: rgba(24, 51, 52, 0.68);
font-size: 10px;
line-height: 1.45;
}
.help strong { color: var(--ink); }
.caption {
position: fixed;
z-index: 4;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
padding: 8px 12px;
border-radius: 20px;
background: rgba(24, 51, 52, 0.82);
color: rgba(255,255,255,0.82);
font-size: 9px;
letter-spacing: 0.09em;
text-transform: uppercase;
pointer-events: none;
}
.tooltip {
position: fixed;
z-index: 10;
width: min(285px, calc(100vw - 32px));
padding: 15px 16px;
border-radius: 4px 14px 4px 4px;
background: var(--ink);
color: #fffaf0;
box-shadow: 0 12px 30px rgba(0,0,0,0.2);
opacity: 0;
pointer-events: none;
transform: translateY(5px);
transition: opacity 160ms ease, transform 160ms ease;
}
.tooltip.visible {
opacity: 1;
transform: translateY(0);
}
.tooltip h2 {
margin: 0 0 5px;
font-size: 13px;
letter-spacing: 0.02em;
}
.tooltip p {
margin: 0;
color: rgba(255,255,255,0.68);
font-size: 11px;
line-height: 1.45;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #e7e9e2;
color: var(--ink);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.title-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 17px;
}
.subtitle { display: none; }
.view-panel {
top: auto;
right: 12px;
bottom: 66px;
padding: 5px;
}
.view-label { display: none; }
.views button {
padding: 8px 9px;
font-size: 10px;
}
.legend { display: none; }
.help {
left: 12px;
bottom: 12px;
max-width: calc(100vw - 24px);
}
.caption { display: none; }
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="panel title-panel">
<div class="eyebrow">Hillside access slice</div>
<h1>Comuna 13</h1>
<p class="subtitle">
A low-poly spatial interpretation of stacked hillside homes, public circulation,
elevated terraces, and an original community mural route.
</p>
</header>
<nav class="panel view-panel" aria-label="Camera views">
<div class="view-label">Study views</div>
<div class="views">
<button class="active" data-view="overview">Overview</button>
<button data-view="access">Access</button>
<button data-view="housing">Housing</button>
<button data-view="art">Murals</button>
</div>
</nav>
<div class="panel legend">
<div class="legend-title">Spatial key</div>
<div class="legend-row"><span class="swatch" style="background:#e66550"></span>Stacked housing</div>
<div class="legend-row"><span class="swatch" style="background:#efbd3b"></span>Public circulation</div>
<div class="legend-row"><span class="swatch" style="background:#258b82"></span>Mural surfaces</div>
<div class="legend-row"><span class="swatch" style="background:#7f8d68"></span>Terraced terrain</div>
</div>
<div class="panel help">
<strong>Drag</strong> to orbit · <strong>Shift-drag / right-drag</strong> to pan ·
<strong>Scroll / pinch</strong> to zoom · <strong>Double-click</strong> to reset
</div>
<div class="caption">Original procedural interpretation · not an exact survey</div>
<div id="tooltip" class="tooltip"></div>
<div id="loading">Building hillside slice…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const tooltip = document.getElementById("tooltip");
const loading = document.getElementById("loading");
const renderer = new THREE.WebGLRenderer({
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.08;
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7e9e2);
scene.fog = new THREE.Fog(0xe7e9e2, 82, 150);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
220
);
const world = new THREE.Group();
const terrainGroup = new THREE.Group();
const architectureGroup = new THREE.Group();
const circulationGroup = new THREE.Group();
const muralGroup = new THREE.Group();
const landscapeGroup = new THREE.Group();
const detailGroup = new THREE.Group();
world.add(terrainGroup, architectureGroup, circulationGroup, muralGroup, landscapeGroup, detailGroup);
scene.add(world);
const hemi = new THREE.HemisphereLight(0xfff8df, 0x52645c, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1cd, 3.3);
sun.position.set(-24, 42, 28);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -42;
sun.shadow.camera.right = 42;
sun.shadow.camera.top = 42;
sun.shadow.camera.bottom = -42;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 105;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9acac8, 0.7);
fill.position.set(28, 18, -28);
scene.add(fill);
let seed = 13013;
function random() {
seed |= 0;
seed = seed + 0x6D2B79F5 | 0;
let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
const between = (a, b) => a + (b - a) * random();
const pick = list => list[Math.floor(random() * list.length)];
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.86,
metalness: 0.02,
flatShading: true,
...options
}));
}
return materialCache.get(key);
}
function box(parent, w, h, d, x, y, z, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
typeof color === "string" || typeof color === "number"
? material(color, options)
: color
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function beamBetween(parent, a, b, thickness, color, options = {}) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(thickness, thickness, length),
typeof color === "string" || typeof color === "number"
? material(color, options)
: color
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 0, 1),
direction.clone().normalize()
);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
function makeMuralTexture(style) {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 512;
const ctx = canvas.getContext("2d");
const palettes = [
["#103c43", "#f0bd35", "#ef6548", "#f3e5c4", "#258b82"],
["#f4dfbd", "#2f7d72", "#e85d46", "#e7ad32", "#173f43"],
["#1c4950", "#e76e51", "#f3c44e", "#f4ead5", "#3c9b8b"],
["#f2dfb6", "#d8523f", "#1e7370", "#153b42", "#e8ad32"]
];
const pal = palettes[style % palettes.length];
ctx.fillStyle = pal[0];
ctx.fillRect(0, 0, 512, 512);
if (style === 0) {
ctx.fillStyle = pal[1];
ctx.beginPath();
ctx.arc(375, 130, 86, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = pal[2];
ctx.beginPath();
ctx.moveTo(0, 380);
ctx.lineTo(130, 190);
ctx.lineTo(250, 350);
ctx.lineTo(360, 235);
ctx.lineTo(512, 390);
ctx.lineTo(512, 512);
ctx.lineTo(0, 512);
ctx.closePath();
ctx.fill();
ctx.strokeStyle = pal[3];
ctx.lineWidth = 14;
ctx.beginPath();
ctx.moveTo(45, 420);
ctx.bezierCurveTo(140, 310, 225, 465, 330, 345);
ctx.bezierCurveTo(400, 265, 445, 350, 495, 305);
ctx.stroke();
ctx.fillStyle = pal[4];
for (let i = 0; i < 18; i++) {
ctx.fillRect(40 + i * 25, 55 + (i % 3) * 27, 10, 10);
}
} else if (style === 1) {
ctx.fillStyle = pal[1];
ctx.beginPath();
ctx.moveTo(245, 512);
ctx.bezierCurveTo(180, 375, 240, 255, 262, 40);
ctx.bezierCurveTo(295, 220, 325, 355, 278, 512);
ctx.fill();
for (let i = 0; i < 11; i++) {
const x = 95 + i * 30;
const y = 115 + (i % 4) * 63;
const flip = i % 2 ? -1 : 1;
ctx.fillStyle = pal[(i % 3) + 2];
ctx.beginPath();
ctx.ellipse(x, y, 31, 65, flip * 0.62, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = pal[0];
ctx.lineWidth = 6;
ctx.beginPath();
ctx.moveTo(x, y + 45);
ctx.lineTo(x + flip * 22, y - 35);
ctx.stroke();
}
} else if (style === 2) {
ctx.fillStyle = pal[3];
ctx.fillRect(24, 24, 464, 464);
ctx.strokeStyle = pal[1];
ctx.lineWidth = 22;
ctx.lineCap = "round";
const figures = [
[115, 225, pal[2]],
[265, 175, pal[4]],
[400, 245, pal[1]]
];
figures.forEach(([x, y, color], index) => {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x, y - 70, 29, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = color;
ctx.lineWidth = 22;
ctx.beginPath();
ctx.moveTo(x, y - 38);
ctx.lineTo(x + (index - 1) * 20, y + 42);
ctx.moveTo(x, y - 18);
ctx.lineTo(x - 55, y + 28);
ctx.moveTo(x, y - 18);
ctx.lineTo(x + 62, y - 2);
ctx.moveTo(x, y + 42);
ctx.lineTo(x - 38, y + 115);
ctx.moveTo(x, y + 42);
ctx.lineTo(x + 40, y + 112);
ctx.stroke();
});
ctx.strokeStyle = pal[2];
ctx.lineWidth = 8;
ctx.beginPath();
ctx.arc(256, 256, 190, 0, Math.PI * 2);
ctx.stroke();
} else {
ctx.fillStyle = pal[3];
ctx.fillRect(28, 28, 456, 456);
ctx.fillStyle = pal[1];
ctx.fillRect(48, 48, 205, 205);
ctx.fillStyle = pal[4];
ctx.fillRect(259, 48, 205, 205);
ctx.fillStyle = pal[2];
ctx.fillRect(48, 259, 205, 205);
ctx.fillStyle = pal[1];
ctx.fillRect(259, 259, 205, 205);
ctx.fillStyle = pal[0];
ctx.font = "900 178px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("13", 256, 262);
ctx.strokeStyle = pal[3];
ctx.lineWidth = 12;
ctx.strokeRect(52, 52, 408, 408);
}
ctx.strokeStyle = "rgba(255,255,255,0.18)";
ctx.lineWidth = 3;
for (let i = 0; i < 24; i++) {
ctx.beginPath();
ctx.moveTo(random() * 512, 0);
ctx.lineTo(random() * 512, 512);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
const muralTextures = [0, 1, 2, 3].map(makeMuralTexture);
function addMural(parent, x, y, z, w, h, style, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
box(group, w + 0.16, h + 0.16, 0.08, 0, 0, -0.045, 0x183b3e);
const mural = new THREE.Mesh(
new THREE.PlaneGeometry(w, h),
new THREE.MeshStandardMaterial({
map: muralTextures[style % muralTextures.length],
roughness: 0.94,
metalness: 0,
side: THREE.DoubleSide
})
);
mural.position.z = 0.005;
mural.receiveShadow = true;
group.add(mural);
parent.add(group);
return group;
}
// Neutral studio floor, separate from the bounded geographic diorama.
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(180, 180),
material(0xe7e9e2, { roughness: 1, castShadow: false })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.48;
floor.receiveShadow = true;
scene.add(floor);
// Bounded base plinth.
box(terrainGroup, 48, 2.2, 38, 0, -1.3, 0, 0x675a47);
box(terrainGroup, 48.5, 0.32, 38.5, 0, -2.28, 0, 0x3e4a42);
box(terrainGroup, 47.8, 0.22, 37.8, 0, -0.12, 0, 0x59694e);
const levels = [
{ y: 0.0, z: 13, depth: 10 },
{ y: 2.8, z: 3, depth: 10 },
{ y: 5.6, z: -7, depth: 10 },
{ y: 8.2, z: -15, depth: 6 }
];
levels.forEach((level, i) => {
const bottom = -0.2;
const wallHeight = level.y - bottom;
box(
terrainGroup,
47.4,
wallHeight,
level.depth,
0,
bottom + wallHeight / 2,
level.z,
i === 0 ? 0x7f8b60 : 0x8b7658
);
box(
terrainGroup,
47.55,
0.18,
level.depth + 0.06,
0,
level.y - 0.09,
level.z,
i === 3 ? 0x829067 : 0x75845f
);
});
// Low-poly rock facets along the cut edges.
for (let i = 0; i < 24; i++) {
const side = i % 2 === 0 ? -1 : 1;
const z = between(-17.5, 17.5);
const rock = new THREE.Mesh(
new THREE.IcosahedronGeometry(between(0.45, 1.15), 0),
material(pick([0x8a7658, 0x76664d, 0x9b8766]))
);
rock.position.set(side * between(23.2, 23.8), between(-1.6, -0.35), z);
rock.scale.set(between(0.7, 1.25), between(0.55, 1.2), between(0.8, 1.5));
rock.rotation.set(random(), random(), random());
rock.castShadow = true;
terrainGroup.add(rock);
}
// Horizontal public paths on each terrace.
const pathZ = [7.0, -3.15, -12.7];
pathZ.forEach((z, i) => {
const y = levels[i + 1].y;
box(circulationGroup, 44.8, 0.10, 1.30, 0, y + 0.055, z, 0xd7c8a8);
box(circulationGroup, 44.8, 0.025, 0.13, 0, y + 0.12, z + 0.42, 0xefbd3b);
});
function addStairs(start, end, width, steps, stairColor, options = {}) {
const group = new THREE.Group();
group.position.set(...start);
const dx = end[0] - start[0];
const dz = end[2] - start[2];
const length = Math.hypot(dx, dz);
const rise = (end[1] - start[1]) / steps;
const run = length / steps;
group.rotation.y = Math.atan2(dx, dz);
for (let i = 0; i < steps; i++) {
const top = (i + 1) * rise;
const z = (i + 0.5) * run;
box(group, width, 0.16, run + 0.045, 0, top - 0.08, z, stairColor);
box(group, width, rise + 0.12, 0.10, 0, top - rise / 2, i * run + 0.03, 0xb8aa8c);
}
[-1, 1].forEach(side => {
const x = side * (width / 2 - 0.08);
beamBetween(group, [x, -0.08, 0], [x, end[1] - start[1] - 0.08, length], 0.18, 0xa9987b);
});
if (options.rails !== false) {
[-1, 1].forEach(side => {
const x = side * (width / 2 + 0.04);
for (let i = 0; i <= steps; i += 3) {
const z = Math.min(i * run, length);
const y = Math.min(i * rise, end[1] - start[1]);
box(group, 0.055, 0.78, 0.055, x, y + 0.46, z, 0x31575a);
}
beamBetween(
group,
[x, 0.82, 0],
[x, end[1] - start[1] + 0.82, length],
0.065,
0x31575a
);
});
}
circulationGroup.add(group);
return group;
}
function addEscalator(start, end, width, steps) {
const group = new THREE.Group();
group.position.set(...start);
const dx = end[0] - start[0];
const dz = end[2] - start[2];
const length = Math.hypot(dx, dz);
const rise = (end[1] - start[1]) / steps;
const run = length / steps;
group.rotation.y = Math.atan2(dx, dz);
for (let i = 0; i < steps; i++) {
const y = (i + 1) * rise;
const z = (i + 0.5) * run;
box(group, width, 0.12, run + 0.025, 0, y - 0.06, z, 0x40585a);
box(group, width - 0.08, 0.025, 0.055, 0, y + 0.012, z + run * 0.30, 0xe9b93c);
}
[-1, 1].forEach(side => {
const x = side * (width / 2 + 0.10);
beamBetween(group, [x, -0.15, 0], [x, end[1] - start[1] - 0.15, length], 0.25, 0x24484b);
const sidePanel = new THREE.Mesh(
new THREE.PlaneGeometry(length, 0.78),
new THREE.MeshStandardMaterial({
color: 0x7fb9b3,
transparent: true,
opacity: 0.26,
roughness: 0.5,
metalness: 0,
side: THREE.DoubleSide,
depthWrite: false
})
);
sidePanel.rotation.y = Math.PI / 2;
sidePanel.rotation.x = -Math.atan2(end[1] - start[1], length);
sidePanel.position.set(x, (end[1] - start[1]) / 2 + 0.45, length / 2);
group.add(sidePanel);
beamBetween(
group,
[x, 0.95, 0],
[x, end[1] - start[1] + 0.95, length],
0.08,
0xe7b83b
);
for (let i = 0; i <= steps; i += 4) {
const z = Math.min(i * run, length);
const y = Math.min(i * rise, end[1] - start[1]);
box(group, 0.045, 0.78, 0.045, x, y + 0.47, z, 0x31575a);
}
});
circulationGroup.add(group);
return group;
}
// Main public stair spine.
addStairs([-1.1, 0.08, 16.7], [-1.1, 2.92, 7.35], 3.5, 13, 0xefd36b);
addStairs([-1.1, 2.92, 6.95], [-1.1, 5.72, -2.75], 3.5, 14, 0xefd36b);
addStairs([-1.1, 5.72, -3.15], [-1.1, 8.32, -12.75], 3.5, 13, 0xefd36b);
// Electric escalator links.
addEscalator([3.65, 0.10, 16.15], [3.65, 2.93, 7.55], 1.25, 17);
addEscalator([4.25, 2.93, 6.55], [4.25, 5.73, -2.75], 1.25, 17);
function addBridge(start, end, width, color = 0xd6c39e) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const length = direction.length();
const deck = new THREE.Mesh(
new THREE.BoxGeometry(length, 0.16, width),
material(color)
);
deck.position.copy(a).add(b).multiplyScalar(0.5);
deck.quaternion.setFromUnitVectors(
new THREE.Vector3(1, 0, 0),
direction.clone().normalize()
);
deck.castShadow = true;
deck.receiveShadow = true;
circulationGroup.add(deck);
const side = new THREE.Vector3(-direction.z, 0, direction.x).normalize().multiplyScalar(width / 2);
[-1, 1].forEach(sign => {
const offset = side.clone().multiplyScalar(sign);
const p1 = a.clone().add(offset).add(new THREE.Vector3(0, 0.85, 0));
const p2 = b.clone().add(offset).add(new THREE.Vector3(0, 0.85, 0));
beamBetween(circulationGroup, p1.toArray(), p2.toArray(), 0.055, 0x31575a);
for (let i = 0; i <= 5; i++) {
const t = i / 5;
const p = a.clone().lerp(b, t).add(offset);
box(circulationGroup, 0.05, 0.78, 0.05, p.x, p.y + 0.46, p.z, 0x31575a);
}
});
}
addBridge([-22.5, 2.91, 7.0], [-5.2, 2.91, 7.0], 1.25);
addBridge([5.8, 2.91, 7.0], [22.5, 2.91, 7.0], 1.25);
addBridge([-22.5, 5.71, -3.15], [-6.3, 5.71, -3.15], 1.15);
addBridge([6.4, 5.71, -3.15], [22.5, 5.71, -3.15], 1.15);
function addElevator(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
const glass = new THREE.Mesh(
new THREE.BoxGeometry(1.48, 3.35, 1.48),
new THREE.MeshStandardMaterial({
color: 0x8bc4bf,
transparent: true,
opacity: 0.22,
roughness: 0.25,
metalness: 0.05,
depthWrite: false
})
);
glass.position.y = 1.68;
group.add(glass);
[-0.68, 0.68].forEach(gx => {
[-0.68, 0.68].forEach(gz => {
box(group, 0.08, 3.5, 0.08, gx, 1.72, gz, 0x294a4b);
});
});
box(group, 1.65, 0.16, 1.65, 0, 3.48, 0, 0x294a4b);
box(group, 1.58, 0.16, 1.58, 0, 0.08, 0, 0x294a4b);
const cabin = box(group, 1.08, 1.08, 1.08, 0, 1.22, 0, 0xf2bd3e);
box(group, 0.82, 0.42, 0.025, 0, 1.36, 0.552, 0x173f43);
box(cabin, 0.7, 0.7, 0.7, 0, 0, 0, 0xf2bd3e);
beamBetween(group, [0, 3.35, 0], [0, 1.75, 0], 0.025, 0x294a4b);
circulationGroup.add(group);
return group;
}
addElevator(6.35, 8.85);
addElevator(-7.0, 8.85);
const housePalette = [
0xe56550, 0xf0b63d, 0x278b82, 0x6678aa,
0xd66b95, 0xeee0bd, 0x9a654b, 0xe17a3d,
0x4f9e98, 0xc95646
];
function addHouse(parent, options) {
const {
x, y, z,
w = between(2.6, 4.0),
d = between(2.5, 3.5),
h = between(2.2, 4.1),
color = pick(housePalette),
rotation = 0,
balcony = true,
muralStyle = null
} = options;
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
box(group, w + 0.14, 0.14, d + 0.14, 0, 0.07, 0, 0x777463);
box(group, w, h, d, 0, h / 2, 0, color);
box(group, w + 0.18, 0.17, d + 0.18, 0, h + 0.085, 0, 0x345758);
// Thin facade bands suggest floor slabs.
if (h > 3.0) {
box(group, w + 0.035, 0.075, d + 0.035, 0, h * 0.52, 0, 0xefe0bd);
}
const floorCount = h > 3.15 ? 2 : 1;
const windowXs = w > 3.6 ? [-w * 0.35, 0, w * 0.35] : [-w * 0.31, w * 0.31];
for (let floor = 0; floor < floorCount; floor++) {
const wy = 0.82 + floor * 1.42;
windowXs.forEach(wx => {
if (muralStyle !== null && floor === floorCount - 1 && Math.abs(wx) < 0.3) return;
box(group, 0.52, 0.63, 0.045, wx, wy, d / 2 + 0.035, 0x244c55);
const lit = random() > 0.55;
box(
group,
0.39,
0.48,
0.05,
wx,
wy,
d / 2 + 0.061,
lit ? 0xf2cc68 : 0x79b2b0,
lit
? { emissive: 0xd69532, emissiveIntensity: 0.22 }
: {}
);
box(group, 0.03, 0.48, 0.055, wx, wy, d / 2 + 0.065, 0x315357);
});
}
// Side door and narrow side windows.
box(group, 0.045, 1.20, 0.57, w / 2 + 0.026, 0.61, -d * 0.13, 0x274a4d);
box(group, 0.05, 0.56, 0.55, w / 2 + 0.034, h * 0.68, d * 0.18, 0x78b2af);
if (balcony && h > 2.25) {
const by = h * 0.46;
box(group, w * 0.76, 0.12, 0.68, 0, by, d / 2 + 0.30, 0xe6d5b5);
box(group, w * 0.76, 0.06, 0.06, 0, by + 0.72, d / 2 + 0.61, 0x31575a);
for (let i = 0; i < 5; i++) {
const px = -w * 0.34 + i * (w * 0.17);
box(group, 0.045, 0.66, 0.045, px, by + 0.38, d / 2 + 0.61, 0x31575a);
}
}
// Roof tank, chimney, antenna, and occasional solar panel.
const tank = new THREE.Mesh(
new THREE.CylinderGeometry(0.25, 0.29, 0.52, 8),
material(0x536d67)
);
tank.position.set(w * 0.25, h + 0.42, -d * 0.22);
tank.castShadow = true;
group.add(tank);
box(group, 0.23, 0.58, 0.23, -w * 0.28, h + 0.38, d * 0.19, 0xc7b597);
beamBetween(group, [-w * 0.12, h + 0.17, -d * 0.22], [-w * 0.12, h + 1.12, -d * 0.22], 0.025, 0x31575a);
beamBetween(group, [-w * 0.28, h + 0.92, -d * 0.22], [w * 0.04, h + 0.92, -d * 0.22], 0.022, 0x31575a);
if (random() > 0.62) {
const panel = box(group, 0.9, 0.06, 0.58, 0.05, h + 0.27, 0.08, 0x244b58);
panel.rotation.x = -0.18;
}
if (muralStyle !== null) {
addMural(
group,
0,
h * 0.76,
d / 2 + 0.072,
Math.min(w * 0.62, 2.25),
Math.min(h * 0.32, 1.18),
muralStyle
);
}
parent.add(group);
return group;
}
function addStackedHouse(x, y, z, index) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = between(-0.08, 0.08);
const w = 3.25;
const d = 2.8;
[-1, 1].forEach(sx => {
[-1, 1].forEach(sz => {
box(group, 0.16, 1.35, 0.16, sx * w * 0.39, 0.67, sz * d * 0.38, 0x54645c);
});
});
addHouse(group, {
x: 0, y: 1.28, z: 0,
w, d, h: 1.45,
color: housePalette[(index + 2) % housePalette.length],
balcony: false
});
addHouse(group, {
x: 0.36, y: 2.72, z: -0.08,
w: 3.45, d: 2.95, h: between(1.8, 2.25),
color: housePalette[(index + 6) % housePalette.length],
rotation: -0.025,
balcony: true
});
architectureGroup.add(group);
}
const lowerHouses = [
[-19, 14.0, 4.0, 3.0, 3.1], [-14, 13.3, 3.3, 3.2, 2.7],
[-9, 14.1, 3.6, 3.0, 3.7], [9.1, 14.0, 3.7, 3.1, 3.2],
[14, 13.4, 3.5, 3.3, 3.8], [19, 14.0, 3.8, 3.0, 2.9]
];
const middleHouses = [
[-19, 5.0, 3.5, 3.2, 3.6], [-14, 4.3, 3.2, 3.0, 2.9],
[-9, 5.0, 3.8, 3.1, 3.5], [-5.8, 4.2, 2.5, 2.7, 2.6],
[6.1, 4.8, 3.1, 3.0, 3.4], [14, 4.3, 3.7, 3.2, 3.8],
[19, 5.0, 3.4, 3.0, 3.0]
];
const upperHouses = [
[-19, -5.1, 3.8, 3.2, 3.7], [-14, -6.0, 3.4, 3.1, 3.0],
[-8.7, -5.2, 3.6, 3.0, 3.4], [7.1, -5.0, 3.5, 3.2, 3.5],
[12, -6.0, 3.4, 3.0, 2.8], [19, -5.1, 3.9, 3.1, 3.7]
];
const topHouses = [
[-16, -15.0, 3.6, 3.0, 3.0], [-11, -16.0, 3.5, 3.0, 3.7],
[-6.5, -15.0, 3.3, 2.9, 2.8], [6.5, -15.0, 3.5, 3.0, 3.2],
[11, -16.0, 3.7, 3.0, 3.6], [18, -15.0, 3.4, 3.0, 3.0]
];
function addHouseList(list, levelY, offset) {
list.forEach(([x, z, w, d, h], i) => {
addHouse(architectureGroup, {
x, y: levelY, z,
w, d, h,
color: pick(housePalette),
rotation: between(-0.07, 0.07),
balcony: random() > 0.22,
muralStyle: i === 1 || i === list.length - 2 ? (offset + i) % 4 : null
});
});
}
addHouseList(lowerHouses, 0, 0);
addHouseList(middleHouses, 2.8, 1);
addHouseList(upperHouses, 5.6, 2);
addHouseList(topHouses, 8.2, 3);
addStackedHouse(-5.8, 2.8, 5.2, 0);
addStackedHouse(9.3, 5.6, -6.7, 1);
addStackedHouse(-16.2, 5.6, -5.7, 2);
addStackedHouse(15.1, 2.8, 5.3, 3);
// Original mural panels on the retaining walls.
const muralRows = [
{ y: 1.40, z: 8.025, xs: [-17, -12.7, 10.9, 16.2] },
{ y: 4.20, z: -1.975, xs: [-17, -12.8, 10.4, 16.0] },
{ y: 6.90, z: -11.975, xs: [-16.5, -11.8, 10.5, 16.2] }
];
muralRows.forEach((row, rowIndex) => {
row.xs.forEach((x, i) => {
addMural(
muralGroup,
x,
row.y,
row.z,
between(2.65, 3.25),
between(1.45, 1.85),
(rowIndex + i) % 4
);
});
});
function addTree(x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.16, 1.7, 6),
material(0x7a5c43)
);
trunk.position.y = 0.85;
trunk.castShadow = true;
group.add(trunk);
const crownColors = [0x587b58, 0x6d8b5d, 0x799565];
for (let i = 0; i < 3; i++) {
const crown = new THREE.Mesh(
new THREE.IcosahedronGeometry(between(0.68, 0.95), 0),
material(pick(crownColors))
);
crown.position.set(between(-0.35, 0.35), between(1.65, 2.25), between(-0.3, 0.3));
crown.rotation.set(random(), random(), random());
crown.castShadow = true;
group.add(crown);
}
landscapeGroup.add(group);
}
[
[-22.3, 0, 15.8, 1.15], [-22.5, 2.8, 2.1, 1.0], [-22.4, 5.6, -9.4, 0.95],
[-21.5, 8.2, -16.1, 0.9], [21.8, 0, 16.2, 1.05], [22.3, 2.8, 3.2, 1.1],
[22.4, 5.6, -9.6, 0.95], [21.2, 8.2, -16.0, 0.9],
[-21.5, 0, 9.8, 0.75], [21.7, 5.6, -2.1, 0.72]
].forEach(args => addTree(...args));
function addLamp(x, y, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
box(group, 0.06, 2.25, 0.06, 0, 1.125, 0, 0x31575a);
box(group, 0.58, 0.06, 0.06, 0.27, 2.22, 0, 0x31575a);
box(group, 0.32, 0.12, 0.20, 0.49, 2.15, 0, 0xf0bd3b, {
emissive: 0xe0a52c,
emissiveIntensity: 0.35
});
detailGroup.add(group);
}
[
[-18, 0, 7.0], [-8, 0, 7.0], [8, 0, 7.0], [17, 0, 7.0],
[-18, 2.8, -3.15], [8, 2.8, -3.15], [17, 2.8, -3.15],
[-18, 5.6, -12.7], [8, 5.6, -12.7], [17, 5.6, -12.7]
].forEach(([x, y, z]) => addLamp(x, y, z));
function addPerson(x, y, z, color, scale = 1, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
group.rotation.y = rotation;
const torso = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.17, 0.48, 6),
material(color)
);
torso.position.y = 0.63;
torso.castShadow = true;
group.add(torso);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.13, 7, 5),
material(0x9f6b4f)
);
head.position.y = 0.98;
head.castShadow = true;
group.add(head);
box(group, 0.075, 0.36, 0.075, -0.07, 0.18, 0, 0x244754);
box(group, 0.075, 0.36, 0.075, 0.07, 0.18, 0, 0x244754);
detailGroup.add(group);
}
[
[-5.5, 0.08, 7.0, 0xe75f42], [2.3, 0.08, 6.9, 0x2f8f83],
[-16.0, 2.88, -3.15, 0xf0b63d], [10.3, 2.88, -3.1, 0x6678aa],
[-12.0, 5.68, -12.7, 0xe17a3d], [12.7, 5.68, -12.7, 0x2f8f83],
[-1.0, 1.1, 13.5, 0xd75c88], [4.0, 4.2, 2.8, 0xf0b63d]
].forEach(args => addPerson(...args));
function makeLabel(text, accent = "#efbd3b") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 144;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(24,51,52,0.91)";
ctx.beginPath();
ctx.roundRect(8, 8, 624, 128, 28);
ctx.fill();
ctx.fillStyle = accent;
ctx.beginPath();
ctx.roundRect(23, 25, 16, 94, 8);
ctx.fill();
ctx.fillStyle = "#fffaf0";
ctx.font = "800 38px Arial, sans-serif";
ctx.textBaseline = "middle";
ctx.fillText(text.toUpperCase(), 60, 74);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
}));
sprite.scale.set(5.4, 1.22, 1);
return sprite;
}
const pickables = [];
function addHotspot(position, title, text, accent, labelOffset = 0.85) {
const dot = new THREE.Mesh(
new THREE.SphereGeometry(0.14, 10, 7),
material(accent, { emissive: accent, emissiveIntensity: 0.18 })
);
dot.position.set(...position);
dot.castShadow = true;
dot.userData = { title, text };
world.add(dot);
pickables.push(dot);
const label = makeLabel(title, accent);
label.position.set(position[0], position[1] + labelOffset, position[2]);
world.add(label);
}
addHotspot(
[3.65, 2.15, 13.6],
"EscPublica",
"An inclined public escalator links the lower and middle terraces.",
"#efbd3b"
);
addHotspot(
[6.35, 3.7, 8.85],
"Elevador",
"A glazed public elevator provides a short, accessible connection between levels.",
"#55b2a9"
);
addHotspot(
[-12.7, 1.65, 8.08],
"MuroVivo",
"Original geometric murals turn retaining walls into a shared visual trail.",
"#e56550"
);
addHotspot(
[9.3, 8.35, -6.7],
"CasaApilada",
"Stacked modular homes use narrow columns to preserve a legible public passage below.",
"#6678aa"
);
// Section label on the front face of the base.
const sectionCanvas = document.createElement("canvas");
sectionCanvas.width = 1024;
sectionCanvas.height = 180;
const sectionCtx = sectionCanvas.getContext("2d");
sectionCtx.fillStyle = "#203c3d";
sectionCtx.fillRect(0, 0, 1024, 180);
sectionCtx.fillStyle = "#efbd3b";
sectionCtx.fillRect(34, 28, 22, 124);
sectionCtx.fillStyle = "#f7f0de";
sectionCtx.font = "800 62px Arial, sans-serif";
sectionCtx.textBaseline = "middle";
sectionCtx.fillText("HILLSIDE ACCESS / 13", 88, 92);
const sectionTexture = new THREE.CanvasTexture(sectionCanvas);
sectionTexture.colorSpace = THREE.SRGBColorSpace;
const sectionPlate = new THREE.Mesh(
new THREE.PlaneGeometry(8.4, 1.48),
new THREE.MeshStandardMaterial({ map: sectionTexture, roughness: 1 })
);
sectionPlate.position.set(0, -1.15, 19.012);
terrainGroup.add(sectionPlate);
// Manual orbit / pan / zoom controls, implemented without external addons.
const orbit = {
target: new THREE.Vector3(0, 3.1, 0),
radius: 53,
theta: 0.72,
phi: 1.02
};
let cameraTween = null;
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
function shortestAngle(from, to) {
let delta = (to - from + Math.PI) % (Math.PI * 2) - Math.PI;
if (delta < -Math.PI) delta += Math.PI * 2;
return delta;
}
function animateCamera(to, duration = 900) {
cameraTween = {
start: performance.now(),
duration,
from: {
target: orbit.target.clone(),
radius: orbit.radius,
theta: orbit.theta,
phi: orbit.phi
},
to: {
target: new THREE.Vector3(...to.target),
radius: to.radius,
theta: to.theta,
phi: to.phi
}
};
}
const views = {
overview: { target: [0, 3.1, 0], radius: 53, theta: 0.72, phi: 1.02 },
access: { target: [0.5, 4.3, 1.5], radius: 38, theta: 0.92, phi: 1.16 },
housing: { target: [-6.5, 4.5, -1.8], radius: 37, theta: 0.80, phi: 1.00 },
art: { target: [-10.5, 2.0, 7.4], radius: 25, theta: 0.40, phi: 1.23 }
};
document.querySelectorAll("[data-view]").forEach(button => {
button.addEventListener("click", () => {
document.querySelectorAll("[data-view]").forEach(b => b.classList.remove("active"));
button.classList.add("active");
animateCamera(views[button.dataset.view]);
});
});
const pointers = new Map();
let pinchDistance = 0;
let pointerTravel = 0;
let pointerStart = null;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(values[0].x - values[1].x, values[0].y - values[1].y);
}
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
pointerTravel = 0;
pointerStart = { x: event.clientX, y: event.clientY };
cameraTween = null;
if (pointers.size === 2) {
pinchDistance = pointerDistance();
}
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
pointerTravel += Math.hypot(dx, dy);
if (pointers.size === 1) {
const panMode = event.shiftKey || (event.buttons & 2) === 2;
if (panMode) {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const scale = orbit.radius * 0.0014;
orbit.target.addScaledVector(right, -dx * scale);
orbit.target.addScaledVector(up, dy * scale);
orbit.target.x = THREE.MathUtils.clamp(orbit.target.x, -30, 30);
orbit.target.y = THREE.MathUtils.clamp(orbit.target.y, -1, 15);
orbit.target.z = THREE.MathUtils.clamp(orbit.target.z, -25, 25);
} else {
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - dy * 0.005, 0.34, 1.46);
}
} else if (pointers.size === 2) {
const distance = pointerDistance();
if (pinchDistance > 0 && distance > 0) {
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * (pinchDistance / distance),
18,
95
);
}
pinchDistance = distance;
}
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
renderer.domElement.addEventListener("pointerup", event => {
if (
event.button === 0 &&
pointerTravel < 6 &&
pointerStart &&
Math.hypot(event.clientX - pointerStart.x, event.clientY - pointerStart.y) < 6
) {
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;
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(pickables, false)[0];
if (hit) {
tooltip.innerHTML = `<h2>${hit.object.userData.title}</h2><p>${hit.object.userData.text}</p>`;
tooltip.style.left = `${Math.min(event.clientX + 15, window.innerWidth - 305)}px`;
tooltip.style.top = `${Math.min(event.clientY + 15, window.innerHeight - 120)}px`;
tooltip.classList.add("visible");
} else {
tooltip.classList.remove("visible");
}
}
pointers.delete(event.pointerId);
if (pointers.size < 2) pinchDistance = 0;
});
renderer.domElement.addEventListener("pointercancel", event => {
pointers.delete(event.pointerId);
if (pointers.size < 2) pinchDistance = 0;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraTween = null;
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
18,
95
);
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
animateCamera(views.overview);
});
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();
function animate(now) {
requestAnimationFrame(animate);
if (cameraTween) {
const t = THREE.MathUtils.clamp(
(now - cameraTween.start) / cameraTween.duration,
0,
1
);
const eased = t < 0.5
? 4 * t * t * t
: 1 - Math.pow(-2 * t + 2, 3) / 2;
orbit.target.lerpVectors(
cameraTween.from.target,
cameraTween.to.target,
eased
);
orbit.radius = THREE.MathUtils.lerp(
cameraTween.from.radius,
cameraTween.to.radius,
eased
);
orbit.phi = THREE.MathUtils.lerp(
cameraTween.from.phi,
cameraTween.to.phi,
eased
);
orbit.theta = cameraTween.from.theta +
shortestAngle(cameraTween.from.theta, cameraTween.to.theta) * eased;
if (t >= 1) cameraTween = null;
}
updateCamera();
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```