Prompt specification
Build or customize the Three.js 3D scene "Arcaded passage and masonry buttresses" 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: Arcaded passage and masonry buttresses
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/arcaded-passage-and-masonry-buttresses-x2171
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: arcaded passage and masonry buttresses. Create a short arcaded passage with visible side supports and one cutaway bay. Trace an idealized compressive load path from roof to foundations through the arch.
Working Three.js Starter (arcaded-passage-and-masonry-buttresses-x2171):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Voxel Masonry Arcade</title>
<style>
:root {
--paper: #f3eee2;
--muted: #aeb8bd;
--cyan: #64e5e2;
--amber: #f1ad63;
--panel: rgba(10, 18, 25, 0.82);
--line: rgba(255, 255, 255, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #091119;
color: var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 46%, transparent 46%, rgba(3, 8, 13, 0.38) 100%),
linear-gradient(180deg, rgba(3, 8, 13, 0.25), transparent 20%, transparent 80%, rgba(3, 8, 13, 0.4));
}
.panel {
position: fixed;
z-index: 5;
border: 1px solid var(--line);
background: var(--panel);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
.intro {
top: 22px;
left: 22px;
width: min(370px, calc(100vw - 44px));
padding: 18px 20px 17px;
border-radius: 4px 16px 16px 16px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--cyan);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 39px);
font-weight: 500;
line-height: 1;
letter-spacing: -0.025em;
}
.intro p {
margin: 11px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.controls {
top: 22px;
right: 22px;
display: flex;
gap: 7px;
padding: 7px;
border-radius: 12px;
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 8px;
padding: 9px 12px;
color: #d8e0e2;
background: rgba(255, 255, 255, 0.045);
font: inherit;
font-size: 11px;
font-weight: 650;
letter-spacing: 0.025em;
cursor: pointer;
transition: 160ms ease;
}
button:hover {
border-color: rgba(255, 255, 255, 0.3);
color: white;
background: rgba(255, 255, 255, 0.09);
transform: translateY(-1px);
}
button.active {
border-color: rgba(100, 229, 226, 0.55);
color: #dffffd;
background: rgba(100, 229, 226, 0.12);
}
.sequence {
left: 22px;
bottom: 22px;
width: 278px;
padding: 15px 17px;
border-radius: 14px 14px 14px 4px;
}
.sequence-title {
margin-bottom: 11px;
color: #d7ddde;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.step {
display: grid;
grid-template-columns: 27px 1fr;
align-items: center;
min-height: 31px;
color: var(--muted);
font-size: 11px;
}
.step b {
color: var(--cyan);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
font-weight: 600;
}
.step:not(:last-child)::after {
content: "";
position: relative;
grid-column: 1;
grid-row: 2;
width: 1px;
height: 14px;
margin-left: 4px;
background: rgba(100, 229, 226, 0.32);
}
.legend {
right: 22px;
bottom: 22px;
padding: 14px 16px;
border-radius: 14px 4px 14px 14px;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin: 7px 0;
color: #c2cbcd;
font-size: 10px;
}
.swatch {
width: 21px;
height: 3px;
border-radius: 3px;
background: var(--cyan);
box-shadow: 0 0 9px rgba(100, 229, 226, 0.65);
}
.swatch.load {
background: var(--amber);
box-shadow: 0 0 9px rgba(241, 173, 99, 0.55);
}
.swatch.cut {
background: transparent;
border: 1px dashed var(--amber);
box-shadow: none;
}
.hint {
position: fixed;
z-index: 4;
bottom: 18px;
left: 50%;
transform: translateX(-50%);
color: rgba(229, 236, 236, 0.58);
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
white-space: nowrap;
}
#labels {
position: fixed;
inset: 0;
z-index: 3;
overflow: hidden;
pointer-events: none;
}
.tag {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
padding: 5px 8px;
transform: translate(-50%, -50%);
border: 1px solid rgba(255, 255, 255, 0.13);
border-left: 2px solid var(--cyan);
border-radius: 3px;
color: #e8eeee;
background: rgba(8, 15, 21, 0.8);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.09em;
text-transform: uppercase;
white-space: nowrap;
opacity: 0;
transition: opacity 180ms ease;
}
.tag.visible {
opacity: 1;
}
.tag.cut {
border-left-color: var(--amber);
color: #ffe0b9;
}
.tag::before {
content: "";
width: 4px;
height: 4px;
border-radius: 50%;
background: currentColor;
box-shadow: 0 0 8px currentColor;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
color: var(--cyan);
background: #091119;
font-size: 11px;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 400ms ease, visibility 400ms ease;
}
#loading.hidden {
visibility: hidden;
opacity: 0;
}
@media (max-width: 720px) {
.intro {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
.intro p {
display: none;
}
.controls {
top: 108px;
right: 12px;
flex-direction: column;
}
.sequence {
left: 12px;
bottom: 12px;
width: 220px;
}
.legend {
right: 12px;
bottom: 12px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<div class="vignette"></div>
<header class="panel intro">
<div class="eyebrow">Structural study · three-bay passage</div>
<h1>Voxel Masonry Arcade</h1>
<p>
A cutaway voxel arcade with stepped buttresses. The cyan overlay traces an
idealized compressive route: roof load → voussoir ring → springing and
lateral thrust → pier → spread footing.
</p>
</header>
<nav class="panel controls" aria-label="Scene controls">
<button id="cutButton" class="active" aria-pressed="true">Restore bay</button>
<button id="loadButton" class="active" aria-pressed="true">Hide load path</button>
<button id="resetButton">Reset view</button>
</nav>
<div id="labels" aria-hidden="true"></div>
<aside class="panel sequence">
<div class="sequence-title">Idealized compressive route</div>
<div class="step"><b>01</b><span>Roof load at the crown</span></div>
<div class="step"><b>02</b><span>Compression through voussoirs</span></div>
<div class="step"><b>03</b><span>Outward thrust at springing</span></div>
<div class="step"><b>04</b><span>Pier reaction into foundation</span></div>
</aside>
<aside class="panel legend">
<div class="legend-row"><i class="swatch load"></i>Applied roof load</div>
<div class="legend-row"><i class="swatch"></i>Arch thrust / bearing path</div>
<div class="legend-row"><i class="swatch cut"></i>Cutaway boundary</div>
</aside>
<div class="hint">Drag to orbit · wheel to zoom · shift-drag to pan · R resets</div>
<div id="loading">Assembling masonry…</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.querySelector("#stage");
const loading = document.querySelector("#loading");
const labelLayer = document.querySelector("#labels");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x091119);
scene.fog = new THREE.Fog(0x091119, 29, 57);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.8));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
stage.appendChild(renderer.domElement);
const world = new THREE.Group();
scene.add(world);
// Lighting ---------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xdbeeff, 0x4a3929, 1.65));
const sun = new THREE.DirectionalLight(0xffe3b5, 3.15);
sun.position.set(9, 17, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -16;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.bias = -0.0005;
scene.add(sun);
const coolFill = new THREE.DirectionalLight(0x6bc8df, 0.8);
coolFill.position.set(-12, 7, -9);
scene.add(coolFill);
const pathLight = new THREE.PointLight(0x52e5df, 8, 15, 2);
pathLight.position.set(0, 6, 1);
scene.add(pathLight);
// Ground -----------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(70, 55),
new THREE.MeshStandardMaterial({
color: 0x111b22,
roughness: 0.96,
metalness: 0.02
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.12;
ground.receiveShadow = true;
world.add(ground);
const grid = new THREE.GridHelper(48, 48, 0x49606a, 0x263740);
grid.position.y = -0.105;
grid.material.transparent = true;
grid.material.opacity = 0.22;
world.add(grid);
// Deterministic masonry generation ---------------------------------------
const stonePalette = [
0xb6a98e,
0xc2b49a,
0xa99b82,
0xc9bda4,
0x9f927c,
0xb1a188,
0xd0c4aa
];
let randomSeed = 481516;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function stoneColor() {
const color = new THREE.Color(
stonePalette[Math.floor(random() * stonePalette.length)]
);
color.offsetHSL(0, 0, (random() - 0.5) * 0.055);
return color;
}
const solidBlocks = [];
const removableBlocks = [];
function addBlock(
collection,
x,
y,
z,
sx,
sy,
sz,
color = stoneColor(),
rx = 0,
ry = 0,
rz = 0
) {
collection.push({
x,
y,
z,
sx,
sy,
sz,
rx,
ry,
rz,
color: color.isColor ? color.clone() : new THREE.Color(color)
});
}
const bayCenters = [-6, 0, 6];
const springY = 3.1;
const archRadius = 4.0;
const passageHalfWidth = 2.72;
// Voxel paving inside the passage.
for (let x = -9.45; x <= 9.45; x += 0.9) {
for (let z = -passageHalfWidth; z <= passageHalfWidth; z += 0.9) {
addBlock(
solidBlocks,
x,
-0.005,
z,
0.84,
0.14,
0.84,
stoneColor()
);
}
}
// Foundations, side piers, and stepped buttresses.
for (let bayIndex = 0; bayIndex < bayCenters.length; bayIndex++) {
const x = bayCenters[bayIndex];
for (const side of [-1, 1]) {
const isRemoved =
bayIndex === 1 && side === 1;
const target = isRemoved ? removableBlocks : solidBlocks;
// Nine-block spread footing.
for (let ix = -1; ix <= 1; ix++) {
for (let iz = -1; iz <= 1; iz++) {
addBlock(
target,
x + ix * 0.62,
0.28,
side * 4.18 + iz * 0.62,
0.58,
0.5,
0.58,
stoneColor()
);
}
}
// Voxel side support.
for (let row = 0; row < 5; row++) {
const y = 0.72 + row * 0.58;
for (const ox of [-0.39, 0.39]) {
for (const oz of [-0.39, 0.39]) {
addBlock(
target,
x + ox,
y,
side * 4.18 + oz,
0.73,
0.52,
0.73,
stoneColor()
);
}
}
}
// Stepped masonry buttress.
const buttressLayers = [
{ y: 0.35, width: 2.25, depth: 2.15 },
{ y: 1.00, width: 2.00, depth: 1.85 },
{ y: 1.65, width: 1.75, depth: 1.55 },
{ y: 2.30, width: 1.50, depth: 1.22 },
{ y: 2.95, width: 1.25, depth: 0.92 },
{ y: 3.55, width: 1.05, depth: 0.68 }
];
for (const layer of buttressLayers) {
const nx = Math.ceil(layer.width / 0.58);
const nz = Math.ceil(layer.depth / 0.58);
const sx = layer.width / nx - 0.035;
const sz = layer.depth / nz - 0.035;
const centerZ = side * (4.75 + layer.depth / 2);
for (let ix = 0; ix < nx; ix++) {
for (let iz = 0; iz < nz; iz++) {
const px =
x - layer.width / 2 + sx / 2 + ix * (sx + 0.035);
const pz =
centerZ - layer.depth / 2 + sz / 2 + iz * (sz + 0.035);
addBlock(
target,
px,
layer.y,
pz,
sx,
0.59,
sz,
stoneColor()
);
}
}
}
}
}
// Transverse voussoir arches.
for (let bayIndex = 0; bayIndex < bayCenters.length; bayIndex++) {
const x = bayCenters[bayIndex];
for (let i = 0; i <= 17; i++) {
const theta = (i / 17) * Math.PI;
const y = springY + archRadius * Math.sin(theta);
const z = archRadius * Math.cos(theta);
const rotationX = Math.PI / 2 - theta;
const isCut =
bayIndex === 1 && theta < Math.PI / 2 - 0.001;
addBlock(
isCut ? removableBlocks : solidBlocks,
x,
y,
z,
1.42,
1.3,
0.73,
stoneColor(),
rotationX
);
}
// Slightly emphasized crown key block.
addBlock(
solidBlocks,
x,
springY + archRadius,
0,
1.46,
1.48,
0.82,
new THREE.Color(0xd2c4a7)
);
}
// Continuous voxel barrel-vault roof.
for (let xi = 0; xi < 24; xi++) {
const x = -8.625 + xi * 0.75;
for (let ti = 0; ti < 12; ti++) {
const theta = THREE.MathUtils.degToRad(25 + (130 * ti) / 11);
const radius = 4.95;
const y = springY + radius * Math.sin(theta);
const z = radius * Math.cos(theta);
const rotationX = Math.PI / 2 - theta;
const inCutBay = Math.abs(x) < 2.72;
const nearHalf = z > 0;
const isCut = inCutBay && nearHalf;
let color = stoneColor();
// Warm edge blocks make the sectional cut legible.
if (nearHalf && Math.abs(Math.abs(x) - 2.9) < 0.38) {
color = new THREE.Color(0xd39b61);
}
addBlock(
isCut ? removableBlocks : solidBlocks,
x,
y,
z,
0.69,
0.55,
0.82,
color,
rotationX
);
}
}
function createMasonryMesh(blocks) {
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.94,
metalness: 0.015
});
const mesh = new THREE.InstancedMesh(
geometry,
material,
blocks.length
);
const dummy = new THREE.Object3D();
blocks.forEach((block, index) => {
dummy.position.set(block.x, block.y, block.z);
dummy.rotation.set(block.rx, block.ry, block.rz);
dummy.scale.set(block.sx, block.sy, block.sz);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
mesh.setColorAt(index, block.color);
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.computeBoundingSphere();
return mesh;
}
const masonry = createMasonryMesh(solidBlocks);
const removedMasonry = createMasonryMesh(removableBlocks);
world.add(masonry, removedMasonry);
// Cutaway section plane and outline --------------------------------------
const cutawayEffects = new THREE.Group();
world.add(cutawayEffects);
const sectionPlane = new THREE.Mesh(
new THREE.PlaneGeometry(5.4, 4.1),
new THREE.MeshBasicMaterial({
color: 0xf1ad63,
transparent: true,
opacity: 0.075,
side: THREE.DoubleSide,
depthWrite: false
})
);
sectionPlane.position.set(0, 5.15, 0.01);
cutawayEffects.add(sectionPlane);
const cutOutlineGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-2.7, 3.1, 0.015),
new THREE.Vector3(-2.7, 7.1, 0.015),
new THREE.Vector3(2.7, 7.1, 0.015),
new THREE.Vector3(2.7, 3.1, 0.015)
]);
const cutOutlineMaterial = new THREE.LineDashedMaterial({
color: 0xf1ad63,
transparent: true,
opacity: 0.8,
dashSize: 0.22,
gapSize: 0.12,
depthTest: false,
depthWrite: false
});
const cutOutline = new THREE.Line(
cutOutlineGeometry,
cutOutlineMaterial
);
cutOutline.computeLineDistances();
cutOutline.renderOrder = 9;
cutawayEffects.add(cutOutline);
// Idealized compressive load path ----------------------------------------
const loadGroup = new THREE.Group();
world.add(loadGroup);
const cyan = 0x64e5e2;
const cyanLight = 0xb8fffb;
const amber = 0xf1ad63;
function makeTube(curve, color, radius = 0.055, opacity = 0.95) {
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, radius, 8, false),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity,
depthTest: false,
depthWrite: false
})
);
tube.renderOrder = 10;
loadGroup.add(tube);
return tube;
}
function addGlow(curve, color) {
const glow = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, 0.14, 8, false),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.13,
depthTest: false,
depthWrite: false,
blending: THREE.AdditiveBlending
})
);
glow.renderOrder = 9;
loadGroup.add(glow);
return glow;
}
function addArrows(curve, count, color, size = 1) {
const arrowGeometry = new THREE.ConeGeometry(
0.115 * size,
0.34 * size,
8
);
const arrowMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.96,
depthTest: false,
depthWrite: false
});
const up = new THREE.Vector3(0, 1, 0);
for (let i = 0; i < count; i++) {
const t = (i + 0.5) / count;
const arrow = new THREE.Mesh(arrowGeometry, arrowMaterial);
arrow.position.copy(curve.getPointAt(t));
arrow.quaternion.setFromUnitVectors(
up,
curve.getTangentAt(t).normalize()
);
arrow.renderOrder = 12;
loadGroup.add(arrow);
}
}
const packets = [];
function addPacketMotion(curve, count, speed, color = cyanLight) {
const geometry = new THREE.BoxGeometry(0.14, 0.14, 0.14);
const material = new THREE.MeshBasicMaterial({
color,
depthTest: false,
depthWrite: false
});
for (let i = 0; i < count; i++) {
const packet = new THREE.Mesh(geometry, material);
packet.renderOrder = 14;
loadGroup.add(packet);
packets.push({
mesh: packet,
curve,
offset: i / count,
speed
});
}
}
const crownY = springY + archRadius;
const roofCurve = new THREE.LineCurve3(
new THREE.Vector3(0, 9.15, 0),
new THREE.Vector3(0, crownY, 0)
);
function archCurve(nearSide) {
const points = [];
for (let i = 0; i <= 14; i++) {
const fraction = i / 14;
const theta = nearSide
? Math.PI / 2 - fraction * Math.PI / 2
: Math.PI / 2 + fraction * Math.PI / 2;
points.push(
new THREE.Vector3(
0,
springY + archRadius * Math.sin(theta),
archRadius * Math.cos(theta)
)
);
}
return new THREE.CatmullRomCurve3(
points,
false,
"centripetal"
);
}
const nearArch = archCurve(true);
const farArch = archCurve(false);
const nearVertical = new THREE.LineCurve3(
new THREE.Vector3(0, springY, archRadius),
new THREE.Vector3(0, 0.08, archRadius)
);
const farVertical = new THREE.LineCurve3(
new THREE.Vector3(0, springY, -archRadius),
new THREE.Vector3(0, 0.08, -archRadius)
);
// Applied roof load.
makeTube(roofCurve, amber, 0.065, 0.98);
addGlow(roofCurve, amber);
addArrows(roofCurve, 3, amber, 1.08);
addPacketMotion(roofCurve, 2, 0.21, 0xffd08a);
// Compression around both halves of the arch.
for (const curve of [nearArch, farArch]) {
makeTube(curve, cyan, 0.06, 0.98);
addGlow(curve, cyan);
addArrows(curve, 8, cyan, 1);
addPacketMotion(curve, 4, 0.18);
}
// Reactions carried down the piers into the footings.
for (const curve of [nearVertical, farVertical]) {
makeTube(curve, cyan, 0.06, 0.98);
addGlow(curve, cyan);
addArrows(curve, 4, cyan, 0.95);
addPacketMotion(curve, 3, 0.17);
}
// Emphasized crown key.
const keyOutline = new THREE.LineSegments(
new THREE.EdgesGeometry(
new THREE.BoxGeometry(1.5, 1.52, 0.86)
),
new THREE.LineBasicMaterial({
color: cyanLight,
transparent: true,
opacity: 0.88,
depthTest: false,
depthWrite: false
})
);
keyOutline.position.set(0, crownY, 0);
keyOutline.renderOrder = 13;
loadGroup.add(keyOutline);
// Three prominent roof-load arrows.
const roofArrowGeometry = new THREE.ConeGeometry(0.16, 0.46, 8);
const roofArrowMaterial = new THREE.MeshBasicMaterial({
color: amber,
depthTest: false,
depthWrite: false
});
for (const x of [-0.72, 0, 0.72]) {
const arrow = new THREE.Mesh(
roofArrowGeometry,
roofArrowMaterial
);
arrow.position.set(x, 9.72, 0);
arrow.rotation.z = Math.PI;
arrow.renderOrder = 12;
loadGroup.add(arrow);
}
// Labels ------------------------------------------------------------------
const labels = [];
function addLabel(text, position, options = {}) {
const element = document.createElement("div");
element.className = `tag${options.cut ? " cut" : ""}`;
element.textContent = text;
labelLayer.appendChild(element);
labels.push({
element,
position: position.clone(),
offset: options.offset || new THREE.Vector2(0, 0),
kind: options.kind || "always"
});
}
addLabel("Roof load", new THREE.Vector3(0, 9.65, 0), {
kind: "load",
offset: new THREE.Vector2(58, -13)
});
addLabel("Crown / keystone", new THREE.Vector3(0, 7.25, 0), {
kind: "load",
offset: new THREE.Vector2(65, -28)
});
addLabel("Springing + thrust", new THREE.Vector3(0, 3.25, 4), {
kind: "load",
offset: new THREE.Vector2(75, 4)
});
addLabel("Spread footing", new THREE.Vector3(0, 0.35, 4.18), {
kind: "load",
offset: new THREE.Vector2(62, 28)
});
addLabel("Cutaway bay", new THREE.Vector3(1.9, 6.15, 2.6), {
cut: true,
kind: "cut",
offset: new THREE.Vector2(55, -22)
});
addLabel("Stepped buttress", new THREE.Vector3(6, 2.6, 5.7), {
offset: new THREE.Vector2(70, 4)
});
// Custom camera controls, implemented without external controls ----------
const orbit = {
radius: 29,
theta: 0.72,
phi: 1.25,
target: new THREE.Vector3(0, 3.4, 0)
};
const defaultOrbit = {
radius: 29,
theta: 0.72,
phi: 1.25,
target: new THREE.Vector3(0, 3.4, 0)
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
camera.updateMatrixWorld();
}
function resetCamera() {
orbit.radius = defaultOrbit.radius;
orbit.theta = defaultOrbit.theta;
orbit.phi = defaultOrbit.phi;
orbit.target.copy(defaultOrbit.target);
updateCamera();
}
const pointer = {
active: false,
x: 0,
y: 0
};
renderer.domElement.addEventListener("pointerdown", (event) => {
pointer.active = true;
pointer.x = event.clientX;
pointer.y = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointer.active) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
const wantsPan = event.shiftKey || event.buttons === 2;
if (wantsPan) {
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
0
);
const scale = orbit.radius * 0.0012;
orbit.target.addScaledVector(right, -dx * scale);
orbit.target.y += dy * scale;
orbit.target.y = THREE.MathUtils.clamp(
orbit.target.y,
0.5,
8
);
} else {
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi + dy * 0.005,
0.28,
1.49
);
}
updateCamera();
});
function releasePointer(event) {
pointer.active = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener(
"pointerup",
releasePointer
);
renderer.domElement.addEventListener(
"pointercancel",
releasePointer
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
14,
46
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetCamera();
if (event.key === "ArrowLeft") orbit.theta += 0.08;
if (event.key === "ArrowRight") orbit.theta -= 0.08;
if (event.key === "ArrowUp") orbit.phi -= 0.06;
if (event.key === "ArrowDown") orbit.phi += 0.06;
if (event.key === "+" || event.key === "=") orbit.radius -= 1;
if (event.key === "-") orbit.radius += 1;
orbit.phi = THREE.MathUtils.clamp(orbit.phi, 0.28, 1.49);
orbit.radius = THREE.MathUtils.clamp(orbit.radius, 14, 46);
updateCamera();
});
// Interface toggles -------------------------------------------------------
let cutawayVisible = true;
let loadVisible = true;
const cutButton = document.querySelector("#cutButton");
const loadButton = document.querySelector("#loadButton");
const resetButton = document.querySelector("#resetButton");
function updateCutButton() {
cutButton.textContent = cutawayVisible ? "Restore bay" : "Cut bay";
cutButton.classList.toggle("active", cutawayVisible);
cutButton.setAttribute("aria-pressed", String(cutawayVisible));
removedMasonry.visible = !cutawayVisible;
cutawayEffects.visible = cutawayVisible;
}
function updateLoadButton() {
loadButton.textContent = loadVisible ? "Hide load path" : "Show load path";
loadButton.classList.toggle("active", loadVisible);
loadButton.setAttribute("aria-pressed", String(loadVisible));
loadGroup.visible = loadVisible;
}
cutButton.addEventListener("click", () => {
cutawayVisible = !cutawayVisible;
updateCutButton();
});
loadButton.addEventListener("click", () => {
loadVisible = !loadVisible;
updateLoadButton();
});
resetButton.addEventListener("click", resetCamera);
updateCutButton();
updateLoadButton();
updateCamera();
// Resize and render loop --------------------------------------------------
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.8));
renderer.setSize(innerWidth, innerHeight);
});
const projected = new THREE.Vector3();
function updateLabels() {
for (const label of labels) {
const kindVisible =
label.kind === "always" ||
(label.kind === "load" && loadVisible) ||
(label.kind === "cut" && cutawayVisible);
if (!kindVisible) {
label.element.classList.remove("visible");
continue;
}
projected.copy(label.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.08 &&
projected.x < 1.08 &&
projected.y > -1.08 &&
projected.y < 1.08;
label.element.classList.toggle("visible", visible);
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
label.element.style.left = `${x + label.offset.x}px`;
label.element.style.top = `${y + label.offset.y}px`;
}
}
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
for (const packet of packets) {
const t = (elapsed * packet.speed + packet.offset) % 1;
packet.mesh.position.copy(packet.curve.getPointAt(t));
packet.mesh.rotation.set(
elapsed * 0.8,
elapsed * 1.1,
elapsed * 0.6
);
}
cutOutlineMaterial.opacity =
0.64 + Math.sin(elapsed * 2.1) * 0.14;
pathLight.intensity = 7.5 + Math.sin(elapsed * 2.5) * 0.7;
updateLabels();
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
});
</script>
</body>
</html>
```