Prompt specification
Build or customize the Three.js 3D scene "Bus Door Aligned With Boarding Pad" 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: Bus Door Aligned With Boarding Pad
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/bus-door-aligned-with-boarding-pad-x2085
Scene Description Prompt:
A voxel bus doorway aligned with a boarding pad, showing waiting positions and clearances. One HTML file with Three.js from cdnjs.
Working Three.js Starter (bus-door-aligned-with-boarding-pad-x2085):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voxel Bus Boarding Alignment</title>
<style>
:root {
--ink: #17343a;
--muted: #587078;
--teal: #138a86;
--teal-light: #d9f0eb;
--amber: #f3bd42;
--coral: #e96b58;
--panel: rgba(255, 255, 255, 0.9);
--border: rgba(23, 52, 58, 0.12);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eaf1ed;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#viewport,
#labels {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#viewport canvas:active {
cursor: grabbing;
}
#labels {
z-index: 3;
pointer-events: none;
overflow: hidden;
}
.world-label {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -50%);
padding: 6px 9px;
border-radius: 7px;
border: 1px solid rgba(255, 255, 255, 0.65);
box-shadow: 0 5px 18px rgba(23, 52, 58, 0.12);
font-size: 11px;
font-weight: 800;
line-height: 1;
letter-spacing: 0.035em;
white-space: nowrap;
will-change: left, top;
}
.world-label.measure {
color: #fff;
background: rgba(23, 52, 58, 0.94);
}
.world-label.zone {
color: #075f5c;
background: rgba(222, 247, 240, 0.95);
border-color: rgba(19, 138, 134, 0.24);
}
.world-label.warning {
color: #8f3327;
background: rgba(255, 235, 226, 0.96);
border-color: rgba(233, 107, 88, 0.3);
}
.panel {
position: fixed;
z-index: 5;
top: 20px;
left: 20px;
width: min(370px, calc(100vw - 40px));
padding: 20px;
border: 1px solid var(--border);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(23, 52, 58, 0.12);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
color: var(--teal);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--teal);
content: "";
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 36px);
font-weight: 850;
line-height: 1.02;
letter-spacing: -0.045em;
}
.subtitle {
max-width: 310px;
margin: 10px 0 16px;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}
.metric {
min-width: 0;
padding: 10px;
border: 1px solid rgba(23, 52, 58, 0.09);
border-radius: 11px;
background: rgba(255, 255, 255, 0.65);
}
.metric strong {
display: block;
margin-bottom: 3px;
font-size: 16px;
font-weight: 850;
}
.metric span {
display: block;
overflow: hidden;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
}
.legend {
position: fixed;
z-index: 5;
left: 20px;
bottom: 20px;
display: flex;
flex-wrap: wrap;
gap: 8px 14px;
max-width: min(470px, calc(100vw - 40px));
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: 13px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 12px 34px rgba(23, 52, 58, 0.09);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.03em;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.swatch {
width: 12px;
height: 12px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(23, 52, 58, 0.12);
}
.swatch.teal {
background: var(--teal);
}
.swatch.amber {
background: var(--amber);
}
.swatch.coral {
background: var(--coral);
}
.controls {
position: fixed;
z-index: 5;
right: 20px;
bottom: 20px;
display: flex;
gap: 8px;
}
button {
appearance: none;
border: 1px solid rgba(23, 52, 58, 0.14);
border-radius: 10px;
padding: 10px 13px;
color: var(--ink);
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 8px 24px rgba(23, 52, 58, 0.1);
cursor: pointer;
font: inherit;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.035em;
transition: transform 140ms ease, background 140ms ease;
}
button:hover {
transform: translateY(-1px);
background: #fff;
}
button.primary {
color: #fff;
background: var(--ink);
}
.hint {
position: fixed;
z-index: 4;
top: 22px;
right: 22px;
padding: 9px 12px;
border: 1px solid rgba(23, 52, 58, 0.1);
border-radius: 10px;
color: var(--muted);
background: rgba(255, 255, 255, 0.68);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.025em;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
@media (max-width: 760px) {
.panel {
top: 12px;
left: 12px;
width: min(330px, calc(100vw - 24px));
padding: 15px;
}
.subtitle {
margin-bottom: 12px;
}
.metric {
padding: 8px;
}
.legend {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<div id="labels"></div>
<section class="panel">
<div class="eyebrow">Boarding bay 08 / access study</div>
<h1>Aligned boarding</h1>
<p class="subtitle">
A voxel bus doorway and boarding pad share a centerline, with the door,
platform gap, waiting setback, and interior aisle clearly dimensioned.
</p>
<div class="metrics">
<div class="metric">
<strong>1.80 m</strong>
<span>Clear door</span>
</div>
<div class="metric">
<strong>0.15 m</strong>
<span>Platform gap</span>
</div>
<div class="metric">
<strong>0.90 m</strong>
<span>Wait setback</span>
</div>
</div>
</section>
<div class="hint">Drag to orbit · Shift-drag to pan · Scroll to zoom</div>
<div class="legend">
<div class="legend-item">
<span class="swatch teal"></span>
Waiting / clear zone
</div>
<div class="legend-item">
<span class="swatch amber"></span>
Safety marking
</div>
<div class="legend-item">
<span class="swatch coral"></span>
Alignment axis
</div>
</div>
<div class="controls">
<button id="resetView">3/4 view</button>
<button id="planView">Plan view</button>
<button id="toggleMeasures" class="primary">Hide measures</button>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.getElementById("viewport");
const labelLayer = document.getElementById("labels");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeaf1ed);
scene.fog = new THREE.Fog(0xeaf1ed, 24, 48);
const renderer = new THREE.WebGLRenderer({
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.05;
viewport.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 6, -6, 0.1, 100);
const target = new THREE.Vector3(0.35, 1.25, 1.2);
const controls = {
yaw: 0.54,
pitch: 0.57,
radius: 18,
zoom: 1
};
const baseViewHeight = 10.7;
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true,
...options
});
}
const mats = {
ground: material(0xdde8e2),
road: material(0x46545a),
roadEdge: material(0x6c797d),
pad: material(0xe8dfc8),
padLine: material(0xc7bda7),
padBorder: material(0xfffaf0),
yellow: material(0xf3bd42),
amber: material(0xe49b27),
teal: material(0x138a86),
tealDark: material(0x0b6664),
tealPale: material(0x8ac8bd),
coral: material(0xe96b58),
navy: material(0x203b43),
charcoal: material(0x26373b),
cream: material(0xf5ead0),
white: material(0xf8faf5),
window: material(0x284e5a, {
roughness: 0.25,
metalness: 0.12
}),
steel: material(0x9eafb0, {
roughness: 0.42,
metalness: 0.42
}),
glass: material(0x8ac5c8, {
transparent: true,
opacity: 0.38,
roughness: 0.18,
metalness: 0.08,
depthWrite: false
}),
seat: material(0xd95d4d),
seatBase: material(0x24434a),
skin: material(0xd99d75),
skinDark: material(0x9d654c),
hair: material(0x3b302c),
shirtCoral: material(0xd85f4d),
shirtBlue: material(0x477f9c),
pants: material(0x344b58)
};
function addBox(size, position, mat, parent = scene, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
// Lighting
scene.add(new THREE.HemisphereLight(0xf7fff8, 0x71837b, 2.1));
const sun = new THREE.DirectionalLight(0xfff6df, 3.2);
sun.position.set(-7, 13, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xa9d8df, 0.7);
fill.position.set(8, 6, -8);
scene.add(fill);
// Ground, road, and grid
addBox([32, 0.1, 28], [0, -0.06, 2], mats.ground);
addBox([11.2, 0.05, 4.2], [0, 0.015, -0.2], mats.road);
addBox([11.25, 0.055, 0.1], [0, 0.02, 1.94], mats.roadEdge);
const grid = new THREE.GridHelper(30, 30, 0x91aaa0, 0xb8cbc1);
grid.position.y = 0.003;
grid.material.transparent = true;
grid.material.opacity = 0.19;
scene.add(grid);
// Boarding pad: starts at z = 2.03 m
const padX = 0.7;
const padCenterZ = 3.78;
const padWidth = 4.8;
const padDepth = 3.5;
addBox(
[padWidth, 0.18, padDepth],
[padX, 0.09, padCenterZ],
mats.pad
);
// Pad border
addBox([padWidth, 0.025, 0.07], [padX, 0.19, 2.06], mats.padBorder);
addBox([padWidth, 0.025, 0.07], [padX, 0.19, 5.50], mats.padBorder);
addBox([0.07, 0.025, padDepth], [-1.67, 0.19, padCenterZ], mats.padBorder);
addBox([0.07, 0.025, padDepth], [3.07, 0.19, padCenterZ], mats.padBorder);
// Tile joints
for (let x = -1.3; x <= 2.8; x += 0.7) {
addBox([0.018, 0.007, 3.28], [x, 0.184, padCenterZ], mats.padLine, scene, {
castShadow: false
});
}
for (let z = 2.4; z <= 5.2; z += 0.7) {
addBox([4.55, 0.007, 0.018], [padX, 0.184, z], mats.padLine, scene, {
castShadow: false
});
}
// Tactile warning studs
for (let i = 0; i < 11; i++) {
addBox(
[0.15, 0.055, 0.15],
[-1.3 + i * 0.4, 0.2075, 2.28],
mats.amber,
scene,
{ castShadow: false }
);
}
// Wait line, 900 mm behind the pad edge
addBox([3.6, 0.035, 0.12], [padX, 0.205, 2.93], mats.yellow, scene, {
castShadow: false
});
// Door-to-pad alignment axis
for (let i = 0; i < 5; i++) {
addBox(
[0.07, 0.018, 0.13],
[padX, 0.205, 2.12 + i * 0.17],
mats.coral,
scene,
{ castShadow: false }
);
}
// Clear corridor edges
for (const x of [-0.08, 1.48]) {
for (let i = 0; i < 3; i++) {
addBox(
[0.045, 0.018, 0.19],
[x, 0.205, 2.35 + i * 0.24],
mats.teal,
scene,
{ castShadow: false }
);
}
}
// Bus
const bus = new THREE.Group();
scene.add(bus);
// Chassis and floor
addBox([9.2, 0.24, 3.2], [0, 0.12, 0], mats.charcoal, bus);
addBox([9.0, 0.1, 3.02], [0, 0.3, 0], mats.cream, bus);
// Door opening in the near wall: x = -0.2 to 1.6
const doorLeft = -0.2;
const doorRight = 1.6;
const doorCenter = (doorLeft + doorRight) / 2;
// Far body wall
addBox([9.2, 3.2, 0.18], [0, 1.95, -1.59], mats.yellow, bus);
// Near wall segments around the actual doorway
addBox([4.4, 3.2, 0.18], [-2.4, 1.95, 1.59], mats.yellow, bus);
addBox([3.0, 3.2, 0.18], [3.1, 1.95, 1.59], mats.yellow, bus);
// End walls and roof
addBox([0.2, 3.2, 3.2], [-4.6, 1.95, 0], mats.yellow, bus);
addBox([0.2, 3.2, 3.2], [4.6, 1.95, 0], mats.yellow, bus);
addBox([9.35, 0.2, 3.3], [0, 3.64, 0], mats.cream, bus);
addBox([9.38, 0.11, 3.34], [0, 3.78, 0], mats.teal, bus);
addBox([1.6, 0.3, 1.35], [1.5, 3.98, -0.25], mats.cream, bus);
addBox([1.35, 0.07, 1.1], [1.5, 4.15, -0.25], mats.tealDark, bus);
// Lower teal body band
addBox([4.4, 0.67, 0.05], [-2.4, 0.72, 1.71], mats.teal, bus);
addBox([3.0, 0.67, 0.05], [3.1, 0.72, 1.71], mats.teal, bus);
addBox([9.0, 0.67, 0.05], [0, 0.72, -1.71], mats.teal, bus);
// Near-side windows
const nearWindows = [
[-3.55, 2.43, 1.32, 1.16],
[-1.55, 2.43, 1.35, 1.16],
[2.45, 2.43, 1.15, 1.16],
[3.73, 2.43, 0.72, 1.16]
];
for (const [x, y, w, h] of nearWindows) {
addBox([w + 0.13, h + 0.13, 0.055], [x, y, 1.705], mats.cream, bus);
addBox([w, h, 0.065], [x, y, 1.745], mats.window, bus);
}
// Far-side windows, visible through the open doorway
for (const [x, w] of [[-3.5, 1.3], [-1.5, 1.3], [2.45, 1.25], [3.8, 0.7]]) {
addBox([w + 0.12, 1.28, 0.055], [x, 2.43, -1.705], mats.cream, bus);
addBox([w, 1.15, 0.065], [x, 2.43, -1.745], mats.window, bus);
}
// End windows
addBox([0.06, 1.42, 2.5], [4.71, 2.45, 0], mats.cream, bus);
addBox([0.07, 1.2, 2.25], [4.75, 2.45, 0], mats.window, bus);
addBox([0.06, 1.42, 2.5], [-4.71, 2.45, 0], mats.cream, bus);
addBox([0.07, 1.2, 2.25], [-4.75, 2.45, 0], mats.window, bus);
// Voxel wheels and square hubs
for (const x of [-3.15, 3.15]) {
for (const z of [-1.69, 1.69]) {
addBox([0.78, 0.78, 0.28], [x, 0.4, z], mats.charcoal, bus);
const hubZ = z > 0 ? z + 0.17 : z - 0.17;
addBox([0.32, 0.32, 0.055], [x, 0.4, hubZ], mats.steel, bus);
}
}
// Doorway threshold: outer edge at z = 1.88 m
addBox([1.8, 0.1, 0.5], [doorCenter, 0.34, 1.63], mats.steel, bus);
// Door frame
addBox([0.17, 3.2, 0.22], [doorLeft - 0.06, 1.95, 1.72], mats.charcoal, bus);
addBox([0.17, 3.2, 0.22], [doorRight + 0.06, 1.95, 1.72], mats.charcoal, bus);
addBox([2.03, 0.22, 0.22], [doorCenter, 3.54, 1.72], mats.charcoal, bus);
// Striped safety blocks on the door jambs
for (const x of [doorLeft - 0.06, doorRight + 0.06]) {
for (let i = 0; i < 8; i++) {
addBox(
[0.18, 0.17, 0.035],
[x, 0.58 + i * 0.38, 1.845],
mats.yellow,
bus,
{ castShadow: false }
);
}
}
// Parked sliding door panes
addBox([0.72, 2.5, 0.045], [-0.94, 2.04, 1.78], mats.glass, bus, {
castShadow: false
});
addBox([0.72, 2.5, 0.045], [2.34, 2.04, 1.78], mats.glass, bus, {
castShadow: false
});
// Interior 1.2 m clear aisle
addBox([1.8, 0.028, 1.2], [doorCenter, 0.362, 0], mats.tealPale, bus, {
castShadow: false
});
// Interior poles
addBox([0.055, 2.42, 0.055], [0.06, 1.65, 0.73], mats.yellow, bus);
addBox([0.055, 2.42, 0.055], [1.34, 1.65, 0.73], mats.yellow, bus);
addBox([1.32, 0.055, 0.055], [doorCenter, 2.77, 0.73], mats.yellow, bus);
// Seats along the far interior wall
for (const x of [-2.8, -1.45, 2.55, 3.85]) {
addBox([0.72, 0.17, 0.68], [x, 0.66, -1.08], mats.seat, bus);
addBox([0.72, 0.75, 0.17], [x, 1.05, -1.38], mats.seat, bus);
addBox([0.12, 0.31, 0.12], [x, 0.48, -1.08], mats.seatBase, bus);
}
// Interior doorway light
const doorwayLight = new THREE.PointLight(0xffdb91, 14, 5, 2);
doorwayLight.position.set(0.7, 2.75, 0.1);
scene.add(doorwayLight);
// Waiting-position outlines
function waitingMarker(x, z, color = mats.teal) {
const y = 0.215;
const s = 1.08;
const t = 0.055;
addBox([s, 0.018, t], [x, y, z - s / 2], color, scene, { castShadow: false });
addBox([s, 0.018, t], [x, y, z + s / 2], color, scene, { castShadow: false });
addBox([t, 0.018, s], [x - s / 2, y, z], color, scene, { castShadow: false });
addBox([t, 0.018, s], [x + s / 2, y, z], color, scene, { castShadow: false });
}
waitingMarker(-0.8, 4.35);
waitingMarker(0.7, 4.35);
waitingMarker(2.2, 4.35);
// Voxel passenger
function createPerson(x, z, shirt, skin, rotation = 0) {
const person = new THREE.Group();
person.position.set(x, 0.18, z);
person.rotation.y = rotation;
scene.add(person);
addBox([0.27, 0.12, 0.35], [-0.16, 0.06, 0.03], mats.charcoal, person);
addBox([0.27, 0.12, 0.35], [0.16, 0.06, 0.03], mats.charcoal, person);
addBox([0.22, 0.58, 0.25], [-0.16, 0.39, 0], mats.pants, person);
addBox([0.22, 0.58, 0.25], [0.16, 0.39, 0], mats.pants, person);
addBox([0.62, 0.62, 0.36], [0, 0.98, 0], shirt, person);
addBox([0.17, 0.57, 0.22], [-0.39, 0.96, 0], shirt, person);
addBox([0.17, 0.57, 0.22], [0.39, 0.96, 0], shirt, person);
addBox([0.16, 0.12, 0.16], [0, 1.34, 0], skin, person);
addBox([0.4, 0.42, 0.38], [0, 1.59, 0], skin, person);
addBox([0.42, 0.11, 0.4], [0, 1.84, -0.01], mats.hair, person);
addBox([0.16, 0.16, 0.025], [0.12, 1.05, 0.194], mats.white, person, {
castShadow: false
});
return person;
}
createPerson(-0.8, 4.35, mats.shirtCoral, mats.skin, 0.08);
createPerson(2.2, 4.35, mats.shirtBlue, mats.skinDark, -0.1);
// Small stop marker
addBox([0.12, 1.5, 0.12], [-2.35, 0.93, 4.72], mats.charcoal);
addBox([1.05, 0.62, 0.1], [-2.35, 1.7, 4.72], mats.teal);
// Canvas text planes, generated locally without extra libraries
function createTextPlane(
text,
width,
height,
{
foreground = "#17343a",
background = "transparent",
border = null,
fontScale = 0.58
} = {}
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = Math.max(128, Math.round(1024 * height / width));
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
if (background !== "transparent") {
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
if (border) {
ctx.strokeStyle = border;
ctx.lineWidth = 12;
ctx.strokeRect(6, 6, canvas.width - 12, canvas.height - 12);
}
ctx.fillStyle = foreground;
ctx.font = `800 ${Math.floor(canvas.height * fontScale)}px Arial, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height * 0.53);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide,
toneMapped: false
})
);
}
// Bus signage
const entrySign = createTextPlane("ENTRY", 1.28, 0.21, {
foreground: "#17343a",
background: "#f3bd42"
});
entrySign.position.set(doorCenter, 3.54, 1.85);
bus.add(entrySign);
const busNumber = createTextPlane("08", 0.72, 0.46, {
foreground: "#f5ead0",
background: "#138a86"
});
busNumber.position.set(3.12, 1.25, 1.79);
bus.add(busNumber);
const busName = createTextPlane("VOXEL TRANSIT", 2.45, 0.34, {
foreground: "#17343a",
background: "#f5ead0"
});
busName.position.set(0.85, 1.24, 1.79);
bus.add(busName);
const stopSign = createTextPlane("08 BOARD", 0.93, 0.45, {
foreground: "#f5ead0",
background: "#138a86"
});
stopSign.position.set(-2.35, 1.7, 4.78);
scene.add(stopSign);
// Floor text
const padText = createTextPlane("BOARDING PAD", 2.65, 0.37, {
foreground: "#50656a",
fontScale: 0.55
});
padText.rotation.x = -Math.PI / 2;
padText.position.set(0.7, 0.205, 5.12);
scene.add(padText);
const keepClearText = createTextPlane("KEEP CLEAR", 1.35, 0.2, {
foreground: "#b44e3e",
fontScale: 0.54
});
keepClearText.rotation.x = -Math.PI / 2;
keepClearText.position.set(0.7, 0.207, 2.62);
scene.add(keepClearText);
// Measurement geometry
const measureGroup = new THREE.Group();
scene.add(measureGroup);
function addDimension(start, end, tick, color) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const tickVector = new THREE.Vector3(...tick);
const direction = b.clone().sub(a).normalize();
const lineMaterial = new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.92,
depthTest: false,
depthWrite: false
});
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([a, b]),
lineMaterial
);
line.renderOrder = 20;
measureGroup.add(line);
const ticks = new THREE.LineSegments(
new THREE.BufferGeometry().setFromPoints([
a.clone().sub(tickVector),
a.clone().add(tickVector),
b.clone().sub(tickVector),
b.clone().add(tickVector)
]),
lineMaterial
);
ticks.renderOrder = 20;
measureGroup.add(ticks);
const arrowHeight = Math.min(0.19, a.distanceTo(b) * 0.38);
const arrowGeometry = new THREE.ConeGeometry(0.065, arrowHeight, 8);
const arrowMaterial = new THREE.MeshBasicMaterial({
color,
depthTest: false,
depthWrite: false
});
const arrowA = new THREE.Mesh(arrowGeometry, arrowMaterial);
arrowA.position.copy(a).addScaledVector(direction, -arrowHeight / 2);
arrowA.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction
);
arrowA.renderOrder = 21;
measureGroup.add(arrowA);
const arrowB = new THREE.Mesh(arrowGeometry, arrowMaterial);
arrowB.position.copy(b).addScaledVector(direction, arrowHeight / 2);
arrowB.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().negate()
);
arrowB.renderOrder = 21;
measureGroup.add(arrowB);
}
// Door width
addDimension(
[doorLeft, 0.53, 2.03],
[doorRight, 0.53, 2.03],
[0, 0.13, 0],
0x17343a
);
// Bus-to-pad gap
addDimension(
[1.95, 0.43, 1.88],
[1.95, 0.43, 2.03],
[0.1, 0, 0],
0xe96b58
);
// Waiting setback
addDimension(
[-1.5, 0.31, 2.03],
[-1.5, 0.31, 2.93],
[0.1, 0, 0],
0x17343a
);
// Interior aisle
addDimension(
[0.7, 0.4, -0.6],
[0.7, 0.4, 0.6],
[0.12, 0, 0],
0x138a86
);
// World-anchored HTML labels
const labels = [];
function addWorldLabel(text, position, type = "measure") {
const element = document.createElement("div");
element.className = `world-label ${type}`;
element.textContent = text;
labelLayer.appendChild(element);
labels.push({
element,
position: new THREE.Vector3(...position)
});
}
addWorldLabel("1,800 mm CLEAR DOOR", [0.7, 0.8, 2.03]);
addWorldLabel("150 mm GAP", [2.23, 0.67, 1.95], "warning");
addWorldLabel("900 mm WAIT SET-BACK", [-1.55, 0.52, 2.48]);
addWorldLabel("1,200 mm CLEAR AISLE", [0.7, 0.73, 0], "zone");
addWorldLabel("DOOR / PAD ALIGNED", [0.7, 0.42, 2.42], "warning");
addWorldLabel("WAITING POSITIONS", [0.7, 0.42, 4.83], "zone");
// Camera controls implemented directly
let dragging = false;
let panning = false;
let lastX = 0;
let lastY = 0;
function updateCamera() {
const horizontalRadius = controls.radius * Math.cos(controls.pitch);
camera.position.set(
target.x + Math.sin(controls.yaw) * horizontalRadius,
target.y + Math.sin(controls.pitch) * controls.radius,
target.z + Math.cos(controls.yaw) * horizontalRadius
);
camera.lookAt(target);
camera.updateMatrixWorld();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = baseViewHeight / controls.zoom;
renderer.setSize(width, height);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
panning = event.shiftKey || event.button === 2;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
if (panning) {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
const right = new THREE.Vector3()
.crossVectors(forward, camera.up)
.normalize();
const up = new THREE.Vector3()
.crossVectors(right, forward)
.normalize();
const worldPerPixel = (baseViewHeight / controls.zoom) / window.innerHeight;
target.addScaledVector(right, -dx * worldPerPixel);
target.addScaledVector(up, dy * worldPerPixel);
target.y = THREE.MathUtils.clamp(target.y, 0.4, 3.2);
} else {
controls.yaw -= dx * 0.006;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.005,
0.18,
1.46
);
}
});
function endDrag(event) {
dragging = false;
panning = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.zoom = THREE.MathUtils.clamp(
controls.zoom * Math.exp(-event.deltaY * 0.001),
0.62,
2.5
);
resize();
},
{ passive: false }
);
function setView(kind) {
if (kind === "plan") {
controls.yaw = 0;
controls.pitch = 1.46;
controls.zoom = 1.08;
target.set(0.25, 0.8, 1.35);
} else {
controls.yaw = 0.54;
controls.pitch = 0.57;
controls.zoom = 1;
target.set(0.35, 1.25, 1.2);
}
resize();
}
document.getElementById("resetView").addEventListener("click", () => {
setView("reset");
});
document.getElementById("planView").addEventListener("click", () => {
setView("plan");
});
const measureButton = document.getElementById("toggleMeasures");
let measuresVisible = true;
measureButton.addEventListener("click", () => {
measuresVisible = !measuresVisible;
measureGroup.visible = measuresVisible;
for (const label of labels) {
label.element.style.display = measuresVisible ? "" : "none";
}
measureButton.textContent = measuresVisible ? "Hide measures" : "Show measures";
});
window.addEventListener("resize", resize);
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
projected.copy(label.position).project(camera);
const visible =
projected.z >= -1 &&
projected.z <= 1 &&
Math.abs(projected.x) < 1.08 &&
Math.abs(projected.y) < 1.08;
label.element.style.display = visible ? "" : "none";
if (visible) {
label.element.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
label.element.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
}
}
}
function animate() {
requestAnimationFrame(animate);
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
resize();
updateCamera();
animate();
</script>
</body>
</html>
```