Prompt specification
Build or customize the Three.js 3D scene "Warehouse courtyard community center" 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: Warehouse courtyard community center
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/warehouse-courtyard-community-center-x2167
Scene Description Prompt:
Convert a low-poly warehouse into classrooms, repair workshop, and shared courtyard, distinguishing retained structure, additions, visitor access, and deliveries. Three.js from cdnjs, standalone HTML.
Working Three.js Starter (warehouse-courtyard-community-center-x2167):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Warehouse Reuse — Learning Hub</title>
<style>
:root {
--ink: #26333b;
--muted: #68757b;
--paper: rgba(249, 247, 241, 0.94);
--line: rgba(38, 51, 59, 0.14);
--retained: #46545e;
--additions: #d99a38;
--visitor: #16a39a;
--deliveries: #ef6a4c;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #e8e3d9;
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;
outline: none;
}
#labels {
position: fixed;
inset: 0;
pointer-events: none;
overflow: hidden;
}
.scene-label {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -100%);
min-width: 124px;
padding: 9px 11px 9px 12px;
border: 1px solid rgba(255,255,255,0.72);
border-radius: 9px;
background: rgba(250, 248, 243, 0.92);
box-shadow: 0 8px 24px rgba(37, 45, 49, 0.16);
backdrop-filter: blur(8px);
pointer-events: auto;
cursor: pointer;
transition: opacity 160ms ease, transform 160ms ease;
}
.scene-label:hover {
background: #fffdf8;
}
.scene-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 17px;
background: rgba(38, 51, 59, 0.45);
}
.scene-label strong {
display: block;
font-size: 11px;
line-height: 1.2;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.scene-label span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 10px;
}
.scene-label .key {
position: absolute;
left: 0;
top: 7px;
bottom: 7px;
width: 4px;
border-radius: 4px;
background: var(--retained);
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(255,255,255,0.7);
background: var(--paper);
box-shadow: 0 12px 38px rgba(38, 45, 49, 0.14);
backdrop-filter: blur(12px);
}
#title-panel {
top: 20px;
left: 20px;
width: min(360px, calc(100vw - 40px));
padding: 18px 19px 17px;
border-radius: 14px;
}
.eyebrow {
color: #7e7a6f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 7px 0 7px;
font-size: clamp(22px, 2.5vw, 31px);
line-height: 1.05;
letter-spacing: -0.04em;
}
#title-panel p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.title-meta {
display: flex;
align-items: center;
gap: 8px;
margin-top: 14px;
color: #5f6a6e;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.title-meta::before {
content: "";
width: 28px;
height: 2px;
background: var(--additions);
}
#view-panel {
top: 20px;
right: 20px;
padding: 10px;
border-radius: 13px;
display: flex;
gap: 5px;
flex-wrap: wrap;
max-width: min(500px, calc(100vw - 40px));
}
.view-button {
appearance: none;
border: 0;
border-radius: 8px;
padding: 9px 11px;
background: transparent;
color: #58646a;
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: background 140ms ease, color 140ms ease;
}
.view-button:hover {
background: rgba(38, 51, 59, 0.06);
color: var(--ink);
}
.view-button.active {
background: var(--ink);
color: white;
}
#legend-panel {
left: 20px;
bottom: 20px;
width: 225px;
padding: 13px;
border-radius: 13px;
}
.legend-title {
margin: 1px 3px 9px;
color: #7c7c73;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-item {
appearance: none;
width: 100%;
display: flex;
align-items: center;
gap: 9px;
padding: 7px 6px;
border: 0;
border-radius: 7px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 11px;
text-align: left;
cursor: pointer;
}
.legend-item:hover {
background: rgba(38, 51, 59, 0.055);
}
.legend-item.off {
opacity: 0.36;
text-decoration: line-through;
}
.swatch {
width: 19px;
height: 8px;
flex: 0 0 auto;
border-radius: 3px;
background: var(--color);
box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.legend-hint {
margin: 9px 4px 1px;
padding-top: 9px;
border-top: 1px solid var(--line);
color: #8b8b81;
font-size: 9px;
line-height: 1.4;
}
#info-panel {
right: 20px;
bottom: 20px;
width: min(340px, calc(100vw - 40px));
padding: 15px 16px;
border-radius: 13px;
}
#info-panel strong {
display: block;
margin: 4px 0 5px;
font-size: 14px;
}
#info-panel p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
#controls-hint {
position: fixed;
z-index: 5;
left: 50%;
bottom: 20px;
transform: translateX(-50%);
padding: 8px 12px;
border-radius: 20px;
background: rgba(38, 51, 59, 0.83);
color: rgba(255,255,255,0.9);
font-size: 10px;
letter-spacing: 0.02em;
pointer-events: none;
}
@media (max-width: 850px) {
#title-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
#title-panel p, .title-meta { display: none; }
#view-panel {
top: 102px;
left: 12px;
right: auto;
max-width: calc(100vw - 24px);
}
#legend-panel {
left: 12px;
bottom: 12px;
width: 185px;
}
#info-panel {
right: 12px;
bottom: 12px;
width: calc(100vw - 221px);
}
#controls-hint { display: none; }
}
@media (max-width: 600px) {
#legend-panel { width: 160px; }
#info-panel { display: none; }
.legend-item { font-size: 10px; padding: 6px 4px; }
.scene-label { min-width: 100px; padding: 7px 9px; }
.scene-label strong { font-size: 9px; }
.scene-label span { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive cutaway model of a reused warehouse"></canvas>
<div id="labels"></div>
<section id="title-panel" class="panel">
<div class="eyebrow">Adaptive reuse / Cutaway axonometric</div>
<h1>Warehouse → Learning Hub</h1>
<p>
A retained industrial shell becomes two classroom and workshop zones,
linked by a shared planted courtyard with separate visitor and delivery routes.
</p>
<div class="title-meta">Existing frame + adaptable infill</div>
</section>
<nav id="view-panel" class="panel" aria-label="Camera views">
<button class="view-button active" data-view="overview">Overview</button>
<button class="view-button" data-view="classroom">Classroom</button>
<button class="view-button" data-view="workshop">Workshop</button>
<button class="view-button" data-view="courtyard">Courtyard</button>
</nav>
<aside id="legend-panel" class="panel" aria-label="Model layers">
<div class="legend-title">Reading the model</div>
<button class="legend-item" data-category="retained" aria-pressed="true">
<span class="swatch" style="--color:var(--retained)"></span>
Retained structure
</button>
<button class="legend-item" data-category="additions" aria-pressed="true">
<span class="swatch" style="--color:var(--additions)"></span>
New additions
</button>
<button class="legend-item" data-category="visitor" aria-pressed="true">
<span class="swatch" style="--color:var(--visitor)"></span>
Visitor access
</button>
<button class="legend-item" data-category="deliveries" aria-pressed="true">
<span class="swatch" style="--color:var(--deliveries)"></span>
Deliveries
</button>
<div class="legend-hint">Click a layer to show or hide it. Labels identify each route.</div>
</aside>
<aside id="info-panel" class="panel">
<div class="eyebrow" id="info-eyebrow">Overall strategy</div>
<strong id="info-title">Keep the frame; build inside it</strong>
<p id="info-body">
The steel shell, slab, and roof geometry remain legible. Lightweight timber
rooms and courtyard elements sit independently within the existing envelope.
</p>
</aside>
<div id="controls-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 light
// ---------------------------------------------------------------------
const canvas = document.querySelector("#scene");
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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const background = 0xe8e3d9;
const scene = new THREE.Scene();
scene.background = new THREE.Color(background);
scene.fog = new THREE.Fog(background, 75, 145);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
250
);
scene.add(new THREE.HemisphereLight(0xfaf5e7, 0x737b7c, 2.1));
const sun = new THREE.DirectionalLight(0xfff4dc, 3.0);
sun.position.set(-24, 42, 28);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -45;
sun.shadow.camera.right = 45;
sun.shadow.camera.top = 38;
sun.shadow.camera.bottom = -38;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 100;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbfd5df, 0.75);
fill.position.set(30, 18, -20);
scene.add(fill);
const groups = {
retained: new THREE.Group(),
additions: new THREE.Group(),
visitor: new THREE.Group(),
deliveries: new THREE.Group(),
context: new THREE.Group()
};
Object.values(groups).forEach(group => scene.add(group));
// ---------------------------------------------------------------------
// Geometry helpers
// ---------------------------------------------------------------------
function box(parent, w, h, d, color, x = 0, y = 0, z = 0, options = {}) {
const material = options.material || new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.82,
metalness: options.metalness ?? 0.02,
flatShading: true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
depthWrite: options.depthWrite ?? true,
side: options.side ?? THREE.FrontSide
});
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? !options.transparent;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent, topRadius, bottomRadius, height, color,
x = 0, y = 0, z = 0, segments = 8, options = {}
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(topRadius, bottomRadius, height, segments),
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.85,
metalness: options.metalness ?? 0.02,
flatShading: true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
})
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(parent, a, b, radius, color) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 6),
new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.12,
flatShading: true
})
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeTextPanel(parent, text, subtext, x, y, z, w, h, color, backgroundColor) {
const textCanvas = document.createElement("canvas");
textCanvas.width = 1024;
textCanvas.height = 256;
const ctx = textCanvas.getContext("2d");
ctx.fillStyle = backgroundColor;
ctx.fillRect(0, 0, textCanvas.width, textCanvas.height);
ctx.fillStyle = color;
ctx.fillRect(0, 0, textCanvas.width, 12);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 76px system-ui, sans-serif";
ctx.fillText(text, 512, subtext ? 102 : 128);
if (subtext) {
ctx.font = "500 29px system-ui, sans-serif";
ctx.fillText(subtext, 512, 183);
}
const texture = new THREE.CanvasTexture(textCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(w, h),
new THREE.MeshBasicMaterial({ map: texture })
);
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
function makeFloorText(parent, text, x, y, z, w, d, color) {
const textCanvas = document.createElement("canvas");
textCanvas.width = 1024;
textCanvas.height = 256;
const ctx = textCanvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 256);
ctx.fillStyle = color;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 98px system-ui, sans-serif";
ctx.fillText(text, 512, 128);
const texture = new THREE.CanvasTexture(textCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(w, d),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide
})
);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
function makeArrow(parent, x, y, z, angle, color) {
const shape = new THREE.Shape();
shape.moveTo(0, 0.8);
shape.lineTo(-0.55, -0.55);
shape.lineTo(0, -0.22);
shape.lineTo(0.55, -0.55);
shape.closePath();
const mesh = new THREE.Mesh(
new THREE.ShapeGeometry(shape),
new THREE.MeshBasicMaterial({
color,
side: THREE.DoubleSide
})
);
mesh.rotation.order = "YXZ";
mesh.rotation.y = angle;
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
function makeTree(parent, x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
cylinder(tree, 0.19, 0.27, 2.2, 0x7e6044, 0, 1.1, 0, 7);
const crown = new THREE.Mesh(
new THREE.DodecahedronGeometry(1.35, 0),
new THREE.MeshStandardMaterial({
color: 0x78935e,
roughness: 0.95,
flatShading: true
})
);
crown.position.y = 3.0;
crown.scale.set(1, 1.08, 0.92);
crown.castShadow = true;
crown.receiveShadow = true;
tree.add(crown);
const crown2 = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.9, 0),
new THREE.MeshStandardMaterial({
color: 0x91a96e,
roughness: 0.95,
flatShading: true
})
);
crown2.position.set(0.65, 2.6, 0.2);
crown2.castShadow = true;
tree.add(crown2);
parent.add(tree);
return tree;
}
function makePerson(parent, x, z, color, rotation = 0, scale = 1) {
const person = new THREE.Group();
person.position.set(x, 0, z);
person.rotation.y = rotation;
person.scale.setScalar(scale);
cylinder(person, 0.16, 0.2, 0.8, 0x3e4c55, -0.18, 0.4, 0, 6);
cylinder(person, 0.16, 0.2, 0.8, 0x3e4c55, 0.18, 0.4, 0, 6);
cylinder(person, 0.31, 0.38, 0.8, color, 0, 1.15, 0, 7);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.27, 10, 7),
new THREE.MeshStandardMaterial({
color: 0xc98f69,
roughness: 0.9,
flatShading: true
})
);
head.position.y = 1.77;
head.castShadow = true;
person.add(head);
box(person, 0.14, 0.62, 0.16, color, -0.43, 1.15, 0);
box(person, 0.14, 0.62, 0.16, color, 0.43, 1.15, 0);
parent.add(person);
return person;
}
function makeDesk(parent, x, z, rotation = 0) {
const desk = new THREE.Group();
desk.position.set(x, 0, z);
desk.rotation.y = rotation;
box(desk, 2.35, 0.14, 1.1, 0xe2b86f, 0, 1.16, 0);
box(desk, 0.12, 1.08, 0.12, 0x69747a, -1.0, 0.56, -0.4);
box(desk, 0.12, 1.08, 0.12, 0x69747a, 1.0, 0.56, -0.4);
box(desk, 0.12, 1.08, 0.12, 0x69747a, -1.0, 0.56, 0.4);
box(desk, 0.12, 1.08, 0.12, 0x69747a, 1.0, 0.56, 0.4);
box(desk, 0.78, 0.12, 0.75, 0x54716f, 0, 0.68, 0.98);
box(desk, 0.78, 0.72, 0.12, 0x54716f, 0, 1.02, 1.29);
box(desk, 0.09, 0.56, 0.09, 0x69747a, -0.29, 0.33, 0.98);
box(desk, 0.09, 0.56, 0.09, 0x69747a, 0.29, 0.33, 0.98);
parent.add(desk);
return desk;
}
function makeBench(parent, x, z, width = 4, rotation = 0) {
const bench = new THREE.Group();
bench.position.set(x, 0, z);
bench.rotation.y = rotation;
box(bench, width, 0.18, 1.1, 0x9c7047, 0, 1.1, 0);
box(bench, width, 0.16, 0.9, 0x76523b, 0, 0.42, 0);
box(bench, 0.18, 1.0, 0.18, 0x566269, -width / 2 + 0.3, 0.5, 0);
box(bench, 0.18, 1.0, 0.18, 0x566269, width / 2 - 0.3, 0.5, 0);
parent.add(bench);
return bench;
}
// ---------------------------------------------------------------------
// Context and retained warehouse structure
// ---------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(180, 180),
new THREE.MeshStandardMaterial({
color: 0xe5dfd4,
roughness: 1
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.56;
ground.receiveShadow = true;
groups.context.add(ground);
const grid = new THREE.GridHelper(80, 40, 0xc9c3b8, 0xd7d0c4);
grid.position.y = -0.535;
grid.material.transparent = true;
grid.material.opacity = 0.3;
groups.context.add(grid);
// Existing concrete slab.
box(groups.retained, 38, 0.5, 28, 0xc7c0b4, 0, -0.25, 0);
// Existing north wall and high window strip.
box(groups.retained, 38, 7.8, 0.38, 0x87908f, 0, 3.9, -13.25);
box(groups.retained, 38, 0.45, 0.55, 0x4b5860, 0, 0.18, -13.0);
for (let x = -15; x <= 15; x += 6) {
box(groups.retained, 4.35, 1.35, 0.12, 0x516873, x, 5.8, -13.02, {
roughness: 0.3,
metalness: 0.16
});
box(groups.retained, 0.12, 1.4, 0.16, 0x46535b, x, 5.8, -12.94);
}
// Low retained side-wall remnants preserve the original footprint.
box(groups.retained, 0.32, 1.15, 25.8, 0x919794, -19.05, 0.55, -0.7);
box(groups.retained, 0.32, 1.15, 25.8, 0x919794, 19.05, 0.55, -0.7);
// Existing columns.
for (const x of [-18, -9, 0, 9, 18]) {
for (const z of [-13, 13]) {
box(groups.retained, 0.48, 8.25, 0.48, 0x46545e, x, 4.12, z);
box(groups.retained, 0.9, 0.25, 0.9, 0x37434b, x, 0.13, z);
}
}
// Existing roof beams and exposed trusses.
for (const z of [-13, 0, 13]) {
box(groups.retained, 36.7, 0.28, 0.32, 0x46545e, 0, 8.35, z);
beam(groups.retained, [-18, 6.8, z], [-9, 8.3, z], 0.10, 0x53616a);
beam(groups.retained, [-9, 8.3, z], [0, 6.8, z], 0.10, 0x53616a);
beam(groups.retained, [0, 6.8, z], [9, 8.3, z], 0.10, 0x53616a);
beam(groups.retained, [9, 8.3, z], [18, 6.8, z], 0.10, 0x53616a);
}
box(groups.retained, 0.28, 0.3, 26.5, 0x46545e, -18, 8.35, 0);
box(groups.retained, 0.28, 0.3, 26.5, 0x46545e, 18, 8.35, 0);
box(groups.retained, 0.22, 0.25, 26.5, 0x53616a, 0, 8.35, 0);
// Existing dock and threshold.
box(groups.retained, 2.7, 0.55, 5.0, 0x9c958b, 19.2, -0.04, -5);
box(groups.retained, 0.45, 3.3, 4.8, 0x4a565d, 16.7, 1.65, -5);
for (let y = 0.6; y <= 3.2; y += 0.45) {
box(groups.retained, 0.12, 0.09, 4.55, 0x7f898d, 16.42, y, -5);
}
makeTextPanel(
groups.retained,
"WAREHOUSE 07",
"RETAINED STRUCTURAL FRAME",
0, 6.5, -13.0, 9.3, 1.7,
"#eef1ed", "#4d5b63"
);
// ---------------------------------------------------------------------
// Classroom addition
// ---------------------------------------------------------------------
const classroom = groups.additions;
box(classroom, 15.0, 0.16, 10.4, 0xe9c47e, -9, 0.08, -5);
box(classroom, 15.0, 3.5, 0.2, 0xd99a38, -9, 1.75, -10.15);
box(classroom, 0.2, 3.4, 10.2, 0xd99a38, -16.45, 1.7, -5);
box(classroom, 0.16, 3.05, 10.0, 0xd7a14b, -1.55, 1.53, -5, {
transparent: true,
opacity: 0.48,
depthWrite: false
});
// Low front walls and upper glazing leave the interior legible.
box(classroom, 6.25, 0.85, 0.18, 0xd99a38, -13.2, 0.43, 0.05);
box(classroom, 6.25, 0.85, 0.18, 0xd99a38, -4.8, 0.43, 0.05);
box(classroom, 6.25, 1.8, 0.08, 0x92c4c1, -13.2, 1.76, 0.05, {
transparent: true,
opacity: 0.3,
depthWrite: false
});
box(classroom, 6.25, 1.8, 0.08, 0x92c4c1, -4.8, 1.76, 0.05, {
transparent: true,
opacity: 0.3,
depthWrite: false
});
// Door frame.
box(classroom, 0.16, 2.65, 0.22, 0xc1822c, -10.15, 1.32, 0.06);
box(classroom, 0.16, 2.65, 0.22, 0xc1822c, -7.85, 1.32, 0.06);
box(classroom, 2.45, 0.16, 0.22, 0xc1822c, -9, 2.58, 0.06);
// Narrow roof strip, intentionally cut away over the learning area.
box(classroom, 15.4, 0.2, 2.8, 0xca8a2e, -9, 3.62, -8.85);
for (const x of [-15.8, -11.2, -6.8, -2.2]) {
box(classroom, 0.16, 3.45, 0.16, 0xc1822c, x, 1.73, -7.45);
}
// Teaching wall and pinboard.
box(classroom, 6.5, 1.65, 0.12, 0x30464b, -9, 2.05, -10.0);
box(classroom, 6.65, 0.12, 0.17, 0xbd8130, -9, 2.91, -9.96);
const chalkMaterial = new THREE.MeshStandardMaterial({
color: 0xf3eee1,
roughness: 1
});
box(classroom, 1.6, 0.08, 0.03, chalkMaterial, -10.6, 2.25, -9.91);
box(classroom, 1.6, 0.08, 0.03, chalkMaterial, -10.6, 1.93, -9.91);
box(classroom, 0.08, 0.42, 0.03, chalkMaterial, -11.3, 2.08, -9.91);
box(classroom, 0.08, 0.42, 0.03, chalkMaterial, -9.9, 2.08, -9.91);
// Classroom furniture.
for (const z of [-7.15, -3.55]) {
for (const x of [-13.3, -9.0, -4.7]) {
makeDesk(classroom, x, z);
}
}
box(classroom, 2.4, 0.14, 1.0, 0xb87a34, -9, 1.15, -8.9);
box(classroom, 1.0, 0.12, 0.8, 0x4f6468, -9, 0.74, -8.15);
makeFloorText(classroom, "CLASSROOM", -9, 0.18, 0.75, 6.5, 1.0, "#8b5b22");
makeTextPanel(
classroom,
"CLASSROOM",
"NEW TIMBER INFILL",
-9, 3.25, -9.99, 5.6, 1.25,
"#fff8e9", "#c7892e"
);
// ---------------------------------------------------------------------
// Repair workshop addition
// ---------------------------------------------------------------------
const workshop = groups.additions;
box(workshop, 15.0, 0.16, 10.4, 0xd9a64f, 9, 0.08, -5);
box(workshop, 15.0, 3.5, 0.2, 0xb8762e, 9, 1.75, -10.15);
box(workshop, 0.2, 3.4, 10.2, 0xb8762e, 1.55, 1.7, -5);
// Open workshop front with a short canopy edge.
box(workshop, 3.5, 0.85, 0.18, 0xb8762e, 4.1, 0.43, 0.05);
box(workshop, 3.5, 0.85, 0.18, 0xb8762e, 13.9, 0.43, 0.05);
box(workshop, 6.3, 1.8, 0.08, 0x86adb1, 4.1, 1.76, 0.05, {
transparent: true,
opacity: 0.27,
depthWrite: false
});
box(workshop, 6.3, 1.8, 0.08, 0x86adb1, 13.9, 1.76, 0.05, {
transparent: true,
opacity: 0.27,
depthWrite: false
});
box(workshop, 15.4, 0.2, 2.6, 0xa96729, 9, 3.62, -8.9);
for (const x of [2.2, 6.0, 12.0, 15.8]) {
box(workshop, 0.16, 3.45, 0.16, 0xa96729, x, 1.73, -7.65);
}
// Tool board.
box(workshop, 7.8, 1.8, 0.12, 0x4b5659, 8.2, 2.0, -10.0);
for (let i = 0; i < 8; i++) {
const x = 5.1 + i * 0.86;
box(workshop, 0.13, 0.7 + (i % 3) * 0.18, 0.06, 0xc8cdca, x, 2.0, -9.91);
box(workshop, 0.38, 0.12, 0.07, 0xdd9a35, x, 2.42, -9.9);
}
// Benches and repair equipment.
makeBench(workshop, 6.0, -7.0, 5.2);
makeBench(workshop, 12.0, -7.0, 5.2);
makeBench(workshop, 6.0, -2.6, 4.2);
makeBench(workshop, 12.0, -2.6, 4.2);
box(workshop, 2.2, 1.7, 1.4, 0x66767b, 15.0, 0.85, -8.3);
box(workshop, 1.55, 0.55, 0.08, 0x394b51, 15.0, 1.28, -7.54);
cylinder(workshop, 0.55, 0.55, 0.7, 0x59686c, 3.4, 1.25, -7.0, 10);
cylinder(workshop, 0.62, 0.62, 0.1, 0x394b51, 3.4, 1.65, -7.0, 10);
// Parts shelving.
for (const x of [4.0, 7.2, 10.4, 13.6]) {
box(workshop, 0.14, 2.4, 1.0, 0x647076, x, 1.2, -9.35);
}
for (const y of [0.45, 1.15, 1.85]) {
box(workshop, 10.2, 0.12, 1.05, 0x788285, 8.8, y, -9.35);
}
for (let i = 0; i < 7; i++) {
box(workshop, 0.75, 0.55, 0.72, i % 2 ? 0xc6923a : 0x8e5a31,
5.0 + i * 1.25, 1.43, -9.3);
}
// Safety circle.
const safetyRing = new THREE.Mesh(
new THREE.RingGeometry(1.45, 1.58, 24),
new THREE.MeshBasicMaterial({
color: 0xe6b642,
side: THREE.DoubleSide
})
);
safetyRing.rotation.x = -Math.PI / 2;
safetyRing.position.set(4.0, 0.18, -3.8);
workshop.add(safetyRing);
makeFloorText(workshop, "REPAIR WORKSHOP", 9, 0.18, 0.75, 8.2, 1.0, "#74451f");
makeTextPanel(
workshop,
"REPAIR WORKSHOP",
"NEW MAKING / FIXING SPACE",
9, 3.25, -9.99, 7.0, 1.25,
"#fff5e7", "#a9652b"
);
// ---------------------------------------------------------------------
// Shared courtyard addition
// ---------------------------------------------------------------------
const courtyard = groups.additions;
box(courtyard, 12.2, 0.16, 10.1, 0xd8c9a7, 0, 0.08, 6.0);
// Paving joints.
for (let x = -5; x <= 5; x += 2) {
box(courtyard, 0.035, 0.015, 9.6, 0xbeb094, x, 0.17, 6);
}
for (let z = 2; z <= 10; z += 2) {
box(courtyard, 11.8, 0.015, 0.035, 0xbeb094, 0, 0.17, z);
}
// Central raised planter.
box(courtyard, 4.6, 0.55, 4.4, 0xc88b34, 0, 0.28, 7.0);
box(courtyard, 4.2, 0.12, 4.0, 0x766348, 0, 0.61, 7.0);
makeTree(courtyard, 0, 7.0, 0.8);
for (const x of [-1.55, 1.55]) {
for (const z of [5.55, 8.45]) {
const shrub = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.55, 0),
new THREE.MeshStandardMaterial({
color: 0x78925f,
roughness: 1,
flatShading: true
})
);
shrub.position.set(x, 0.95, z);
shrub.castShadow = true;
courtyard.add(shrub);
}
}
// Pergola.
for (const x of [-5.1, 5.1]) {
for (const z of [2.0, 10.0]) {
box(courtyard, 0.22, 3.35, 0.22, 0xb7782d, x, 1.67, z);
}
box(courtyard, 0.22, 0.22, 8.4, 0xb7782d, x, 3.25, 6);
}
for (let z = 2.1; z <= 10; z += 1.1) {
box(courtyard, 10.4, 0.15, 0.18, 0xc38a38, 0, 3.34, z);
}
// Outdoor tables and benches.
for (const z of [3.0, 9.7]) {
box(courtyard, 2.4, 0.14, 1.15, 0xd0a862, 0, 1.02, z);
box(courtyard, 0.16, 0.95, 0.16, 0x6e7473, 0, 0.48, z);
box(courtyard, 2.4, 0.16, 0.6, 0xb18148, 0, 0.62, z + 1.0);
}
makeBench(courtyard, -4.3, 5.9, 2.8, Math.PI / 2);
makeBench(courtyard, 4.3, 8.2, 2.8, Math.PI / 2);
makeFloorText(courtyard, "SHARED COURTYARD", 0, 0.19, 11.35, 8.6, 1.0, "#72522d");
// ---------------------------------------------------------------------
// Visitor route and entrance
// ---------------------------------------------------------------------
const visitor = groups.visitor;
box(visitor, 4.2, 0.16, 2.0, 0x16a39a, -14, 0.08, 13.45);
box(visitor, 2.3, 0.12, 8.2, 0x16a39a, -14, 0.08, 9.0);
box(visitor, 9.0, 0.12, 2.3, 0x16a39a, -10.2, 0.08, 6.0);
box(visitor, 2.3, 0.12, 6.2, 0x16a39a, -9.0, 0.08, 3.0);
box(visitor, 2.3, 0.12, 6.2, 0x16a39a, 9.0, 0.08, 3.0);
box(visitor, 18.1, 0.12, 2.0, 0x16a39a, 0, 0.08, 0.45);
makeArrow(visitor, -14, 0.16, 10.7, 0, 0xeafffb);
makeArrow(visitor, -11.6, 0.16, 6.0, Math.PI / 2, 0xeafffb);
makeArrow(visitor, -9, 0.16, 3.0, 0, 0xeafffb);
makeArrow(visitor, 9, 0.16, 3.0, 0, 0xeafffb);
// Visitor gate.
for (const x of [-15.7, -12.3]) {
box(visitor, 0.18, 2.65, 0.18, 0x117b76, x, 1.32, 13.9);
}
box(visitor, 3.6, 0.18, 0.18, 0x117b76, -14, 2.58, 13.9);
makeTextPanel(
visitor,
"VISITOR ENTRY",
"PUBLIC ACCESS",
-14, 2.0, 14.02, 3.4, 0.92,
"#effffc", "#117b76"
);
makePerson(visitor, -14, 11.5, 0x16a39a, 0, 0.95);
makePerson(visitor, -10.4, 6.0, 0x3b7b9a, 0.2, 0.9);
makePerson(visitor, 9.2, 3.2, 0x567a63, 0, 0.9);
// ---------------------------------------------------------------------
// Delivery route, dock, and truck
// ---------------------------------------------------------------------
const deliveries = groups.deliveries;
// Dashed perimeter route from the service gate to the loading dock.
for (let z = -4.5; z <= 11.5; z += 1.35) {
box(deliveries, 1.05, 0.08, 0.72, 0xef6a4c, 22, 0.16, z);
}
for (let x = 16.2; x <= 21.6; x += 1.25) {
box(deliveries, 0.72, 0.08, 1.05, 0xef6a4c, x, 0.16, -5);
}
// Internal delivery strip through the workshop.
for (let x = 3.0; x <= 16.2; x += 1.25) {
box(deliveries, 0.72, 0.08, 0.8, 0xef6a4c, x, 0.19, -5);
}
makeArrow(deliveries, 22, 0.22, 7.0, 0, 0xffddd4);
makeArrow(deliveries, 19.0, 0.22, -5, -Math.PI / 2, 0xffddd4);
makeArrow(deliveries, 10.0, 0.25, -5, -Math.PI / 2, 0xffddd4);
// Service gate.
for (const z of [10.4, 13.2]) {
box(deliveries, 0.18, 2.5, 0.18, 0xb44c37, 22, 1.25, z);
}
box(deliveries, 0.18, 0.18, 3.0, 0xb44c37, 22, 2.42, 11.8);
makeTextPanel(
deliveries,
"SERVICE GATE",
"DELIVERIES ONLY",
22, 1.7, 13.28, 3.5, 1.0,
"#fff0eb", "#b84d36"
);
// Small low-poly delivery truck, oriented north-south.
const truck = new THREE.Group();
truck.position.set(22, 0, 4.1);
box(truck, 2.35, 2.25, 4.6, 0xef6a4c, 0, 1.75, -0.6);
box(truck, 2.2, 1.75, 1.7, 0xd75a40, 0, 1.45, 2.55);
box(truck, 1.8, 0.82, 0.08, 0x526b76, 0, 1.82, 3.42, {
roughness: 0.25,
metalness: 0.15
});
box(truck, 2.45, 0.18, 5.7, 0x4f5d65, 0, 0.7, 0.3);
for (const x of [-1.18, 1.18]) {
for (const z of [-1.6, 1.0, 2.55]) {
const wheel = cylinder(
truck, 0.48, 0.48, 0.3, 0x30383d,
x, 0.53, z, 10
);
wheel.rotation.x = Math.PI / 2;
}
}
box(truck, 0.06, 0.28, 0.08, 0xffdfb1, -0.75, 1.25, 3.47);
box(truck, 0.06, 0.28, 0.08, 0xffdfb1, 0.75, 1.25, 3.47);
deliveries.add(truck);
makePerson(deliveries, 19.8, -4.4, 0xef6a4c, -Math.PI / 2, 1.0);
makePerson(deliveries, 10.8, -4.1, 0xc89336, Math.PI / 2, 0.95);
// ---------------------------------------------------------------------
// Peripheral context
// ---------------------------------------------------------------------
makeTree(groups.context, -26, -12, 1.2);
makeTree(groups.context, -28, 7, 1.35);
makeTree(groups.context, 29, 12, 1.15);
makeTree(groups.context, 28, -16, 1.25);
// ---------------------------------------------------------------------
// Camera controls — implemented directly, without addons
// ---------------------------------------------------------------------
const presets = {
overview: {
target: new THREE.Vector3(0, 1.0, 0),
theta: 0.72,
phi: 1.13,
radius: 61
},
classroom: {
target: new THREE.Vector3(-9, 1.0, -4.2),
theta: 0.56,
phi: 1.08,
radius: 24
},
workshop: {
target: new THREE.Vector3(9, 1.0, -4.2),
theta: 1.03,
phi: 1.08,
radius: 24
},
courtyard: {
target: new THREE.Vector3(0, 1.0, 6.0),
theta: 0.72,
phi: 1.08,
radius: 28
},
retained: {
target: new THREE.Vector3(0, 2.0, -1),
theta: 0.72,
phi: 1.13,
radius: 61
},
visitor: {
target: new THREE.Vector3(-10.5, 0.8, 7.5),
theta: 0.48,
phi: 1.12,
radius: 29
},
deliveries: {
target: new THREE.Vector3(17.5, 0.8, -4.5),
theta: 1.05,
phi: 1.12,
radius: 27
}
};
const desired = {
target: presets.overview.target.clone(),
theta: presets.overview.theta,
phi: presets.overview.phi,
radius: presets.overview.radius
};
const current = {
target: desired.target.clone(),
theta: desired.theta,
phi: desired.phi,
radius: desired.radius
};
const infoContent = {
overview: {
eyebrow: "Overall strategy",
title: "Keep the frame; build inside it",
body: "The steel shell, slab, and roof geometry remain legible. Lightweight rooms and courtyard elements sit independently within the existing envelope."
},
classroom: {
eyebrow: "New addition",
title: "A calm, daylight learning room",
body: "A glazed timber infill creates six teaching bays while preserving the original structural grid and an open cutaway roof for visibility."
},
workshop: {
eyebrow: "New addition",
title: "Repair and making space",
body: "Robust benches, tool storage, material shelving, and a direct dock connection support noisy work without routing visitors through the workshop."
},
courtyard: {
eyebrow: "Shared addition",
title: "A planted social heart",
body: "The courtyard brings both rooms together around a tree, pergola, outdoor tables, and informal benches while remaining directly visible from the visitor route."
},
retained: {
eyebrow: "Retained structure",
title: "The industrial frame remains readable",
body: "Existing concrete, steel columns, roof trusses, high windows, and loading threshold remain in place and are expressed as a permanent structural layer."
},
visitor: {
eyebrow: "Visitor circulation",
title: "Public access follows the teal route",
body: "Visitors enter from the southwest, reach the courtyard, and branch directly to classroom and workshop entrances without entering the delivery lane."
},
deliveries: {
eyebrow: "Service circulation",
title: "Deliveries use a separate dock route",
body: "The service gate and dashed orange route connect directly to the existing loading dock and workshop workbench zone, keeping logistics separate from visitors."
}
};
function activateView(name) {
const preset = presets[name];
if (!preset) return;
desired.target.copy(preset.target);
desired.theta = preset.theta;
desired.phi = preset.phi;
desired.radius = preset.radius;
document.querySelectorAll(".view-button").forEach(button => {
button.classList.toggle("active", button.dataset.view === name);
});
const info = infoContent[name] || infoContent.overview;
document.querySelector("#info-eyebrow").textContent = info.eyebrow;
document.querySelector("#info-title").textContent = info.title;
document.querySelector("#info-body").textContent = info.body;
}
document.querySelectorAll(".view-button").forEach(button => {
button.addEventListener("click", () => activateView(button.dataset.view));
});
// Layer toggles.
document.querySelectorAll(".legend-item").forEach(button => {
button.addEventListener("click", () => {
const category = button.dataset.category;
groups[category].visible = !groups[category].visible;
button.classList.toggle("off", !groups[category].visible);
button.setAttribute("aria-pressed", String(groups[category].visible));
});
});
const pointers = new Map();
let pinchDistance = 0;
function panCamera(dx, dy) {
const factor = desired.radius * 0.00125;
const right = new THREE.Vector3(
Math.cos(desired.theta),
0,
-Math.sin(desired.theta)
);
const forward = new THREE.Vector3(
-Math.sin(desired.theta),
0,
-Math.cos(desired.theta)
);
desired.target.addScaledVector(right, -dx * factor);
desired.target.addScaledVector(forward, dy * factor);
desired.target.x = THREE.MathUtils.clamp(desired.target.x, -28, 28);
desired.target.z = THREE.MathUtils.clamp(desired.target.z, -22, 24);
desired.target.y = THREE.MathUtils.clamp(desired.target.y, 0, 5);
}
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", event => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
if (event.shiftKey || event.buttons === 2 || event.buttons === 4) {
panCamera(dx, dy);
} else {
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi - dy * 0.005,
0.35,
1.43
);
}
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (pinchDistance > 0 && distance > 0) {
desired.radius = THREE.MathUtils.clamp(
desired.radius * (pinchDistance / distance),
12,
95
);
}
pinchDistance = distance;
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
pinchDistance = 0;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
12,
95
);
}, { passive: false });
// ---------------------------------------------------------------------
// Projected HTML labels
// ---------------------------------------------------------------------
const labelContainer = document.querySelector("#labels");
const labelDefinitions = [
{
id: "retained-label",
category: "retained",
view: "retained",
title: "Retained structure",
subtitle: "Slab · frame · trusses",
anchor: new THREE.Vector3(-2, 8.8, -13),
color: "#46545e"
},
{
id: "classroom-label",
category: "additions",
view: "classroom",
title: "Classroom addition",
subtitle: "6 flexible teaching bays",
anchor: new THREE.Vector3(-9, 4.1, -7),
color: "#d99a38"
},
{
id: "workshop-label",
category: "additions",
view: "workshop",
title: "Repair workshop",
subtitle: "Benches · tools · storage",
anchor: new THREE.Vector3(9, 4.1, -7),
color: "#d99a38"
},
{
id: "courtyard-label",
category: "additions",
view: "courtyard",
title: "Shared courtyard",
subtitle: "Learning · meeting · resting",
anchor: new THREE.Vector3(0, 3.9, 7),
color: "#d99a38"
},
{
id: "visitor-label",
category: "visitor",
view: "visitor",
title: "Visitor access",
subtitle: "Public entrance and route",
anchor: new THREE.Vector3(-14, 2.5, 12.2),
color: "#16a39a"
},
{
id: "delivery-label",
category: "deliveries",
view: "deliveries",
title: "Deliveries",
subtitle: "Service gate and loading dock",
anchor: new THREE.Vector3(22, 3.4, 4.0),
color: "#ef6a4c"
}
];
const projectedLabels = labelDefinitions.map(definition => {
const element = document.createElement("div");
element.className = "scene-label";
element.id = definition.id;
element.innerHTML = `
<span class="key" style="background:${definition.color}"></span>
<strong>${definition.title}</strong>
<span>${definition.subtitle}</span>
`;
element.addEventListener("click", () => activateView(definition.view));
labelContainer.appendChild(element);
return { ...definition, element };
});
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
projectedLabels.forEach(label => {
const projected = label.anchor.clone().project(camera);
const visible =
groups[label.category].visible &&
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.15 &&
projected.x < 1.15 &&
projected.y > -1.15 &&
projected.y < 1.15;
label.element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
});
}
// ---------------------------------------------------------------------
// Resize and render loop
// ---------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
function animate() {
requestAnimationFrame(animate);
const damping = 0.105;
current.target.lerp(desired.target, damping);
current.theta += (desired.theta - current.theta) * damping;
current.phi += (desired.phi - current.phi) * damping;
current.radius += (desired.radius - current.radius) * damping;
const sinPhi = Math.sin(current.phi);
camera.position.set(
current.target.x + current.radius * sinPhi * Math.sin(current.theta),
current.target.y + current.radius * Math.cos(current.phi),
current.target.z + current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(current.target);
camera.updateMatrixWorld();
updateLabels();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```