Prompt specification
Build or customize the Three.js 3D scene "Explore access with one elevated link closed" 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: Explore access with one elevated link closed
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/explore-access-with-one-elevated-link-closed-x2664
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Fortaleza's Dragão do Mar cultural complex. Let users close a hypothetical walkway connection in the schematic model. Show alternate ground-level routes and clearly label the closure as an educational scenario. Voxel style.
Working Three.js Starter (explore-access-with-one-elevated-link-closed-x2664):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dragão do Mar — Educational Walkway Closure</title>
<style>
:root {
--ink: #172b31;
--muted: #52656a;
--paper: #f6f1e7;
--paper-strong: #fffaf0;
--teal: #087f7c;
--teal-light: #d8efea;
--orange: #e47732;
--orange-light: #f8e3d2;
--red: #c53d3d;
--red-light: #f7d8d4;
--line: rgba(23, 43, 49, 0.16);
--shadow: 0 14px 42px rgba(31, 44, 43, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8d1c4;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#app {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
}
#scene {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
#label-layer {
position: absolute;
inset: 0;
z-index: 2;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
left: 0;
top: 0;
display: flex;
align-items: center;
gap: 7px;
max-width: 230px;
padding: 6px 9px 6px 7px;
transform: translate(-50%, -50%);
border: 1px solid rgba(23, 43, 49, 0.13);
border-radius: 8px;
background: rgba(255, 250, 240, 0.91);
box-shadow: 0 5px 16px rgba(24, 38, 39, 0.12);
color: var(--ink);
font-size: 11px;
font-weight: 750;
line-height: 1.18;
letter-spacing: 0.015em;
white-space: nowrap;
backdrop-filter: blur(7px);
will-change: left, top;
}
.world-label .label-pin {
flex: 0 0 auto;
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--ink);
box-shadow: 0 0 0 3px rgba(23, 43, 49, 0.09);
}
.world-label.building .label-pin {
background: var(--orange);
}
.world-label.route {
max-width: 270px;
border-color: rgba(8, 127, 124, 0.28);
background: rgba(239, 250, 245, 0.94);
color: #075f5d;
}
.world-label.route .label-pin {
background: var(--teal);
}
.world-label.route-b {
border-color: rgba(228, 119, 50, 0.32);
background: rgba(255, 245, 233, 0.95);
color: #8a421d;
}
.world-label.route-b .label-pin {
background: var(--orange);
}
.world-label.closure {
max-width: 190px;
border: 2px solid var(--red);
background: rgba(255, 239, 235, 0.97);
color: #842b2b;
text-align: center;
box-shadow: 0 7px 22px rgba(132, 43, 43, 0.2);
}
.world-label.closure .label-pin {
background: var(--red);
animation: warning-pulse 1.4s ease-in-out infinite;
}
@keyframes warning-pulse {
50% {
opacity: 0.35;
transform: scale(0.8);
}
}
.glass-card {
position: absolute;
z-index: 5;
border: 1px solid rgba(255, 255, 255, 0.58);
border-radius: 14px;
background: rgba(248, 244, 234, 0.9);
box-shadow: var(--shadow);
backdrop-filter: blur(15px) saturate(1.08);
}
.title-card {
top: 18px;
left: 18px;
width: min(395px, calc(100vw - 36px));
padding: 17px 18px 16px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: #6c5148;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--orange);
}
h1 {
margin: 0;
font-size: clamp(24px, 2.5vw, 34px);
font-weight: 850;
line-height: 1.02;
letter-spacing: -0.035em;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.scenario-badge {
display: inline-flex;
align-items: center;
gap: 6px;
margin-top: 12px;
padding: 6px 9px;
border: 1px solid rgba(197, 61, 61, 0.3);
border-radius: 999px;
background: var(--red-light);
color: #8e2d2d;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.controls-card {
top: 18px;
right: 18px;
width: 266px;
padding: 13px;
}
.control-title {
margin: 0 0 9px;
color: var(--muted);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.control-button {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
min-height: 41px;
margin-top: 7px;
padding: 9px 11px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.62);
color: var(--ink);
font-size: 12px;
font-weight: 800;
cursor: pointer;
transition:
transform 120ms ease,
border-color 120ms ease,
background 120ms ease;
}
.control-button:hover {
transform: translateY(-1px);
border-color: rgba(23, 43, 49, 0.32);
background: var(--paper-strong);
}
.control-button:active {
transform: translateY(0);
}
.control-button:focus-visible,
.route-item:focus-visible {
outline: 3px solid rgba(8, 127, 124, 0.3);
outline-offset: 2px;
}
.control-button.primary {
border-color: transparent;
background: var(--teal);
color: white;
box-shadow: 0 6px 15px rgba(8, 127, 124, 0.2);
}
.control-button.primary.closed {
background: var(--red);
box-shadow: 0 6px 15px rgba(197, 61, 61, 0.19);
}
.button-icon {
font-size: 17px;
line-height: 1;
}
.keyboard-note {
margin: 10px 2px 0;
color: #647579;
font-size: 10px;
line-height: 1.45;
}
kbd {
padding: 1px 4px;
border: 1px solid rgba(23, 43, 49, 0.18);
border-bottom-width: 2px;
border-radius: 4px;
background: rgba(255, 255, 255, 0.72);
color: var(--ink);
font-family: inherit;
font-size: 9px;
font-weight: 800;
}
.scenario-banner {
right: 18px;
bottom: 18px;
display: flex;
gap: 12px;
width: min(440px, calc(100vw - 36px));
padding: 14px 15px;
border-color: rgba(197, 61, 61, 0.28);
background: rgba(255, 242, 237, 0.94);
}
.scenario-banner.open {
border-color: rgba(8, 127, 124, 0.25);
background: rgba(237, 249, 243, 0.94);
}
.scenario-icon {
display: grid;
flex: 0 0 auto;
place-items: center;
width: 34px;
height: 34px;
border-radius: 9px;
background: var(--red);
color: white;
font-size: 19px;
font-weight: 900;
}
.scenario-banner.open .scenario-icon {
background: var(--teal);
}
.scenario-banner strong {
display: block;
margin: 1px 0 3px;
color: #822f2f;
font-size: 12px;
letter-spacing: 0.035em;
text-transform: uppercase;
}
.scenario-banner.open strong {
color: #07635f;
}
.scenario-banner p {
margin: 0;
color: #645451;
font-size: 11px;
line-height: 1.45;
}
.route-card {
bottom: 18px;
left: 18px;
width: 370px;
padding: 13px;
}
.route-header {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin-bottom: 8px;
}
.route-header h2 {
margin: 0;
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.route-header span {
color: var(--muted);
font-size: 9px;
}
.route-item {
display: grid;
grid-template-columns: 29px 1fr;
align-items: center;
gap: 9px;
width: 100%;
padding: 8px;
border: 1px solid transparent;
border-radius: 9px;
background: transparent;
color: var(--ink);
text-align: left;
cursor: pointer;
transition:
background 120ms ease,
border-color 120ms ease;
}
.route-item:hover {
border-color: var(--line);
background: rgba(255, 255, 255, 0.55);
}
.route-letter {
display: grid;
place-items: center;
width: 29px;
height: 29px;
border-radius: 8px;
background: var(--teal);
color: white;
font-size: 13px;
font-weight: 900;
}
.route-letter.orange {
background: var(--orange);
}
.route-name {
display: block;
font-size: 11px;
font-weight: 850;
}
.route-desc {
display: block;
margin-top: 1px;
color: var(--muted);
font-size: 9px;
line-height: 1.35;
}
.disclaimer {
margin: 8px 3px 0;
color: #6a7373;
font-size: 9px;
line-height: 1.4;
}
.gesture-hint {
position: absolute;
z-index: 4;
left: 50%;
bottom: 18px;
transform: translateX(-50%);
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 999px;
background: rgba(31, 45, 47, 0.68);
color: rgba(255, 255, 255, 0.92);
font-size: 10px;
font-weight: 700;
pointer-events: none;
backdrop-filter: blur(8px);
}
#loading {
position: absolute;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #d8d1c4;
color: var(--ink);
font-size: 13px;
font-weight: 800;
letter-spacing: 0.04em;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 820px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px;
}
h1 {
font-size: 24px;
}
.subtitle {
font-size: 11px;
}
.scenario-badge {
margin-top: 8px;
}
.controls-card {
top: 154px;
right: 12px;
width: 226px;
padding: 10px;
}
.route-card {
bottom: 103px;
left: 12px;
width: calc(100vw - 24px);
padding: 10px;
}
.scenario-banner {
right: 12px;
bottom: 12px;
width: calc(100vw - 24px);
padding: 11px 12px;
}
.gesture-hint {
display: none;
}
.world-label {
font-size: 9px;
padding: 5px 7px 5px 6px;
}
.world-label.route {
max-width: 190px;
}
}
@media (max-width: 520px) {
.controls-card {
top: 143px;
right: 12px;
left: 12px;
width: auto;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6px;
}
.control-title,
.keyboard-note {
display: none;
}
.control-button {
min-height: 38px;
margin: 0;
padding: 7px 9px;
font-size: 10px;
}
.control-button.primary {
grid-column: 1 / -1;
}
.route-card {
bottom: 97px;
}
.route-header span,
.disclaimer {
display: none;
}
.route-item {
padding: 5px;
}
.route-desc {
display: none;
}
.world-label.building {
display: none;
}
}
</style>
</head>
<body>
<main id="app">
<canvas
id="scene"
aria-label="Interactive voxel schematic of Fortaleza's Dragão do Mar cultural complex"
></canvas>
<div id="label-layer" aria-hidden="true"></div>
<header class="glass-card title-card">
<div class="eyebrow">Fortaleza · Ceará · Brazil</div>
<h1>Dragão do Mar</h1>
<p class="subtitle">
Voxel cultural-complex schematic with a hypothetical upper-walkway
closure and accessible ground-level alternatives.
</p>
<div class="scenario-badge">
Educational scenario · not an official access map
</div>
</header>
<aside class="glass-card controls-card" aria-label="Scenario controls">
<div class="control-title">Scenario controls</div>
<button
id="closure-button"
class="control-button primary closed"
type="button"
aria-pressed="true"
>
<span id="closure-button-text">Reopen hypothetical link</span>
<span class="button-icon" aria-hidden="true">↗</span>
</button>
<button id="route-button" class="control-button" type="button">
<span id="route-button-text">Route emphasis: ON</span>
<span class="button-icon" aria-hidden="true">◎</span>
</button>
<button id="reset-button" class="control-button" type="button">
<span>Reset overview</span>
<span class="button-icon" aria-hidden="true">⌂</span>
</button>
<p class="keyboard-note">
<kbd>C</kbd> closure · <kbd>R</kbd> reset · <kbd>1</kbd> route A ·
<kbd>2</kbd> route B
</p>
</aside>
<section
id="scenario-banner"
class="glass-card scenario-banner"
role="status"
aria-live="polite"
>
<div id="scenario-icon" class="scenario-icon" aria-hidden="true">×</div>
<div>
<strong id="scenario-title">
Educational scenario · hypothetical closure
</strong>
<p id="scenario-text">
The upper connection is closed in this scenario. Ground-level routes
A and B remain open and provide schematic alternatives.
</p>
</div>
</section>
<section class="glass-card route-card" aria-label="Ground-level alternatives">
<div class="route-header">
<h2>Ground-level alternatives</h2>
<span>Click a route to focus</span>
</div>
<button id="route-a" class="route-item" type="button">
<span class="route-letter">A</span>
<span>
<span class="route-name">West arrival → MAC → courtyard</span>
<span class="route-desc">
Passes south of the complex without using the upper link.
</span>
</span>
</button>
<button id="route-b" class="route-item" type="button">
<span class="route-letter orange">B</span>
<span>
<span class="route-name">North plaza → theatre east entrance</span>
<span class="route-desc">
Follows the east perimeter to the main cultural building.
</span>
</span>
</button>
<p class="disclaimer">
Simplified, hypothetical diagram. Routes are not surveyed accessibility
guidance and do not represent current operating conditions.
</p>
</section>
<div class="gesture-hint">
Drag to rotate · Shift/right-drag to pan · Scroll to zoom
</div>
<div id="loading">Building the educational schematic…</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 canvas = document.querySelector("#scene");
const labelLayer = document.querySelector("#label-layer");
const loading = document.querySelector("#loading");
const scenarioBanner = document.querySelector("#scenario-banner");
const scenarioIcon = document.querySelector("#scenario-icon");
const scenarioTitle = document.querySelector("#scenario-title");
const scenarioText = document.querySelector("#scenario-text");
const closureButton = document.querySelector("#closure-button");
const closureButtonText = document.querySelector("#closure-button-text");
const routeButton = document.querySelector("#route-button");
const routeButtonText = document.querySelector("#route-button-text");
const resetButton = document.querySelector("#reset-button");
const routeAButton = document.querySelector("#route-a");
const routeBButton = document.querySelector("#route-b");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d1c4);
scene.fog = new THREE.Fog(0xd8d1c4, 38, 66);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const world = new THREE.Group();
scene.add(world);
const camera = new THREE.OrthographicCamera(-14, 14, 9, -9, 0.1, 100);
const defaultView = {
azimuth: 0.72,
elevation: 0.72,
zoom: 1,
target: new THREE.Vector3(0, 0.75, -0.65)
};
const view = {
azimuth: defaultView.azimuth,
elevation: defaultView.elevation,
zoom: defaultView.zoom,
target: defaultView.target.clone()
};
let cameraTween = null;
let closureActive = true;
let routeEmphasis = true;
const hemisphere = new THREE.HemisphereLight(0xfff6df, 0x697b78, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe7bd, 3.25);
sun.position.set(-13, 22, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.0006;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xaed9d3, 0.75);
fill.position.set(12, 8, -10);
scene.add(fill);
const palette = {
ground: 0xd6cbb5,
groundSide: 0xb6aa91,
plaza: 0xeee6d4,
street: 0x84908c,
streetEdge: 0xb7bdb4,
cream: 0xf0e4ca,
white: 0xfff5df,
coral: 0xcb6a50,
coralDark: 0x934c40,
teal: 0x287f7c,
tealDark: 0x174f52,
glass: 0x214c56,
glassLight: 0x8bb9b2,
gold: 0xe0aa50,
roof: 0x60716e,
dark: 0x33474a,
red: 0xc53d3d,
yellow: 0xf3c451,
routeA: 0x087f7c,
routeB: 0xe47732,
tree: 0x4e7960,
treeLight: 0x72956d
};
const material = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
...extra
});
const materials = {
ground: material(palette.ground),
groundSide: material(palette.groundSide),
plaza: material(palette.plaza),
street: material(palette.street),
streetEdge: material(palette.streetEdge),
cream: material(palette.cream),
white: material(palette.white),
coral: material(palette.coral),
coralDark: material(palette.coralDark),
teal: material(palette.teal),
tealDark: material(palette.tealDark),
glass: material(palette.glass, {
roughness: 0.3,
metalness: 0.12,
emissive: 0x102f35,
emissiveIntensity: 0.18
}),
glassLight: material(palette.glassLight, {
roughness: 0.28,
metalness: 0.08
}),
gold: material(palette.gold),
roof: material(palette.roof),
dark: material(palette.dark),
red: material(palette.red),
yellow: material(palette.yellow),
tree: material(palette.tree),
treeLight: material(palette.treeLight)
};
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x263a3e,
transparent: true,
opacity: 0.15
});
function addEdges(mesh) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry),
edgeMaterial
);
mesh.add(edges);
return mesh;
}
function box(
parent,
width,
height,
depth,
x,
y,
z,
mat,
withEdges = false
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (withEdges) addEdges(mesh);
return mesh;
}
// ------------------------------------------------------------------
// Ground plane, plaza, and abstract urban blocks
// ------------------------------------------------------------------
const base = box(
world,
24,
0.55,
18,
0,
-0.31,
0,
materials.ground
);
addEdges(base);
box(
world,
24,
0.14,
0.42,
0,
0.015,
-8.05,
materials.street
);
box(
world,
0.42,
0.14,
16.5,
-10.55,
0.015,
-0.6,
materials.street
);
box(
world,
16.8,
0.14,
11.8,
-0.2,
0.075,
-0.55,
materials.plaza
);
const plazaEdge = box(
world,
16.8,
0.07,
0.16,
-0.2,
0.17,
5.35,
materials.streetEdge
);
plazaEdge.receiveShadow = true;
// Subtle paving strips.
for (let i = -7; i <= 7; i += 2) {
box(
world,
0.035,
0.018,
10.8,
i - 0.2,
0.153,
-0.55,
materials.streetEdge
);
}
function cityBlock(x, z, width, depth, height, color) {
const group = new THREE.Group();
group.position.set(x, 0, z);
world.add(group);
const bodyMaterial = material(color);
const body = box(
group,
width,
height,
depth,
0,
height / 2 + 0.12,
0,
bodyMaterial,
true
);
box(
group,
width + 0.16,
0.18,
depth + 0.16,
0,
height + 0.18,
0,
materials.roof
);
const windowCount = Math.max(1, Math.floor(width / 0.65));
for (let i = 0; i < windowCount; i++) {
const wx =
-width / 2 + 0.42 + (i * (width - 0.84)) / Math.max(1, windowCount - 1);
box(
group,
0.27,
0.32,
0.035,
wx,
height * 0.59,
depth / 2 + 0.022,
materials.glass
);
}
return body;
}
cityBlock(-9.2, -6.4, 2.15, 1.9, 1.65, 0xb9a990);
cityBlock(-6.5, -7.25, 2.5, 1.45, 2.05, 0xa9b2aa);
cityBlock(-2.0, -7.35, 2.35, 1.45, 1.45, 0xc6b397);
cityBlock(1.1, -7.35, 1.75, 1.55, 2.15, 0x9aaea8);
cityBlock(8.75, -7.1, 2.3, 1.55, 1.55, 0xb4aa99);
cityBlock(9.25, -4.15, 1.8, 2.2, 2.0, 0xa7b0a7);
cityBlock(9.35, -0.9, 1.6, 1.9, 1.25, 0xc1ad92);
cityBlock(9.3, 3.2, 1.8, 2.1, 1.5, 0x9caeaa);
cityBlock(-8.85, 6.6, 2.2, 1.25, 1.4, 0xb4aa97);
cityBlock(-5.7, 6.85, 2.4, 1.15, 1.8, 0xa9b4ad);
cityBlock(-2.1, 6.85, 2.5, 1.15, 1.15, 0xc3ae92);
function voxelTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.12, z);
group.scale.setScalar(scale);
world.add(group);
box(group, 0.18, 0.8, 0.18, 0, 0.4, 0, materials.coralDark);
box(group, 0.8, 0.62, 0.8, 0, 1.05, 0, materials.tree, true);
box(group, 0.55, 0.48, 0.55, 0, 1.55, 0, materials.treeLight, true);
}
voxelTree(-8.9, 2.9, 0.75);
voxelTree(-8.8, 4.2, 0.68);
voxelTree(-6.9, 5.6, 0.72);
voxelTree(7.7, 5.7, 0.7);
voxelTree(8.0, -5.7, 0.66);
voxelTree(-8.7, -3.7, 0.72);
// ------------------------------------------------------------------
// Dragão do Mar cultural complex
// ------------------------------------------------------------------
// MAC — Museu de Arte Contemporânea.
const mac = new THREE.Group();
mac.position.set(-5.4, 0.12, 0.15);
world.add(mac);
box(mac, 4.9, 0.24, 3.7, 0, 0.12, 0, materials.plaza);
box(mac, 4.55, 2.8, 3.25, 0, 1.55, 0, materials.coral, true);
box(mac, 4.25, 0.35, 3.05, -0.12, 3.1, 0, materials.cream, true);
box(mac, 3.45, 0.28, 2.45, -0.28, 3.4, 0, materials.white);
box(mac, 2.25, 0.3, 1.65, -0.55, 3.67, 0, materials.gold);
for (let i = 0; i < 6; i++) {
box(
mac,
0.45,
0.78,
0.05,
-1.7 + i * 0.68,
1.55,
1.645,
i === 2 ? materials.glassLight : materials.glass
);
}
for (let i = 0; i < 4; i++) {
box(
mac,
0.05,
0.74,
0.48,
-2.29,
1.55,
-1.08 + i * 0.72,
materials.glass
);
}
box(mac, 1.45, 0.14, 0.9, 0, 2.0, 2.02, materials.gold);
box(mac, 1.05, 1.42, 0.08, 0, 1.15, 1.7, materials.glass);
// Main circular theatre: radial voxel facade.
const theatre = new THREE.Group();
theatre.position.set(2.1, 0.12, 0);
world.add(theatre);
box(theatre, 5.2, 0.13, 5.2, 0, 0.065, 0, materials.dark);
const ringCount = 28;
const ringRadius = 3.25;
for (let i = 0; i < ringCount; i++) {
// Leave an opening on the south-facing entrance.
if (i === 6 || i === 7 || i === 8) continue;
const angle = (i / ringCount) * Math.PI * 2;
const x = Math.cos(angle) * ringRadius;
const z = Math.sin(angle) * ringRadius;
const rotation = Math.PI / 2 - angle;
const facadeMaterial = i % 3 === 0 ? materials.cream : materials.coral;
box(
theatre,
0.79,
2.35,
0.72,
x,
1.3,
z,
facadeMaterial,
true
);
box(
theatre,
0.86,
0.3,
0.78,
x,
2.59,
z,
materials.gold
);
box(
theatre,
0.34,
0.7,
0.045,
x * 0.985,
1.45,
z * 0.985,
materials.glass
);
}
// Upper staggered roof blocks give the theatre a voxel silhouette.
for (let i = 0; i < 10; i++) {
const angle = (i / 10) * Math.PI * 2 + 0.12;
box(
theatre,
0.78,
0.42,
0.7,
Math.cos(angle) * 2.35,
2.78,
Math.sin(angle) * 2.35,
i % 2 ? materials.roof : materials.teal,
true
);
}
box(theatre, 2.2, 0.8, 2.0, 0, 0.53, -0.2, materials.tealDark, true);
box(theatre, 1.65, 0.42, 1.5, 0, 1.1, -0.2, materials.glass);
box(theatre, 2.0, 0.13, 0.75, 0, 0.16, 3.38, materials.gold);
box(theatre, 2.7, 0.13, 0.6, 0, 0.16, 3.85, materials.cream);
// Museum of Theatre.
const museum = new THREE.Group();
museum.position.set(-4.0, 0.12, -5.15);
world.add(museum);
box(museum, 4.0, 0.2, 2.65, 0, 0.1, 0, materials.plaza);
box(museum, 3.7, 1.85, 2.3, 0, 1.15, 0, materials.cream, true);
box(museum, 2.25, 1.0, 2.45, -0.55, 2.52, 0, materials.teal, true);
box(museum, 1.0, 0.75, 2.1, 1.05, 2.38, 0, materials.gold, true);
for (let i = 0; i < 5; i++) {
box(
museum,
0.43,
0.62,
0.05,
-1.25 + i * 0.62,
1.25,
1.165,
i === 2 ? materials.glassLight : materials.glass
);
}
// Memorial Pres.Reference.
const memorial = new THREE.Group();
memorial.position.set(3.05, 0.12, -5.1);
world.add(memorial);
box(memorial, 3.5, 0.2, 2.7, 0, 0.1, 0, materials.plaza);
box(memorial, 3.15, 1.65, 2.25, 0, 1.05, 0, materials.tealDark, true);
box(memorial, 2.35, 0.85, 1.85, -0.3, 2.25, 0, materials.cream, true);
box(memorial, 1.25, 0.8, 1.4, 0.55, 2.95, 0, materials.gold, true);
box(memorial, 0.7, 1.35, 0.8, -0.9, 2.9, 0.25, materials.coral, true);
for (let i = 0; i < 4; i++) {
box(
memorial,
0.37,
0.72,
0.05,
-1.05 + i * 0.7,
1.18,
1.145,
materials.glass
);
}
// ------------------------------------------------------------------
// Hypothetical elevated connection
// ------------------------------------------------------------------
const interactiveObjects = [];
const walkway = new THREE.Group();
world.add(walkway);
const deck = box(
walkway,
3.65,
0.22,
1.38,
-1.45,
2.44,
0,
materials.teal,
true
);
interactiveObjects.push(deck);
for (const z of [-0.69, 0.69]) {
const rail = box(
walkway,
3.65,
0.13,
0.12,
-1.45,
2.94,
z,
materials.cream
);
interactiveObjects.push(rail);
for (const x of [-3.15, -2.3, -1.45, -0.6, 0.25]) {
box(
walkway,
0.09,
0.48,
0.09,
x,
2.72,
z,
materials.cream
);
}
}
for (const x of [-2.95, 0.05]) {
box(
walkway,
0.25,
2.3,
0.28,
x,
1.29,
0,
materials.glass,
true
);
}
const closureBarrier = new THREE.Group();
closureBarrier.position.set(-1.45, 0, 0);
world.add(closureBarrier);
box(
closureBarrier,
0.16,
0.72,
1.48,
0,
2.93,
0,
materials.red
);
for (const y of [2.72, 2.92, 3.12]) {
box(
closureBarrier,
0.18,
0.09,
1.47,
0,
y,
0,
materials.yellow
);
}
const crossA = box(
closureBarrier,
0.18,
0.12,
1.67,
0,
3.02,
0,
materials.red
);
crossA.rotation.x = 0.51;
const crossB = box(
closureBarrier,
0.18,
0.12,
1.67,
0,
3.02,
0,
materials.red
);
crossB.rotation.x = -0.51;
box(
closureBarrier,
0.5,
0.05,
1.35,
0,
2.58,
0,
materials.red
);
closureBarrier.traverse((object) => {
if (object.isMesh) interactiveObjects.push(object);
});
// Open/closed status beacons.
const openBeacon = new THREE.Group();
openBeacon.position.set(-1.45, 3.2, 0);
world.add(openBeacon);
box(openBeacon, 0.08, 0.48, 0.08, 0, -0.18, 0, materials.dark);
box(openBeacon, 0.34, 0.3, 0.34, 0, 0.15, 0, materials.teal);
const closedBeacon = new THREE.Group();
closedBeacon.position.set(-1.45, 3.2, 0);
world.add(closedBeacon);
box(closedBeacon, 0.08, 0.48, 0.08, 0, -0.18, 0, materials.dark);
box(closedBeacon, 0.38, 0.34, 0.38, 0, 0.17, 0, materials.red);
openBeacon.traverse((object) => {
if (object.isMesh) interactiveObjects.push(object);
});
closedBeacon.traverse((object) => {
if (object.isMesh) interactiveObjects.push(object);
});
// ------------------------------------------------------------------
// Ground-level routes
// ------------------------------------------------------------------
const routesGroup = new THREE.Group();
world.add(routesGroup);
const routeMaterials = [];
const routeArrows = [];
function createArrow(color) {
const group = new THREE.Group();
const arrowMaterial = material(color, {
transparent: true,
opacity: 0.95,
emissive: color,
emissiveIntensity: 0.15
});
box(group, 0.47, 0.035, 0.1, -0.05, 0, 0, arrowMaterial);
box(group, 0.37, 0.035, 0.1, 0.13, 0, 0.13, arrowMaterial).rotation.y = 0.5;
box(group, 0.37, 0.035, 0.1, 0.13, 0, -0.13, arrowMaterial).rotation.y = -0.5;
routesGroup.add(group);
routeArrows.push({ group, material: arrowMaterial });
return group;
}
function makeRoute(points, color, phaseOffset) {
const routeMaterial = material(color, {
transparent: true,
opacity: 0.94,
emissive: color,
emissiveIntensity: 0.24
});
routeMaterials.push(routeMaterial);
for (let i = 0; i < points.length - 1; i++) {
const a = new THREE.Vector3(points[i][0], 0, points[i][1]);
const b = new THREE.Vector3(points[i + 1][0], 0, points[i + 1][1]);
const dx = b.x - a.x;
const dz = b.z - a.z;
const length = Math.hypot(dx, dz);
const angle = Math.atan2(-dz, dx);
const midpoint = a.clone().add(b).multiplyScalar(0.5);
const underlay = box(
routesGroup,
length,
0.055,
0.76,
midpoint.x,
0.145,
midpoint.z,
materials.streetEdge
);
underlay.rotation.y = angle;
const strip = box(
routesGroup,
Math.max(0.1, length - 0.04),
0.035,
0.58,
midpoint.x,
0.19,
midpoint.z,
routeMaterial
);
strip.rotation.y = angle;
const arrow = createArrow(color);
arrow.rotation.y = angle;
routeArrows[routeArrows.length - 1].a = a.clone();
routeArrows[routeArrows.length - 1].b = b.clone();
routeArrows[routeArrows.length - 1].offset =
(phaseOffset + i * 0.31) % 1;
}
}
makeRoute(
[
[-10.2, 0.05],
[-10.2, 4.7],
[0.45, 4.7],
[2.1, 3.48]
],
palette.routeA,
0.05
);
makeRoute(
[
[6.55, -8.15],
[6.55, 0.05],
[5.3, 0.05]
],
palette.routeB,
0.52
);
// ------------------------------------------------------------------
// Projected HTML labels
// ------------------------------------------------------------------
const labels = [];
function addLabel(text, anchor, className = "") {
const element = document.createElement("div");
element.className = `world-label ${className}`;
element.innerHTML = `
<span class="label-pin"></span>
<span class="label-copy">${text}</span>
`;
labelLayer.appendChild(element);
const label = {
element,
anchor: anchor.clone(),
visible: true
};
labels.push(label);
return label;
}
addLabel(
"MAC · Museu de Arte Contemporânea",
new THREE.Vector3(-5.4, 4.15, 0.15),
"building"
);
addLabel(
"Espaço Cultural Dragão do Mar",
new THREE.Vector3(2.4, 4.15, 0.25),
"building"
);
addLabel(
"Museu do Teatro",
new THREE.Vector3(-4.0, 3.8, -5.15),
"building"
);
addLabel(
"Memorial Pres.Reference",
new THREE.Vector3(3.05, 4.15, -5.1),
"building"
);
const closureLabel = addLabel(
"HYPOTHETICAL CLOSURE",
new THREE.Vector3(-1.65, 4.05, 0),
"closure"
);
addLabel(
"A · West arrival → MAC → courtyard",
new THREE.Vector3(-4.6, 0.35, 4.75),
"route"
);
addLabel(
"B · North plaza → theatre",
new THREE.Vector3(6.58, 0.35, -2.8),
"route route-b"
);
addLabel(
"WEST ARRIVAL",
new THREE.Vector3(-10.2, 0.35, -0.5)
);
addLabel(
"NORTH PLAZA",
new THREE.Vector3(6.55, 0.35, -8.45)
);
function updateLabels() {
for (const label of labels) {
const projected = label.anchor.clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.15 &&
projected.x < 1.15 &&
projected.y > -1.15 &&
projected.y < 1.15;
label.element.style.display = visible ? "flex" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
// ------------------------------------------------------------------
// Scenario state
// ------------------------------------------------------------------
function setClosure(active, announce = true) {
closureActive = active;
closureBarrier.visible = active;
openBeacon.visible = !active;
closedBeacon.visible = active;
closureButton.classList.toggle("closed", active);
closureButton.setAttribute("aria-pressed", String(active));
closureButtonText.textContent = active
? "Reopen hypothetical link"
: "Close hypothetical link";
scenarioBanner.classList.toggle("open", !active);
scenarioIcon.textContent = active ? "×" : "↗";
if (active) {
scenarioTitle.textContent =
"Educational scenario · hypothetical closure";
scenarioText.textContent =
"The upper connection is closed in this scenario. Ground-level routes A and B remain open and provide schematic alternatives.";
closureLabel.element.querySelector(".label-copy").innerHTML =
"HYPOTHETICAL CLOSURE<br>Upper connection closed";
} else {
scenarioTitle.textContent =
"Educational scenario · walkway reopened";
scenarioText.textContent =
"The upper connection is open in this scenario. Compare it with the two ground-level alternatives.";
closureLabel.element.querySelector(".label-copy").innerHTML =
"HYPOTHETICAL UPPER LINK<br>Open in this scenario";
}
if (active) {
setRouteEmphasis(true);
}
if (announce) {
closureButton.focus({ preventScroll: true });
}
}
function setRouteEmphasis(enabled) {
routeEmphasis = enabled;
routeButtonText.textContent = enabled
? "Route emphasis: ON"
: "Route emphasis: OFF";
for (const mat of routeMaterials) {
mat.opacity = enabled ? 0.94 : 0.27;
mat.emissiveIntensity = enabled ? 0.24 : 0.03;
}
for (const arrow of routeArrows) {
arrow.material.opacity = enabled ? 0.95 : 0.18;
arrow.material.emissiveIntensity = enabled ? 0.15 : 0;
}
}
// ------------------------------------------------------------------
// Camera and direct pointer controls
// ------------------------------------------------------------------
function updateCamera() {
const radius = 30;
const horizontal = Math.cos(view.elevation) * radius;
camera.position.set(
view.target.x + Math.sin(view.azimuth) * horizontal,
view.target.y + Math.sin(view.elevation) * radius,
view.target.z + Math.cos(view.azimuth) * horizontal
);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
camera.lookAt(view.target);
camera.updateMatrixWorld();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const halfHeight = Math.max(8.8, 13.8 / aspect);
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
renderer.setSize(width, height, false);
updateCamera();
}
window.addEventListener("resize", resize);
function tweenCamera(targetState) {
cameraTween = {
start: performance.now(),
duration: 650,
from: {
azimuth: view.azimuth,
elevation: view.elevation,
zoom: view.zoom,
target: view.target.clone()
},
to: {
azimuth: targetState.azimuth ?? view.azimuth,
elevation: targetState.elevation ?? view.elevation,
zoom: targetState.zoom ?? view.zoom,
target: targetState.target
? targetState.target.clone()
: view.target.clone()
}
};
}
function resetView() {
tweenCamera(defaultView);
}
function focusRouteA() {
tweenCamera({
target: new THREE.Vector3(-4.0, 0.6, 3.0),
zoom: 1.42,
elevation: 0.76
});
}
function focusRouteB() {
tweenCamera({
target: new THREE.Vector3(5.2, 0.6, -2.7),
zoom: 1.42,
elevation: 0.76
});
}
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function pointerToNDC(event) {
const rect = canvas.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
return pointer;
}
function isInteractiveHit(event) {
raycaster.setFromCamera(pointerToNDC(event), camera);
return raycaster.intersectObjects(interactiveObjects, true).length > 0;
}
let drag = null;
canvas.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.button !== 2) return;
canvas.setPointerCapture(event.pointerId);
drag = {
pointerId: event.pointerId,
lastX: event.clientX,
lastY: event.clientY,
totalDistance: 0,
mode:
event.button === 2 || event.shiftKey || event.ctrlKey
? "pan"
: "rotate"
};
});
canvas.addEventListener("pointermove", (event) => {
if (!drag || drag.pointerId !== event.pointerId) {
canvas.style.cursor = isInteractiveHit(event) ? "pointer" : "grab";
return;
}
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.totalDistance += Math.hypot(dx, dy);
if (drag.mode === "rotate") {
view.azimuth -= dx * 0.006;
view.elevation = THREE.MathUtils.clamp(
view.elevation + dy * 0.0045,
0.34,
1.22
);
} else {
const frustumHeight =
(camera.top - camera.bottom) / camera.zoom;
const unitsPerPixel = frustumHeight / window.innerHeight;
const right = new THREE.Vector3(
Math.cos(view.azimuth),
0,
-Math.sin(view.azimuth)
);
const forward = new THREE.Vector3(
-Math.sin(view.azimuth),
0,
-Math.cos(view.azimuth)
);
view.target.addScaledVector(right, -dx * unitsPerPixel);
view.target.addScaledVector(forward, dy * unitsPerPixel);
view.target.x = THREE.MathUtils.clamp(view.target.x, -7, 7);
view.target.z = THREE.MathUtils.clamp(view.target.z, -6, 6);
}
cameraTween = null;
updateCamera();
});
canvas.addEventListener("pointerup", (event) => {
if (!drag || drag.pointerId !== event.pointerId) return;
const wasClick = drag.totalDistance < 5 && event.button === 0;
drag = null;
if (wasClick && isInteractiveHit(event)) {
setClosure(!closureActive);
}
});
canvas.addEventListener("pointercancel", () => {
drag = null;
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.zoom = THREE.MathUtils.clamp(
view.zoom * Math.exp(-event.deltaY * 0.001),
0.65,
2.55
);
cameraTween = null;
updateCamera();
},
{ passive: false }
);
// ------------------------------------------------------------------
// UI events
// ------------------------------------------------------------------
closureButton.addEventListener("click", () => {
setClosure(!closureActive);
});
routeButton.addEventListener("click", () => {
setRouteEmphasis(!routeEmphasis);
});
resetButton.addEventListener("click", resetView);
routeAButton.addEventListener("click", focusRouteA);
routeBButton.addEventListener("click", focusRouteB);
window.addEventListener("keydown", (event) => {
if (
event.target instanceof HTMLInputElement ||
event.target instanceof HTMLTextAreaElement
) {
return;
}
const key = event.key.toLowerCase();
if (key === "c") {
setClosure(!closureActive);
} else if (key === "r") {
resetView();
} else if (key === "1") {
focusRouteA();
} else if (key === "2") {
focusRouteB();
}
});
// ------------------------------------------------------------------
// Animation
// ------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
if (cameraTween) {
const t = Math.min(
1,
(performance.now() - cameraTween.start) / cameraTween.duration
);
const eased = 1 - Math.pow(1 - t, 3);
view.azimuth = THREE.MathUtils.lerp(
cameraTween.from.azimuth,
cameraTween.to.azimuth,
eased
);
view.elevation = THREE.MathUtils.lerp(
cameraTween.from.elevation,
cameraTween.to.elevation,
eased
);
view.zoom = THREE.MathUtils.lerp(
cameraTween.from.zoom,
cameraTween.to.zoom,
eased
);
view.target.lerpVectors(
cameraTween.from.target,
cameraTween.to.target,
eased
);
if (t >= 1) cameraTween = null;
}
for (const arrow of routeArrows) {
if (!arrow.a || !arrow.b) continue;
const t = (elapsed * 0.115 + arrow.offset) % 1;
arrow.group.position.lerpVectors(arrow.a, arrow.b, t);
arrow.group.position.y = 0.245;
const pulse = 0.9 + Math.sin(elapsed * 4.2 + arrow.offset * 8) * 0.1;
arrow.group.scale.setScalar(pulse);
}
if (closureActive) {
const pulse = 0.86 + Math.sin(elapsed * 4.5) * 0.14;
closedBeacon.scale.setScalar(pulse);
} else {
openBeacon.scale.setScalar(1);
}
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
resize();
setClosure(true, false);
setRouteEmphasis(true);
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
});
</script>
</body>
</html>
```