Prompt specification
Build or customize the Three.js 3D scene "Outdoor escalator landing and stair pair" 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: Outdoor escalator landing and stair pair
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/outdoor-escalator-landing-and-stair-pair-x2749
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts a referenced Comuna 13 circulation fragment with escalator landing and adjacent stairs. Show the two routes reaching the same level through different mechanical arrangements. Voxel style.
Working Three.js Starter (outdoor-escalator-landing-and-stair-pair-x2749):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Comuna 13 — Circulation Fragment</title>
<style>
:root {
--ink: #202434;
--paper: #f3eadb;
--yellow: #f6bb35;
--orange: #ed633b;
--cyan: #38b9c8;
--green: #319778;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: #5a6170;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 23px;
height: 4px;
background: var(--orange);
content: "";
}
#intro {
position: absolute;
top: 28px;
left: 30px;
width: min(380px, calc(100vw - 60px));
}
h1 {
max-width: 360px;
margin: 0;
font-size: clamp(28px, 4vw, 54px);
font-weight: 850;
letter-spacing: -0.055em;
line-height: 0.94;
}
#intro p {
max-width: 315px;
margin: 15px 0 0;
color: #5c6270;
font-size: 12px;
font-weight: 550;
line-height: 1.55;
}
.controls {
position: absolute;
top: 28px;
right: 30px;
display: flex;
align-items: center;
gap: 12px;
}
.control-copy {
padding: 9px 12px;
border: 1px solid rgba(32, 36, 52, 0.12);
border-radius: 9px;
background: rgba(255, 255, 255, 0.55);
color: #5f6470;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
backdrop-filter: blur(9px);
}
button {
pointer-events: auto;
border: 0;
border-radius: 9px;
padding: 10px 13px;
background: var(--ink);
color: white;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
cursor: pointer;
box-shadow: 0 6px 20px rgba(32, 36, 52, 0.15);
}
button:hover {
background: #343a4b;
}
#legend {
position: absolute;
bottom: 28px;
left: 30px;
display: flex;
align-items: stretch;
gap: 8px;
}
.legend-card {
display: grid;
grid-template-columns: 28px 1fr;
min-width: 142px;
padding: 10px 13px 10px 10px;
border: 1px solid rgba(32, 36, 52, 0.1);
border-radius: 10px;
background: rgba(255, 255, 255, 0.68);
box-shadow: 0 8px 25px rgba(38, 39, 47, 0.06);
backdrop-filter: blur(10px);
}
.legend-number {
align-self: center;
color: #7b7e85;
font-size: 10px;
font-weight: 850;
}
.legend-card strong {
display: block;
font-size: 10px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.legend-card small {
display: block;
margin-top: 3px;
color: #747983;
font-size: 9px;
font-weight: 600;
}
.legend-card.stairs {
border-top: 3px solid var(--yellow);
}
.legend-card.escalator {
border-top: 3px solid var(--cyan);
}
.legend-card.landing {
border-top: 3px solid var(--green);
}
#scale {
position: absolute;
right: 30px;
bottom: 30px;
display: flex;
align-items: center;
gap: 9px;
color: #646975;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#scale-line {
position: relative;
width: 76px;
height: 8px;
border-bottom: 2px solid #646975;
}
#scale-line::before,
#scale-line::after {
position: absolute;
bottom: -4px;
width: 2px;
height: 8px;
background: #646975;
content: "";
}
#scale-line::before {
left: 0;
}
#scale-line::after {
right: 0;
}
.scene-label {
position: absolute;
z-index: 4;
min-width: 112px;
padding: 8px 10px;
border: 1px solid rgba(32, 36, 52, 0.12);
border-radius: 8px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 8px 24px rgba(32, 36, 52, 0.1);
opacity: 0;
transform: translate(-50%, -100%);
transition: opacity 120ms linear;
backdrop-filter: blur(8px);
}
.scene-label::after {
position: absolute;
bottom: -18px;
left: 50%;
width: 1px;
height: 18px;
background: rgba(32, 36, 52, 0.28);
content: "";
}
.scene-label strong {
display: block;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.scene-label small {
display: block;
margin-top: 2px;
color: #747984;
font-size: 8px;
font-weight: 650;
}
.scene-label.stairs {
border-left: 4px solid var(--yellow);
}
.scene-label.escalator {
border-left: 4px solid var(--cyan);
}
.scene-label.landing {
border-left: 4px solid var(--green);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: var(--paper);
color: var(--ink);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
#intro {
top: 20px;
left: 20px;
}
#intro p,
.control-copy,
#scale {
display: none;
}
.controls {
top: 20px;
right: 20px;
}
#legend {
right: 20px;
bottom: 18px;
left: 20px;
gap: 5px;
}
.legend-card {
min-width: 0;
flex: 1;
grid-template-columns: 1fr;
padding: 8px;
}
.legend-number,
.legend-card small {
display: none;
}
.scene-label {
min-width: 95px;
padding: 6px 8px;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<div class="hud">
<section id="intro">
<div class="eyebrow">Medellín · Colombia</div>
<h1>Comuna 13<br />Circulation Fragment</h1>
<p>
A voxel study of a shared upper landing: an inclined escalator and
an adjacent stepped route arrive at the same elevation.
</p>
</section>
<div class="controls">
<div class="control-copy">Drag to orbit · Scroll to zoom</div>
<button id="reset" type="button">Reset view</button>
</div>
<div id="legend">
<div class="legend-card stairs">
<div class="legend-number">01</div>
<div>
<strong>Stepped route</strong>
<small>Solid voxel treads</small>
</div>
</div>
<div class="legend-card escalator">
<div class="legend-number">02</div>
<div>
<strong>Inclined route</strong>
<small>Moving tread conveyor</small>
</div>
</div>
<div class="legend-card landing">
<div class="legend-number">03</div>
<div>
<strong>Shared landing</strong>
<small>Common upper level</small>
</div>
</div>
</div>
<div id="scale">
<span id="scale-line"></span>
<span>Shared datum</span>
</div>
<div id="label-stairs" class="scene-label stairs">
<strong>Stepped ascent</strong>
<small>Discrete load-bearing treads</small>
</div>
<div id="label-escalator" class="scene-label escalator">
<strong>Escalator ascent</strong>
<small>Continuous inclined mechanism</small>
</div>
<div id="label-landing" class="scene-label landing">
<strong>Shared landing</strong>
<small>Both routes reach +3.15</small>
</div>
</div>
<div id="loading">Building circulation fragment…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const loading = document.querySelector("#loading");
// -------------------------------------------------------------------------
// Renderer, camera and lighting
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color("#efe4d2");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
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;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel model of a Comuna 13 stair and escalator circulation fragment"
);
stage.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 6, -6, 0.1, 100);
const hemisphere = new THREE.HemisphereLight(
"#fff5dc",
"#5c526e",
1.75
);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0cf", 3.4);
sun.position.set(8, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 14;
sun.shadow.camera.bottom = -14;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b9d9ff", 1.15);
fill.position.set(-10, 7, 6);
scene.add(fill);
const warmBounce = new THREE.PointLight("#ff9361", 25, 14, 2);
warmBounce.position.set(5, 5, 1);
scene.add(warmBounce);
// -------------------------------------------------------------------------
// Small geometry helpers
// -------------------------------------------------------------------------
const materialCache = new Map();
function getMaterial(color, options = {}) {
if (options.material) return options.material;
const key = `${color}-${options.roughness ?? 0.82}-${
options.metalness ?? 0
}-${options.emissive ?? "none"}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.82,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? "#000000",
emissiveIntensity: options.emissiveIntensity ?? 0
})
);
}
return materialCache.get(key);
}
function addBox(parent, size, position, color, options = {}) {
const geometry = new THREE.BoxGeometry(...size);
const material =
color && color.isMaterial
? color
: getMaterial(color, options);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
parent.add(mesh);
return mesh;
}
function barBetween(parent, start, end, thickness, color, options = {}) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const length = direction.length();
const mesh = addBox(
parent,
[thickness, thickness, length],
a.clone().add(b).multiplyScalar(0.5).toArray(),
color,
options
);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 0, 1),
direction.normalize()
);
return mesh;
}
function addRailing(parent, x1, x2, z, y) {
const length = x2 - x1;
const count = Math.max(2, Math.ceil(length / 0.72));
addBox(
parent,
[length, 0.09, 0.09],
[(x1 + x2) / 2, y + 0.92, z],
"#207a60"
);
addBox(
parent,
[length, 0.055, 0.055],
[(x1 + x2) / 2, y + 0.48, z],
"#2e9675"
);
for (let i = 0; i <= count; i++) {
const x = THREE.MathUtils.lerp(x1, x2, i / count);
addBox(parent, [0.075, 0.92, 0.075], [x, y + 0.46, z], "#207a60");
}
}
let seed = 13;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
// -------------------------------------------------------------------------
// Level dimensions
// -------------------------------------------------------------------------
const LEVEL = 3.15;
const STAIR_X = -2.45;
const ESCALATOR_X = 2.1;
const RUN = 5.4;
const BOTTOM_Z = 4.35;
const TOP_Z = BOTTOM_Z - RUN;
// -------------------------------------------------------------------------
// Lower ground and paving
// -------------------------------------------------------------------------
addBox(
scene,
[15.8, 0.5, 11.4],
[0, -0.36, 0.2],
"#303448"
);
const tileColors = [
"#d8c6a8",
"#e4d3b5",
"#cbb89d",
"#d9cbb5",
"#c5b7a5",
"#e0cfaa"
];
for (let ix = 0; ix < 15; ix++) {
for (let iz = 0; iz < 10; iz++) {
const x = -7 + ix * 1.0;
const z = -4.0 + iz * 1.0;
const color = tileColors[Math.floor(random() * tileColors.length)];
addBox(
scene,
[0.94, 0.075, 0.94],
[x, -0.045, z],
color,
{ castShadow: false }
);
}
}
// Colored route aprons on the lower level.
addBox(
scene,
[2.6, 0.028, 1.05],
[STAIR_X, 0.014, 4.75],
"#f2bb39"
);
addBox(
scene,
[2.2, 0.028, 1.05],
[ESCALATOR_X, 0.014, 4.75],
"#39b8c5"
);
// Left-side mural wall.
addBox(
scene,
[0.24, 3.25, 9.1],
[-7.58, 1.48, 0.1],
"#286c78"
);
const muralColors = [
"#f4bd38",
"#ed6944",
"#f0dfb9",
"#8cbf72",
"#8c6bb3"
];
for (let i = 0; i < 22; i++) {
const y = 0.25 + Math.floor(i / 7) * 0.72;
const z = -3.9 + (i % 7) * 1.18 + (Math.floor(i / 7) % 2) * 0.24;
const size = 0.28 + random() * 0.38;
addBox(
scene,
[0.08, size, size],
[-7.42, y, z],
muralColors[i % muralColors.length]
);
}
// -------------------------------------------------------------------------
// Shared upper landing
// -------------------------------------------------------------------------
addBox(
scene,
[11.25, 0.36, 3.25],
[0, LEVEL - 0.18, -2.35],
"#eadab9"
);
addBox(
scene,
[11.45, 0.16, 0.2],
[0, LEVEL - 0.12, -0.69],
"#bd4e38"
);
// Supports beneath the landing.
for (const x of [-4.9, 0, 4.9]) {
addBox(
scene,
[0.42, LEVEL - 0.38, 0.42],
[x, (LEVEL - 0.38) / 2, -1.05],
"#7e7c7b"
);
addBox(
scene,
[0.85, 0.22, 0.85],
[x, 0.06, -1.05],
"#555765"
);
}
addBox(
scene,
[10.4, 0.28, 0.38],
[0, LEVEL - 0.52, -2.8],
"#777477"
);
// Front guardrails leave openings for both routes.
addRailing(scene, -5.45, -3.72, -0.61, LEVEL);
addRailing(scene, 3.25, 5.45, -0.61, LEVEL);
// Colored paths merge into a shared green datum.
addBox(
scene,
[2.25, 0.028, 0.17],
[-1.28, LEVEL + 0.018, -1.28],
"#f2ba37"
);
addBox(
scene,
[2.25, 0.028, 0.17],
[1.28, LEVEL + 0.018, -1.28],
"#39b8c5"
);
addBox(
scene,
[0.42, 0.03, 0.28],
[0, LEVEL + 0.02, -1.28],
"#319778"
);
// Small floor arrows.
function floorArrow(parent, x, z, y, color, rotation = 0) {
const arrow = new THREE.Group();
arrow.position.set(x, y, z);
arrow.rotation.y = rotation;
parent.add(arrow);
addBox(arrow, [0.13, 0.035, 0.75], [0, 0, 0], color);
addBox(
arrow,
[0.13, 0.035, 0.55],
[-0.17, 0, -0.26],
color,
{ rotation: [0, 0.72, 0] }
);
addBox(
arrow,
[0.13, 0.035, 0.55],
[0.17, 0, -0.26],
color,
{ rotation: [0, -0.72, 0] }
);
}
floorArrow(scene, STAIR_X, 3.25, 0.04, "#f5f0df", Math.PI);
floorArrow(scene, ESCALATOR_X, 3.25, 0.04, "#eaf8f4", Math.PI);
floorArrow(scene, 0, -1.55, LEVEL + 0.035, "#247b66", Math.PI);
// -------------------------------------------------------------------------
// Conventional stair route
// -------------------------------------------------------------------------
const stairCount = 15;
const stairStepDepth = RUN / stairCount;
const stairRise = LEVEL / stairCount;
for (let i = 0; i < stairCount; i++) {
const top = (i + 1) * stairRise;
const z = BOTTOM_Z - (i + 0.5) * stairStepDepth;
// Each step is a solid voxel block, rather than a continuous ramp.
addBox(
scene,
[2.45, top, stairStepDepth],
[STAIR_X, top / 2, z],
i % 2 === 0 ? "#d8d0bd" : "#cec5b2"
);
// Crisp tread cap and warm nosing.
addBox(
scene,
[2.48, 0.055, stairStepDepth + 0.025],
[STAIR_X, top + 0.025, z],
"#eee5d2"
);
addBox(
scene,
[2.48, 0.045, 0.065],
[STAIR_X, top + 0.055, z + stairStepDepth / 2 - 0.02],
"#f4bd37"
);
}
// Green handrails on both sides.
for (const side of [-1, 1]) {
const x = STAIR_X + side * 1.26;
barBetween(
scene,
[x, 1.02, BOTTOM_Z - 0.1],
[x, LEVEL + 1.02, TOP_Z + 0.02],
0.095,
"#176c53"
);
for (let i = 0; i < stairCount; i += 3) {
const top = (i + 1) * stairRise;
const z = BOTTOM_Z - (i + 0.5) * stairStepDepth;
addBox(
scene,
[0.075, 0.96, 0.075],
[x, top + 0.48, z],
"#23795e"
);
}
}
// -------------------------------------------------------------------------
// Escalator route
// -------------------------------------------------------------------------
const escalatorLength = Math.hypot(RUN, LEVEL);
const escalatorAngle = Math.atan2(LEVEL, RUN);
const escalatorMidZ = (BOTTOM_Z + TOP_Z) / 2;
// Orange structural side chassis.
for (const side of [-1, 1]) {
const x = ESCALATOR_X + side * 1.0;
addBox(
scene,
[0.26, 0.58, escalatorLength],
[x, LEVEL / 2, escalatorMidZ],
"#dc5838",
{ rotation: [escalatorAngle, 0, 0] }
);
// Blue-green translucent balustrade panels.
const glass = new THREE.MeshStandardMaterial({
color: "#63c8cb",
roughness: 0.25,
metalness: 0.05,
transparent: true,
opacity: 0.33,
depthWrite: false
});
addBox(
scene,
[0.075, 0.66, escalatorLength],
[x, LEVEL / 2 + 0.55, escalatorMidZ],
glass,
{
rotation: [escalatorAngle, 0, 0],
castShadow: false
}
);
// Black rubber handrail.
addBox(
scene,
[0.13, 0.13, escalatorLength],
[x, LEVEL / 2 + 0.92, escalatorMidZ],
"#222a35",
{ rotation: [escalatorAngle, 0, 0], roughness: 0.55 }
);
}
// Dark conveyor bed beneath the moving treads.
addBox(
scene,
[1.82, 0.18, escalatorLength],
[ESCALATOR_X, LEVEL / 2 - 0.08, escalatorMidZ],
"#353a43",
{ rotation: [escalatorAngle, 0, 0] }
);
// Bottom and upper comb plates.
addBox(
scene,
[2.25, 0.18, 0.9],
[ESCALATOR_X, 0.01, BOTTOM_Z + 0.18],
"#d8b23e"
);
addBox(
scene,
[2.2, 0.18, 0.84],
[ESCALATOR_X, LEVEL - 0.09, TOP_Z - 0.16],
"#d8b23e"
);
for (let i = 0; i < 8; i++) {
addBox(
scene,
[0.065, 0.025, 0.52],
[ESCALATOR_X - 0.63 + i * 0.18, 0.11, BOTTOM_Z + 0.2],
"#30343d"
);
addBox(
scene,
[0.065, 0.025, 0.48],
[ESCALATOR_X - 0.63 + i * 0.18, LEVEL + 0.01, TOP_Z - 0.17],
"#30343d"
);
}
// Animated moving escalator treads.
const movingStepCount = 18;
const movingSpacing = RUN / movingStepCount;
const movingSteps = [];
for (let i = 0; i < movingStepCount; i++) {
const step = new THREE.Group();
scene.add(step);
addBox(
step,
[1.48, 0.14, 0.29],
[0, 0, 0],
"#424a54"
);
addBox(
step,
[1.48, 0.025, 0.035],
[0, 0.083, -0.135],
"#f3c344"
);
for (let rib = 0; rib < 7; rib++) {
addBox(
step,
[0.035, 0.018, 0.22],
[-0.54 + rib * 0.18, 0.079, 0],
"#5e6670",
{ castShadow: false }
);
}
movingSteps.push(step);
}
// Escalator entry indicator.
addBox(
scene,
[0.09, 1.05, 0.09],
[ESCALATOR_X + 1.45, 0.52, 4.7],
"#4a4c57"
);
const signalMaterial = new THREE.MeshStandardMaterial({
color: "#69d77d",
emissive: "#2ea950",
emissiveIntensity: 1.2,
roughness: 0.45
});
addBox(
scene,
[0.22, 0.22, 0.12],
[ESCALATOR_X + 1.45, 1.07, 4.7],
signalMaterial
);
// -------------------------------------------------------------------------
// Colorful voxel façades behind the landing
// -------------------------------------------------------------------------
function buildHouse(x, width, height, wallColor, accentColor) {
const frontZ = -2.92;
addBox(
scene,
[width, height, 1.55],
[x, LEVEL + height / 2, -3.7],
wallColor
);
addBox(
scene,
[width + 0.12, 0.17, 1.68],
[x, LEVEL + height + 0.06, -3.7],
accentColor
);
// Flat roof details.
addBox(
scene,
[0.65, 0.38, 0.55],
[x - width * 0.22, LEVEL + height + 0.32, -3.66],
"#d4cbb4"
);
addBox(
scene,
[0.18, 0.75, 0.18],
[x + width * 0.34, LEVEL + height + 0.45, -3.77],
accentColor
);
// Front windows.
const rows = Math.max(1, Math.floor((height - 0.8) / 1.05));
const columns = width > 2.45 ? 2 : 1;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < columns; col++) {
const wx =
x +
(columns === 1 ? 0 : (col - 0.5) * width * 0.42);
const wy = LEVEL + 0.72 + row * 1.02;
addBox(
scene,
[0.7, 0.79, 0.09],
[wx, wy, frontZ],
accentColor
);
addBox(
scene,
[0.54, 0.63, 0.11],
[wx, wy, frontZ + 0.065],
"#294957"
);
addBox(
scene,
[0.055, 0.64, 0.12],
[wx, wy, frontZ + 0.085],
"#e8d8b8",
{ castShadow: false }
);
}
}
// Door.
const doorY = LEVEL + 0.55;
addBox(
scene,
[0.68, 1.1, 0.12],
[x, doorY, frontZ + 0.02],
"#8b4b3c"
);
addBox(
scene,
[0.08, 0.08, 0.08],
[x + 0.22, doorY, frontZ + 0.1],
"#f0c052"
);
// Small balcony ledge.
if (height > 2.8) {
addBox(
scene,
[width * 0.56, 0.13, 0.48],
[x, LEVEL + 1.42, frontZ + 0.15],
accentColor
);
}
}
buildHouse(-4.05, 2.65, 2.65, "#e7a934", "#f2cf74");
buildHouse(-1.2, 2.55, 3.35, "#d95e43", "#f0a05d");
buildHouse(1.55, 2.75, 2.5, "#4a9c91", "#88c7b8");
buildHouse(4.35, 2.65, 3.05, "#e9893b", "#f4c36a");
// Pipes and façade blocks add dense Comuna-like detail.
addBox(
scene,
[0.13, 2.3, 0.13],
[-5.18, LEVEL + 1.3, -2.85],
"#347f73"
);
addBox(
scene,
[0.13, 1.7, 0.13],
[-0.48, LEVEL + 1.5, -2.84],
"#74527d"
);
addBox(
scene,
[0.85, 0.45, 0.42],
[2.72, LEVEL + 3.02, -2.9],
"#e2b84f"
);
// -------------------------------------------------------------------------
// Planters, trees and street details
// -------------------------------------------------------------------------
function buildPlanter(x, z) {
addBox(scene, [1.35, 0.48, 1.35], [x, 0.19, z], "#bf6544");
addBox(scene, [1.12, 0.12, 1.12], [x, 0.43, z], "#4e4132");
addBox(scene, [0.2, 1.1, 0.2], [x, 0.95, z], "#6d4b36");
const foliage = [
[-0.33, 1.48, -0.15, 0.72],
[0.31, 1.62, 0.05, 0.82],
[0.02, 1.96, -0.1, 0.7],
[-0.05, 1.5, 0.31, 0.68]
];
foliage.forEach((p, i) => {
addBox(
scene,
[p[3], p[3], p[3]],
[x + p[0], p[1], z + p[2]],
i % 2 ? "#5d9b5f" : "#78ad64"
);
});
}
buildPlanter(-5.8, 3.65);
buildPlanter(5.85, 3.6);
buildPlanter(5.95, 0.2);
// Bollards.
for (const x of [-4.4, -0.1, 4.2]) {
addBox(scene, [0.16, 0.7, 0.16], [x, 0.31, 5.0], "#4b4f5a");
addBox(scene, [0.18, 0.1, 0.18], [x, 0.69, 5.0], "#f1b83c");
}
// Lower-level wayfinding marker.
addBox(scene, [0.1, 1.25, 0.1], [3.65, 0.58, 4.65], "#454957");
addBox(scene, [0.72, 0.58, 0.12], [3.65, 1.18, 4.65], "#f0b93a");
// Pixel arrow on the sign.
addBox(scene, [0.42, 0.1, 0.07], [3.57, 1.18, 4.73], "#343846");
addBox(
scene,
[0.1, 0.1, 0.07],
[3.81, 1.3, 4.73],
"#343846",
{ rotation: [0, 0, -0.72] }
);
addBox(
scene,
[0.1, 0.1, 0.07],
[3.81, 1.06, 4.73],
"#343846",
{ rotation: [0, 0, 0.72] }
);
// -------------------------------------------------------------------------
// Voxel people
// -------------------------------------------------------------------------
function makePerson(shirt, trousers, skin = "#b97955") {
const person = new THREE.Group();
addBox(person, [0.1, 0.37, 0.12], [-0.075, 0.185, 0], trousers);
addBox(person, [0.1, 0.37, 0.12], [0.075, 0.185, 0], trousers);
addBox(person, [0.34, 0.4, 0.22], [0, 0.57, 0], shirt);
addBox(person, [0.1, 0.34, 0.12], [-0.225, 0.55, 0], skin);
addBox(person, [0.1, 0.34, 0.12], [0.225, 0.55, 0], skin);
addBox(person, [0.23, 0.23, 0.22], [0, 0.89, 0], skin);
addBox(person, [0.24, 0.07, 0.23], [0, 1.02, 0], "#30303a");
person.userData.height = 1.06;
return person;
}
const personA = makePerson("#f2c146", "#354e68");
personA.position.set(-3.9, LEVEL, -1.8);
personA.rotation.y = -0.3;
personA.scale.setScalar(0.88);
scene.add(personA);
const personB = makePerson("#e96548", "#3d4453", "#8f563e");
personB.position.set(0.15, 0, 3.6);
personB.rotation.y = 0.5;
personB.scale.setScalar(0.95);
scene.add(personB);
const personC = makePerson("#3aa7b1", "#344054");
personC.position.set(4.65, LEVEL, -2.15);
personC.rotation.y = 1.2;
personC.scale.setScalar(0.82);
scene.add(personC);
const stairWalker = makePerson("#e96243", "#31445a");
stairWalker.scale.setScalar(0.82);
scene.add(stairWalker);
const escalatorRider = makePerson("#f4bf3e", "#3c4250");
escalatorRider.scale.setScalar(0.8);
scene.add(escalatorRider);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan-free rotation and zoom
// -------------------------------------------------------------------------
const cameraState = {
yaw: 0.67,
pitch: 0.57,
zoom: 1,
target: new THREE.Vector3(0, 2.15, 0.25)
};
function updateCamera() {
const radius = 25;
const cp = Math.cos(cameraState.pitch);
const sp = Math.sin(cameraState.pitch);
camera.position.set(
cameraState.target.x + radius * Math.sin(cameraState.yaw) * cp,
cameraState.target.y + radius * sp,
cameraState.target.z + radius * Math.cos(cameraState.yaw) * cp
);
camera.lookAt(cameraState.target);
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
function resetCamera() {
cameraState.yaw = 0.67;
cameraState.pitch = 0.57;
cameraState.zoom = 1;
updateCamera();
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
if (!event.isPrimary) return;
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging || !event.isPrimary) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.yaw -= dx * 0.006;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + dy * 0.0045,
0.22,
1.12
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event &&
renderer.domElement.hasPointerCapture &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * Math.exp(event.deltaY * 0.001),
0.68,
2.25
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
document.querySelector("#reset").addEventListener("click", resetCamera);
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const halfHeight = Math.max(5.7, 9.6 / aspect);
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
renderer.setSize(width, height);
updateCamera();
}
window.addEventListener("resize", resize);
// -------------------------------------------------------------------------
// Projected HTML labels
// -------------------------------------------------------------------------
const labels = [
{
element: document.querySelector("#label-stairs"),
position: new THREE.Vector3(STAIR_X - 0.25, 2.05, 2.05),
offsetX: -18,
offsetY: -6
},
{
element: document.querySelector("#label-escalator"),
position: new THREE.Vector3(ESCALATOR_X + 0.25, 2.35, 1.9),
offsetX: 18,
offsetY: -6
},
{
element: document.querySelector("#label-landing"),
position: new THREE.Vector3(0, LEVEL + 0.78, -1.55),
offsetX: 0,
offsetY: -8
}
];
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
labels.forEach(label => {
const projected = label.position.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.opacity = visible ? "1" : "0";
const x = (projected.x * 0.5 + 0.5) * width + label.offsetX;
const y = (-projected.y * 0.5 + 0.5) * height + label.offsetY;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
});
}
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
// Moving escalator tread conveyor.
const phase = (elapsed * 0.72) % RUN;
movingSteps.forEach((step, index) => {
const distance = (phase + index * movingSpacing) % RUN;
const y = 0.02 + (LEVEL - 0.09) * (distance / RUN);
step.position.set(
ESCALATOR_X,
y,
BOTTOM_Z - distance
);
});
// A small person moving on the stepped route.
const stairDistance = (elapsed * 0.72) % RUN;
const stairIndex = Math.min(
stairCount - 1,
Math.floor(stairDistance / stairStepDepth)
);
stairWalker.position.set(
STAIR_X,
(stairIndex + 1) * stairRise,
BOTTOM_Z - (stairIndex + 0.5) * stairStepDepth
);
// Another person riding the moving treads.
const escalatorDistance = (elapsed * 0.9) % RUN;
const escalatorY =
0.02 +
(LEVEL - 0.09) * (escalatorDistance / RUN) +
0.07;
escalatorRider.position.set(
ESCALATOR_X,
escalatorY,
BOTTOM_Z - escalatorDistance
);
signalMaterial.emissiveIntensity =
0.8 + Math.max(0, Math.sin(elapsed * 3.2)) * 0.9;
updateLabels();
renderer.render(scene, camera);
}
resize();
updateCamera();
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
});
</script>
</body>
</html>
```