Prompt specification
Build or customize the Three.js 3D scene "Small clinic from repeated room modules" 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: Small clinic from repeated room modules
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/small-clinic-from-repeated-room-modules-x2207
Scene Description Prompt:
Create a standalone low-poly scene in one HTML file using Three.js from cdnjs. Create a compact clinic layout from repeated rooms, corridor, and entrance module. Maintain clear door access and visibly adapt one module for a larger shared waiting area.
Working Three.js Starter (small-clinic-from-repeated-room-modules-x2207):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Compact Care Clinic</title>
<style>
:root {
--ink: #173e49;
--muted: #60777c;
--teal: #258d82;
--teal-soft: #d8eee9;
--paper: rgba(250, 252, 249, 0.93);
--line: rgba(23, 62, 73, 0.13);
--shadow: 0 16px 45px rgba(23, 62, 73, 0.13);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe8e5;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
top: 22px;
left: 22px;
width: min(350px, calc(100vw - 44px));
padding: 22px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 20px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
z-index: 10;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 12px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 23px;
height: 3px;
border-radius: 4px;
background: var(--teal);
content: "";
}
h1 {
margin: 0;
max-width: 280px;
font-size: clamp(27px, 3vw, 38px);
line-height: 1.04;
letter-spacing: -0.045em;
}
.intro {
margin: 13px 0 18px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
overflow: hidden;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.58);
}
.stat {
padding: 11px 8px 10px;
text-align: center;
}
.stat + .stat {
border-left: 1px solid var(--line);
}
.stat strong {
display: block;
font-size: 17px;
letter-spacing: -0.03em;
}
.stat span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.adaptation {
margin-top: 14px;
padding: 13px 14px;
border-left: 3px solid #df9b67;
border-radius: 0 11px 11px 0;
background: #fff4e9;
}
.adaptation strong {
display: block;
margin-bottom: 4px;
font-size: 12px;
}
.adaptation p {
margin: 0;
color: #775f4c;
font-size: 11px;
line-height: 1.45;
}
.controls {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 10;
display: flex;
gap: 7px;
padding: 7px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 15px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
}
.controls button {
min-width: 72px;
padding: 9px 12px;
border: 0;
border-radius: 10px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: background 160ms ease, transform 160ms ease;
}
.controls button:hover {
background: var(--teal-soft);
transform: translateY(-1px);
}
.controls button.active {
background: var(--ink);
color: white;
}
.hint {
position: fixed;
left: 50%;
bottom: 25px;
z-index: 9;
padding: 8px 12px;
border-radius: 99px;
background: rgba(23, 62, 73, 0.78);
color: white;
font-size: 10px;
font-weight: 650;
letter-spacing: 0.02em;
transform: translateX(-50%);
pointer-events: none;
backdrop-filter: blur(8px);
}
.brand-mark {
position: fixed;
top: 24px;
right: 25px;
z-index: 9;
display: flex;
align-items: center;
gap: 10px;
color: var(--ink);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
pointer-events: none;
}
.brand-mark i {
display: block;
width: 26px;
height: 26px;
border-radius: 8px 8px 8px 2px;
background: var(--teal);
box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.76);
transform: rotate(-4deg);
}
@media (max-width: 760px) {
.panel {
top: 12px;
left: 12px;
width: min(315px, calc(100vw - 24px));
padding: 16px;
border-radius: 16px;
}
h1 {
font-size: 27px;
}
.intro {
display: none;
}
.stats {
margin-top: 13px;
}
.adaptation {
margin-top: 10px;
padding: 9px 11px;
}
.brand-mark {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
.controls button {
min-width: auto;
padding: 9px 10px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<section class="panel">
<div class="eyebrow">Dollhouse study / 01</div>
<h1>Compact Care Clinic</h1>
<p class="intro">
Repeated clinical modules flank a clear central corridor. The two southern
modules merge into one larger shared waiting space without interrupting circulation.
</p>
<div class="stats">
<div class="stat">
<strong>6</strong>
<span>Care rooms</span>
</div>
<div class="stat">
<strong>3.6 m</strong>
<span>Clear corridor</span>
</div>
<div class="stat">
<strong>2×</strong>
<span>Waiting module</span>
</div>
</div>
<div class="adaptation">
<strong>Adapted module</strong>
<p>
The partition between two standard rooms is removed. A wider portal,
more seating, and a reception counter turn the combined footprint into a shared waiting area.
</p>
</div>
</section>
<div class="brand-mark"><i></i> Neighborhood health</div>
<nav class="controls" aria-label="Scene controls">
<button id="iso" class="active">Isometric</button>
<button id="plan">Plan</button>
<button id="labels">Labels</button>
<button id="reset">Reset</button>
</nav>
<div class="hint">Drag to orbit · Shift/right-drag to pan · Scroll to zoom</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------------
// Renderer, scene, and camera
// ---------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe8e5);
scene.fog = new THREE.Fog(0xdbe8e5, 44, 78);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.12;
document.body.prepend(renderer.domElement);
const aspect = window.innerWidth / window.innerHeight;
const camera = new THREE.OrthographicCamera(
-23 * aspect,
23 * aspect,
23,
-23,
0.1,
140
);
const target = new THREE.Vector3(-1.2, 0, 0);
const cameraState = {
azimuth: 0.72,
polar: 0.87,
zoom: 1
};
const cameraGoal = {
azimuth: cameraState.azimuth,
polar: cameraState.polar,
zoom: cameraState.zoom
};
function updateCamera() {
const radius = 43;
const offset = new THREE.Vector3().setFromSphericalCoords(
radius,
cameraState.polar,
cameraState.azimuth
);
camera.position.copy(target).add(offset);
camera.lookAt(target);
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
updateCamera();
// ---------------------------------------------------------------------------
// Lighting and materials
// ---------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xeaf8f4, 0x8ca39e, 2.0));
const sun = new THREE.DirectionalLight(0xfff4df, 3.1);
sun.position.set(-11, 25, 15);
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.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8dce8, 0.85);
fill.position.set(15, 12, -15);
scene.add(fill);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
const M = {
ground: material(0xcbdcd5),
plinth: material(0x7c9892),
corridor: material(0xe6ebe6),
floorA: material(0xe8dfcf),
floorB: material(0xdce8e3),
floorC: material(0xe6ddd3),
waiting: material(0xf0dfbd),
wall: material(0xf2eee3),
wallShade: material(0xd9dfd7),
teal: material(0x258d82),
tealLight: material(0x78b9aa),
navy: material(0x244d59),
coral: material(0xd98763),
yellow: material(0xe2b95f),
white: material(0xfbfaf4),
wood: material(0xb7875f),
woodDark: material(0x72533f),
metal: material(0x8ca4a2, { metalness: 0.42, roughness: 0.36 }),
glass: material(0x9acbc4, {
transparent: true,
opacity: 0.33,
roughness: 0.16,
metalness: 0.08,
depthWrite: false,
side: THREE.DoubleSide
}),
leaf: material(0x4f8f68),
leafLight: material(0x79aa72),
dark: material(0x304e53)
};
const labels = new THREE.Group();
scene.add(labels);
// ---------------------------------------------------------------------------
// Geometry helpers
// ---------------------------------------------------------------------------
function box(w, h, d, mat, x, y, z, parent = scene, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(rTop, rBottom, h, mat, x, y, z, segments = 8, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rTop, rBottom, h, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function ico(radius, mat, x, y, z, parent = scene, detail = 0) {
const mesh = new THREE.Mesh(new THREE.IcosahedronGeometry(radius, detail), mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const FLOOR = 0.12;
function wallX(x1, x2, z, height = 1.55, mat = M.wall) {
const width = x2 - x1;
return box(
width,
height,
0.17,
mat,
(x1 + x2) / 2,
FLOOR + height / 2,
z
);
}
function wallZ(x, z1, z2, height = 1.55, mat = M.wall) {
const depth = z2 - z1;
return box(
0.17,
height,
depth,
mat,
x,
FLOOR + height / 2,
(z1 + z2) / 2
);
}
function portalX(center, z, width) {
const edge = 0.08;
box(
edge,
1.95,
0.25,
M.navy,
center - width / 2,
FLOOR + 0.975,
z
);
box(
edge,
1.95,
0.25,
M.navy,
center + width / 2,
FLOOR + 0.975,
z
);
box(
width + edge * 2,
0.18,
0.25,
M.navy,
center,
FLOOR + 1.87,
z
);
box(width, 0.025, 0.34, M.tealLight, center, FLOOR + 0.02, z, scene, false);
}
function wallWithOpeningsX(x1, x2, z, openings) {
let cursor = x1;
openings
.slice()
.sort((a, b) => a.center - b.center)
.forEach((opening) => {
const left = opening.center - opening.width / 2;
const right = opening.center + opening.width / 2;
wallX(cursor, left, z);
portalX(opening.center, z, opening.width);
cursor = right;
});
wallX(cursor, x2, z);
}
function labelTexture(text, bg = "#244d59", fg = "#ffffff") {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 160;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = bg;
const r = 28;
const x = 8;
const y = 8;
const w = canvas.width - 16;
const h = canvas.height - 16;
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.fill();
const lines = text.split("|");
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = fg;
if (lines.length > 1) {
ctx.font = "800 42px system-ui, sans-serif";
ctx.fillText(lines[0], canvas.width / 2, 65);
ctx.globalAlpha = 0.8;
ctx.font = "700 25px system-ui, sans-serif";
ctx.fillText(lines[1], canvas.width / 2, 112);
} else {
ctx.font = "800 47px system-ui, sans-serif";
ctx.fillText(lines[0], canvas.width / 2, canvas.height / 2);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function makeLabel(text, x, y, z, width = 2.3, bg = "#244d59") {
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: labelTexture(text, bg),
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.position.set(x, y, z);
sprite.scale.set(width, width * (160 / 768), 1);
sprite.renderOrder = 20;
labels.add(sprite);
return sprite;
}
function floorText(text, x, z, width = 4.2, color = "#ffffff") {
const texture = labelTexture(text, "rgba(0,0,0,0)", color);
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, width * (160 / 768)),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide
})
);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, FLOOR + 0.065, z);
scene.add(mesh);
}
// ---------------------------------------------------------------------------
// Doors
// ---------------------------------------------------------------------------
function addDoorLeafX(hingeX, z, width, leafDirection = 1, angle = 1.02) {
const pivot = new THREE.Group();
pivot.position.set(hingeX, FLOOR, z);
pivot.rotation.y = angle;
scene.add(pivot);
const centerX = leafDirection * width * 0.5;
box(
width - 0.11,
1.62,
0.035,
M.glass,
centerX,
0.87,
0,
pivot,
false
);
box(0.055, 1.7, 0.07, M.navy, 0, 0.86, 0, pivot);
box(
0.055,
1.7,
0.07,
M.navy,
leafDirection * (width - 0.055),
0.86,
0,
pivot
);
box(width, 0.065, 0.07, M.navy, centerX, 0.08, 0, pivot);
box(width, 0.065, 0.07, M.navy, centerX, 1.66, 0, pivot);
box(
0.18,
0.035,
0.045,
M.metal,
leafDirection * (width - 0.18),
0.88,
0.09,
pivot
);
}
function addRoomDoor(center, z, width, swingsSouth) {
const angle = swingsSouth ? -1.02 : 1.02;
addDoorLeafX(center - width / 2 + 0.025, z, width - 0.05, 1, angle);
}
function addDoubleRoomDoor(center, z, width) {
const leaf = width / 2 - 0.04;
// Left leaf opens into the waiting room.
addDoorLeafX(center - width / 2 + 0.025, z, leaf, 1, -1.0);
// Right leaf mirrors the hinge direction.
addDoorLeafX(center + width / 2 - 0.025, z, leaf, -1, 1.0);
}
function addEntranceDoor() {
const x = -13;
const z0 = -0.95;
const z1 = 0.95;
box(0.1, 1.95, 0.26, M.navy, x, FLOOR + 0.975, z0);
box(0.1, 1.95, 0.26, M.navy, x, FLOOR + 0.975, z1);
box(0.26, 0.18, 2.1, M.navy, x, FLOOR + 1.87, 0);
function leaf(hingeZ, extension, angle) {
const pivot = new THREE.Group();
pivot.position.set(x, FLOOR, hingeZ);
pivot.rotation.y = angle;
scene.add(pivot);
const zc = extension * 0.45;
box(0.035, 1.62, 0.84, M.glass, 0, 0.87, zc, pivot, false);
box(0.07, 1.7, 0.055, M.navy, 0, 0.86, 0, pivot);
box(0.07, 1.7, 0.055, M.navy, 0, 0.86, extension * 0.9, pivot);
box(0.07, 0.065, 0.9, M.navy, 0, 0.08, zc, pivot);
box(0.07, 0.065, 0.9, M.navy, 0, 1.66, zc, pivot);
}
leaf(z0 + 0.025, 1, 1.02);
leaf(z1 - 0.025, -1, -1.02);
}
// ---------------------------------------------------------------------------
// Furniture
// ---------------------------------------------------------------------------
function addChair(x, z, rotation = 0, accent = M.teal, parent = scene) {
const chair = new THREE.Group();
chair.position.set(x, FLOOR, z);
chair.rotation.y = rotation;
parent.add(chair);
box(0.68, 0.12, 0.62, accent, 0, 0.48, 0, chair);
box(0.68, 0.56, 0.11, accent, 0, 0.78, 0.26, chair);
[-0.25, 0.25].forEach((lx) => {
[-0.22, 0.22].forEach((lz) => {
box(0.055, 0.43, 0.055, M.metal, lx, 0.22, lz, chair);
});
});
return chair;
}
function addDesk(x, z, rotation = 0, parent = scene) {
const desk = new THREE.Group();
desk.position.set(x, FLOOR, z);
desk.rotation.y = rotation;
parent.add(desk);
box(1.45, 0.12, 0.72, M.white, 0, 0.82, 0, desk);
box(0.1, 0.76, 0.62, M.wood, -0.58, 0.41, 0, desk);
box(0.1, 0.76, 0.62, M.wood, 0.58, 0.41, 0, desk);
box(0.12, 0.12, 0.28, M.navy, 0, 0.93, 0.08, desk);
box(0.08, 0.45, 0.08, M.navy, 0, 1.17, 0.12, desk);
box(0.62, 0.39, 0.07, M.navy, 0, 1.42, 0.16, desk);
box(0.52, 0.29, 0.025, M.tealLight, 0, 1.42, 0.12, desk);
box(0.43, 0.04, 0.3, M.coral, -0.35, 0.91, -0.08, desk);
cylinder(0.08, 0.07, 0.22, M.white, 0.45, 1.0, -0.08, 8, desk);
return desk;
}
function addBed(x, z, accent, north) {
const bed = new THREE.Group();
bed.position.set(x, FLOOR, z);
scene.add(bed);
box(1.9, 0.16, 0.86, M.white, 0, 0.5, 0, bed);
box(1.78, 0.19, 0.76, accent, 0.02, 0.66, 0, bed);
box(0.58, 0.14, 0.66, M.white, -0.59, 0.8, 0, bed);
[-0.73, 0.73].forEach((lx) => {
[-0.28, 0.28].forEach((lz) => {
box(0.07, 0.42, 0.07, M.metal, lx, 0.22, lz, bed);
});
});
box(1.72, 0.48, 0.08, M.white, 0, 0.78, 0.43, bed);
if (!north) {
bed.rotation.y = Math.PI;
}
return bed;
}
function addCabinet(x, z, accent = M.tealLight) {
box(0.95, 1.05, 0.55, M.white, x, FLOOR + 0.525, z);
box(1.0, 0.08, 0.59, accent, x, FLOOR + 1.08, z);
[-0.23, 0.23].forEach((dx) => {
box(0.035, 0.26, 0.035, M.navy, x + dx, FLOOR + 0.68, z + 0.29);
});
}
function addPlant(x, z, size = 1) {
const group = new THREE.Group();
group.position.set(x, FLOOR, z);
group.scale.setScalar(size);
scene.add(group);
cylinder(0.3, 0.23, 0.42, M.coral, 0, 0.21, 0, 8, group);
cylinder(0.045, 0.055, 0.9, M.woodDark, 0, 0.82, 0, 6, group);
ico(0.48, M.leaf, -0.18, 1.25, 0.02, group);
ico(0.43, M.leafLight, 0.23, 1.42, -0.04, group);
ico(0.36, M.leaf, 0.05, 1.7, 0.08, group);
return group;
}
function addTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, -0.18, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(0.55, 0.65, 0.48, M.wallShade, 0, 0.24, 0, 8, group);
cylinder(0.12, 0.17, 1.7, M.woodDark, 0, 1.15, 0, 7, group);
ico(0.95, M.leaf, 0, 2.35, 0, group);
ico(0.73, M.leafLight, -0.55, 2.12, 0.12, group);
ico(0.7, M.leaf, 0.53, 2.18, -0.1, group);
}
function addExamRoom(cx, north, accent, title) {
const outerZ = north ? -5.85 : 5.85;
const innerZ = north ? -3.15 : 3.15;
const bedZ = north ? -4.55 : 4.55;
addBed(cx - 1.05, bedZ, accent, north);
addDesk(cx + 1.25, innerZ, north ? Math.PI : 0);
addCabinet(cx + 1.48, outerZ, accent);
addChair(cx + 0.15, innerZ + (north ? -0.05 : 0.05), north ? 0 : Math.PI, accent);
box(0.58, 0.62, 0.48, M.white, cx - 1.9, FLOOR + 0.31, innerZ + 0.05);
cylinder(0.12, 0.12, 0.05, M.coral, cx - 1.9, FLOOR + 0.65, innerZ + 0.05, 8);
makeLabel(
title,
cx,
1.67,
north ? -1.61 : 1.61,
title.length > 8 ? 2.5 : 1.9
);
}
// ---------------------------------------------------------------------------
// Site, plinth, and floors
// ---------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(90, 90),
M.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.25;
ground.receiveShadow = true;
scene.add(ground);
// Exterior approach and entry landing.
box(4.1, 0.12, 3.5, M.wallShade, -15.1, -0.13, 0);
box(1.0, 0.12, 4.0, M.wallShade, -13.5, -0.13, 0);
// Building plinth.
box(20, 0.24, 3.6, M.plinth, 0, -0.04, 0);
box(20, 0.24, 4.8, M.plinth, 0, -0.04, -4.2);
box(20, 0.24, 4.8, M.plinth, 0, -0.04, 4.2);
box(3, 0.24, 4, M.plinth, -11.5, -0.04, 0);
// Room floor overlays.
const northRooms = [
[-10, -5],
[-5, 0],
[0, 5],
[5, 10]
];
northRooms.forEach(([x1, x2], i) => {
box(
x2 - x1,
0.055,
4.8,
i % 2 === 0 ? M.floorA : M.floorB,
(x1 + x2) / 2,
FLOOR - 0.025,
-4.2
);
});
box(10, 0.055, 4.8, M.waiting, -5, FLOOR - 0.025, 4.2);
box(5, 0.055, 4.8, M.floorC, 2.5, FLOOR - 0.025, 4.2);
box(5, 0.055, 4.8, M.floorA, 7.5, FLOOR - 0.025, 4.2);
box(20, 0.055, 3.6, M.corridor, 0, FLOOR - 0.025, 0);
box(3, 0.055, 4, M.floorB, -11.5, FLOOR - 0.025, 0);
// ---------------------------------------------------------------------------
// Walls and repeated module partitions
// ---------------------------------------------------------------------------
// Low outer walls preserve the dollhouse cutaway view.
wallX(-10, 10, -6.6, 1.35);
wallX(-10, 10, 6.6, 1.35);
// End walls, leaving the west corridor open to the vestibule.
wallZ(-10, -6.6, -1.8);
wallZ(-10, 1.8, 6.6);
wallZ(10, -6.6, -1.8);
wallZ(10, 1.8, 6.6);
// North partitions divide four standard modules.
[-5, 0, 5].forEach((x) => wallZ(x, -6.6, -1.8));
// South: the wall at x=-5 is intentionally absent, merging two modules.
[0, 5].forEach((x) => wallZ(x, 1.8, 6.6));
const northOpenings = [
{ center: -7.5, width: 1.3 },
{ center: -2.5, width: 1.3 },
{ center: 2.5, width: 1.3 },
{ center: 7.5, width: 1.3 }
];
const southOpenings = [
{ center: -3.3, width: 2.8 },
{ center: 2.5, width: 1.3 },
{ center: 7.5, width: 1.3 }
];
wallWithOpeningsX(-10, 10, -1.8, northOpenings);
wallWithOpeningsX(-10, 10, 1.8, southOpenings);
northOpenings.forEach((opening) => {
addRoomDoor(opening.center, -1.8, opening.width, false);
});
addDoubleRoomDoor(southOpenings[0].center, 1.8, southOpenings[0].width);
addRoomDoor(southOpenings[1].center, 1.8, southOpenings[1].width, true);
addRoomDoor(southOpenings[2].center, 1.8, southOpenings[2].width, true);
// A recessed window closes the east end of the corridor visually.
box(0.17, 0.62, 3.6, M.wall, 10, FLOOR + 0.31, 0);
box(0.035, 1.08, 2.85, M.glass, 10, FLOOR + 1.25, 0, scene, false);
box(0.08, 1.15, 0.08, M.navy, 10, FLOOR + 1.25, -1.44);
box(0.08, 1.15, 0.08, M.navy, 10, FLOOR + 1.25, 1.44);
box(0.08, 0.08, 2.95, M.navy, 10, FLOOR + 1.82, 0);
// Entrance vestibule walls.
wallX(-13, -10, -2, 1.45);
wallX(-13, -10, 2, 1.45);
wallZ(-13, -2, -0.95, 1.45);
wallZ(-13, 0.95, 2, 1.45);
addEntranceDoor();
// Canopy.
box(1.45, 0.14, 4.35, M.teal, -13.05, 2.42, 0);
[-13.55, -12.55].forEach((x) => {
[-1.78, 1.78].forEach((z) => {
cylinder(0.07, 0.08, 2.27, M.navy, x, 1.25, z, 8);
});
});
// Tactile arrival strip.
for (let i = 0; i < 9; i++) {
box(0.14, 0.025, 1.65, M.yellow, -14.1 - i * 0.19, 0.015, 0, scene, false);
}
// ---------------------------------------------------------------------------
// Corridor wayfinding
// ---------------------------------------------------------------------------
box(20, 0.018, 0.09, M.tealLight, 0, FLOOR + 0.02, 0, scene, false);
box(3, 0.018, 0.09, M.tealLight, -11.5, FLOOR + 0.02, 0, scene, false);
function floorArrow(x, z) {
const shape = new THREE.Shape();
shape.moveTo(-0.38, -0.22);
shape.lineTo(0.04, -0.22);
shape.lineTo(0.04, -0.43);
shape.lineTo(0.43, 0);
shape.lineTo(0.04, 0.43);
shape.lineTo(0.04, 0.22);
shape.lineTo(-0.38, 0.22);
shape.closePath();
const arrow = new THREE.Mesh(
new THREE.ShapeGeometry(shape),
new THREE.MeshBasicMaterial({ color: 0x258d82, side: THREE.DoubleSide })
);
arrow.rotation.x = -Math.PI / 2;
arrow.position.set(x, FLOOR + 0.045, z);
scene.add(arrow);
}
[-8.3, -2.6, 3.8, 8.5].forEach((x) => floorArrow(x, 0));
// ---------------------------------------------------------------------------
// Repeated clinical rooms
// ---------------------------------------------------------------------------
addExamRoom(-7.5, true, M.tealLight, "EXAM 01");
addExamRoom(-2.5, true, M.coral, "EXAM 02");
addExamRoom(2.5, true, M.tealLight, "EXAM 03");
addExamRoom(7.5, true, M.yellow, "TREATMENT");
addExamRoom(2.5, false, M.coral, "PHYSIO");
addExamRoom(7.5, false, M.tealLight, "LAB");
// A treatment cart and storage in the treatment module.
box(0.85, 0.75, 0.58, M.white, 8.7, FLOOR + 0.38, -5.6);
box(0.92, 0.07, 0.63, M.yellow, 8.7, FLOOR + 0.79, -5.6);
box(0.24, 0.13, 0.18, M.coral, 8.45, FLOOR + 0.88, -5.6);
// ---------------------------------------------------------------------------
// Adapted shared waiting module
// ---------------------------------------------------------------------------
// Rug and low table.
box(5.15, 0.025, 2.55, M.tealLight, -6.95, FLOOR + 0.035, 4.85, scene, false);
box(0.05, 0.018, 5.0, M.teal, -9.43, FLOOR + 0.055, 4.85, scene, false);
box(0.05, 0.018, 5.0, M.teal, -4.47, FLOOR + 0.055, 4.85, scene, false);
const waitingXs = [-8.7, -7.55, -6.4, -5.25];
waitingXs.forEach((x, i) => {
addChair(x, 4.15, 0, i % 2 ? M.teal : M.navy);
addChair(x, 5.25, 0, i % 2 ? M.navy : M.teal);
});
// Reception counter.
box(2.05, 0.94, 0.72, M.wood, -1.2, FLOOR + 0.47, 4.9);
box(2.15, 0.1, 0.8, M.navy, -1.2, FLOOR + 0.98, 4.9);
box(0.12, 0.12, 0.28, M.navy, -1.55, FLOOR + 1.09, 4.98);
box(0.08, 0.43, 0.08, M.navy, -1.55, FLOOR + 1.34, 5.04);
box(0.64, 0.4, 0.07, M.navy, -1.55, FLOOR + 1.58, 5.1);
box(0.54, 0.3, 0.025, M.tealLight, -1.55, FLOOR + 1.58, 5.05);
addChair(-1.25, 5.95, Math.PI, M.coral);
// Low communal table.
cylinder(0.64, 0.64, 0.1, M.wood, -6.95, FLOOR + 0.48, 3.35, 10);
cylinder(0.09, 0.13, 0.43, M.woodDark, -6.95, FLOOR + 0.23, 3.35, 8);
addPlant(-9.15, 2.55, 0.85);
addPlant(-0.55, 6.0, 0.78);
// Ghost line showing the removed standard partition.
const ghostGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-5, FLOOR + 0.075, 1.9),
new THREE.Vector3(-5, FLOOR + 0.075, 6.4)
]);
const ghostLine = new THREE.Line(
ghostGeometry,
new THREE.LineDashedMaterial({
color: 0xffffff,
dashSize: 0.22,
gapSize: 0.16,
transparent: true,
opacity: 0.8
})
);
ghostLine.computeLineDistances();
scene.add(ghostLine);
floorText("SHARED WAITING / 2 MODULES", -6.8, 2.48, 4.8, "#ffffff");
makeLabel("SHARED WAITING|TWO MODULES MERGED", -3.3, 1.68, 1.57, 3.65, "#258d82");
// ---------------------------------------------------------------------------
// Landscape and wayfinding accents
// ---------------------------------------------------------------------------
addTree(-15.2, -4.6, 1.05);
addTree(12.3, 7.0, 1.1);
addTree(14.3, -5.8, 0.9);
addPlant(11.3, 3.2, 0.9);
makeLabel("CARE CLINIC|ENTRANCE", -13.0, 2.66, 0, 3.25, "#258d82");
// A small ground compass.
cylinder(0.8, 0.8, 0.035, M.wall, 12.65, -0.205, -1.3, 16);
const compassShape = new THREE.Shape();
compassShape.moveTo(0, 0.56);
compassShape.lineTo(-0.24, -0.34);
compassShape.lineTo(0, -0.12);
compassShape.lineTo(0.24, -0.34);
compassShape.closePath();
const compass = new THREE.Mesh(
new THREE.ShapeGeometry(compassShape),
new THREE.MeshBasicMaterial({ color: 0x258d82, side: THREE.DoubleSide })
);
compass.rotation.x = -Math.PI / 2;
compass.position.set(12.65, -0.18, -1.3);
scene.add(compass);
makeLabel("N", 12.65, 0.25, -1.95, 0.55, "#ffffff");
// ---------------------------------------------------------------------------
// Direct camera controls: orbit, pan, and zoom
// ---------------------------------------------------------------------------
let dragging = null;
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = {
x: event.clientX,
y: event.clientY,
pan: event.button === 2 || event.shiftKey,
pointerId: event.pointerId
};
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - dragging.x;
const dy = event.clientY - dragging.y;
dragging.x = event.clientX;
dragging.y = event.clientY;
if (dragging.pan) {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const direction = new THREE.Vector3();
camera.getWorldDirection(direction);
const up = new THREE.Vector3().crossVectors(right, direction).normalize();
const scale = 24 / cameraState.zoom / window.innerHeight;
target.addScaledVector(right, -dx * scale);
target.addScaledVector(up, dy * scale);
} else {
cameraGoal.azimuth -= dx * 0.006;
cameraGoal.polar = THREE.MathUtils.clamp(
cameraGoal.polar - dy * 0.005,
0.08,
1.36
);
}
});
function stopDrag(event) {
if (dragging && renderer.domElement.hasPointerCapture(dragging.pointerId)) {
renderer.domElement.releasePointerCapture(dragging.pointerId);
}
dragging = null;
}
renderer.domElement.addEventListener("pointerup", stopDrag);
renderer.domElement.addEventListener("pointercancel", stopDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraGoal.zoom = THREE.MathUtils.clamp(
cameraGoal.zoom * Math.exp(-event.deltaY * 0.001),
0.55,
2.7
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
const step = 0.09;
if (event.key === "ArrowLeft") cameraGoal.azimuth += step;
if (event.key === "ArrowRight") cameraGoal.azimuth -= step;
if (event.key === "ArrowUp") {
cameraGoal.polar = THREE.MathUtils.clamp(cameraGoal.polar - step, 0.08, 1.36);
}
if (event.key === "ArrowDown") {
cameraGoal.polar = THREE.MathUtils.clamp(cameraGoal.polar + step, 0.08, 1.36);
}
if (event.key === "+" || event.key === "=") {
cameraGoal.zoom = THREE.MathUtils.clamp(cameraGoal.zoom * 1.1, 0.55, 2.7);
}
if (event.key === "-" || event.key === "_") {
cameraGoal.zoom = THREE.MathUtils.clamp(cameraGoal.zoom / 1.1, 0.55, 2.7);
}
if (event.key.toLowerCase() === "f") resetCamera();
if (event.key.toLowerCase() === "p") setPlanCamera();
});
function resetCamera() {
cameraGoal.azimuth = 0.72;
cameraGoal.polar = 0.87;
cameraGoal.zoom = 1;
target.set(-1.2, 0, 0);
setActiveButton("iso");
}
function setPlanCamera() {
cameraGoal.azimuth = 0;
cameraGoal.polar = 0.08;
cameraGoal.zoom = 1.05;
target.set(-1.2, 0, 0);
setActiveButton("plan");
}
function setActiveButton(id) {
document.querySelectorAll(".controls button").forEach((button) => {
button.classList.toggle("active", button.id === id);
});
}
document.getElementById("iso").addEventListener("click", resetCamera);
document.getElementById("plan").addEventListener("click", setPlanCamera);
document.getElementById("labels").addEventListener("click", (event) => {
labels.visible = !labels.visible;
event.currentTarget.classList.toggle("active", labels.visible);
});
document.getElementById("reset").addEventListener("click", resetCamera);
// ---------------------------------------------------------------------------
// Resize and animation
// ---------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const nextAspect = width / height;
camera.left = -23 * nextAspect;
camera.right = 23 * nextAspect;
camera.top = 23;
camera.bottom = -23;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
function animate() {
requestAnimationFrame(animate);
const damping = 0.12;
cameraState.azimuth +=
(cameraGoal.azimuth - cameraState.azimuth) * damping;
cameraState.polar +=
(cameraGoal.polar - cameraState.polar) * damping;
cameraState.zoom +=
(cameraGoal.zoom - cameraState.zoom) * damping;
updateCamera();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```