Prompt specification
Build or customize the Three.js 3D scene "Workshop bay converted into a reading room" 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: Workshop bay converted into a reading room
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/workshop-bay-converted-into-a-reading-room-x2166
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: workshop bay converted into a reading room. Create a former workshop bay with retained beams and new shelves, lighting, and seating. Keep old structure recognizable while showing an unobstructed new circulation path. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (workshop-bay-converted-into-a-reading-room-x2166):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bay 03 — Workshop Reading Room</title>
<style>
:root {
--ink: #26332f;
--muted: #66716c;
--paper: rgba(248, 246, 238, 0.91);
--line: rgba(38, 51, 47, 0.14);
--accent: #d9a62e;
--green: #3f6659;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d9ded8;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#stage,
#stage canvas {
width: 100%;
height: 100%;
display: block;
touch-action: none;
}
#stage canvas {
cursor: grab;
outline: none;
}
#stage canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--line);
background: var(--paper);
box-shadow: 0 12px 35px rgba(35, 48, 43, 0.12);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.brief {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 18px 19px 16px;
border-radius: 4px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--green);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 34px);
line-height: 1.02;
letter-spacing: -0.045em;
}
.brief p {
margin: 11px 0 0;
max-width: 330px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.measure {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 13px;
color: var(--ink);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.measure::before {
content: "";
width: 22px;
height: 3px;
background: var(--accent);
}
.legend {
left: 22px;
bottom: 22px;
display: flex;
flex-wrap: wrap;
gap: 13px;
max-width: min(560px, calc(100vw - 44px));
padding: 11px 14px;
border-radius: 4px;
color: var(--muted);
font-size: 10px;
font-weight: 650;
letter-spacing: 0.035em;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
white-space: nowrap;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 1px;
}
.swatch.old { background: #38544f; }
.swatch.new { background: #b9864b; }
.swatch.route { background: #d9d0b9; border: 1px solid #bdb39a; }
.swatch.seat { background: #6c8d87; }
.controls {
right: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 5px;
padding: 6px;
border-radius: 4px;
}
button {
min-height: 34px;
padding: 0 11px;
border: 1px solid transparent;
border-radius: 2px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.055em;
text-transform: uppercase;
cursor: pointer;
transition: background 140ms ease, color 140ms ease;
}
button:hover {
background: rgba(63, 102, 89, 0.09);
}
button.active {
border-color: rgba(217, 166, 46, 0.45);
background: rgba(217, 166, 46, 0.15);
}
button.zoom {
width: 34px;
padding: 0;
font-size: 17px;
}
.hint {
position: fixed;
z-index: 9;
right: 24px;
bottom: 79px;
color: rgba(38, 51, 47, 0.65);
font-size: 10px;
font-weight: 650;
letter-spacing: 0.025em;
pointer-events: none;
text-shadow: 0 1px 8px rgba(255,255,255,.7);
}
#labels {
position: fixed;
inset: 0;
z-index: 6;
pointer-events: none;
overflow: hidden;
}
.world-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
transform: translate(-50%, -50%);
padding: 6px 9px;
border: 1px solid rgba(38, 51, 47, 0.16);
border-radius: 2px;
background: rgba(249, 247, 239, 0.91);
box-shadow: 0 5px 16px rgba(35, 48, 43, 0.1);
color: var(--ink);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
white-space: nowrap;
transition: opacity 120ms ease;
}
.world-label::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 3px rgba(63, 102, 89, 0.12);
}
.world-label.route::before {
background: var(--accent);
box-shadow: 0 0 0 3px rgba(217, 166, 46, 0.16);
}
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: #d9ded8;
color: var(--green);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.brief {
top: 12px;
left: 12px;
width: min(330px, calc(100vw - 24px));
padding: 14px 15px;
}
.brief p { display: none; }
.measure { margin-top: 10px; }
.legend { display: none; }
.controls {
right: 12px;
bottom: 12px;
}
.hint {
display: none;
}
.world-label {
font-size: 8px;
}
}
</style>
</head>
<body>
<main id="stage" aria-label="Interactive voxel reading room"></main>
<div id="labels" aria-hidden="true">
<div class="world-label" id="label-structure">Retained steel structure</div>
<div class="world-label" id="label-shelves">New timber shelving</div>
<div class="world-label route" id="label-route">4 m clear circulation spine</div>
</div>
<section class="panel brief">
<div class="eyebrow">Adaptive reuse / Bay 03</div>
<h1>Workshop bay,<br>now a reading room.</h1>
<p>
Original brick, steel columns, crane rail and service equipment remain legible.
New joinery, warm lighting and soft seating occupy the side bays.
</p>
<div class="measure">Unobstructed central route</div>
</section>
<div class="panel legend">
<span><i class="swatch old"></i>Retained structure</span>
<span><i class="swatch new"></i>New joinery</span>
<span><i class="swatch seat"></i>Reading furniture</span>
<span><i class="swatch route"></i>Clear circulation</span>
</div>
<div class="hint">Drag to orbit · Shift/right-drag to pan · Scroll to zoom · Double-click to reset</div>
<nav class="panel controls" aria-label="Scene controls">
<button id="reset" title="Reset camera">Reset</button>
<button id="route" aria-pressed="false">Route</button>
<button id="labels-toggle" class="active" aria-pressed="true">Labels</button>
<button id="zoom-out" class="zoom" aria-label="Zoom out">−</button>
<button id="zoom-in" class="zoom" aria-label="Zoom in">+</button>
</nav>
<div id="loading">Constructing Bay 03</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd9ded8);
scene.fog = new THREE.Fog(0xd9ded8, 42, 76);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-20, 20, 12, -12, 0.1, 140);
const root = new THREE.Group();
scene.add(root);
const structure = new THREE.Group();
const joinery = new THREE.Group();
const furniture = new THREE.Group();
const lighting = new THREE.Group();
const routeGroup = new THREE.Group();
root.add(structure, joinery, furniture, lighting, routeGroup);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
const dummy = new THREE.Object3D();
let randomSeed = 42017;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function standardMaterial(color, roughness = 0.84, metalness = 0) {
const key = `${color}|${roughness}|${metalness}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness,
metalness
}));
}
return materialCache.get(key);
}
function addBox(parent, size, position, color, options = {}) {
const material = options.material ||
standardMaterial(
color,
options.roughness ?? 0.84,
options.metalness ?? 0
);
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
if (options.rotation) {
mesh.rotation.set(
options.rotation[0] ?? 0,
options.rotation[1] ?? 0,
options.rotation[2] ?? 0
);
}
parent.add(mesh);
return mesh;
}
function addInstances(parent, items, material, castShadow = false) {
const mesh = new THREE.InstancedMesh(unitBox, material, items.length);
items.forEach((item, index) => {
dummy.position.set(item.position[0], item.position[1], item.position[2]);
dummy.rotation.set(0, item.rotation?.[1] ?? 0, 0);
dummy.scale.set(item.size[0], item.size[1], item.size[2]);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
if (item.color !== undefined) {
mesh.setColorAt(index, new THREE.Color(item.color));
}
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
mesh.frustumCulled = false;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xf4f0df, 0x586761, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1ce, 3.25);
sun.position.set(-9, 18, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d0cf, 0.85);
fill.position.set(15, 10, -12);
scene.add(fill);
// Ground and slab.
addBox(
scene,
[100, 0.12, 100],
[0, -0.72, 0],
0xd9ded8,
{ castShadow: false, roughness: 1 }
);
addBox(
structure,
[22.5, 0.56, 14.5],
[0, -0.31, 0],
0x59615d,
{ roughness: 0.94 }
);
// ---------------------------------------------------------------------
// Concrete tile floor with a continuous, lighter central route.
// ---------------------------------------------------------------------
const floorTiles = [];
const concreteColors = [
0x7d817a, 0x858982, 0x777d76, 0x8d9088, 0x747a73
];
const routeColors = [
0xd9d1bd, 0xe2dac7, 0xd3cbb7, 0xded6c2
];
for (let iz = 0; iz < 14; iz++) {
for (let ix = 0; ix < 22; ix++) {
const x = -10.5 + ix;
const z = -6.5 + iz;
const inRoute = x >= -1.5 && x <= 1.5;
const palette = inRoute ? routeColors : concreteColors;
floorTiles.push({
position: [x, 0.015, z],
size: [0.965, 0.07, 0.965],
color: palette[Math.floor(random() * palette.length)]
});
}
}
addInstances(
structure,
floorTiles,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.94,
metalness: 0
})
);
const brass = standardMaterial(0xb99045, 0.42, 0.56);
addBox(structure, [0.045, 0.028, 14], [-2.0, 0.071, 0], 0xffffff, {
material: brass,
castShadow: false
});
addBox(structure, [0.045, 0.028, 14], [2.0, 0.071, 0], 0xffffff, {
material: brass,
castShadow: false
});
// ---------------------------------------------------------------------
// Brick shell.
// ---------------------------------------------------------------------
const brickItems = [];
const brickColors = [
0x76574d, 0x815f52, 0x6f5047, 0x8a6657,
0x765a50, 0x906b59, 0x694d45
];
function brickBackRect(x0, x1, y0, y1) {
for (let y = y0; y < y1 - 0.01; y += 0.5) {
const height = Math.min(0.5, y1 - y);
for (let x = x0; x < x1 - 0.01; x += 1) {
const width = Math.min(1, x1 - x);
brickItems.push({
position: [x + width / 2, y + height / 2, -7.02],
size: [width - 0.035, height - 0.035, 0.28],
color: brickColors[Math.floor(random() * brickColors.length)]
});
}
}
}
function brickLeftRect(z0, z1, y0, y1) {
for (let y = y0; y < y1 - 0.01; y += 0.5) {
const height = Math.min(0.5, y1 - y);
for (let z = z0; z < z1 - 0.01; z += 1) {
const width = Math.min(1, z1 - z);
brickItems.push({
position: [-11.03, y + height / 2, z + width / 2],
size: [0.28, height - 0.035, width - 0.035],
color: brickColors[Math.floor(random() * brickColors.length)]
});
}
}
}
brickBackRect(-11.1, -2.2, 0, 7.2);
brickBackRect(2.2, 11.1, 0, 7.2);
brickBackRect(-2.2, 2.2, 4.8, 7.2);
brickLeftRect(-7.1, 7.1, 0, 7.2);
addInstances(
structure,
brickItems,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1
})
);
// Dark plinth at the base of the retained masonry.
addBox(structure, [8.9, 0.38, 0.13], [-6.65, 0.24, -6.83], 0x48534d);
addBox(structure, [8.9, 0.38, 0.13], [6.65, 0.24, -6.83], 0x48534d);
// ---------------------------------------------------------------------
// Retained steel frame and crane rail.
// ---------------------------------------------------------------------
const steel = 0x38534d;
const steelDark = 0x2c413d;
const rust = 0x76503b;
function steelColumn(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
addBox(group, [0.16, 6.65, 0.62], [-0.27, 3.46, 0], steelDark);
addBox(group, [0.16, 6.65, 0.62], [0.27, 3.46, 0], steelDark);
addBox(group, [0.43, 6.65, 0.18], [0, 3.46, 0], steel);
addBox(group, [0.95, 0.13, 0.92], [0, 0.12, 0], steelDark);
addBox(group, [0.77, 0.10, 0.75], [0, 6.78, 0], steelDark);
// Small rust marks retain the workshop character.
addBox(group, [0.09, 0.55, 0.66], [-0.28, 1.25, 0], rust, {
castShadow: false
});
addBox(group, [0.13, 0.25, 0.64], [0.28, 4.95, 0], rust, {
castShadow: false
});
structure.add(group);
}
[-10, -4, 4, 10].forEach((x) => steelColumn(x, -6.72));
function iBeam(length, position, rotationY = 0, color = steel) {
const group = new THREE.Group();
group.position.set(...position);
group.rotation.y = rotationY;
addBox(group, [length, 0.38, 0.18], [0, 0, 0], color);
addBox(group, [length, 0.13, 0.72], [0, 0.27, 0], color);
addBox(group, [length, 0.13, 0.72], [0, -0.27, 0], color);
structure.add(group);
return group;
}
iBeam(22.1, [0, 6.76, -6.68], 0, steel);
[-10, -4, 4, 10].forEach((x) => {
iBeam(14.05, [x, 6.76, 0], Math.PI / 2, steel);
});
// Retained yellow crane rail and trolley.
const craneYellow = 0xc99d31;
addBox(structure, [21.9, 0.25, 0.28], [0, 6.43, -4.78], craneYellow, {
roughness: 0.58,
metalness: 0.35
});
addBox(structure, [0.9, 0.48, 0.78], [-6.5, 6.13, -4.78], craneYellow, {
roughness: 0.6,
metalness: 0.3
});
addBox(structure, [0.055, 1.2, 0.055], [-6.5, 5.25, -4.78], steelDark);
addBox(structure, [0.32, 0.18, 0.2], [-6.5, 4.62, -4.78], steelDark);
// Service conduit along the retained wall.
addBox(structure, [0.12, 0.12, 12.6], [-10.78, 5.45, -0.35], steelDark);
addBox(structure, [9.3, 0.12, 0.12], [-6.15, 5.45, -6.78], steelDark);
// ---------------------------------------------------------------------
// Converted loading opening, now a glazed reading-room portal.
// ---------------------------------------------------------------------
const portal = new THREE.Group();
portal.position.set(0, 0, -6.82);
addBox(portal, [0.18, 4.8, 0.28], [-2.24, 2.4, 0], steelDark);
addBox(portal, [0.18, 4.8, 0.28], [2.24, 2.4, 0], steelDark);
addBox(portal, [4.65, 0.2, 0.3], [0, 4.72, 0], steelDark);
const glassMaterial = new THREE.MeshStandardMaterial({
color: 0x9cb8b2,
roughness: 0.18,
metalness: 0.05,
transparent: true,
opacity: 0.30,
depthWrite: false
});
addBox(portal, [1.92, 4.35, 0.055], [-1.03, 2.2, 0], 0xffffff, {
material: glassMaterial,
castShadow: false
});
addBox(portal, [1.92, 4.35, 0.055], [1.03, 2.2, 0], 0xffffff, {
material: glassMaterial,
castShadow: false
});
addBox(portal, [0.06, 0.72, 0.12], [-0.25, 2.1, 0.12], brass);
addBox(portal, [0.06, 0.72, 0.12], [0.25, 2.1, 0.12], brass);
// Remnants of the roller shutter above the opening.
addBox(portal, [4.55, 0.36, 0.42], [0, 4.88, 0], 0x8b8b78);
for (let i = 0; i < 3; i++) {
addBox(portal, [4.18, 0.08, 0.12], [0, 4.54 - i * 0.11, 0.12], 0x6c7068);
}
structure.add(portal);
// ---------------------------------------------------------------------
// Shelving and books.
// ---------------------------------------------------------------------
const bookColors = [
0x8d4e3d, 0x3f665d, 0xd2a14c, 0x5d7184,
0xb56b55, 0x6d7862, 0x364c56, 0xe1d1ad,
0x9c7655, 0x496f6c, 0xa64f45, 0x74705c
];
const oak = 0xb9864b;
const oakLight = 0xc6975b;
const shelfBack = 0x52675d;
function makeShelf({
x, z, width, height, depth, rotation = 0, levels = 4
}) {
const group = new THREE.Group();
group.position.set(x, 0.05, z);
group.rotation.y = rotation;
addBox(group, [0.16, height, depth], [-width / 2 + 0.08, height / 2, 0], oak);
addBox(group, [0.16, height, depth], [width / 2 - 0.08, height / 2, 0], oak);
addBox(group, [width - 0.24, height - 0.14, 0.09], [0, height / 2, -depth / 2 + 0.045], shelfBack);
addBox(group, [width, 0.17, depth], [0, height - 0.085, 0], oakLight);
const spacing = (height - 0.42) / (levels - 1);
const shelfLightMaterial = new THREE.MeshStandardMaterial({
color: 0xffd99a,
emissive: 0xffc568,
emissiveIntensity: 1.7,
roughness: 0.5
});
for (let level = 0; level < levels; level++) {
const shelfY = 0.22 + level * spacing;
addBox(
group,
[width - 0.2, 0.11, depth - 0.03],
[0, shelfY, 0],
oakLight
);
addBox(
group,
[width - 0.30, 0.025, 0.035],
[0, shelfY + 0.072, depth / 2 - 0.055],
0xffffff,
{
material: shelfLightMaterial,
castShadow: false
}
);
let cursor = -width / 2 + 0.2;
const right = width / 2 - 0.2;
while (cursor < right - 0.1) {
const bookWidth = 0.15 + random() * 0.15;
if (cursor + bookWidth > right) break;
const bookHeight = 0.42 + random() * 0.39;
const bookDepth = 0.31 + random() * 0.10;
const color = bookColors[Math.floor(random() * bookColors.length)];
addBox(
group,
[bookWidth, bookHeight, bookDepth],
[
cursor + bookWidth / 2,
shelfY + 0.055 + bookHeight / 2,
0.015 + (random() - 0.5) * 0.035
],
color,
{ roughness: 0.94 }
);
cursor += bookWidth + 0.025 + random() * 0.035;
}
}
joinery.add(group);
return group;
}
makeShelf({
x: -7.35, z: -6.38, width: 4.25, height: 4.45,
depth: 0.68, rotation: 0, levels: 4
});
makeShelf({
x: 7.35, z: -6.38, width: 4.25, height: 4.45,
depth: 0.68, rotation: 0, levels: 4
});
makeShelf({
x: -10.48, z: -2.0, width: 6.5, height: 4.30,
depth: 0.68, rotation: Math.PI / 2, levels: 4
});
// ---------------------------------------------------------------------
// Reading rugs, armchairs, sofa and tables.
// ---------------------------------------------------------------------
const rugMaterial = new THREE.MeshStandardMaterial({
color: 0x7b8f83,
roughness: 1
});
addBox(furniture, [6.35, 0.035, 4.6], [-5.55, 0.086, 3.45], 0xffffff, {
material: rugMaterial,
castShadow: false
});
addBox(furniture, [6.55, 0.035, 4.75], [6.0, 0.086, 3.25], 0xffffff, {
material: new THREE.MeshStandardMaterial({
color: 0xb49b73,
roughness: 1
}),
castShadow: false
});
function makeArmchair(x, z, rotation, color) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
group.rotation.y = rotation;
addBox(group, [1.48, 0.34, 1.48], [0, 0.47, 0], 0x465e57);
addBox(group, [1.38, 0.24, 1.32], [0, 0.75, 0.03], color);
addBox(group, [1.50, 1.12, 0.34], [0, 1.31, -0.58], color);
addBox(group, [0.25, 0.62, 1.40], [-0.73, 0.97, -0.02], color);
addBox(group, [0.25, 0.62, 1.40], [0.73, 0.97, -0.02], color);
[-0.55, 0.55].forEach((lx) => {
[-0.48, 0.48].forEach((lz) => {
addBox(group, [0.12, 0.34, 0.12], [lx, 0.18, lz], 0x3e3931);
});
});
furniture.add(group);
}
function makeSofa(x, z, rotation, color) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
group.rotation.y = rotation;
addBox(group, [3.25, 0.38, 1.44], [0, 0.48, 0], 0x4d6259);
addBox(group, [3.25, 1.15, 0.34], [0, 1.25, -0.57], color);
addBox(group, [0.28, 0.66, 1.45], [-1.54, 0.91, 0], color);
addBox(group, [0.28, 0.66, 1.45], [1.54, 0.91, 0], color);
for (let i = -1; i <= 1; i++) {
addBox(group, [0.91, 0.24, 1.18], [i * 0.98, 0.76, 0.04], color);
addBox(group, [0.83, 0.66, 0.20], [i * 0.98, 1.30, -0.38], color);
}
[-1.30, 1.30].forEach((lx) => {
[-0.48, 0.48].forEach((lz) => {
addBox(group, [0.12, 0.34, 0.12], [lx, 0.18, lz], 0x3e3931);
});
});
addBox(group, [0.55, 0.50, 0.16], [-0.65, 1.10, -0.20], 0xd5a34d);
furniture.add(group);
}
function makeTable(x, z, width = 1.5, depth = 1.2) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
addBox(group, [width, 0.15, depth], [0, 0.86, 0], oakLight);
addBox(group, [0.12, 0.76, 0.12], [-width / 2 + 0.18, 0.40, -depth / 2 + 0.18], 0x47443d);
addBox(group, [0.12, 0.76, 0.12], [width / 2 - 0.18, 0.40, -depth / 2 + 0.18], 0x47443d);
addBox(group, [0.12, 0.76, 0.12], [-width / 2 + 0.18, 0.40, depth / 2 - 0.18], 0x47443d);
addBox(group, [0.12, 0.76, 0.12], [width / 2 - 0.18, 0.40, depth / 2 - 0.18], 0x47443d);
addBox(group, [0.60, 0.08, 0.42], [-0.22, 0.975, 0.04], 0x7a4c40, {
rotation: [0, 0.12, 0]
});
addBox(group, [0.52, 0.06, 0.36], [-0.18, 1.045, 0.03], 0xd5c6a3, {
rotation: [0, -0.08, 0]
});
addBox(group, [0.20, 0.24, 0.20], [0.48, 1.055, 0.02], 0xe6d8b6);
addBox(group, [0.08, 0.15, 0.08], [0.61, 1.07, 0.02], 0xe6d8b6);
furniture.add(group);
}
makeArmchair(-7.25, 3.20, Math.PI / 2, 0x73968e);
makeArmchair(-3.90, 3.20, -Math.PI / 2, 0x73968e);
makeTable(-5.57, 3.25, 1.48, 1.18);
makeArmchair(4.05, 2.35, Math.PI / 2, 0xbd755e);
makeSofa(7.05, 4.55, Math.PI, 0xc79a4c);
makeTable(5.92, 2.62, 1.58, 1.22);
// ---------------------------------------------------------------------
// Retained workshop objects: bench, tool board, cabinet and bollards.
// ---------------------------------------------------------------------
const workbench = new THREE.Group();
workbench.position.set(-9.65, 0, 4.65);
addBox(workbench, [1.38, 0.17, 2.92], [0, 1.48, 0], 0x80664b);
[-0.53, 0.53].forEach((lx) => {
[-1.22, 1.22].forEach((lz) => {
addBox(workbench, [0.12, 1.42, 0.12], [lx, 0.73, lz], steelDark);
});
});
addBox(workbench, [0.62, 0.38, 0.82], [0.05, 1.76, -0.72], 0x9b493c);
addBox(workbench, [0.12, 0.12, 0.32], [0.05, 1.97, -0.72], steelDark);
addBox(workbench, [0.36, 0.24, 0.34], [-0.15, 1.68, 0.46], 0x4e5c58);
structure.add(workbench);
// Pegboard on the left wall.
addBox(structure, [0.12, 1.58, 2.75], [-10.84, 3.08, 4.65], 0x9b7654);
for (let i = 0; i < 8; i++) {
for (let j = 0; j < 3; j++) {
addBox(
structure,
[0.035, 0.055, 0.055],
[-10.765, 2.52 + j * 0.56, 3.57 + i * 0.30],
0x544d42,
{ castShadow: false }
);
}
}
// Blocky hanging tools.
for (let i = 0; i < 4; i++) {
const z = 3.72 + i * 0.55;
addBox(structure, [0.07, 0.60, 0.10], [-10.72, 3.07, z], steelDark);
addBox(structure, [0.08, 0.18, 0.34], [-10.71, 3.40, z], steelDark);
}
// Retained electrical cabinet.
addBox(structure, [1.05, 1.78, 0.48], [-3.0, 1.18, -6.57], 0x66746b);
addBox(structure, [0.47, 1.60, 0.06], [-3.27, 1.18, -6.30], 0x59675f);
addBox(structure, [0.47, 1.60, 0.06], [-2.73, 1.18, -6.30], 0x59675f);
addBox(structure, [0.06, 0.24, 0.08], [-3.10, 1.18, -6.24], brass);
addBox(structure, [0.06, 0.24, 0.08], [-2.90, 1.18, -6.24], brass);
// Safety posts outside the central clear route.
[-2.55, 2.55].forEach((x) => {
addBox(structure, [0.19, 1.12, 0.19], [x, 0.61, -5.78], craneYellow);
addBox(structure, [0.205, 0.20, 0.205], [x, 0.38, -5.78], 0x39413d);
addBox(structure, [0.205, 0.20, 0.205], [x, 0.82, -5.78], 0x39413d);
addBox(structure, [0.34, 0.10, 0.34], [x, 0.11, -5.78], steelDark);
});
// Faded former-machine footprint in the side bay.
const fadedPaint = new THREE.MeshStandardMaterial({
color: 0xb69748,
roughness: 1,
transparent: true,
opacity: 0.33,
depthWrite: false
});
const paintX = 7.55;
const paintZ = -0.95;
const paintW = 3.8;
const paintD = 2.1;
[[-1, -1], [1, -1], [-1, 1], [1, 1]].forEach(([sx, sz]) => {
addBox(
structure,
[1.0, 0.018, 0.055],
[paintX + sx * (paintW / 2 - 0.5), 0.067, paintZ + sz * paintD / 2],
0xffffff,
{ material: fadedPaint, castShadow: false }
);
addBox(
structure,
[0.055, 0.018, 0.72],
[paintX + sx * paintW / 2, 0.067, paintZ + sz * (paintD / 2 - 0.36)],
0xffffff,
{ material: fadedPaint, castShadow: false }
);
});
// ---------------------------------------------------------------------
// Pendant lighting.
// ---------------------------------------------------------------------
function pendant(x, z, intensity = 25) {
addBox(lighting, [0.035, 1.20, 0.035], [x, 6.48, z], steelDark);
addBox(lighting, [1.22, 0.32, 0.86], [x, 5.73, z], 0x364440);
addBox(lighting, [1.02, 0.055, 0.68], [x, 5.53, z], 0xffe3a6, {
material: new THREE.MeshStandardMaterial({
color: 0xffe3a6,
emissive: 0xffc76d,
emissiveIntensity: 2.1,
roughness: 0.45
}),
castShadow: false
});
const light = new THREE.PointLight(0xffd39a, intensity, 9, 2);
light.position.set(x, 5.38, z);
lighting.add(light);
}
pendant(-5.55, 3.25, 30);
pendant(5.95, 2.62, 30);
pendant(0, -2.30, 22);
// ---------------------------------------------------------------------
// Voxel plants.
// ---------------------------------------------------------------------
function makePlant(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.08, z);
group.scale.setScalar(scale);
addBox(group, [0.62, 0.52, 0.62], [0, 0.28, 0], 0xb76f4d);
addBox(group, [0.52, 0.08, 0.52], [0, 0.56, 0], 0x4a3e31);
addBox(group, [0.14, 1.25, 0.14], [0, 1.12, 0], 0x67513a);
const leafColors = [0x52745f, 0x668b69, 0x3f6657, 0x78916a];
const leaves = [
[0, 1.75, 0, 0.80, 0.60, 0.65],
[-0.38, 1.55, 0.05, 0.58, 0.55, 0.58],
[0.38, 1.48, -0.08, 0.62, 0.48, 0.55],
[0.10, 1.42, 0.36, 0.52, 0.46, 0.52],
[-0.18, 2.08, -0.10, 0.58, 0.55, 0.54]
];
leaves.forEach((leaf, index) => {
addBox(
group,
[leaf[3], leaf[4], leaf[5]],
[leaf[0], leaf[1], leaf[2]],
leafColors[index % leafColors.length]
);
});
furniture.add(group);
}
makePlant(9.45, 5.75, 1.0);
makePlant(-9.45, -5.65, 0.82);
// ---------------------------------------------------------------------
// Signs made with canvas textures; no external assets.
// ---------------------------------------------------------------------
function makeSign(text, subtitle, width, height, position, background, foreground) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = foreground;
ctx.globalAlpha = 0.55;
ctx.lineWidth = 6;
ctx.strokeRect(14, 14, canvas.width - 28, canvas.height - 28);
ctx.globalAlpha = 1;
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "700 78px ui-monospace, Menlo, Consolas, monospace";
ctx.fillText(text, 512, 103);
ctx.globalAlpha = 0.78;
ctx.font = "600 28px ui-monospace, Menlo, Consolas, monospace";
ctx.fillText(subtitle, 512, 185);
ctx.globalAlpha = 1;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
toneMapped: false,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
mesh.position.set(...position);
joinery.add(mesh);
return mesh;
}
makeSign(
"BAY 03",
"FORMER WORKSHOP / RETAINED",
4.80, 1.12,
[0, 5.72, -6.84],
"#293b36",
"#e7bd50"
);
makeSign(
"READING ROOM",
"NEW JOINERY / QUIET STUDY",
4.30, 0.90,
[7.35, 5.25, -6.83],
"#e7e1d2",
"#34574f"
);
function makeFloorLabel() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(74, 91, 82, 0.62)";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 72px ui-monospace, Menlo, Consolas, monospace";
ctx.fillText("KEEP CLEAR", 512, 92);
ctx.font = "700 38px ui-monospace, Menlo, Consolas, monospace";
ctx.fillText("4 m SPINE", 512, 174);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(3.3, 0.82), material);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(0, 0.077, 3.35);
routeGroup.add(mesh);
}
makeFloorLabel();
const routeOverlay = new THREE.Mesh(
new THREE.PlaneGeometry(3.95, 13.95),
new THREE.MeshBasicMaterial({
color: 0xffc85a,
transparent: true,
opacity: 0.18,
depthWrite: false,
side: THREE.DoubleSide
})
);
routeOverlay.rotation.x = -Math.PI / 2;
routeOverlay.position.y = 0.072;
routeGroup.add(routeOverlay);
routeGroup.visible = false;
// ---------------------------------------------------------------------
// Camera controls implemented directly without Three.js addons.
// ---------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 2.0, 0),
yaw: 0.73,
pitch: 0.64,
zoom: 1,
distance: 31,
baseViewHeight: 22
};
function updateCamera() {
const horizontal = Math.cos(controls.pitch) * controls.distance;
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * horizontal,
controls.target.y + Math.sin(controls.pitch) * controls.distance,
controls.target.z + Math.cos(controls.yaw) * horizontal
);
camera.lookAt(controls.target);
camera.zoom = controls.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
controls.baseViewHeight = aspect < 1
? Math.max(30, 30 / aspect)
: 22;
camera.left = -controls.baseViewHeight * aspect / 2;
camera.right = controls.baseViewHeight * aspect / 2;
camera.top = controls.baseViewHeight / 2;
camera.bottom = -controls.baseViewHeight / 2;
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", resize);
resize();
let dragging = false;
let dragMode = "orbit";
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
dragMode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
if (dragMode === "orbit") {
controls.yaw -= dx * 0.006;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.0045,
0.27,
1.22
);
} else {
const panScale =
(controls.baseViewHeight / controls.zoom) /
renderer.domElement.clientHeight * 1.05;
const right = new THREE.Vector3(
Math.cos(controls.yaw),
0,
-Math.sin(controls.yaw)
);
const forward = new THREE.Vector3(
-Math.sin(controls.yaw),
0,
-Math.cos(controls.yaw)
);
controls.target.addScaledVector(right, -dx * panScale);
controls.target.addScaledVector(forward, dy * panScale);
controls.target.x = THREE.MathUtils.clamp(controls.target.x, -7, 7);
controls.target.z = THREE.MathUtils.clamp(controls.target.z, -6, 6);
}
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
controls.zoom = THREE.MathUtils.clamp(
controls.zoom * Math.exp(-event.deltaY * 0.0011),
0.62,
2.35
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
controls.target.set(0, 2, 0);
controls.yaw = 0.73;
controls.pitch = 0.64;
controls.zoom = 1;
updateCamera();
});
function resetView() {
controls.target.set(0, 2, 0);
controls.yaw = 0.73;
controls.pitch = 0.64;
controls.zoom = 1;
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetView);
document.getElementById("zoom-in").addEventListener("click", () => {
controls.zoom = THREE.MathUtils.clamp(controls.zoom * 1.15, 0.62, 2.35);
updateCamera();
});
document.getElementById("zoom-out").addEventListener("click", () => {
controls.zoom = THREE.MathUtils.clamp(controls.zoom / 1.15, 0.62, 2.35);
updateCamera();
});
const routeButton = document.getElementById("route");
routeButton.addEventListener("click", () => {
routeGroup.visible = !routeGroup.visible;
routeButton.classList.toggle("active", routeGroup.visible);
routeButton.setAttribute("aria-pressed", String(routeGroup.visible));
});
const labelsButton = document.getElementById("labels-toggle");
const labelsLayer = document.getElementById("labels");
labelsButton.addEventListener("click", () => {
const visible = !labelsLayer.classList.contains("hidden");
labelsLayer.classList.toggle("hidden", visible);
labelsButton.classList.toggle("active", !visible);
labelsButton.setAttribute("aria-pressed", String(!visible));
});
// ---------------------------------------------------------------------
// Screen-space labels projected from scene anchors.
// ---------------------------------------------------------------------
const labelAnchors = [
{
element: document.getElementById("label-structure"),
point: new THREE.Vector3(3.9, 6.45, -4.72)
},
{
element: document.getElementById("label-shelves"),
point: new THREE.Vector3(-9.9, 4.55, -2.0)
},
{
element: document.getElementById("label-route"),
point: new THREE.Vector3(0, 0.18, 1.6)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const width = renderer.domElement.clientWidth;
const height = renderer.domElement.clientHeight;
labelAnchors.forEach(({ element, point }) => {
projected.copy(point).project(camera);
const inView =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.15 &&
projected.x < 1.15 &&
projected.y > -1.15 &&
projected.y < 1.15;
element.style.opacity = inView ? "1" : "0";
element.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
});
}
updateCamera();
renderer.setAnimationLoop(() => {
updateLabels();
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
});
</script>
</body>
</html>
```