Prompt specification
Build or customize the Three.js 3D scene "Neighborhood library entrance choices" 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: Neighborhood library entrance choices
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/neighborhood-library-entrance-choices-x0459
Scene Description Prompt:
Compose a library entrance with stairs, ramp, railings, seating, and visitors using varied mobility aids; both routes should reach the same welcoming doorway. Use Three.js from cdnjs in a single HTML file, with visible voxel blocks.
Working Three.js Starter (neighborhood-library-entrance-choices-x0459):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Library Entrance</title>
<style>
:root {
color-scheme: light;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9ee;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(255, 255, 255, 0.72);
background: rgba(250, 252, 250, 0.84);
box-shadow: 0 12px 35px rgba(35, 58, 64, 0.14);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#title-card {
top: 22px;
left: 22px;
max-width: 360px;
padding: 18px 20px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 5px;
color: #39736d;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: #263b3c;
font-size: clamp(23px, 3vw, 34px);
line-height: 1.03;
letter-spacing: -0.045em;
}
#title-card p {
margin: 10px 0 0;
color: #55706e;
font-size: 13px;
line-height: 1.5;
}
.route-key {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 13px;
}
.route-key span {
padding: 6px 9px;
border-radius: 999px;
color: #294f4b;
background: #dcefeb;
font-size: 11px;
font-weight: 750;
}
#controls {
right: 22px;
top: 22px;
display: flex;
gap: 8px;
padding: 8px;
border-radius: 14px;
}
button {
border: 0;
border-radius: 10px;
padding: 10px 13px;
color: #fff;
background: #315f59;
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
box-shadow: 0 4px 10px rgba(31, 67, 62, 0.2);
}
button:hover {
background: #244f4a;
}
#help {
left: 50%;
bottom: 18px;
transform: translateX(-50%);
padding: 10px 14px;
border-radius: 999px;
color: #4b6663;
font-size: 11px;
font-weight: 650;
white-space: nowrap;
pointer-events: none;
}
#labels {
position: fixed;
inset: 0;
z-index: 5;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
transform: translate(-50%, -50%);
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 9px;
color: #294b48;
background: rgba(255, 255, 255, 0.88);
box-shadow: 0 5px 16px rgba(37, 66, 64, 0.16);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.08em;
white-space: nowrap;
}
#label-stairs {
color: #745526;
background: rgba(255, 245, 217, 0.92);
}
#label-ramp {
color: #1d6561;
background: rgba(222, 249, 244, 0.93);
}
#label-door {
color: #7b4727;
background: rgba(255, 238, 214, 0.94);
}
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
color: #315f59;
background: #e7efed;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 0.35s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
#title-card {
top: 12px;
left: 12px;
max-width: calc(100vw - 24px);
padding: 13px 15px;
}
#title-card p,
.route-key {
display: none;
}
#controls {
top: auto;
right: 12px;
bottom: 12px;
}
#help {
display: none;
}
}
</style>
</head>
<body>
<div id="loading">Building the library…</div>
<div id="title-card" class="panel">
<p class="eyebrow">An inclusive civic space</p>
<h1>The Common Door</h1>
<p>
A stepped route and a gentle 1:12 ramp converge on the same warm,
welcoming library entrance.
</p>
<div class="route-key">
<span>5-step route</span>
<span>1:12 ramp</span>
<span>Wheelchair access</span>
<span>Cane & walker</span>
</div>
</div>
<div id="controls" class="panel">
<button id="reset" type="button">Reset view</button>
</div>
<div id="help" class="panel">
Drag to orbit · Shift/right-drag to pan · Scroll to zoom
</div>
<div id="labels">
<div id="label-stairs" class="world-label">STEPS TO THE LIBRARY</div>
<div id="label-ramp" class="world-label">1:12 ACCESSIBLE RAMP</div>
<div id="label-door" class="world-label">ONE WELCOMING DOOR</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color("#dce9ee");
scene.fog = new THREE.Fog("#dce9ee", 27, 56);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
document.body.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight("#eaf6ff", "#7d8061", 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0d5", 3.25);
sun.position.set(-9, 17, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 48;
sun.shadow.bias = -0.0004;
scene.add(sun);
const doorLight = new THREE.PointLight("#ffb55d", 24, 8, 2);
doorLight.position.set(0, 2.55, -0.8);
scene.add(doorLight);
// Shared unit cube keeps the visible voxel language consistent.
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color, emissive = null) {
if (color?.isMaterial) return color;
const key = `${color}-${emissive || ""}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: emissive ? 0.55 : 0.82,
metalness: 0,
emissive: emissive || "#000000",
emissiveIntensity: emissive ? 0.8 : 0
})
);
}
return materialCache.get(key);
}
function block(
parent,
width,
height,
depth,
x,
y,
z,
color,
emissive = null
) {
const mesh = new THREE.Mesh(unitBox, material(color, emissive));
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = height > 0.08;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(parent, a, b, thickness, color) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const mesh = new THREE.Mesh(
unitBox,
material(color)
);
mesh.scale.set(thickness, thickness, length);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 0, 1),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Landscape and paved plaza
// -------------------------------------------------------------------------
block(scene, 34, 0.55, 23, 1.4, -0.31, 0, "#92ad78");
block(scene, 29, 0.12, 16, 1.2, 0.015, 0.9, "#d7d1c3");
block(scene, 27.4, 0.035, 14.5, 1.2, 0.09, 0.9, "#e4dfd4");
// Individual paving blocks emphasize the voxel construction.
for (let x = -11; x <= 13; x += 1.05) {
for (let z = -5.5; z <= 8.5; z += 1.05) {
if (Math.abs(x) < 5.7 && z < -1.2) continue;
if (x > 0.1 && x < 13.8 && z > 0.25 && z < 2.55) continue;
const shade = (Math.round(x * 3 + z * 5) % 3 === 0)
? "#e9e3d8"
: "#ddd7cb";
block(scene, 0.97, 0.035, 0.97, x, 0.13, z, shade);
}
}
// -------------------------------------------------------------------------
// Voxel library building
// -------------------------------------------------------------------------
const masonry = [
"#d9c7a8",
"#e1d0b2",
"#cfbd9f",
"#e7d8bd",
"#d5c1a1"
];
block(scene, 10.9, 6.6, 3.8, 0, 3.25, -3.65, "#c9b797");
block(scene, 11.3, 0.42, 4.25, 0, 6.65, -3.6, "#49766f");
block(scene, 10.7, 0.24, 3.9, 0, 6.91, -3.6, "#345d58");
// Facade masonry with a clear opening for the entrance.
for (let row = 0; row < 13; row++) {
for (let col = 0; col < 13; col++) {
const x = -4.8 + col * 0.8;
const y = 0.25 + row * 0.5;
const inDoorway = Math.abs(x) < 1.21 && y < 3.25;
if (inDoorway) continue;
const color = masonry[(row * 3 + col * 2) % masonry.length];
block(scene, 0.76, 0.46, 0.3, x, y, -1.6, color);
}
}
// Deep window frames and colored glass blocks.
function libraryWindow(x, y) {
block(scene, 1.9, 1.65, 0.16, x, y, -1.39, "#355b59");
block(scene, 1.64, 1.38, 0.08, x, y, -1.29, "#8ec7c5", "#153f43");
block(scene, 0.09, 1.42, 0.1, x, y, -1.22, "#e8eee8");
block(scene, 1.68, 0.09, 0.1, x, y, -1.22, "#e8eee8");
block(scene, 2.12, 0.16, 0.34, x, y - 0.88, -1.29, "#f0e4ce");
}
libraryWindow(-3.35, 2.65);
libraryWindow(3.35, 2.65);
libraryWindow(-3.35, 4.8);
libraryWindow(3.35, 4.8);
// Canopy over the common doorway.
block(scene, 5.6, 0.34, 1.7, 0, 3.37, -0.48, "#356a64");
block(scene, 5.9, 0.12, 1.84, 0, 3.59, -0.48, "#4f8279");
for (const x of [-2.35, 2.35]) {
block(scene, 0.16, 0.46, 0.16, x, 3.02, 0.16, "#d5c19e");
block(scene, 0.3, 0.16, 0.3, x, 2.82, 0.16, "#f0c979", "#6e3f12");
}
// -------------------------------------------------------------------------
// Pixel-block LIBRARY sign
// -------------------------------------------------------------------------
const pixelPatterns = {
L: [
"10000",
"10000",
"10000",
"10000",
"10000",
"10000",
"11111"
],
I: [
"11111",
"00100",
"00100",
"00100",
"00100",
"00100",
"11111"
],
B: [
"11110",
"10001",
"10001",
"11110",
"10001",
"10001",
"11110"
],
R: [
"11110",
"10001",
"10001",
"11110",
"10100",
"10010",
"10001"
],
A: [
"01110",
"10001",
"10001",
"11111",
"10001",
"10001",
"10001"
],
Y: [
"10001",
"10001",
"01010",
"00100",
"00100",
"00100",
"00100"
]
};
function pixelText(text, centerX, centerY, frontZ, scale, color) {
const totalWidth = text.length * 6 * scale - scale;
let cursor = centerX - totalWidth / 2;
for (const letter of text) {
const pattern = pixelPatterns[letter];
for (let row = 0; row < pattern.length; row++) {
for (let col = 0; col < pattern[row].length; col++) {
if (pattern[row][col] !== "1") continue;
block(
scene,
scale * 0.82,
scale * 0.82,
0.09,
cursor + col * scale,
centerY + (3 - row) * scale,
frontZ,
color
);
}
}
cursor += 6 * scale;
}
}
block(scene, 6.45, 1.22, 0.2, 0, 4.7, -1.34, "#244e4b");
block(scene, 6.1, 0.92, 0.08, 0, 4.7, -1.21, "#f1e7d0");
pixelText("LIBRARY", 0, 4.7, -1.13, 0.13, "#244e4b");
// -------------------------------------------------------------------------
// Welcoming double doorway
// -------------------------------------------------------------------------
block(scene, 2.2, 2.3, 0.12, 0, 2.12, -1.51, "#f5b55d", "#d16f1f");
block(scene, 0.18, 2.35, 0.3, -1.22, 2.12, -1.35, "#244b49");
block(scene, 0.18, 2.35, 0.3, 1.22, 2.12, -1.35, "#244b49");
block(scene, 2.62, 0.18, 0.3, 0, 3.28, -1.35, "#244b49");
function makeDoorLeaf(hingeSide) {
const pivot = new THREE.Group();
pivot.position.set(hingeSide * 1.08, 1.02, -1.29);
pivot.rotation.y = hingeSide * 0.32;
scene.add(pivot);
const centerX = -hingeSide * 0.49;
block(pivot, 0.98, 2.15, 0.13, centerX, 1.075, 0, "#315e5b");
block(pivot, 0.72, 1.36, 0.07, centerX, 1.32, 0.085, "#a3d6cc", "#315c55");
block(pivot, 0.055, 1.4, 0.09, centerX, 1.32, 0.13, "#e7efe6");
const handleX = -hingeSide * 0.82;
block(pivot, 0.07, 0.42, 0.09, handleX, 1.0, 0.12, "#f3c65e");
}
makeDoorLeaf(-1);
makeDoorLeaf(1);
// Small voxel welcome mat.
block(scene, 2.1, 0.045, 0.72, 0, 1.045, -0.98, "#7fa99d");
for (let i = -3; i <= 3; i++) {
block(scene, 0.12, 0.025, 0.58, i * 0.25, 1.08, -0.98, "#d8c9a6");
}
// -------------------------------------------------------------------------
// Raised entrance landing
// -------------------------------------------------------------------------
block(scene, 6.4, 1.0, 2.08, 0, 0.5, -0.44, "#b9b19f");
for (let x = -2.8; x <= 2.8; x += 0.8) {
for (let z = -1.2; z <= 0.4; z += 0.8) {
const shade = (Math.round(x + z) % 2 === 0)
? "#eee8db"
: "#ded8ca";
block(scene, 0.73, 0.055, 0.73, x, 1.025, z, shade);
}
}
// -------------------------------------------------------------------------
// Stair route
// -------------------------------------------------------------------------
const stairX = -1.75;
const stairWidth = 2.8;
const stairDepth = 0.62;
const stepCount = 5;
for (let i = 0; i < stepCount; i++) {
const top = (stepCount - i) * 0.2;
const z = 0.6 + (i + 0.5) * stairDepth;
block(
scene,
stairWidth,
top,
stairDepth,
stairX,
top / 2,
z,
i % 2 ? "#c9c1b2" : "#d4ccbd"
);
// Contrasting nosing makes the individual voxel steps easy to read.
block(
scene,
stairWidth - 0.08,
0.035,
0.075,
stairX,
top + 0.025,
z + stairDepth / 2 - 0.045,
"#f0c66b"
);
}
function stairSurfaceAt(z) {
const index = Math.min(
stepCount - 1,
Math.max(0, Math.floor((z - 0.6) / stairDepth))
);
return (stepCount - index) * 0.2;
}
for (const x of [stairX - stairWidth / 2, stairX + stairWidth / 2]) {
beam(
scene,
[x, 1.22, 3.72],
[x, 2.02, 0.59],
0.11,
"#315e5b"
);
for (let i = 0; i < stepCount; i++) {
const z = 0.6 + (i + 0.5) * stairDepth;
const top = (stepCount - i) * 0.2;
const railY = top + 0.98;
block(scene, 0.1, 0.98, 0.1, x, top + 0.49, z, "#315e5b");
block(scene, 0.14, 0.14, 0.14, x, railY, z, "#e5b85e");
}
}
// -------------------------------------------------------------------------
// Accessible ramp: 1.0 m rise over 12 m run
// -------------------------------------------------------------------------
const rampStartX = 13.4;
const rampEndX = 1.4;
const rampCenterX = (rampStartX + rampEndX) / 2;
const rampCenterZ = 1.4;
const rampWidth = 1.6;
const rampAngle = Math.atan2(1, 12);
const ramp = block(
scene,
12,
0.16,
rampWidth,
rampCenterX,
0.42,
rampCenterZ,
"#c9d2c7"
);
ramp.rotation.z = -rampAngle;
// Raised ramp edge curbs.
for (const z of [rampCenterZ - rampWidth / 2, rampCenterZ + rampWidth / 2]) {
const curb = block(
scene,
12,
0.13,
0.1,
rampCenterX,
0.48,
z,
"#e8c66e"
);
curb.rotation.z = -rampAngle;
}
function rampSurfaceAt(x) {
return (rampStartX - x) / 12;
}
// Voxel supports beneath the sloped slab.
for (const x of [12.2, 9.4, 6.6, 3.8]) {
const surface = rampSurfaceAt(x);
const height = Math.max(0.1, surface - 0.11);
block(scene, 0.42, height, 1.45, x, height / 2, rampCenterZ, "#aaa895");
}
// Top landing turns left onto the same platform as the stairs.
block(scene, 1.1, 1.0, 1.6, 0.85, 0.5, 1.4, "#c6c1b3");
block(scene, 1.08, 0.05, 1.58, 0.85, 1.025, 1.4, "#e1ddd0");
// Ramp handrails on both sides.
for (const z of [0.62, 2.18]) {
beam(
scene,
[rampStartX, 1.0, z],
[rampEndX, 2.0, z],
0.11,
"#315e5b"
);
beam(
scene,
[rampStartX, 0.48, z],
[rampEndX, 1.48, z],
0.075,
"#477b74"
);
for (const x of [13.4, 11, 8.6, 6.2, 3.8, 1.4]) {
const surface = rampSurfaceAt(x);
block(scene, 0.1, 0.96, 0.1, x, surface + 0.48, z, "#315e5b");
block(scene, 0.14, 0.14, 0.14, x, surface + 0.97, z, "#e5b85e");
}
}
// A small ramp information marker built from blocks.
block(scene, 0.12, 1.55, 0.12, 13.45, 0.78, 2.65, "#315e5b");
block(scene, 1.42, 0.68, 0.12, 13.75, 1.35, 2.65, "#2d625d");
block(scene, 0.82, 0.09, 0.08, 13.75, 1.48, 2.72, "#f0ca71");
block(scene, 0.09, 0.42, 0.08, 13.47, 1.33, 2.72, "#f0ca71");
// -------------------------------------------------------------------------
// Benches, planters, books, and voxel trees
// -------------------------------------------------------------------------
function bench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.16, z);
group.rotation.y = rotation;
scene.add(group);
for (let i = 0; i < 3; i++) {
block(group, 1.95, 0.12, 0.17, 0, 0.62, -0.22 + i * 0.2, "#a96d43");
}
for (let i = 0; i < 3; i++) {
block(group, 1.95, 0.14, 0.11, 0, 0.94 + i * 0.18, -0.36, "#b97849");
}
for (const side of [-0.75, 0.75]) {
block(group, 0.14, 0.58, 0.62, side, 0.29, 0, "#315e5b");
block(group, 0.12, 1.1, 0.12, side, 0.7, -0.38, "#315e5b");
}
}
bench(-6.2, 2.1);
bench(6.1, 4.15, Math.PI);
bench(-7.5, -2.5, Math.PI / 2);
function tree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
block(group, 1.55, 0.42, 1.55, 0, 0.22, 0, "#9e9b86");
block(group, 1.3, 0.08, 1.3, 0, 0.46, 0, "#5f7350");
block(group, 0.44, 2.35, 0.44, 0, 1.48, 0, "#8a6043");
const leaves = [
[-0.55, 2.45, 0.1, 1.35, "#6f9a61"],
[0.55, 2.55, -0.1, 1.25, "#7da568"],
[0, 3.15, 0.05, 1.45, "#83ad6d"],
[-0.25, 2.8, 0.62, 1.0, "#759d5f"],
[0.4, 2.9, -0.62, 1.05, "#83a76a"]
];
for (const [lx, ly, lz, size, color] of leaves) {
block(group, size, size, size, lx, ly, lz, color);
}
}
tree(-7.5, -2.8, 1.05);
tree(7.6, -4.3, 1.1);
tree(16.3, -1.4, 1.0);
tree(-10.7, 6.1, 1.1);
// Stacked books beside a bench.
const bookColors = ["#d56a54", "#497e78", "#e6b856", "#607ba4"];
for (let i = 0; i < 4; i++) {
block(
scene,
0.68,
0.13,
0.45,
-4.95,
0.23 + i * 0.14,
2.12,
bookColors[i]
);
}
// -------------------------------------------------------------------------
// Visitors made from small cuboids
// -------------------------------------------------------------------------
function standingPerson({
shirt = "#497e78",
pants = "#354a5d",
skin = "#d69a72",
hair = "#3f2c27"
} = {}) {
const group = new THREE.Group();
block(group, 0.25, 0.14, 0.4, -0.17, 0.08, 0.08, "#263638");
block(group, 0.25, 0.14, 0.4, 0.17, 0.08, 0.08, "#263638");
block(group, 0.2, 0.49, 0.23, -0.17, 0.39, 0, pants);
block(group, 0.2, 0.49, 0.23, 0.17, 0.39, 0, pants);
block(group, 0.62, 0.61, 0.37, 0, 0.93, 0, shirt);
block(group, 0.17, 0.49, 0.2, -0.42, 0.91, 0.01, shirt);
block(group, 0.17, 0.49, 0.2, 0.42, 0.91, 0.01, shirt);
block(group, 0.18, 0.18, 0.19, -0.42, 0.61, 0.02, skin);
block(group, 0.18, 0.18, 0.19, 0.42, 0.61, 0.02, skin);
block(group, 0.2, 0.12, 0.2, 0, 1.29, 0, skin);
block(group, 0.43, 0.43, 0.41, 0, 1.53, 0.02, skin);
block(group, 0.46, 0.16, 0.44, 0, 1.76, 0.01, hair);
block(group, 0.45, 0.18, 0.1, 0, 1.49, 0.205, hair);
return group;
}
function addCane(person) {
block(person, 0.055, 0.94, 0.055, 0.53, 0.52, 0.13, "#5a473b");
block(person, 0.22, 0.07, 0.08, 0.48, 1.0, 0.13, "#5a473b");
block(person, 0.075, 0.075, 0.075, 0.53, 0.08, 0.13, "#2c3030");
}
function addWalker(person) {
const walker = new THREE.Group();
person.add(walker);
for (const x of [-0.38, 0.38]) {
block(walker, 0.065, 0.84, 0.065, x, 0.46, 0.61, "#467a74");
block(walker, 0.065, 0.65, 0.065, x, 0.4, 0.42, "#467a74");
block(walker, 0.11, 0.09, 0.11, x, 0.08, 0.61, "#293b3b");
}
block(walker, 0.82, 0.075, 0.075, 0, 0.88, 0.61, "#467a74");
block(walker, 0.075, 0.075, 0.38, 0, 0.88, 0.61, "#467a74");
}
function wheelchairPerson() {
const group = new THREE.Group();
// Chassis and seat.
block(group, 0.7, 0.12, 0.68, 0, 0.62, -0.05, "#315f5b");
block(group, 0.7, 0.66, 0.12, 0, 0.94, -0.36, "#315f5b");
block(group, 0.56, 0.08, 0.58, 0, 0.71, -0.02, "#557f79");
// Rear wheels.
const rearGeometry = new THREE.CylinderGeometry(0.35, 0.35, 0.12, 16);
const rearMaterial = new THREE.MeshStandardMaterial({
color: "#273538",
roughness: 0.78
});
for (const x of [-0.41, 0.41]) {
const wheel = new THREE.Mesh(rearGeometry, rearMaterial);
wheel.rotation.z = Math.PI / 2;
wheel.position.set(x, 0.36, -0.15);
wheel.castShadow = true;
group.add(wheel);
const hub = new THREE.Mesh(
new THREE.CylinderGeometry(0.1, 0.1, 0.135, 12),
new THREE.MeshStandardMaterial({ color: "#d9b55e" })
);
hub.rotation.z = Math.PI / 2;
hub.position.set(x, 0.36, -0.15);
group.add(hub);
// Push rim.
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.27, 0.025, 6, 18),
new THREE.MeshStandardMaterial({ color: "#b8c6bf" })
);
rim.rotation.y = Math.PI / 2;
rim.position.set(x + Math.sign(x) * 0.075, 0.36, -0.15);
group.add(rim);
}
// Front casters and foot platform.
for (const x of [-0.31, 0.31]) {
block(group, 0.08, 0.42, 0.08, x, 0.32, 0.32, "#456f6a");
const caster = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.14, 0.08, 12),
new THREE.MeshStandardMaterial({ color: "#263638" })
);
caster.rotation.z = Math.PI / 2;
caster.position.set(x, 0.15, 0.42);
caster.castShadow = true;
group.add(caster);
}
block(group, 0.62, 0.07, 0.32, 0, 0.2, 0.58, "#315f5b");
// Seated visitor.
block(group, 0.59, 0.58, 0.35, 0, 1.0, -0.04, "#d56a54");
block(group, 0.18, 0.17, 0.18, -0.41, 0.91, 0.03, "#d69a72");
block(group, 0.18, 0.17, 0.18, 0.41, 0.91, 0.03, "#d69a72");
block(group, 0.43, 0.42, 0.4, 0, 1.51, 0.02, "#d69a72");
block(group, 0.46, 0.16, 0.43, 0, 1.74, 0.01, "#44332e");
block(group, 0.2, 0.2, 0.5, -0.17, 0.72, 0.26, "#354a5d");
block(group, 0.2, 0.2, 0.5, 0.17, 0.72, 0.26, "#354a5d");
block(group, 0.2, 0.42, 0.2, -0.17, 0.4, 0.48, "#354a5d");
block(group, 0.2, 0.42, 0.2, 0.17, 0.4, 0.48, "#354a5d");
block(group, 0.23, 0.14, 0.36, -0.17, 0.16, 0.57, "#263638");
block(group, 0.23, 0.14, 0.36, 0.17, 0.16, 0.57, "#263638");
// A book held in the lap.
block(group, 0.48, 0.07, 0.34, 0, 0.92, 0.32, "#e6b856");
return group;
}
// Visitor climbing the stairs toward the door.
const stairVisitor = standingPerson({
shirt: "#d56a54",
pants: "#354a5d",
skin: "#9e674d",
hair: "#252326"
});
stairVisitor.scale.setScalar(0.84);
stairVisitor.position.set(-1.7, 0.84, 1.52);
stairVisitor.rotation.y = Math.PI;
scene.add(stairVisitor);
// A carried book.
block(stairVisitor, 0.38, 0.09, 0.3, 0.39, 0.72, 0.3, "#e8c35d");
block(stairVisitor, 0.32, 0.07, 0.25, 0.39, 0.78, 0.3, "#527f7a");
// Visitor using a cane on the shared entrance platform.
const caneVisitor = standingPerson({
shirt: "#6f7da4",
pants: "#45535d",
skin: "#e0aa83",
hair: "#ddd3bd"
});
caneVisitor.scale.setScalar(0.82);
caneVisitor.position.set(1.8, 1.06, -0.32);
caneVisitor.rotation.y = Math.PI;
addCane(caneVisitor);
scene.add(caneVisitor);
// Wheelchair user travelling up the ramp.
const wheelchair = wheelchairPerson();
wheelchair.position.set(7.8, rampSurfaceAt(7.8) + 0.035, 1.4);
wheelchair.rotation.y = -Math.PI / 2;
scene.add(wheelchair);
// Visitor using a walker at the ramp approach.
const walkerVisitor = standingPerson({
shirt: "#d8a94c",
pants: "#4f5b65",
skin: "#754a37",
hair: "#312725"
});
walkerVisitor.scale.setScalar(0.8);
walkerVisitor.position.set(12.25, 0.17, 2.85);
walkerVisitor.rotation.y = -Math.PI / 2;
addWalker(walkerVisitor);
scene.add(walkerVisitor);
// A seated reader on the left bench.
const reader = new THREE.Group();
reader.position.set(-6.2, 0.16, 2.05);
scene.add(reader);
block(reader, 0.56, 0.58, 0.34, 0, 1.04, 0, "#4f8c7c");
block(reader, 0.18, 0.5, 0.19, -0.39, 1.0, 0.03, "#4f8c7c");
block(reader, 0.18, 0.5, 0.19, 0.39, 1.0, 0.03, "#4f8c7c");
block(reader, 0.18, 0.18, 0.19, -0.39, 0.7, 0.04, "#b87852");
block(reader, 0.18, 0.18, 0.19, 0.39, 0.7, 0.04, "#b87852");
block(reader, 0.42, 0.42, 0.4, 0, 1.52, 0, "#b87852");
block(reader, 0.45, 0.15, 0.43, 0, 1.75, 0, "#38302d");
block(reader, 0.22, 0.22, 0.5, -0.17, 0.71, 0.22, "#46566a");
block(reader, 0.22, 0.22, 0.5, 0.17, 0.71, 0.22, "#46566a");
block(reader, 0.2, 0.42, 0.2, -0.17, 0.4, 0.43, "#46566a");
block(reader, 0.2, 0.42, 0.2, 0.17, 0.4, 0.43, "#46566a");
block(reader, 0.62, 0.08, 0.43, 0, 1.03, 0.43, "#d76853");
// A small visitor just inside the shared landing.
const arrivingVisitor = standingPerson({
shirt: "#4e9b91",
pants: "#354a5d",
skin: "#6f4634",
hair: "#292426"
});
arrivingVisitor.scale.setScalar(0.72);
arrivingVisitor.position.set(-0.65, 1.06, -0.46);
arrivingVisitor.rotation.y = Math.PI;
scene.add(arrivingVisitor);
// -------------------------------------------------------------------------
// Direct camera controls implemented without external addons
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(1.5, 1.8, 0.4);
const defaultTarget = cameraTarget.clone();
let radius = 30;
let theta = 0.45;
let phi = 1.05;
let dragging = false;
let panning = false;
let previousX = 0;
let previousY = 0;
const minRadius = 13;
const maxRadius = 43;
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
cameraTarget.x + radius * sinPhi * Math.sin(theta),
cameraTarget.y + radius * Math.cos(phi),
cameraTarget.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(cameraTarget);
camera.updateMatrixWorld();
}
function resetCamera() {
cameraTarget.copy(defaultTarget);
radius = 30;
theta = 0.45;
phi = 1.05;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
panning = event.button === 2 || event.shiftKey;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (panning) {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const panScale = radius * 0.0016;
cameraTarget
.addScaledVector(right, -dx * panScale)
.addScaledVector(up, dy * panScale);
cameraTarget.x = THREE.MathUtils.clamp(cameraTarget.x, -8, 12);
cameraTarget.y = THREE.MathUtils.clamp(cameraTarget.y, 0.5, 7);
cameraTarget.z = THREE.MathUtils.clamp(cameraTarget.z, -5, 7);
} else {
theta -= dx * 0.006;
phi = THREE.MathUtils.clamp(phi - dy * 0.005, 0.45, 1.43);
}
updateCamera();
});
function endPointer(event) {
dragging = false;
panning = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
minRadius,
maxRadius
);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset").addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Projected route labels
// -------------------------------------------------------------------------
const projected = new THREE.Vector3();
function positionLabel(element, worldPosition) {
projected.copy(worldPosition).project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "block" : "none";
if (!visible) return;
element.style.left = `${(projected.x * 0.5 + 0.5) * innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * innerHeight}px`;
}
const stairsLabel = document.getElementById("label-stairs");
const rampLabel = document.getElementById("label-ramp");
const doorLabel = document.getElementById("label-door");
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function onResize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
addEventListener("resize", onResize);
updateCamera();
renderer.setAnimationLoop(() => {
positionLabel(stairsLabel, new THREE.Vector3(-1.75, 2.25, 3.15));
positionLabel(rampLabel, new THREE.Vector3(8.1, 2.4, 1.4));
positionLabel(doorLabel, new THREE.Vector3(0, 3.95, -0.25));
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```