Prompt specification
Build or customize the Three.js 3D scene "Mid-Levels escalator landing and stair fragment" 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: Mid-Levels escalator landing and stair fragment
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/mid-levels-escalator-landing-and-stair-fragment-x2985
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Hong Kong's Central–Mid-Levels escalator connections. Build a referenced Hong Kong circulation fragment with covered escalator landing and adjacent steps. Make the slope, upper landing, and lower street connection distinct. Voxel style.
Working Three.js Starter (mid-levels-escalator-landing-and-stair-fragment-x2985):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Central–Mid-Levels Escalator — Voxel Circulation Fragment</title>
<style>
:root {
--ink: #233238;
--paper: rgba(248, 246, 237, 0.94);
--red: #d4483f;
--teal: #087f83;
--blue: #376986;
--orange: #df8b39;
--line: rgba(35, 50, 56, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce5e2;
color: var(--ink);
font-family:
Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
sans-serif;
}
#app,
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
#scene {
display: block;
outline: none;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 10;
}
.title-card {
position: absolute;
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 19px 21px 18px;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.72);
border-left: 5px solid var(--red);
box-shadow: 0 12px 36px rgba(39, 58, 62, 0.14);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 8px;
color: var(--red);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(23px, 2.4vw, 34px);
line-height: 1.02;
letter-spacing: -0.045em;
}
.subtitle {
margin: 9px 0 0;
color: #607075;
font-size: 13px;
line-height: 1.4;
}
.location-line {
display: flex;
align-items: center;
gap: 8px;
margin-top: 13px;
padding-top: 11px;
border-top: 1px solid var(--line);
color: #52646a;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.location-line::before {
content: "";
width: 8px;
height: 8px;
background: var(--teal);
box-shadow: 0 0 0 3px rgba(8, 127, 131, 0.13);
}
.controls {
position: absolute;
top: 24px;
right: 24px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
border: 1px solid rgba(35, 50, 56, 0.16);
background: rgba(248, 246, 237, 0.92);
color: var(--ink);
padding: 10px 13px;
border-radius: 2px;
box-shadow: 0 5px 18px rgba(39, 58, 62, 0.09);
font: inherit;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
cursor: pointer;
transition:
transform 120ms ease,
background 120ms ease;
}
button:hover {
background: #fffdf5;
transform: translateY(-1px);
}
button:active {
transform: translateY(0);
}
.legend {
position: absolute;
left: 24px;
bottom: 24px;
display: grid;
grid-template-columns: repeat(2, minmax(170px, 1fr));
gap: 1px;
width: min(460px, calc(100vw - 48px));
overflow: hidden;
background: var(--line);
border: 1px solid rgba(255, 255, 255, 0.7);
box-shadow: 0 12px 36px rgba(39, 58, 62, 0.12);
backdrop-filter: blur(12px);
}
.legend-item {
min-height: 65px;
padding: 12px 14px;
background: var(--paper);
}
.legend-item strong {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 5px;
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend-item strong::before {
content: "";
flex: 0 0 auto;
width: 9px;
height: 9px;
background: var(--swatch);
}
.legend-item span {
color: #65747a;
font-size: 11px;
line-height: 1.35;
}
.hint {
position: absolute;
right: 24px;
bottom: 24px;
padding: 10px 13px;
border: 1px solid rgba(35, 50, 56, 0.12);
background: rgba(248, 246, 237, 0.84);
color: #53666c;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
backdrop-filter: blur(10px);
}
.loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #dce5e2;
color: #53666c;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
.subtitle {
display: none;
}
.controls {
top: auto;
right: 14px;
bottom: 14px;
}
button {
padding: 9px 10px;
font-size: 9px;
}
.legend {
left: 14px;
bottom: 64px;
grid-template-columns: 1fr 1fr;
width: calc(100vw - 28px);
}
.legend-item {
min-height: 58px;
padding: 9px 10px;
}
.legend-item span {
display: none;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="hud">
<section class="title-card">
<div class="eyebrow">Hong Kong · Circulation Study 01</div>
<h1>Central ↔ Mid-Levels</h1>
<p class="subtitle">
A voxel interpretation of the famous covered escalator connection:
an inclined ride, adjacent fixed steps, a sheltered upper landing, and
a direct lower-street threshold.
</p>
<div class="location-line">22.281° N · 114.158° E</div>
</section>
<nav class="controls" aria-label="Scene controls">
<button id="reset-view" type="button">Reset</button>
<button id="plan-view" type="button">Plan</button>
<button id="toggle-labels" type="button">Labels</button>
</nav>
<section class="legend" aria-label="Scene legend">
<div class="legend-item" style="--swatch: var(--orange)">
<strong>Lower street</strong>
<span>Sidewalk, curb, crossing, and taxi connection</span>
</div>
<div class="legend-item" style="--swatch: var(--teal)">
<strong>Escalator slope</strong>
<span>Continuous inclined movement and safety edge</span>
</div>
<div class="legend-item" style="--swatch: var(--blue)">
<strong>Adjacent steps</strong>
<span>Parallel fixed stair route with handrails</span>
</div>
<div class="legend-item" style="--swatch: var(--red)">
<strong>Upper landing</strong>
<span>Distinct elevated platform beneath a voxel canopy</span>
</div>
</section>
<div class="hint">Drag to orbit · Wheel to zoom · Shift-drag to pan</div>
</div>
<div class="loading" 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 app = document.getElementById("app");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce5e2);
scene.fog = new THREE.Fog(0xdce5e2, 22, 39);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.id = "scene";
renderer.domElement.setAttribute("aria-label", "Interactive voxel model of the Central–Mid-Levels escalator");
app.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xf7fbfa, 0x87948d, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff4db, 3.1);
sun.position.set(-7, 13, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc9e4ea, 0.7);
fill.position.set(10, 6, -8);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
...options,
});
const M = {
board: material(0xb8c8c2),
ground: material(0xcbd7d0),
concrete: material(0xd4d0c3),
pale: material(0xe8e3d7),
white: material(0xf3f0e6),
asphalt: material(0x465258),
asphaltDark: material(0x354149),
tread: material(0x66747a),
riser: material(0x414f55),
handrail: material(0x244a55),
teal: material(0x087f83),
tealDark: material(0x075c61),
red: material(0xd4483f),
orange: material(0xdf8b39),
yellow: material(0xf0bd55),
dark: material(0x26343a),
glass: material(0x315667, { roughness: 0.34, metalness: 0.12 }),
glassLight: material(0x6d929a, { roughness: 0.42 }),
buildingA: material(0x93aaa7),
buildingB: material(0xaebcb5),
buildingC: material(0x819996),
roof: material(0x426f68),
roofEdge: material(0xd7c9a5),
skin: material(0xe0aa83),
navy: material(0x36566b),
ochre: material(0xc08a3e),
green: material(0x6b8f73),
};
function block(parent, size, position, mat, castShadow = true) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function slopedBlock(
parent,
size,
position,
angle,
mat,
castShadow = true
) {
const mesh = block(parent, size, position, mat, castShadow);
mesh.rotation.z = angle;
return mesh;
}
function makeTextTexture(lines, accent = "#d4483f") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#f7f2df";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = accent;
ctx.lineWidth = 18;
ctx.strokeRect(9, 9, canvas.width - 18, canvas.height - 18);
ctx.fillStyle = accent;
ctx.fillRect(32, 32, 178, 192);
ctx.fillStyle = "#ffffff";
ctx.font = "800 90px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("↕", 121, 129);
ctx.textAlign = "left";
ctx.fillStyle = "#24363b";
ctx.font = "800 52px Arial, sans-serif";
ctx.fillText(lines[0], 246, 87);
ctx.fillStyle = "#52666a";
ctx.font = "600 37px Arial, sans-serif";
ctx.fillText(lines[1], 248, 151);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
renderer.capabilities.getMaxAnisotropy(),
8
);
return texture;
}
function makeTagTexture(title, subtitle, accent) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(249, 247, 238, 0.96)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 24, canvas.height);
ctx.strokeStyle = "rgba(35, 50, 56, 0.22)";
ctx.lineWidth = 5;
ctx.strokeRect(2, 2, canvas.width - 4, canvas.height - 4);
ctx.textAlign = "left";
ctx.textBaseline = "alphabetic";
ctx.fillStyle = "#26383d";
ctx.font = "800 48px Arial, sans-serif";
ctx.fillText(title, 54, 77);
ctx.fillStyle = "#64767b";
ctx.font = "600 30px Arial, sans-serif";
ctx.fillText(subtitle, 55, 132);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
return texture;
}
const labels = new THREE.Group();
scene.add(labels);
function addTag(title, subtitle, accent, position, scale = 2.2) {
const texture = makeTagTexture(title, subtitle, accent);
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
})
);
sprite.position.set(...position);
sprite.scale.set(scale, scale * 0.25, 1);
sprite.renderOrder = 20;
labels.add(sprite);
return sprite;
}
// ------------------------------------------------------------------
// Urban base and lower street connection
// ------------------------------------------------------------------
block(scene, [17.2, 0.42, 10.6], [0, -0.42, 0], M.board);
block(scene, [16.7, 0.08, 10.1], [0, -0.17, 0], M.ground, false);
const roadX = -6.58;
block(scene, [2.62, 0.13, 10.1], [roadX, -0.055, 0], M.asphalt, false);
block(scene, [0.17, 0.23, 10.1], [-5.20, -0.03, 0], M.pale, false);
block(scene, [1.12, 0.23, 10.1], [-4.64, -0.03, 0], M.concrete, false);
// Road center dashes.
for (let z = -4.45; z <= 4.5; z += 1.35) {
block(scene, [0.08, 0.025, 0.72], [roadX, 0.026, z], M.white, false);
}
// Zebra crossing aligned with the lower landing.
for (let i = 0; i < 7; i++) {
block(
scene,
[0.24, 0.028, 2.05],
[-7.48 + i * 0.32, 0.03, 0.35],
M.white,
false
);
}
// Sidewalk joints.
for (let z = -4.5; z <= 4.6; z += 1.05) {
block(scene, [1.10, 0.012, 0.035], [-4.64, 0.091, z], M.buildingC, false);
}
// Small curb bollards.
for (const z of [-2.4, -0.9, 2.3, 3.65]) {
block(scene, [0.15, 0.62, 0.15], [-5.03, 0.38, z], M.dark);
block(scene, [0.16, 0.08, 0.16], [-5.03, 0.63, z], M.yellow);
}
// Lower landing, clearly raised above the street.
block(scene, [1.03, 0.44, 2.48], [-3.88, 0.28, 0.35], M.pale);
block(scene, [1.03, 0.08, 2.48], [-3.88, 0.54, 0.35], M.white);
block(scene, [0.12, 0.52, 2.48], [-3.39, 0.28, 0.35], M.teal);
// Voxel Hong Kong red taxi on the lower street.
const taxi = new THREE.Group();
taxi.position.set(roadX, 0.04, 3.28);
scene.add(taxi);
block(taxi, [1.04, 0.42, 1.85], [0, 0.34, 0], M.red);
block(taxi, [0.88, 0.32, 1.02], [0, 0.69, -0.03], M.red);
block(taxi, [0.90, 0.26, 0.76], [0, 0.72, 0.02], M.glass);
block(taxi, [0.94, 0.06, 1.08], [0, 0.90, 0], M.red);
block(taxi, [0.42, 0.13, 0.24], [0, 1.01, 0], M.white);
block(taxi, [0.90, 0.10, 0.12], [0, 0.40, 0.94], M.yellow);
block(taxi, [0.90, 0.10, 0.12], [0, 0.40, -0.94], M.yellow);
for (const x of [-0.54, 0.54]) {
for (const z of [-0.58, 0.58]) {
block(taxi, [0.12, 0.30, 0.31], [x, 0.19, z], M.dark);
}
}
// ------------------------------------------------------------------
// Voxel context buildings
// ------------------------------------------------------------------
function addBuilding(x, z, width, depth, height, mat) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
block(group, [width, height, depth], [0, height / 2 - 0.12, 0], mat);
const front = depth / 2 + 0.025;
const cols = Math.max(2, Math.floor(width / 0.62));
const rows = Math.max(3, Math.floor((height - 0.8) / 0.78));
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
const wx = -width / 2 + 0.42 + col * ((width - 0.84) / Math.max(1, cols - 1));
const wy = 0.72 + row * 0.78;
block(
group,
[0.34, 0.39, 0.045],
[wx, wy, front],
row % 3 === 0 ? M.glassLight : M.glass,
false
);
}
}
const sideX = width / 2 + 0.025;
const sideRows = Math.max(3, Math.floor((height - 0.8) / 0.8));
const sideCols = Math.max(2, Math.floor(depth / 0.7));
for (let row = 0; row < sideRows; row++) {
for (let col = 0; col < sideCols; col++) {
const wz = -depth / 2 + 0.42 + col * ((depth - 0.84) / Math.max(1, sideCols - 1));
const wy = 0.72 + row * 0.8;
block(
group,
[0.045, 0.38, 0.32],
[sideX, wy, wz],
row % 4 === 0 ? M.glassLight : M.glass,
false
);
}
}
block(
group,
[width + 0.16, 0.18, depth + 0.16],
[0, height - 0.05, 0],
M.concrete
);
block(
group,
[width * 0.34, 0.48, depth * 0.35],
[width * 0.16, height + 0.25, -depth * 0.12],
M.buildingC
);
return group;
}
addBuilding(4.12, -3.75, 3.35, 2.72, 9.15, M.buildingA);
addBuilding(0.15, -4.02, 2.35, 2.30, 7.05, M.buildingB);
addBuilding(7.35, -3.62, 2.05, 2.55, 6.25, M.buildingC);
// A smaller street-side block provides density without blocking the route.
const streetBlock = new THREE.Group();
streetBlock.position.set(-4.26, 0, -3.65);
scene.add(streetBlock);
block(streetBlock, [2.45, 3.35, 1.75], [0, 1.57, 0], M.buildingB);
block(streetBlock, [2.55, 0.18, 1.86], [0, 3.30, 0], M.concrete);
block(streetBlock, [2.62, 0.20, 0.62], [0, 2.38, 1.02], M.teal);
for (const x of [-0.67, 0, 0.67]) {
block(streetBlock, [0.44, 1.30, 0.05], [x, 1.28, 0.90], M.glass);
}
// ------------------------------------------------------------------
// Escalator: lower entrance, inclined treads, side rails
// ------------------------------------------------------------------
const startX = -3.42;
const endX = 3.46;
const startY = 0.56;
const endY = 4.40;
const run = endX - startX;
const rise = endY - startY;
const length = Math.hypot(run, rise);
const angle = Math.atan2(rise, run);
const escalatorZ = 0.46;
const escalatorWidth = 1.56;
const escalatorCount = 31;
const escalator = new THREE.Group();
scene.add(escalator);
for (let i = 0; i < escalatorCount; i++) {
const t = (i + 0.5) / escalatorCount;
const x = startX + run * t;
const topY = startY + rise * ((i + 1) / escalatorCount);
const treadDepth = run / escalatorCount + 0.025;
block(
escalator,
[treadDepth, 0.16, escalatorWidth],
[x, topY - 0.08, escalatorZ],
M.tread
);
block(
escalator,
[0.035, 0.045, escalatorWidth - 0.05],
[x - treadDepth * 0.39, topY + 0.016, escalatorZ],
M.yellow
);
const riserHeight = rise / escalatorCount + 0.03;
block(
escalator,
[0.04, riserHeight, escalatorWidth - 0.02],
[x - treadDepth * 0.48, topY - riserHeight / 2, escalatorZ],
M.riser,
false
);
}
const midX = (startX + endX) / 2;
const midY = (startY + endY) / 2;
for (const side of [-1, 1]) {
const sideZ = escalatorZ + side * (escalatorWidth / 2 + 0.10);
slopedBlock(
escalator,
[length, 0.43, 0.20],
[midX, midY + 0.08, sideZ],
angle,
M.pale
);
slopedBlock(
escalator,
[length, 0.12, 0.17],
[midX, midY + 0.56, sideZ],
angle,
M.handrail
);
slopedBlock(
escalator,
[length, 0.07, 0.21],
[midX, midY + 0.24, sideZ],
angle,
M.teal
);
}
// Rail posts.
for (let i = 0; i <= 10; i++) {
const t = i / 10;
const x = startX + run * t;
const y = startY + rise * t;
for (const side of [-1, 1]) {
block(
escalator,
[0.09, 0.62, 0.09],
[
x,
y + 0.34,
escalatorZ + side * (escalatorWidth / 2 + 0.10),
],
M.handrail
);
}
}
// Direction indicators at the lower and upper ends.
block(escalator, [0.12, 0.18, 0.22], [-3.55, 0.85, 1.35], M.green);
block(escalator, [0.12, 0.18, 0.22], [3.57, 4.68, 1.35], M.red);
// Entrance threshold.
block(escalator, [0.34, 0.18, 2.10], [-3.49, 0.56, escalatorZ], M.teal);
block(escalator, [0.14, 0.10, 2.08], [-3.58, 0.67, escalatorZ], M.yellow);
// ------------------------------------------------------------------
// Adjacent fixed staircase
// ------------------------------------------------------------------
const stairZ = -1.33;
const stairWidth = 1.28;
const stairCount = 18;
const stairRun = run / stairCount;
const stairRise = rise / stairCount;
const stairs = new THREE.Group();
scene.add(stairs);
for (let i = 0; i < stairCount; i++) {
const x = startX + stairRun * (i + 0.5);
const topY = startY + stairRise * (i + 1);
block(
stairs,
[stairRun + 0.018, 0.13, stairWidth],
[x, topY - 0.065, stairZ],
M.pale
);
block(
stairs,
[0.055, stairRise + 0.02, stairWidth],
[x - stairRun / 2, topY - stairRise / 2, stairZ],
M.concrete,
false
);
block(
stairs,
[0.045, 0.035, stairWidth - 0.06],
[x - stairRun * 0.36, topY + 0.012, stairZ],
M.orange
);
}
for (const side of [-1, 1]) {
const sideZ = stairZ + side * (stairWidth / 2 + 0.08);
slopedBlock(
stairs,
[length, 0.12, 0.10],
[midX, midY + 0.92, sideZ],
angle,
M.handrail
);
slopedBlock(
stairs,
[length, 0.26, 0.10],
[midX, midY - 0.04, sideZ],
angle,
M.blue,
false
);
for (let i = 0; i <= 8; i++) {
const t = i / 8;
const x = startX + run * t;
const y = startY + rise * t;
block(
stairs,
[0.08, 0.93, 0.08],
[x, y + 0.46, sideZ],
M.handrail
);
}
}
// ------------------------------------------------------------------
// Upper landing and covered canopy
// ------------------------------------------------------------------
const upper = new THREE.Group();
scene.add(upper);
block(upper, [2.06, 0.32, 4.18], [4.48, 4.24, -0.39], M.concrete);
block(upper, [2.06, 0.08, 4.18], [4.48, 4.44, -0.39], M.white);
block(upper, [0.16, 0.10, 4.18], [3.50, 4.49, -0.39], M.teal);
// Landing tile grid.
for (let z = -2.15; z < 1.45; z += 0.72) {
block(upper, [1.86, 0.012, 0.026], [4.55, 4.487, z], M.buildingC, false);
}
for (const x of [4.08, 4.75]) {
block(upper, [0.026, 0.012, 4.02], [x, 4.487, -0.39], M.buildingC, false);
}
// Support columns.
for (const x of [3.72, 5.22]) {
for (const z of [-2.06, 1.04]) {
block(upper, [0.19, 4.10, 0.19], [x, 2.30, z], M.pale);
block(upper, [0.28, 0.15, 0.28], [x, 4.38, z], M.teal);
}
}
// Canopy roof and edge.
block(upper, [3.03, 0.20, 3.85], [4.46, 5.91, -0.39], M.roof);
block(upper, [3.13, 0.10, 3.94], [4.46, 6.04, -0.39], M.roofEdge);
block(upper, [3.08, 0.12, 0.12], [4.46, 5.82, 1.57], M.teal);
// Upper-level outer railing.
for (const z of [-2.06, -1.05, -0.04, 0.97]) {
block(upper, [0.10, 0.92, 0.10], [5.38, 4.94, z], M.handrail);
}
block(upper, [0.12, 0.12, 4.14], [5.38, 5.38, -0.39], M.handrail);
// Hanging destination sign.
const signTexture = makeTextTexture(
["CENTRAL ↔ MID-LEVELS", "中環 · 半山扶梯"],
"#d4483f"
);
const signMaterial = new THREE.MeshBasicMaterial({ map: signTexture });
const sign = new THREE.Mesh(new THREE.PlaneGeometry(2.54, 0.63), signMaterial);
sign.position.set(4.47, 5.37, 1.545);
upper.add(sign);
block(upper, [2.70, 0.76, 0.10], [4.47, 5.37, 1.48], M.dark, false);
// Small landing sign pylon.
block(upper, [0.17, 1.28, 0.17], [5.12, 5.05, 0.87], M.teal);
block(upper, [0.68, 0.39, 0.12], [4.86, 5.61, 0.88], M.red);
// ------------------------------------------------------------------
// Voxel pedestrians
// ------------------------------------------------------------------
function makePerson(color, scale = 1) {
const group = new THREE.Group();
const shirt = material(color);
block(group, [0.16, 0.43, 0.18], [-0.10, 0.22, 0], M.dark);
block(group, [0.16, 0.43, 0.18], [0.10, 0.22, 0], M.dark);
block(group, [0.37, 0.48, 0.32], [0, 0.66, 0], shirt);
block(group, [0.28, 0.28, 0.28], [0, 1.04, 0], M.skin);
block(group, [0.32, 0.10, 0.30], [0, 1.19, 0], M.dark);
group.scale.setScalar(scale);
return group;
}
const lowerPerson = makePerson(M.ochre, 0.92);
lowerPerson.position.set(-4.00, 0.58, 0.94);
lowerPerson.rotation.y = Math.PI;
scene.add(lowerPerson);
const upperPerson = makePerson(M.teal, 0.98);
upperPerson.position.set(4.62, 4.48, 0.70);
upperPerson.rotation.y = -Math.PI / 2;
scene.add(upperPerson);
const stairPerson = makePerson(M.navy, 0.86);
const stairPersonT = 0.57;
stairPerson.position.set(
startX + run * stairPersonT,
startY + rise * stairPersonT + 0.03,
stairZ
);
stairPerson.rotation.y = Math.PI / 2;
scene.add(stairPerson);
const streetPerson = makePerson(M.green, 0.82);
streetPerson.position.set(-4.67, 0.11, -0.85);
streetPerson.rotation.y = Math.PI;
scene.add(streetPerson);
// ------------------------------------------------------------------
// Scene annotations
// ------------------------------------------------------------------
addTag(
"LOWER STREET",
"Crossing · curb · sidewalk",
"#df8b39",
[-5.00, 1.46, 2.34],
1.95
);
addTag(
"ESCALATOR SLOPE",
"Continuous inclined route",
"#087f83",
[-0.28, 2.47, 1.39],
2.05
);
addTag(
"ADJACENT STEPS",
"Parallel fixed stair",
"#376986",
[-0.52, 2.17, -2.42],
1.95
);
addTag(
"UPPER LANDING",
"Covered elevated threshold",
"#d4483f",
[4.69, 6.42, 1.17],
2.12
);
// Small directional arrows embedded at the lower threshold.
for (let i = 0; i < 3; i++) {
block(
escalator,
[0.16, 0.03, 0.10],
[-3.15 + i * 0.20, 0.72 + i * 0.13, escalatorZ],
M.white,
false
);
}
// ------------------------------------------------------------------
// Custom camera controls — no addons
// ------------------------------------------------------------------
const orbit = {
target: new THREE.Vector3(-0.15, 2.25, -0.18),
radius: 16.8,
theta: 0.68,
phi: 1.10,
};
const defaultView = {
target: orbit.target.clone(),
radius: orbit.radius,
theta: orbit.theta,
phi: orbit.phi,
};
function updateCamera() {
orbit.phi = THREE.MathUtils.clamp(orbit.phi, 0.18, 1.46);
orbit.radius = THREE.MathUtils.clamp(orbit.radius, 9.5, 25);
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);
}
updateCamera();
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
if (event.shiftKey) {
const viewDirection = new THREE.Vector3(
Math.sin(orbit.phi) * Math.sin(orbit.theta),
0,
Math.sin(orbit.phi) * Math.cos(orbit.theta)
).normalize();
const right = new THREE.Vector3().crossVectors(
viewDirection,
new THREE.Vector3(0, 1, 0)
);
const panScale = orbit.radius * 0.00115;
orbit.target.addScaledVector(right, -dx * panScale);
orbit.target.addScaledVector(viewDirection, -dy * panScale);
} else {
orbit.theta -= dx * 0.006;
orbit.phi += dy * 0.005;
}
updateCamera();
});
function endDrag(event) {
dragging = false;
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius *= Math.exp(event.deltaY * 0.001);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
orbit.target.copy(defaultView.target);
orbit.radius = defaultView.radius;
orbit.theta = defaultView.theta;
orbit.phi = defaultView.phi;
updateCamera();
});
document.getElementById("reset-view").addEventListener("click", () => {
orbit.target.copy(defaultView.target);
orbit.radius = defaultView.radius;
orbit.theta = defaultView.theta;
orbit.phi = defaultView.phi;
updateCamera();
});
document.getElementById("plan-view").addEventListener("click", () => {
orbit.target.set(-0.15, 2.15, -0.25);
orbit.radius = 15.6;
orbit.theta = 0.001;
orbit.phi = 0.22;
updateCamera();
});
document.getElementById("toggle-labels").addEventListener("click", (event) => {
labels.visible = !labels.visible;
event.currentTarget.textContent = labels.visible ? "Labels" : "Show labels";
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
});
// Very subtle signal-light pulse.
const signalMaterials = [
material(0x37c875, { emissive: 0x0b5e2b, emissiveIntensity: 0.5 }),
material(0xef493d, { emissive: 0x681510, emissiveIntensity: 0.5 }),
];
const signalLights = [
new THREE.Mesh(unitBox, signalMaterials[0]),
new THREE.Mesh(unitBox, signalMaterials[1]),
];
signalLights[0].scale.set(0.13, 0.19, 0.23);
signalLights[0].position.set(-3.55, 0.85, 1.36);
signalLights[1].scale.set(0.13, 0.19, 0.23);
signalLights[1].position.set(3.57, 4.68, 1.36);
scene.add(signalLights[0], signalLights[1]);
renderer.setAnimationLoop((time) => {
signalMaterials[0].emissiveIntensity =
0.36 + Math.sin(time * 0.0035) * 0.22;
signalMaterials[1].emissiveIntensity =
0.42 + Math.sin(time * 0.0035 + 1.8) * 0.18;
renderer.render(scene, camera);
});
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
</script>
</body>
</html>
```