Prompt specification
Build or customize the Three.js 3D scene "Community center facilities corridor" 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: Community center facilities corridor
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/community-center-facilities-corridor-x0451
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows accessible public restrooms. Compose a public facilities corridor with clear signs, private cubicles, and waiting space; show varied visitors reaching the same shared corridor without segregated circulation paths. Voxel style.
Working Three.js Starter (community-center-facilities-corridor-x0451):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Shared Public Restrooms — Voxel Facilities Corridor</title>
<style>
:root {
color-scheme: light;
--ink: #163943;
--muted: #527078;
--paper: rgba(255, 255, 255, 0.92);
--teal: #167b78;
--blue: #2865c7;
--coral: #d96f5d;
--line: rgba(22, 57, 67, 0.14);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9e7;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app {
position: relative;
width: 100%;
height: 100%;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
canvas:active { cursor: grabbing; }
.card {
position: absolute;
z-index: 2;
border: 1px solid var(--line);
background: var(--paper);
box-shadow: 0 16px 40px rgba(29, 64, 71, 0.12);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.intro {
top: 22px;
left: 22px;
width: min(430px, calc(100vw - 44px));
padding: 20px 22px 18px;
border-radius: 20px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 8px;
color: var(--teal);
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
h1 {
margin: 0;
max-width: 390px;
font-size: clamp(1.55rem, 3vw, 2.35rem);
line-height: 1.04;
letter-spacing: -0.045em;
}
.intro p {
margin: 11px 0 0;
max-width: 390px;
color: var(--muted);
font-size: 0.9rem;
line-height: 1.5;
}
.legend {
left: 22px;
bottom: 22px;
display: flex;
flex-wrap: wrap;
gap: 8px;
width: min(540px, calc(100vw - 44px));
padding: 12px;
border-radius: 16px;
pointer-events: none;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 7px 9px;
border-radius: 9px;
background: rgba(255, 255, 255, 0.76);
color: #355861;
font-size: 0.76rem;
font-weight: 700;
}
.dot {
width: 10px;
height: 10px;
border-radius: 3px;
background: var(--teal);
}
.dot.blue { background: var(--blue); }
.dot.coral { background: var(--coral); }
.dot.cream { background: #e9dfc8; border: 1px solid #bdb39f; }
.controls {
right: 22px;
top: 22px;
display: grid;
grid-template-columns: repeat(2, minmax(42px, 1fr));
gap: 7px;
padding: 10px;
border-radius: 16px;
}
.controls button {
min-width: 46px;
min-height: 40px;
border: 0;
border-radius: 10px;
background: #e8f0ee;
color: var(--ink);
font: inherit;
font-size: 0.78rem;
font-weight: 800;
cursor: pointer;
}
.controls button:hover { background: #d5e6e2; }
.controls button:active { transform: translateY(1px); }
.controls button:focus-visible { outline: 3px solid #69a9ff; outline-offset: 2px; }
.controls .wide { grid-column: 1 / -1; }
.hint {
right: 22px;
bottom: 22px;
max-width: 260px;
padding: 11px 14px;
border-radius: 14px;
color: var(--muted);
font-size: 0.75rem;
line-height: 1.45;
pointer-events: none;
}
.hint strong { color: var(--ink); }
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 700px) {
.intro {
top: 12px;
left: 12px;
width: calc(100vw - 86px);
padding: 15px 16px;
border-radius: 15px;
}
.intro p { display: none; }
.controls { right: 12px; top: 12px; padding: 7px; }
.controls button { min-width: 34px; min-height: 34px; font-size: 0.7rem; }
.legend { left: 12px; bottom: 12px; width: calc(100vw - 24px); padding: 8px; }
.legend span { padding: 6px 7px; font-size: 0.68rem; }
.hint { display: none; }
}
</style>
</head>
<body>
<main id="app">
<canvas
id="scene"
tabindex="0"
role="img"
aria-label="Interactive voxel-style cutaway of a public restroom facility. A single broad corridor leads to private all-gender cubicles, an accessible step-free cubicle, washbasins, and a waiting area. Diverse visitors use the same route."
></canvas>
<section class="card intro" aria-labelledby="title">
<p class="eyebrow">Civic facilities · Voxel wayfinding study</p>
<h1 id="title">Public restrooms, one shared route.</h1>
<p>
Private all-gender cubicles, a wide step-free accessible stall, washbasins,
and a waiting area are organized around one inclusive corridor.
</p>
</section>
<section class="card legend" aria-label="Scene legend">
<span><i class="dot"></i> Shared circulation</span>
<span><i class="dot blue"></i> Accessible facilities</span>
<span><i class="dot coral"></i> Waiting area</span>
<span><i class="dot cream"></i> Private cubicles</span>
</section>
<nav class="card controls" aria-label="Camera controls">
<button id="left" type="button" aria-label="Rotate left">↶</button>
<button id="right" type="button" aria-label="Rotate right">↷</button>
<button id="in" type="button" aria-label="Zoom in">+</button>
<button id="out" type="button" aria-label="Zoom out">−</button>
<button id="reset" class="wide" type="button">Reset overview</button>
</nav>
<aside class="card hint">
<strong>Explore the cutaway</strong><br />
Drag to orbit · Scroll to zoom · Arrow keys rotate · +/− zoom · R resets
</aside>
<div id="status" class="sr-only" aria-live="polite"></div>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, camera, lighting
// ------------------------------------------------------------
const canvas = document.querySelector("#scene");
const status = document.querySelector("#status");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
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;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#dce9e7");
scene.fog = new THREE.Fog("#dce9e7", 48, 92);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
140
);
const target = new THREE.Vector3(0, 1.15, 0);
const spherical = new THREE.Spherical(49, 1.02, 0.72);
function updateCamera() {
const p = new THREE.Vector3().setFromSpherical(spherical).add(target);
camera.position.copy(p);
camera.lookAt(target);
}
updateCamera();
const hemi = new THREE.HemisphereLight("#f7ffff", "#78929a", 2.2);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff4d9", 3.2);
sun.position.set(-13, 25, 17);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -27;
sun.shadow.camera.right = 27;
sun.shadow.camera.top = 24;
sun.shadow.camera.bottom = -24;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.0003;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b7ddeb", 1.1);
fill.position.set(18, 12, -20);
scene.add(fill);
// ------------------------------------------------------------
// Shared geometry and material helpers
// ------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
flatShading: true
})
);
}
return materialCache.get(color);
}
function box(w, h, d, x, y, z, color, parent = scene) {
const mesh = new THREE.Mesh(unitBox, material(color));
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function group(x = 0, y = 0, z = 0, parent = scene) {
const g = new THREE.Group();
g.position.set(x, y, z);
parent.add(g);
return g;
}
// ------------------------------------------------------------
// Canvas-based wayfinding signs, built entirely in the page
// ------------------------------------------------------------
function roundedRect(ctx, x, y, w, h, r) {
r = Math.min(r, w / 2, h / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
function drawAccessibleIcon(ctx, x, y, scale, color) {
ctx.save();
ctx.translate(x, y);
ctx.scale(scale, scale);
ctx.strokeStyle = color;
ctx.fillStyle = color;
ctx.lineWidth = 8;
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.beginPath();
ctx.arc(34, 34, 27, -0.15 * Math.PI, 1.45 * Math.PI);
ctx.stroke();
ctx.beginPath();
ctx.arc(13, -48, 9, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.moveTo(10, -30);
ctx.lineTo(2, 12);
ctx.lineTo(33, 12);
ctx.lineTo(48, 47);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(3, 12);
ctx.lineTo(-12, 50);
ctx.stroke();
ctx.restore();
}
function makeSign(
title,
subtitle = "",
width = 5,
height = 1.2,
options = {}
) {
const canvasSign = document.createElement("canvas");
const pixelHeight = Math.max(180, Math.round(1024 * height / width));
canvasSign.width = 1024;
canvasSign.height = pixelHeight;
const ctx = canvasSign.getContext("2d");
const bg = options.bg || "#164a55";
const fg = options.fg || "#ffffff";
const accent = options.accent || "#f1c85b";
ctx.fillStyle = bg;
ctx.fillRect(0, 0, canvasSign.width, canvasSign.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 18, pixelHeight);
let textX = 52;
if (options.icon === "accessible") {
drawAccessibleIcon(ctx, 48, pixelHeight * 0.53, pixelHeight / 125, fg);
textX = 155;
}
let titleSize = Math.min(66, pixelHeight * 0.25);
ctx.font = `800 ${titleSize}px system-ui, sans-serif`;
while (ctx.measureText(title).width > 940 - textX && titleSize > 30) {
titleSize -= 2;
ctx.font = `800 ${titleSize}px system-ui, sans-serif`;
}
ctx.fillStyle = fg;
ctx.textBaseline = "middle";
ctx.fillText(title, textX, subtitle ? pixelHeight * 0.39 : pixelHeight * 0.52);
if (subtitle) {
const subtitleSize = Math.min(31, pixelHeight * 0.115);
ctx.globalAlpha = 0.86;
ctx.font = `700 ${subtitleSize}px system-ui, sans-serif`;
ctx.fillText(subtitle, textX, pixelHeight * 0.71);
ctx.globalAlpha = 1;
}
const texture = new THREE.CanvasTexture(canvasSign);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const board = new THREE.Group();
box(
width + 0.14,
height + 0.14,
0.13,
0,
0,
-0.075,
options.frame || "#123b44",
board
);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false,
side: THREE.DoubleSide
})
);
face.position.z = 0.002;
board.add(face);
return board;
}
// ------------------------------------------------------------
// Platform and tiled floor
// ------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(120, 120),
material("#d7e4e2")
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.57;
ground.receiveShadow = true;
scene.add(ground);
box(33.5, 0.5, 23, 0, -0.28, 0, "#355760");
box(32.5, 0.08, 22, 0, -0.01, 0, "#e7dfce");
const tileCount = 32 * 22;
const tiles = new THREE.InstancedMesh(
unitBox,
new THREE.MeshStandardMaterial({
color: "#ffffff",
roughness: 0.9,
metalness: 0,
flatShading: true
}),
tileCount
);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
let tileIndex = 0;
for (let ix = 0; ix < 32; ix++) {
for (let iz = 0; iz < 22; iz++) {
const x = -15.5 + ix;
const z = -10.5 + iz;
const inCorridor = z >= -2 && z <= 2;
const inWaiting = z <= -3;
const inStalls = z >= 3 && x >= -9 && x <= 11;
if (inCorridor) {
color.set(ix % 2 === 0 ? "#83cfc4" : "#91d6cc");
} else if (inWaiting) {
color.set(ix % 2 === 0 ? "#efd0c4" : "#f0d5ca");
} else if (inStalls) {
color.set(ix % 2 === 0 ? "#e9e0ce" : "#eee6d7");
} else {
color.set(ix % 2 === 0 ? "#d6e4df" : "#dce8e3");
}
dummy.position.set(x, 0.045, z);
dummy.scale.set(0.96, 0.1, 0.96);
dummy.updateMatrix();
tiles.setMatrixAt(tileIndex, dummy.matrix);
tiles.setColorAt(tileIndex, color);
tileIndex++;
}
}
tiles.receiveShadow = true;
scene.add(tiles);
// A smooth, visible entrance ramp makes the step-free access legible.
const ramp = box(3.5, 0.14, 5.1, -17.65, -0.245, 0, "#9dc7c0");
ramp.rotation.z = 0.165;
for (const z of [-2.48, 2.48]) {
const rail = box(3.55, 0.09, 0.09, -17.63, 0.08, z, "#376a71");
rail.rotation.z = 0.165;
}
// ------------------------------------------------------------
// Architectural shell
// ------------------------------------------------------------
// Back wall and trim.
box(32.7, 4.1, 0.35, 0, 2.05, 10.75, "#f3eddf");
box(32.7, 0.55, 0.39, 0, 0.28, 10.72, "#6caea4");
// Entrance wall pieces leave a broad, level opening.
box(0.35, 3.6, 8.5, -16.05, 1.8, -6.25, "#f3eddf");
box(0.35, 3.6, 8.5, -16.05, 1.8, 6.25, "#f3eddf");
// Cutaway columns.
for (const x of [-16, -9, -3, 3, 11, 16]) {
box(0.42, 3.35, 0.42, x, 1.68, 10.47, "#dfd5bf");
}
// Stall partitions.
for (const x of [-9, -3, 3, 11]) {
box(0.2, 2.55, 7.15, x, 1.28, 6.98, "#e6ddc9");
box(0.23, 0.24, 7.2, x, 2.35, 6.98, "#7ab6ad");
}
// Front wall segments leave three private door openings.
const frontSegments = [
[-9, -7],
[-5, -1],
[1, 5],
[9, 11]
];
for (const [a, b] of frontSegments) {
const w = b - a;
box(w, 2.25, 0.22, (a + b) / 2, 1.13, 3.43, "#eee6d6");
box(w, 0.22, 0.25, (a + b) / 2, 2.05, 3.43, "#70aea5");
}
// Small upper transom bands.
box(20.2, 0.16, 0.28, 1, 2.37, 3.44, "#c8bfa9");
function makeDoor(x, width, angle, colorHex, label) {
const pivot = group(x, 0.08, 3.43);
pivot.rotation.y = -angle;
box(width, 2.12, 0.13, width / 2, 1.06, 0, colorHex, pivot);
box(width - 0.28, 0.12, 0.16, width / 2, 1.77, 0.015, "#ffffff", pivot);
box(0.08, 0.3, 0.16, width - 0.28, 0.95, 0.12, "#344f56", pivot);
const plaque = makeSign(label, "PRIVATE", Math.min(width - 0.35, 1.8), 0.42, {
bg: "#245760",
accent: "#8ad1c7",
frame: "#173e47"
});
plaque.position.set(width / 2, 1.48, 0.082);
pivot.add(plaque);
return pivot;
}
makeDoor(-7, 2, 0.95, "#4b9992", "WC 01");
makeDoor(-1, 2, 0.38, "#559f98", "WC 02");
makeDoor(5, 4, 1.17, "#337ec4", "ACCESSIBLE");
// Cubicle labels above each doorway.
const sign01 = makeSign("WC 01", "PRIVATE CUBICLE", 2.2, 0.56, {
bg: "#19535d",
accent: "#83c9bf"
});
sign01.position.set(-8, 2.76, 3.57);
scene.add(sign01);
const sign02 = makeSign("WC 02", "PRIVATE CUBICLE", 2.2, 0.56, {
bg: "#19535d",
accent: "#83c9bf"
});
sign02.position.set(-2, 2.76, 3.57);
scene.add(sign02);
const signAccess = makeSign(
"ACCESSIBLE",
"STEP-FREE + CHANGING",
3.65,
0.7,
{
bg: "#245ca8",
accent: "#f0c75e",
icon: "accessible"
}
);
signAccess.position.set(3, 2.82, 3.57);
scene.add(signAccess);
// ------------------------------------------------------------
// Cubicle fixtures
// ------------------------------------------------------------
function makeToilet(x, z) {
box(0.62, 0.55, 0.72, x, 0.37, z, "#f7f6f1");
box(0.86, 0.16, 1.02, x, 0.71, z - 0.06, "#fdfdfb");
box(0.84, 0.92, 0.27, x, 0.79, z + 0.61, "#e7eceb");
box(0.18, 0.08, 0.08, x, 1.13, z + 0.45, "#52717a");
}
makeToilet(-6, 8.75);
makeToilet(0, 8.75);
makeToilet(7.4, 8.7);
// Accessible grab rails.
box(0.09, 0.09, 3.1, 3.48, 1.22, 6.9, "#2865c7");
box(0.09, 1.45, 0.09, 3.48, 0.78, 5.42, "#2865c7");
box(0.09, 0.09, 2.2, 10.52, 1.22, 7.1, "#2865c7");
// A clear turning-space marker in the accessible cubicle.
for (let i = 0; i < 12; i++) {
const a = (i / 12) * Math.PI * 2;
const dash = box(
0.34, 0.035, 0.09,
7 + Math.cos(a) * 1.62,
0.14,
6.2 + Math.sin(a) * 1.62,
"#4d88dd"
);
dash.rotation.y = -a;
}
// ------------------------------------------------------------
// Washbasin area
// ------------------------------------------------------------
box(3.15, 0.9, 1.05, 13.3, 0.52, 8.75, "#83b7ad");
box(3.35, 0.16, 1.22, 13.3, 1.03, 8.75, "#f9f7ef");
box(1.05, 0.05, 0.7, 12.65, 1.13, 8.55, "#91adb0");
box(1.05, 0.05, 0.7, 14.0, 1.13, 8.55, "#91adb0");
for (const x of [12.65, 14.0]) {
box(0.08, 0.28, 0.08, x, 1.28, 8.88, "#506b73");
box(0.08, 0.08, 0.34, x, 1.39, 8.73, "#506b73");
}
box(3.25, 1.45, 0.12, 13.3, 2.35, 10.52, "#a9d6d7");
box(3.05, 1.25, 0.13, 13.3, 2.35, 10.43, "#d7eeee");
const sinkSign = makeSign("WASH + REFILL", "SENSOR TAPS", 2.7, 0.58, {
bg: "#315e66",
accent: "#e7c664"
});
sinkSign.position.set(13.3, 3.35, 10.48);
scene.add(sinkSign);
// ------------------------------------------------------------
// Waiting area
// ------------------------------------------------------------
function makeBench(x, z, length) {
const g = group(x, 0, z);
box(length, 0.2, 1.05, 0, 0.62, 0, "#bd735f", g);
box(length, 0.95, 0.18, 0, 1.08, -0.47, "#d88b74", g);
for (const lx of [-length * 0.36, length * 0.36]) {
box(0.22, 0.58, 0.7, lx, 0.3, 0, "#45646a", g);
}
box(length - 0.35, 0.08, 0.08, 0, 0.98, -0.34, "#f1c6b7", g);
return g;
}
makeBench(-5.1, -7.1, 5.3);
makeBench(4.2, -9.05, 5.5);
box(1.65, 0.16, 1.65, -0.35, 0.75, -7.15, "#e6c56c");
box(0.45, 0.72, 0.45, -0.35, 0.36, -7.15, "#55757b");
function makePlant(x, z, scale = 1) {
const g = group(x, 0.08, z);
g.scale.setScalar(scale);
box(0.85, 0.7, 0.85, 0, 0.35, 0, "#d38b6e", g);
box(0.16, 1.25, 0.16, 0, 1.15, 0, "#54735d", g);
box(0.85, 0.65, 0.75, 0, 1.8, 0, "#4d9b70", g);
box(0.65, 0.55, 0.65, 0.4, 2.25, -0.08, "#73b982", g);
box(0.62, 0.5, 0.62, -0.38, 2.12, 0.12, "#5da775", g);
return g;
}
makePlant(12.4, -7.7, 1.15);
makePlant(-12.6, -9.1, 0.9);
makePlant(11.8, -3.25, 0.75);
// A compact information point near the shared entrance.
box(1.65, 1.05, 1.1, -12.1, 0.52, -5.4, "#497f7c");
box(1.9, 0.14, 1.3, -12.1, 1.12, -5.4, "#f0e6ce");
const info = makeSign("INFORMATION", "STEP-FREE ASSISTANCE", 2.4, 0.65, {
bg: "#236b68",
accent: "#efc85c"
});
info.position.set(-12.1, 1.55, -4.82);
scene.add(info);
const waitingSign = makeSign(
"WAITING AREA",
"DIRECTLY OFF THE SHARED LOBBY",
4.7,
0.9,
{ bg: "#9a5549", accent: "#f3c971" }
);
waitingSign.position.set(-5.3, 1.85, -10.55);
scene.add(waitingSign);
box(0.12, 1.9, 0.12, -7.4, 0.95, -10.58, "#765e59");
box(0.12, 1.9, 0.12, -3.2, 0.95, -10.58, "#765e59");
// ------------------------------------------------------------
// Prominent public-facing wayfinding
// ------------------------------------------------------------
const entranceSign = makeSign(
"PUBLIC RESTROOMS",
"ALL-GENDER • STEP-FREE • OPEN TO EVERYONE",
5.9,
1.42,
{
bg: "#124d59",
accent: "#efc85a",
icon: "accessible"
}
);
entranceSign.position.set(-12.8, 2.95, -2.75);
scene.add(entranceSign);
box(0.13, 2.9, 0.13, -15.35, 1.45, -2.78, "#315f66");
box(0.13, 2.9, 0.13, -10.25, 1.45, -2.78, "#315f66");
const overheadSign = makeSign(
"RESTROOMS ↑ WAITING ↓",
"PRIVATE CUBICLES • ACCESSIBLE STALL",
8.7,
1.1,
{ bg: "#164f59", accent: "#f0c65a" }
);
overheadSign.position.set(1.5, 3.55, 3.58);
scene.add(overheadSign);
// Shared route arrows: one visual system for every visitor.
function makeArrow(x, z, direction = 0, arrowColor = "#f7f2df") {
const g = group(x, 0.14, z);
g.rotation.y = direction;
box(0.78, 0.045, 0.16, -0.24, 0, 0, arrowColor, g);
const a = box(0.52, 0.045, 0.13, 0.18, 0, 0.15, arrowColor, g);
a.rotation.y = -Math.PI / 4;
const b = box(0.52, 0.045, 0.13, 0.18, 0, -0.15, arrowColor, g);
b.rotation.y = Math.PI / 4;
return g;
}
for (const x of [-13.5, -11.7, -8.5, -6.7, -3.3, -1.5, 2.0, 4.0]) {
makeArrow(x, 0, 0);
}
makeArrow(-10, 1.7, -Math.PI / 2);
makeArrow(-9.8, 2.7, -Math.PI / 2);
makeArrow(2.1, -3.4, Math.PI / 2);
// ------------------------------------------------------------
// Voxel visitors
// ------------------------------------------------------------
const walkers = [];
function makePerson(parent, options = {}) {
const {
skin = "#c88962",
shirt = "#3d82a5",
pants = "#354b5c",
hair = "#3b302d",
headwear = "hair",
scale = 1
} = options;
const g = new THREE.Group();
g.scale.setScalar(scale);
parent.add(g);
// Torso and clothing.
box(0.44, 0.7, 0.58, 0, 1.08, 0, shirt, g);
box(0.46, 0.12, 0.6, 0, 1.32, 0, shirt, g);
// Legs and shoes.
box(0.34, 0.66, 0.22, 0.02, 0.42, 0.17, pants, g);
box(0.34, 0.66, 0.22, 0.02, 0.42, -0.17, pants, g);
box(0.48, 0.15, 0.25, 0.12, 0.08, 0.17, "#24343b", g);
box(0.48, 0.15, 0.25, 0.12, 0.08, -0.17, "#24343b", g);
// Head and simple face.
box(0.43, 0.44, 0.45, 0, 1.65, 0, skin, g);
box(0.1, 0.09, 0.12, 0.235, 1.63, 0, skin, g);
box(0.055, 0.055, 0.045, 0.255, 1.7, 0.1, "#28373b", g);
box(0.055, 0.055, 0.045, 0.255, 1.7, -0.1, "#28373b", g);
// Arms.
box(0.27, 0.59, 0.19, 0.02, 1.05, 0.39, shirt, g);
box(0.27, 0.59, 0.19, 0.02, 1.05, -0.39, shirt, g);
box(0.18, 0.17, 0.17, 0.03, 0.7, 0.39, skin, g);
box(0.18, 0.17, 0.17, 0.03, 0.7, -0.39, skin, g);
if (headwear === "hijab") {
box(0.56, 0.18, 0.57, -0.01, 1.83, 0, shirt, g);
box(0.13, 0.62, 0.55, -0.27, 1.55, 0, shirt, g);
} else if (headwear === "cap") {
box(0.48, 0.15, 0.51, -0.01, 1.84, 0, hair, g);
box(0.32, 0.08, 0.5, 0.19, 1.82, 0, hair, g);
} else {
box(0.49, 0.17, 0.5, -0.02, 1.84, 0, hair, g);
box(0.11, 0.4, 0.49, -0.24, 1.65, 0, hair, g);
}
return g;
}
function makeWheelchairPerson(parent) {
const g = new THREE.Group();
parent.add(g);
const wheelPivots = [];
box(0.76, 0.15, 0.76, 0.03, 0.61, 0, "#315b74", g);
box(0.15, 0.8, 0.76, -0.33, 1.0, 0, "#315b74", g);
box(0.68, 0.08, 0.08, 0.05, 1.05, 0.43, "#516d76", g);
box(0.68, 0.08, 0.08, 0.05, 1.05, -0.43, "#516d76", g);
for (const z of [-0.48, 0.48]) {
const pivot = new THREE.Group();
pivot.position.set(-0.12, 0.39, z);
g.add(pivot);
const wheel = new THREE.Mesh(
new THREE.CylinderGeometry(0.39, 0.39, 0.13, 12),
material("#26383e")
);
wheel.rotation.x = Math.PI / 2;
wheel.castShadow = true;
pivot.add(wheel);
box(0.58, 0.055, 0.15, 0, 0, 0, "#a8b4b4", pivot);
box(0.055, 0.58, 0.15, 0, 0, 0, "#a8b4b4", pivot);
wheelPivots.push(pivot);
}
for (const z of [-0.3, 0.3]) {
const caster = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.13, 0.1, 10),
material("#33464d")
);
caster.rotation.x = Math.PI / 2;
caster.position.set(0.57, 0.19, z);
caster.castShadow = true;
g.add(caster);
box(0.09, 0.42, 0.09, 0.49, 0.38, z, "#687a7d", g);
}
box(0.4, 0.62, 0.55, 0.02, 1.18, 0, "#d96f5d", g);
box(0.4, 0.18, 0.54, 0.04, 1.56, 0, "#f0a283", g);
box(0.43, 0.43, 0.44, 0.08, 1.83, 0, "#9d684b", g);
box(0.12, 0.09, 0.11, 0.31, 1.82, 0, "#9d684b", g);
box(0.13, 0.4, 0.54, -0.22, 1.8, 0, "#3f302e", g);
box(0.7, 0.19, 0.23, 0.39, 0.72, 0.17, "#384b5c", g);
box(0.7, 0.19, 0.23, 0.39, 0.72, -0.17, "#384b5c", g);
box(0.28, 0.14, 0.24, 0.73, 0.66, 0.17, "#26363d", g);
box(0.28, 0.14, 0.24, 0.73, 0.66, -0.17, "#26363d", g);
box(0.28, 0.48, 0.18, 0.03, 1.13, 0.37, "#d96f5d", g);
box(0.28, 0.48, 0.18, 0.03, 1.13, -0.37, "#d96f5d", g);
g.userData.wheelPivots = wheelPivots;
return g;
}
function makeServiceDog(parent) {
const g = new THREE.Group();
g.position.set(0.9, 0, 0.85);
parent.add(g);
box(0.78, 0.36, 0.34, 0, 0.42, 0, "#7e6654", g);
box(0.35, 0.34, 0.32, 0.48, 0.55, 0, "#8f7560", g);
box(0.22, 0.16, 0.22, 0.64, 0.5, 0, "#3d332f", g);
box(0.16, 0.25, 0.1, 0.38, 0.78, 0.11, "#59483d", g);
box(0.16, 0.25, 0.1, 0.38, 0.78, -0.11, "#59483d", g);
for (const x of [-0.25, 0.27]) {
box(0.13, 0.3, 0.12, x, 0.18, 0.12, "#604c40", g);
box(0.13, 0.3, 0.12, x, 0.18, -0.12, "#604c40", g);
}
box(0.035, 0.035, 0.68, -0.38, 0.72, -0.4, "#334d54", g);
return g;
}
function addWalker(x, z, speed, builder) {
const g = group(x, 0.1, z);
builder(g);
walkers.push({ group: g, speed, phase: Math.random() * 6 });
return g;
}
addWalker(-14.2, -0.65, 0.20, (g) => {
const person = makePerson(g, {
skin: "#bd7f59",
shirt: "#7b4f86",
pants: "#344b61",
hair: "#302a2a",
headwear: "hijab"
});
makeServiceDog(g);
const leash = box(0.035, 0.035, 0.9, 0.48, 0.92, 0.42, "#334d54", g);
leash.rotation.y = 0.2;
});
addWalker(-10.2, 0.85, 0.19, (g) => {
makeWheelchairPerson(g);
});
addWalker(-6.2, -0.55, 0.21, (g) => {
makePerson(g, {
skin: "#e2aa7f",
shirt: "#dfb044",
pants: "#4b5966",
hair: "#5d3c2c"
});
makePerson(g, {
skin: "#8e583e",
shirt: "#e67c61",
pants: "#3b536d",
hair: "#2f2927",
scale: 0.64
}).position.set(0.25, 0, 0.9);
});
addWalker(-2.3, 0.8, 0.17, (g) => {
const person = makePerson(g, {
skin: "#d49668",
shirt: "#397f8c",
pants: "#313f50",
hair: "#4c3329",
headwear: "cap"
});
box(0.28, 0.56, 0.48, -0.33, 1.11, 0, "#d66f4f", person);
});
addWalker(-15.0, 0.25, 0.18, (g) => {
const person = makePerson(g, {
skin: "#f0c39c",
shirt: "#666aa2",
pants: "#31444d",
hair: "#d3d0c9"
});
const cane = box(0.045, 1.25, 0.045, 0.25, 0.62, 0.52, "#5d4638", person);
cane.rotation.z = -0.13;
box(0.05, 0.05, 0.22, 0.16, 1.23, 0.52, "#5d4638", person);
});
// A visitor seated in the waiting area.
const seated = group(3.6, 0.1, -9.0);
box(0.5, 0.62, 0.58, 0, 1.18, 0, "#e6c75d", seated);
box(0.43, 0.43, 0.45, 0, 1.68, 0, "#b87955", seated);
box(0.48, 0.15, 0.49, -0.02, 1.87, 0, "#4b3730", seated);
box(0.7, 0.2, 0.24, 0, 0.73, 0.22, "#42566b", seated);
box(0.7, 0.2, 0.24, 0, 0.73, -0.22, "#42566b", seated);
box(0.18, 0.65, 0.18, 0.25, 1.1, 0.36, "#e6c75d", seated);
box(0.18, 0.65, 0.18, 0.25, 1.1, -0.36, "#e6c75d", seated);
// ------------------------------------------------------------
// Direct camera controls — no addons or external controls
// ------------------------------------------------------------
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.focus({ preventScroll: true });
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
spherical.theta -= dx * 0.006;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi + dy * 0.005,
0.34,
1.42
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
spherical.radius = THREE.MathUtils.clamp(
spherical.radius * Math.exp(event.deltaY * 0.001),
27,
72
);
updateCamera();
},
{ passive: false }
);
function rotate(amount) {
spherical.theta += amount;
updateCamera();
}
function zoom(amount) {
spherical.radius = THREE.MathUtils.clamp(
spherical.radius + amount,
27,
72
);
updateCamera();
}
function resetCamera() {
spherical.set(49, 1.02, 0.72);
target.set(0, 1.15, 0);
updateCamera();
status.textContent = "Camera reset to the overview.";
}
document.querySelector("#left").addEventListener("click", () => {
rotate(-0.14);
status.textContent = "Camera rotated left.";
});
document.querySelector("#right").addEventListener("click", () => {
rotate(0.14);
status.textContent = "Camera rotated right.";
});
document.querySelector("#in").addEventListener("click", () => {
zoom(-4);
status.textContent = "Camera zoomed in.";
});
document.querySelector("#out").addEventListener("click", () => {
zoom(4);
status.textContent = "Camera zoomed out.";
});
document.querySelector("#reset").addEventListener("click", resetCamera);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft": rotate(-0.1); break;
case "ArrowRight": rotate(0.1); break;
case "ArrowUp": spherical.phi = THREE.MathUtils.clamp(spherical.phi - 0.08, 0.34, 1.42); updateCamera(); break;
case "ArrowDown": spherical.phi = THREE.MathUtils.clamp(spherical.phi + 0.08, 0.34, 1.42); updateCamera(); break;
case "+":
case "=": zoom(-3); break;
case "-":
case "_": zoom(3); break;
case "r":
case "R": resetCamera(); break;
default: handled = false;
}
if (handled) event.preventDefault();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
for (const walker of walkers) {
walker.group.position.x += walker.speed * dt;
walker.group.position.y = 0.1 + Math.sin(time * 4.4 + walker.phase) * 0.025;
if (walker.group.position.x > 4.2) {
walker.group.position.x = -15.7;
}
const wheelchair = walker.group.children.find(
(child) => child.userData && child.userData.wheelPivots
);
if (wheelchair) {
for (const wheel of wheelchair.userData.wheelPivots) {
wheel.rotation.z -= walker.speed * dt * 5;
}
}
}
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```