Prompt specification
Build or customize the Three.js 3D scene "Equal floor area in two layouts" 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: Equal floor area in two layouts
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/equal-floor-area-in-two-layouts-x2230
Scene Description Prompt:
Create a standalone cutaway scene in one HTML file using Three.js from cdnjs. Compare a low wide block with two narrower taller blocks using equal total floor area. Display footprints, heights, and access paths without treating one layout as universally preferable.
Working Three.js Starter (equal-floor-area-in-two-layouts-x2230):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Equal Floor Area — Cutaway Massing Comparison</title>
<style>
:root {
--ink: #18242d;
--muted: #61717d;
--paper: #f1f4f6;
--panel: rgba(255, 255, 255, 0.9);
--line: rgba(35, 53, 65, 0.15);
--scheme-a: #397da6;
--scheme-b: #c96f4a;
--path: #d58a25;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background: var(--paper);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#sceneCanvas {
position: fixed;
inset: 0;
width: 100vw;
height: 100vh;
display: block;
touch-action: none;
outline: none;
}
#labelLayer {
position: fixed;
inset: 0;
z-index: 3;
overflow: hidden;
pointer-events: none;
}
.projected {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -50%);
white-space: nowrap;
will-change: left, top;
}
.scheme-label {
min-width: 205px;
padding: 9px 12px 10px;
border: 1px solid rgba(25, 40, 50, 0.15);
border-left: 4px solid var(--scheme-a);
border-radius: 8px;
background: rgba(255, 255, 255, 0.94);
box-shadow: 0 8px 25px rgba(32, 48, 59, 0.12);
backdrop-filter: blur(8px);
}
.scheme-label.b {
border-left-color: var(--scheme-b);
}
.scheme-label .scheme-name {
display: block;
margin-bottom: 4px;
color: var(--scheme-a);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.scheme-label.b .scheme-name {
color: var(--scheme-b);
}
.scheme-label .main {
display: block;
margin-bottom: 5px;
font-size: 15px;
font-weight: 750;
letter-spacing: -0.01em;
}
.scheme-label .detail {
display: block;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.dim-label {
padding: 3px 6px;
border: 1px solid rgba(29, 45, 56, 0.16);
border-radius: 4px;
color: #344550;
background: rgba(255, 255, 255, 0.92);
box-shadow: 0 2px 7px rgba(28, 42, 51, 0.08);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.02em;
}
.path-label {
padding: 4px 8px;
border: 1px solid rgba(177, 111, 24, 0.25);
border-radius: 999px;
color: #805414;
background: rgba(255, 248, 235, 0.94);
font-size: 10px;
font-weight: 750;
box-shadow: 0 3px 10px rgba(76, 57, 23, 0.08);
}
.hero {
position: fixed;
z-index: 10;
top: 22px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 17px 19px 16px;
border: 1px solid rgba(30, 46, 57, 0.13);
border-radius: 12px;
background: var(--panel);
box-shadow: 0 14px 40px rgba(35, 50, 60, 0.11);
backdrop-filter: blur(14px);
}
.eyebrow {
color: #62737f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
h1 {
margin: 8px 0 8px;
font-size: clamp(24px, 2.2vw, 35px);
line-height: 1.05;
letter-spacing: -0.045em;
}
h1 span {
color: #526672;
font-weight: 500;
}
.hero p {
max-width: 340px;
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.equal-badge {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 12px;
padding: 6px 9px;
border: 1px solid rgba(35, 63, 78, 0.12);
border-radius: 6px;
background: #eef4f7;
font-size: 11px;
}
.equal-badge span {
color: var(--muted);
}
.equal-badge strong {
color: #2e4654;
}
.toolbar {
position: fixed;
z-index: 11;
top: 22px;
right: 24px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 6px;
width: min(360px, calc(100vw - 48px));
}
.toolbar button {
padding: 8px 10px;
border: 1px solid rgba(31, 47, 58, 0.15);
border-radius: 7px;
color: #3f505b;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 4px 14px rgba(36, 50, 60, 0.07);
cursor: pointer;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.02em;
backdrop-filter: blur(10px);
}
.toolbar button:hover {
background: #fff;
transform: translateY(-1px);
}
.toolbar button.active {
border-color: rgba(45, 102, 133, 0.35);
color: #22516b;
background: #e9f2f6;
}
.toolbar .separator {
width: 1px;
margin: 4px 2px;
background: rgba(32, 47, 58, 0.12);
}
.legend {
position: fixed;
z-index: 9;
top: 78px;
right: 24px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 11px;
max-width: 360px;
padding: 8px 11px;
border: 1px solid rgba(30, 46, 57, 0.1);
border-radius: 8px;
color: #596a75;
background: rgba(255, 255, 255, 0.78);
font-size: 10px;
backdrop-filter: blur(8px);
}
.legend span {
display: inline-flex;
align-items: center;
gap: 5px;
}
.legend i {
display: inline-block;
width: 14px;
height: 5px;
border-radius: 3px;
}
.legend .a {
background: var(--scheme-a);
}
.legend .b {
background: var(--scheme-b);
}
.legend .p {
background: var(--path);
}
.legend .d {
height: 1px;
background: #53616b;
}
.comparison {
position: fixed;
z-index: 10;
right: 24px;
bottom: 20px;
left: 24px;
display: grid;
grid-template-columns: 255px 255px minmax(280px, 1fr);
gap: 10px;
align-items: stretch;
}
.card {
padding: 13px 14px;
border: 1px solid rgba(29, 45, 56, 0.13);
border-radius: 10px;
background: var(--panel);
box-shadow: 0 10px 32px rgba(33, 48, 58, 0.1);
backdrop-filter: blur(13px);
}
.card-title {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
}
.card-title i {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--scheme-a);
}
.card.b .card-title i {
background: var(--scheme-b);
}
.card-title strong {
font-size: 12px;
letter-spacing: 0.02em;
}
.card-title span {
margin-left: auto;
color: var(--muted);
font-size: 10px;
}
.metric {
display: grid;
grid-template-columns: 62px 1fr;
gap: 8px;
padding: 4px 0;
border-top: 1px solid rgba(35, 50, 60, 0.07);
font-size: 10px;
line-height: 1.35;
}
.metric:first-of-type {
border-top: 0;
}
.metric span {
color: var(--muted);
}
.metric b {
font-weight: 700;
}
.neutral-card {
display: grid;
grid-template-columns: minmax(170px, 0.65fr) 1fr;
gap: 15px;
align-items: center;
}
.neutral-card h2 {
margin: 0 0 5px;
font-size: 14px;
letter-spacing: -0.01em;
}
.neutral-card p {
margin: 0;
color: var(--muted);
font-size: 10px;
line-height: 1.5;
}
.factors {
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.factors span {
padding: 5px 7px;
border: 1px solid rgba(39, 55, 66, 0.11);
border-radius: 999px;
color: #52636f;
background: rgba(244, 247, 248, 0.86);
font-size: 9px;
font-weight: 650;
}
.hint {
position: fixed;
z-index: 8;
right: 26px;
bottom: 185px;
color: rgba(46, 62, 72, 0.72);
font-size: 10px;
text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
pointer-events: none;
}
#loading {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
color: #5f717d;
background: var(--paper);
font-size: 13px;
letter-spacing: 0.03em;
}
@media (max-width: 1050px) {
.comparison {
grid-template-columns: 1fr 1fr;
}
.neutral-card {
grid-column: 1 / -1;
grid-template-columns: 1fr 1fr;
}
.hint {
display: none;
}
}
@media (max-width: 700px) {
.hero {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
h1 {
font-size: 25px;
}
.hero p {
display: none;
}
.toolbar {
top: 165px;
right: 12px;
left: 12px;
width: auto;
}
.legend {
top: 220px;
right: 12px;
left: 12px;
justify-content: flex-start;
max-width: none;
}
.comparison {
right: 12px;
bottom: 12px;
left: 12px;
grid-template-columns: 1fr 1fr;
gap: 6px;
}
.card {
padding: 10px;
}
.metric {
grid-template-columns: 52px 1fr;
gap: 4px;
font-size: 9px;
}
.neutral-card {
grid-template-columns: 1fr;
gap: 7px;
padding: 9px 10px;
}
.factors {
display: none;
}
}
</style>
</head>
<body>
<canvas
id="sceneCanvas"
tabindex="0"
aria-label="Interactive cutaway comparison of two architectural massing schemes with equal floor area"
></canvas>
<div id="labelLayer"></div>
<header class="hero">
<div class="eyebrow">Cutaway massing study · equal total floor area</div>
<h1>Same floor area.<br><span>Different spatial trade-offs.</span></h1>
<p>
A low, wide block is compared with two narrower, taller blocks.
Dimensions, footprints, and external access routes are shown for direct comparison.
</p>
<div class="equal-badge">
<span>Equal GFA</span>
<strong>1,152 m² per scheme</strong>
</div>
</header>
<nav class="toolbar" aria-label="Scene controls">
<button class="view-button active" data-view="iso" type="button">Axonometric</button>
<button class="view-button" data-view="plan" type="button">Plan</button>
<button class="view-button" data-view="elevation" type="button">Elevation</button>
<div class="separator"></div>
<button id="dimensionsButton" class="active" type="button" aria-pressed="true">Dimensions</button>
<button id="pathsButton" class="active" type="button" aria-pressed="true">Access paths</button>
<button id="resetButton" type="button">Reset view</button>
</nav>
<div class="legend" aria-label="Scene legend">
<span><i class="a"></i> Scheme A</span>
<span><i class="b"></i> Scheme B</span>
<span><i class="p"></i> Access</span>
<span><i class="d"></i> Dimensions</span>
<span>Grid: 2 m</span>
</div>
<section class="comparison" aria-label="Scheme comparison">
<article class="card">
<div class="card-title">
<i></i>
<strong>Scheme A</strong>
<span>Low + wide</span>
</div>
<div class="metric">
<span>Footprint</span>
<b>24 × 16 m · 384 m²</b>
</div>
<div class="metric">
<span>Height</span>
<b>9 m · 3 floors</b>
</div>
<div class="metric">
<span>Access</span>
<b>One direct approach</b>
</div>
<div class="metric">
<span>Total GFA</span>
<b>1,152 m²</b>
</div>
</article>
<article class="card b">
<div class="card-title">
<i></i>
<strong>Scheme B</strong>
<span>Narrow + tall</span>
</div>
<div class="metric">
<span>Footprint</span>
<b>2 × 12 × 12 m · 288 m²</b>
</div>
<div class="metric">
<span>Height</span>
<b>14 m · 4 floors each</b>
</div>
<div class="metric">
<span>Access</span>
<b>Shared spine + two branches</b>
</div>
<div class="metric">
<span>Total GFA</span>
<b>1,152 m²</b>
</div>
</article>
<article class="card neutral-card">
<div>
<h2>Context, not a universal winner</h2>
<p>
A occupies more ground but remains lower. B covers less ground but rises
higher and uses two separate blocks. The better fit depends on the site
and program rather than massing alone.
</p>
</div>
<div class="factors" aria-label="Factors affecting suitability">
<span>Site</span>
<span>Daylight</span>
<span>Privacy</span>
<span>Egress</span>
<span>Servicing</span>
<span>Views</span>
<span>Program</span>
</div>
</article>
</section>
<div class="hint">Drag to orbit · right-drag to pan · wheel to zoom</div>
<div id="loading">Loading Three.js cutaway scene…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const canvas = document.getElementById("sceneCanvas");
const loading = document.getElementById("loading");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent =
"This scene requires a browser with WebGL enabled.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf1f4f6);
const camera = new THREE.OrthographicCamera(-40, 40, 22, -22, 0.1, 240);
const orbit = {
azimuth: 0.67,
phi: 0.79,
zoom: 1,
target: new THREE.Vector3(0, 3.2, 0)
};
const dimensionsGroup = new THREE.Group();
const pathsGroup = new THREE.Group();
scene.add(dimensionsGroup, pathsGroup);
const hemisphere = new THREE.HemisphereLight(0xffffff, 0xa9b3ba, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff8ec, 2.6);
sun.position.set(-25, 46, 28);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -48;
sun.shadow.camera.right = 48;
sun.shadow.camera.top = 36;
sun.shadow.camera.bottom = -36;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 120;
sun.shadow.bias = -0.00035;
scene.add(sun, sun.target);
const fill = new THREE.DirectionalLight(0xdceeff, 0.8);
fill.position.set(35, 18, -25);
scene.add(fill);
// -------------------------------------------------------------------------
// Ground, site pads, and grid
// -------------------------------------------------------------------------
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xe7ecef,
roughness: 1
});
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(78, 44),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.13;
ground.receiveShadow = true;
scene.add(ground);
const padMaterial = new THREE.MeshStandardMaterial({
color: 0xf5f7f8,
roughness: 1
});
function addSitePad(x) {
const pad = new THREE.Mesh(
new THREE.BoxGeometry(34, 0.12, 28),
padMaterial
);
pad.position.set(x, -0.06, 0);
pad.receiveShadow = true;
scene.add(pad);
}
addSitePad(-19);
addSitePad(19);
const gridPositions = [];
for (let x = -38; x <= 38; x += 2) {
gridPositions.push(x, 0.012, -20, x, 0.012, 20);
}
for (let z = -20; z <= 20; z += 2) {
gridPositions.push(-38, 0.012, z, 38, 0.012, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridPositions, 3)
);
const grid = new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: 0x6c7b85,
transparent: true,
opacity: 0.14
})
);
scene.add(grid);
const dividerGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-1, 0.025, -15),
new THREE.Vector3(-1, 0.025, 15)
]);
const divider = new THREE.Line(
dividerGeometry,
new THREE.LineDashedMaterial({
color: 0x7b8992,
dashSize: 0.8,
gapSize: 0.55,
transparent: true,
opacity: 0.45
})
);
divider.computeLineDistances();
scene.add(divider);
// -------------------------------------------------------------------------
// Projected HTML labels
// -------------------------------------------------------------------------
const labelLayer = document.getElementById("labelLayer");
const projectedLabels = [];
function addProjectedLabel(html, position, className = "", key = "always") {
const element = document.createElement("div");
element.className = `projected ${className}`;
element.innerHTML = html;
element.style.display = "none";
labelLayer.appendChild(element);
const item = {
element,
position: position.clone(),
key
};
projectedLabels.push(item);
return item;
}
addProjectedLabel(
`
<span class="scheme-name">Scheme A</span>
<span class="main">Low + wide block</span>
<span class="detail">
Footprint: 24 × 16 m / 384 m²<br>
Height: 9 m · 3 floors · GFA: 1,152 m²
</span>
`,
new THREE.Vector3(-19, 12.3, -0.7),
"scheme-label"
);
addProjectedLabel(
`
<span class="scheme-name">Scheme B</span>
<span class="main">Two narrow + tall blocks</span>
<span class="detail">
Footprint: 2 × 12 × 12 m / 288 m² total<br>
Height: 14 m · 4 floors each · GFA: 1,152 m²
</span>
`,
new THREE.Vector3(19, 17.2, -0.7),
"scheme-label b"
);
// -------------------------------------------------------------------------
// Architectural helpers
// -------------------------------------------------------------------------
function makeBox(parent, size, position, material, edgeColor = null) {
const geometry = new THREE.BoxGeometry(...size);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (edgeColor !== null) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry),
new THREE.LineBasicMaterial({
color: edgeColor,
transparent: true,
opacity: 0.38
})
);
mesh.add(edges);
}
return mesh;
}
function createFootprint(x, z, width, depth, accent) {
const fill = new THREE.Mesh(
new THREE.PlaneGeometry(width, depth),
new THREE.MeshBasicMaterial({
color: accent,
transparent: true,
opacity: 0.12,
depthWrite: false
})
);
fill.rotation.x = -Math.PI / 2;
fill.position.set(x, 0.025, z);
scene.add(fill);
const halfW = width / 2;
const halfD = depth / 2;
const outlinePoints = [
new THREE.Vector3(x - halfW, 0.065, z - halfD),
new THREE.Vector3(x + halfW, 0.065, z - halfD),
new THREE.Vector3(x + halfW, 0.065, z + halfD),
new THREE.Vector3(x - halfW, 0.065, z + halfD),
new THREE.Vector3(x - halfW, 0.065, z - halfD)
];
const outline = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(outlinePoints),
new THREE.LineBasicMaterial({
color: accent,
transparent: true,
opacity: 0.9
})
);
scene.add(outline);
}
function createCutawayBlock({
x,
z,
width,
depth,
height,
floors,
accent,
wallColor,
slabColor
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
const floorHeight = height / floors;
const wallMaterial = new THREE.MeshStandardMaterial({
color: wallColor,
roughness: 0.82,
metalness: 0
});
const slabMaterial = new THREE.MeshStandardMaterial({
color: slabColor,
roughness: 0.76,
metalness: 0
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: accent,
roughness: 0.65,
metalness: 0.03
});
const partitionMaterial = new THREE.MeshStandardMaterial({
color: accent,
transparent: true,
opacity: 0.22,
roughness: 0.9,
depthWrite: false
});
const coreMaterial = new THREE.MeshStandardMaterial({
color: 0x566671,
transparent: true,
opacity: 0.78,
roughness: 0.85
});
// Visible floor plates.
for (let floor = 0; floor < floors; floor++) {
makeBox(
group,
[width, 0.18, depth],
[0, 0.18 + floor * floorHeight, 0],
slabMaterial,
accent
);
}
// Rear and left walls remain; the front and right sides are cut away.
makeBox(
group,
[width, height, 0.17],
[0, height / 2, -depth / 2],
wallMaterial,
accent
);
makeBox(
group,
[0.17, height, depth],
[-width / 2, height / 2, 0],
wallMaterial,
accent
);
// A partial roof exposes the top floor.
const roofDepth = depth * 0.46;
const roofZ = -depth / 2 + roofDepth / 2;
makeBox(
group,
[width, 0.18, roofDepth],
[0, height - 0.09, roofZ],
slabMaterial,
accent
);
// A visible circulation core near the open side.
makeBox(
group,
[2.5, height - 0.45, 2.8],
[width / 2 - 2.1, (height - 0.45) / 2, -depth / 2 + 2.2],
coreMaterial
);
// Simple floor divisions and stair treads reveal the cutaway interior.
for (let floor = 0; floor < floors; floor++) {
const storyBase = 0.29 + floor * floorHeight;
const storyHeight = floorHeight - 0.36;
makeBox(
group,
[0.13, storyHeight * 0.78, depth * 0.52],
[-width * 0.12, storyBase + storyHeight / 2, -depth * 0.1],
partitionMaterial
);
makeBox(
group,
[0.13, storyHeight * 0.72, depth * 0.34],
[width * 0.08, storyBase + storyHeight / 2, -depth * 0.25],
partitionMaterial
);
for (let step = 0; step < 7; step++) {
makeBox(
group,
[1.7, 0.13, 0.38],
[
width / 2 - 3.5,
storyBase + 0.22 + step * (storyHeight - 0.55) / 7,
-depth / 2 + 3.2 + step * 0.44
],
accentMaterial
);
}
}
createFootprint(x, z, width, depth, accent);
return group;
}
// Scheme A: 24 × 16 m, 3 floors, 9 m high.
// GFA = 24 × 16 × 3 = 1,152 m².
createCutawayBlock({
x: -19,
z: 0,
width: 24,
depth: 16,
height: 9,
floors: 3,
accent: 0x397da6,
wallColor: 0xd9e7ef,
slabColor: 0xc7d8e3
});
// Scheme B: two 12 × 12 m blocks, 4 floors each, 14 m high.
// GFA = 2 × 12 × 12 × 4 = 1,152 m².
createCutawayBlock({
x: 12,
z: 0,
width: 12,
depth: 12,
height: 14,
floors: 4,
accent: 0xc96f4a,
wallColor: 0xf0ddd4,
slabColor: 0xe2c4b6
});
createCutawayBlock({
x: 26,
z: 0,
width: 12,
depth: 12,
height: 14,
floors: 4,
accent: 0xc96f4a,
wallColor: 0xf0ddd4,
slabColor: 0xe2c4b6
});
// -------------------------------------------------------------------------
// Dimensions
// -------------------------------------------------------------------------
function addDimension(start, end, tickDirection, label, labelPosition) {
const tick = tickDirection.clone().normalize().multiplyScalar(0.34);
const points = [
start,
end,
start.clone().sub(tick),
start.clone().add(tick),
end.clone().sub(tick),
end.clone().add(tick)
];
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const line = new THREE.LineSegments(
geometry,
new THREE.LineBasicMaterial({
color: 0x53616b,
transparent: true,
opacity: 0.9
})
);
dimensionsGroup.add(line);
addProjectedLabel(
label,
labelPosition,
"dim-label",
"dimensions"
);
}
// Scheme A dimensions.
addDimension(
new THREE.Vector3(-31, 0.32, 9.25),
new THREE.Vector3(-7, 0.32, 9.25),
new THREE.Vector3(0, 0, 1),
"24 m",
new THREE.Vector3(-19, 0.48, 9.25)
);
addDimension(
new THREE.Vector3(-5.6, 0.32, -8),
new THREE.Vector3(-5.6, 0.32, 8),
new THREE.Vector3(1, 0, 0),
"16 m",
new THREE.Vector3(-5.6, 0.48, 0)
);
addDimension(
new THREE.Vector3(-4.85, 0, 8.8),
new THREE.Vector3(-4.85, 9, 8.8),
new THREE.Vector3(1, 0, 0),
"9 m high",
new THREE.Vector3(-4.85, 4.7, 8.8)
);
// Scheme B block widths.
addDimension(
new THREE.Vector3(6, 0.32, 7.35),
new THREE.Vector3(18, 0.32, 7.35),
new THREE.Vector3(0, 0, 1),
"12 m",
new THREE.Vector3(12, 0.48, 7.35)
);
addDimension(
new THREE.Vector3(20, 0.32, 7.35),
new THREE.Vector3(32, 0.32, 7.35),
new THREE.Vector3(0, 0, 1),
"12 m",
new THREE.Vector3(26, 0.48, 7.35)
);
// Shared depth dimension for the square blocks.
addDimension(
new THREE.Vector3(33.35, 0.32, -6),
new THREE.Vector3(33.35, 0.32, 6),
new THREE.Vector3(1, 0, 0),
"12 m deep",
new THREE.Vector3(33.35, 0.48, 0)
);
// Height dimensions for both blocks.
addDimension(
new THREE.Vector3(4.8, 0, 6.8),
new THREE.Vector3(4.8, 14, 6.8),
new THREE.Vector3(1, 0, 0),
"14 m high",
new THREE.Vector3(4.8, 7.1, 6.8)
);
addDimension(
new THREE.Vector3(34.15, 0, 6.8),
new THREE.Vector3(34.15, 14, 6.8),
new THREE.Vector3(1, 0, 0),
"14 m high",
new THREE.Vector3(34.15, 7.1, 6.8)
);
// -------------------------------------------------------------------------
// Access paths
// -------------------------------------------------------------------------
const pathAnimations = [];
const pathColor = 0xd58a25;
function createAccessPath(points, arrowTimes = [0.45, 0.78]) {
const vectors = points.map(
(point) => new THREE.Vector3(point[0], 0.24, point[2])
);
const curve = new THREE.CatmullRomCurve3(
vectors,
false,
"centripetal"
);
const underlay = new THREE.Mesh(
new THREE.TubeGeometry(curve, 56, 0.16, 6, false),
new THREE.MeshBasicMaterial({
color: pathColor,
transparent: true,
opacity: 0.14,
depthWrite: false
})
);
pathsGroup.add(underlay);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 56, 0.065, 6, false),
new THREE.MeshStandardMaterial({
color: pathColor,
emissive: 0x7d4608,
emissiveIntensity: 0.12,
roughness: 0.7
})
);
pathsGroup.add(tube);
const arrowMaterial = new THREE.MeshStandardMaterial({
color: pathColor,
emissive: 0x713d05,
emissiveIntensity: 0.15,
roughness: 0.65
});
for (const time of arrowTimes) {
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.23, 0.65, 3),
arrowMaterial
);
arrow.position.copy(curve.getPointAt(time));
const tangent = curve.getTangentAt(time).normalize();
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
tangent
);
pathsGroup.add(arrow);
}
const marker = new THREE.Mesh(
new THREE.SphereGeometry(0.18, 12, 8),
new THREE.MeshStandardMaterial({
color: 0xf5b34c,
emissive: pathColor,
emissiveIntensity: 0.55,
roughness: 0.45
})
);
pathsGroup.add(marker);
pathAnimations.push({
curve,
marker,
offset: Math.random()
});
}
// Scheme A: direct approach to the primary frontage.
createAccessPath([
[-19, 0, 17],
[-19, 0, 10]
]);
// Scheme B: shared approach spine with two branches.
createAccessPath([
[19, 0, 17],
[19, 0, 8]
], [0.55]);
createAccessPath([
[19, 0, 8],
[12, 0, 8],
[12, 0, 6.8]
], [0.68]);
createAccessPath([
[19, 0, 8],
[26, 0, 8],
[26, 0, 6.8]
], [0.68]);
addProjectedLabel(
"Direct front approach",
new THREE.Vector3(-19, 0.55, 14.7),
"path-label",
"paths"
);
addProjectedLabel(
"Shared spine + two branches",
new THREE.Vector3(19, 0.55, 15),
"path-label",
"paths"
);
// -------------------------------------------------------------------------
// Camera controls implemented without external addons
// -------------------------------------------------------------------------
const clamp = THREE.MathUtils.clamp;
function applyCamera() {
const radius = 80;
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + radius * sinPhi * Math.sin(orbit.azimuth),
orbit.target.y + radius * Math.cos(orbit.phi),
orbit.target.z + radius * sinPhi * Math.cos(orbit.azimuth)
);
camera.zoom = orbit.zoom;
camera.lookAt(orbit.target);
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(43, 78 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
renderer.setSize(width, height, false);
applyCamera();
}
window.addEventListener("resize", resize);
let pointerState = null;
canvas.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointerState = {
id: event.pointerId,
lastX: event.clientX,
lastY: event.clientY,
pan: event.button === 2 || event.button === 1 || event.shiftKey
};
});
canvas.addEventListener("pointermove", (event) => {
if (!pointerState || pointerState.id !== event.pointerId) {
return;
}
const dx = event.clientX - pointerState.lastX;
const dy = event.clientY - pointerState.lastY;
pointerState.lastX = event.clientX;
pointerState.lastY = event.clientY;
if (pointerState.pan) {
camera.updateMatrixWorld();
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrixWorld,
0
);
const up = new THREE.Vector3().setFromMatrixColumn(
camera.matrixWorld,
1
);
const unitsPerPixel =
(camera.top - camera.bottom) / camera.zoom / canvas.clientHeight;
orbit.target.addScaledVector(right, -dx * unitsPerPixel);
orbit.target.addScaledVector(up, dy * unitsPerPixel);
orbit.target.x = clamp(orbit.target.x, -18, 18);
orbit.target.y = clamp(orbit.target.y, 0, 9);
orbit.target.z = clamp(orbit.target.z, -10, 10);
} else {
orbit.azimuth -= dx * 0.006;
orbit.phi = clamp(orbit.phi - dy * 0.005, 0.025, 1.46);
}
applyCamera();
});
function endPointer(event) {
if (pointerState && pointerState.id === event.pointerId) {
pointerState = null;
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.zoom = clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.0012),
0.55,
2.3
);
applyCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
setView("iso");
});
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLInputElement) {
return;
}
const key = event.key.toLowerCase();
if (key === "arrowleft") {
orbit.azimuth += 0.08;
} else if (key === "arrowright") {
orbit.azimuth -= 0.08;
} else if (key === "arrowup") {
orbit.phi = clamp(orbit.phi - 0.06, 0.025, 1.46);
} else if (key === "arrowdown") {
orbit.phi = clamp(orbit.phi + 0.06, 0.025, 1.46);
} else if (key === "+" || key === "=") {
orbit.zoom = clamp(orbit.zoom * 1.08, 0.55, 2.3);
} else if (key === "-") {
orbit.zoom = clamp(orbit.zoom / 1.08, 0.55, 2.3);
} else if (key === "r") {
setView("iso");
return;
} else {
return;
}
event.preventDefault();
applyCamera();
});
function setView(view) {
document.querySelectorAll(".view-button").forEach((button) => {
button.classList.toggle("active", button.dataset.view === view);
});
if (view === "plan") {
orbit.azimuth = 0;
orbit.phi = 0.025;
orbit.zoom = 1.03;
orbit.target.set(0, 0, 0);
} else if (view === "elevation") {
orbit.azimuth = 0;
orbit.phi = 1.43;
orbit.zoom = 1;
orbit.target.set(0, 5, 0);
} else {
orbit.azimuth = 0.67;
orbit.phi = 0.79;
orbit.zoom = 1;
orbit.target.set(0, 3.2, 0);
}
applyCamera();
}
document.querySelectorAll(".view-button").forEach((button) => {
button.addEventListener("click", () => {
setView(button.dataset.view);
});
});
document.getElementById("resetButton").addEventListener("click", () => {
setView("iso");
});
let dimensionsVisible = true;
let pathsVisible = true;
const dimensionsButton = document.getElementById("dimensionsButton");
const pathsButton = document.getElementById("pathsButton");
dimensionsButton.addEventListener("click", () => {
dimensionsVisible = !dimensionsVisible;
dimensionsGroup.visible = dimensionsVisible;
dimensionsButton.classList.toggle("active", dimensionsVisible);
dimensionsButton.setAttribute("aria-pressed", String(dimensionsVisible));
});
pathsButton.addEventListener("click", () => {
pathsVisible = !pathsVisible;
pathsGroup.visible = pathsVisible;
pathsButton.classList.toggle("active", pathsVisible);
pathsButton.setAttribute("aria-pressed", String(pathsVisible));
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
const projectedPoint = new THREE.Vector3();
function updateProjectedLabels() {
const width = canvas.clientWidth;
const height = canvas.clientHeight;
for (const label of projectedLabels) {
let visible = true;
if (label.key === "dimensions" && !dimensionsVisible) {
visible = false;
}
if (label.key === "paths" && !pathsVisible) {
visible = false;
}
projectedPoint.copy(label.position).project(camera);
if (
projectedPoint.z < -1 ||
projectedPoint.z > 1 ||
projectedPoint.x < -1.08 ||
projectedPoint.x > 1.08 ||
projectedPoint.y < -1.08 ||
projectedPoint.y > 1.08
) {
visible = false;
}
label.element.style.display = visible ? "block" : "none";
if (visible) {
const x = (projectedPoint.x * 0.5 + 0.5) * width;
const y = (-projectedPoint.y * 0.5 + 0.5) * height;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
}
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
for (const animation of pathAnimations) {
const t = (elapsed * 0.08 + animation.offset) % 1;
animation.marker.position.copy(animation.curve.getPointAt(t));
animation.marker.position.y += 0.08;
}
updateProjectedLabels();
renderer.render(scene, camera);
});
resize();
applyCamera();
loading.remove();
</script>
</body>
</html>
```