Prompt specification
Build or customize the Three.js 3D scene "Small pavilion construction stages" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Small pavilion construction stages
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/small-pavilion-construction-stages-x2187
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring construction stages with structural dependencies. Create a four-stage pavilion build from foundations through frame, roof, and enclosure. Preserve existing geometry between stages and show which new parts depend on earlier supports. Low-poly.
Working Three.js Starter (small-pavilion-construction-stages-x2187):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dependency Pavilion — Four-Stage Construction</title>
<style>
:root {
--bg: #0a1217;
--panel: rgba(13, 24, 29, 0.82);
--panel-solid: #101c22;
--line: rgba(190, 222, 224, 0.14);
--text: #edf4f1;
--muted: #8fa5a7;
--accent: #f0a45d;
--cyan: #6de3d3;
--green: #80d99b;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button { font: inherit; }
#viewport {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 48% 44%, transparent 38%, rgba(4, 10, 13, 0.26) 100%),
linear-gradient(180deg, rgba(6, 13, 17, 0.18), transparent 25%, transparent 75%, rgba(6, 13, 17, 0.36));
}
.topbar {
position: fixed;
z-index: 5;
top: 24px;
left: 26px;
right: 26px;
display: flex;
align-items: flex-start;
justify-content: space-between;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
width: 42px;
height: 42px;
position: relative;
border: 1px solid rgba(240, 164, 93, 0.65);
border-radius: 11px;
background: rgba(240, 164, 93, 0.08);
transform: rotate(45deg);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
background: var(--accent);
opacity: 0.85;
}
.brand-mark::before {
width: 20px;
height: 2px;
left: 10px;
top: 19px;
}
.brand-mark::after {
width: 2px;
height: 20px;
left: 19px;
top: 10px;
}
.brand-copy {
transform: translateY(-1px);
text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}
.eyebrow {
margin: 0 0 5px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 20px;
font-weight: 650;
letter-spacing: -0.025em;
}
.interaction-hint {
margin-top: 7px;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.03em;
}
.progress-chip {
border: 1px solid var(--line);
border-radius: 999px;
padding: 9px 13px;
color: var(--muted);
background: rgba(11, 20, 24, 0.72);
backdrop-filter: blur(12px);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.progress-chip strong {
color: var(--text);
margin-right: 5px;
font-size: 13px;
}
.info-panel {
position: fixed;
z-index: 5;
top: 108px;
right: 26px;
width: 320px;
padding: 21px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(18px);
pointer-events: none;
}
.info-panel .stage-kicker {
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.info-panel h2 {
margin: 10px 0 10px;
font-size: 25px;
line-height: 1.12;
letter-spacing: -0.035em;
font-weight: 650;
}
.info-panel p {
margin: 0;
color: #a9babb;
font-size: 12.5px;
line-height: 1.65;
}
.support-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 18px;
}
.support-cell {
min-height: 82px;
padding: 12px;
border: 1px solid rgba(190, 222, 224, 0.1);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
}
.support-cell span {
display: block;
margin-bottom: 7px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.support-cell strong {
display: block;
color: #e4eeeb;
font-size: 11px;
line-height: 1.42;
font-weight: 650;
}
.support-cell.new {
border-color: rgba(240, 164, 93, 0.22);
background: rgba(240, 164, 93, 0.055);
}
.support-cell.new span { color: var(--accent); }
.load-path {
margin-top: 18px;
padding-top: 16px;
border-top: 1px solid var(--line);
}
.load-path-label {
margin-bottom: 11px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.path-row {
display: flex;
align-items: center;
gap: 7px;
flex-wrap: wrap;
}
.path-node {
padding: 6px 8px;
border: 1px solid rgba(190, 222, 224, 0.1);
border-radius: 7px;
color: #718789;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.path-node.done {
color: var(--green);
border-color: rgba(128, 217, 155, 0.2);
background: rgba(128, 217, 155, 0.05);
}
.path-node.active {
color: var(--accent);
border-color: rgba(240, 164, 93, 0.3);
background: rgba(240, 164, 93, 0.08);
}
.path-arrow {
color: #496063;
font-size: 11px;
}
.retained-note {
display: flex;
align-items: center;
gap: 8px;
margin-top: 15px;
color: #92a9aa;
font-size: 10.5px;
}
.retained-note::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 12px rgba(128, 217, 155, 0.65);
}
.scene-tools {
position: fixed;
z-index: 6;
left: 26px;
bottom: 126px;
display: flex;
gap: 8px;
align-items: center;
flex-wrap: wrap;
}
.tool-button {
height: 38px;
padding: 0 13px;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 7px;
border: 1px solid var(--line);
border-radius: 10px;
color: #c4d1d0;
background: rgba(13, 24, 29, 0.78);
backdrop-filter: blur(12px);
cursor: pointer;
transition: 160ms ease;
font-size: 11px;
font-weight: 650;
}
.tool-button:hover {
color: white;
border-color: rgba(240, 164, 93, 0.38);
background: rgba(21, 35, 41, 0.92);
transform: translateY(-1px);
}
.tool-button.active {
color: var(--accent);
border-color: rgba(240, 164, 93, 0.35);
background: rgba(240, 164, 93, 0.08);
}
.tool-button.icon-only {
width: 38px;
padding: 0;
font-size: 17px;
}
.dependency-legend {
display: flex;
align-items: center;
gap: 8px;
margin-left: 5px;
color: var(--muted);
font-size: 10px;
}
.dependency-legend i {
width: 25px;
height: 0;
border-top: 1px dashed var(--cyan);
box-shadow: 0 0 8px rgba(109, 227, 211, 0.45);
}
.timeline-shell {
position: fixed;
z-index: 7;
left: 50%;
bottom: 20px;
width: min(900px, calc(100% - 52px));
transform: translateX(-50%);
padding: 8px;
border: 1px solid var(--line);
border-radius: 17px;
background: rgba(11, 20, 24, 0.86);
box-shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
backdrop-filter: blur(18px);
}
.timeline-progress {
position: absolute;
z-index: 2;
top: -1px;
left: 0;
width: 0;
height: 2px;
background: linear-gradient(90deg, var(--accent), #ffd1a6);
box-shadow: 0 0 14px rgba(240, 164, 93, 0.55);
transition: width 500ms cubic-bezier(.2,.8,.2,1);
}
.timeline {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
}
.stage-button {
position: relative;
min-width: 0;
height: 70px;
padding: 11px 12px 11px 48px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
border: 1px solid transparent;
border-radius: 12px;
color: #829799;
background: transparent;
cursor: pointer;
text-align: left;
transition: 180ms ease;
}
.stage-button:hover {
color: #c9d6d5;
background: rgba(255,255,255,0.025);
}
.stage-button.active {
color: var(--text);
border-color: rgba(240, 164, 93, 0.25);
background: rgba(240, 164, 93, 0.065);
}
.stage-button.completed { color: #9fb2b2; }
.step-number {
position: absolute;
left: 13px;
top: 50%;
transform: translateY(-50%);
width: 25px;
height: 25px;
display: grid;
place-items: center;
border: 1px solid rgba(190, 222, 224, 0.16);
border-radius: 50%;
color: #718789;
font-size: 9px;
font-weight: 800;
}
.stage-button.completed .step-number {
color: var(--green);
border-color: rgba(128, 217, 155, 0.3);
background: rgba(128, 217, 155, 0.07);
}
.stage-button.active .step-number {
color: #1c1711;
border-color: var(--accent);
background: var(--accent);
box-shadow: 0 0 18px rgba(240, 164, 93, 0.25);
}
.stage-button strong {
overflow: hidden;
width: 100%;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 12px;
font-weight: 700;
}
.stage-button small {
margin-top: 4px;
overflow: hidden;
width: 100%;
color: #657b7d;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 9.5px;
}
.stage-button.active small { color: #a68e78; }
#loader {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: var(--bg);
transition: opacity 500ms ease, visibility 500ms ease;
}
#loader.hidden {
opacity: 0;
visibility: hidden;
}
.loader-inner {
text-align: center;
}
.loader-cube {
width: 38px;
height: 38px;
margin: 0 auto 18px;
border: 1px solid var(--accent);
transform: rotate(45deg);
animation: loaderPulse 1.5s ease-in-out infinite;
}
.loader-inner p {
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
@keyframes loaderPulse {
0%, 100% { opacity: .25; transform: rotate(45deg) scale(.86); }
50% { opacity: 1; transform: rotate(135deg) scale(1); }
}
@media (max-width: 760px) {
.topbar { top: 16px; left: 16px; right: 16px; }
.brand-mark { width: 34px; height: 34px; }
.brand-mark::before { left: 6px; top: 15px; }
.brand-mark::after { left: 15px; top: 6px; }
h1 { font-size: 16px; }
.interaction-hint { display: none; }
.progress-chip { padding: 7px 9px; font-size: 9px; }
.info-panel {
top: 75px;
left: 16px;
right: 16px;
width: auto;
padding: 14px 16px;
}
.info-panel h2 { margin: 6px 0; font-size: 18px; }
.info-panel p, .support-grid, .load-path, .retained-note { display: none; }
.scene-tools { left: 16px; bottom: 115px; }
.dependency-legend { display: none; }
.timeline-shell { width: calc(100% - 24px); bottom: 12px; }
.stage-button { height: 64px; padding: 9px 5px 9px 35px; }
.step-number { left: 7px; width: 21px; height: 21px; }
.stage-button strong { font-size: 10px; }
.stage-button small { display: none; }
.tool-button { height: 34px; padding: 0 10px; font-size: 10px; }
.tool-button.icon-only { width: 34px; }
}
</style>
</head>
<body>
<div id="viewport"></div>
<div class="vignette"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div class="brand-copy">
<p class="eyebrow">Structural build study</p>
<h1>Dependency Pavilion</h1>
<div class="interaction-hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
</div>
</div>
<div class="progress-chip"><strong id="progressNumber">01 / 04</strong> Assembly</div>
</header>
<aside class="info-panel" aria-live="polite">
<div class="stage-kicker" id="stageKicker">Stage 01 · Foundations</div>
<h2 id="stageTitle">A stable load path starts below grade.</h2>
<p id="stageDescription"></p>
<div class="support-grid">
<div class="support-cell new">
<span>New assembly</span>
<strong id="newAssembly"></strong>
</div>
<div class="support-cell">
<span>Depends on</span>
<strong id="supportAssembly"></strong>
</div>
</div>
<div class="load-path">
<div class="load-path-label">Continuous load path</div>
<div class="path-row" id="loadPath"></div>
</div>
<div class="retained-note">Earlier geometry stays in place and unchanged.</div>
</aside>
<div class="scene-tools">
<button class="tool-button" id="playButton"><span>▶</span><span>Play sequence</span></button>
<button class="tool-button active" id="linksButton" aria-pressed="true">Links on</button>
<button class="tool-button icon-only" id="zoomIn" aria-label="Zoom in">+</button>
<button class="tool-button icon-only" id="zoomOut" aria-label="Zoom out">−</button>
<button class="tool-button" id="resetView">Reset view</button>
<div class="dependency-legend"><i></i>Support → dependent part</div>
</div>
<nav class="timeline-shell" aria-label="Construction stages">
<div class="timeline-progress" id="timelineProgress"></div>
<div class="timeline" id="timeline"></div>
</nav>
<div id="loader">
<div class="loader-inner">
<div class="loader-cube"></div>
<p>Assembling load paths</p>
</div>
</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
const viewport = document.getElementById('viewport');
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a1217);
scene.fog = new THREE.Fog(0x0a1217, 24, 48);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute(
'aria-label',
'Interactive low-poly pavilion showing four construction stages and support dependencies.'
);
viewport.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xcde8ec, 0x263339, 2.1);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffd7a6, 3.2);
sun.position.set(9, 14, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x59c9dd, 1.3);
fill.position.set(-9, 7, -7);
scene.add(fill);
const warmFill = new THREE.PointLight(0xffa85c, 12, 16, 2);
warmFill.position.set(0, 3.3, 0);
scene.add(warmFill);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
}
// Permanent site context.
const groundMaterial = standardMaterial(0x142329, { roughness: 1 });
const ground = new THREE.Mesh(new THREE.PlaneGeometry(70, 70), groundMaterial);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.025;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(42, 42, 0x416064, 0x263c42);
grid.position.y = -0.005;
grid.material.transparent = true;
grid.material.opacity = 0.3;
grid.material.depthWrite = false;
scene.add(grid);
const siteMaterial = standardMaterial(0x22343a, { roughness: 1 });
const sitePad = new THREE.Mesh(
new THREE.CylinderGeometry(7.5, 7.8, 0.08, 12),
siteMaterial
);
sitePad.position.y = -0.025;
sitePad.receiveShadow = true;
scene.add(sitePad);
function addTree(x, z, scale, color) {
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.12, 0.18, 1.4, 5),
standardMaterial(0x58483b)
);
trunk.position.set(x, 0.7 * scale, z);
trunk.scale.setScalar(scale);
trunk.castShadow = true;
scene.add(trunk);
const crown = new THREE.Mesh(
new THREE.ConeGeometry(0.95, 2.3, 6),
standardMaterial(color, { flatShading: true })
);
crown.position.set(x, 2.1 * scale, z);
crown.scale.setScalar(scale);
crown.castShadow = true;
scene.add(crown);
}
addTree(-8.2, -4.8, 1.15, 0x345c50);
addTree(7.9, -5.5, 0.9, 0x3e6256);
addTree(8.5, 4.8, 1.25, 0x304f48);
addTree(-8.6, 5.6, 0.78, 0x3b5c4e);
const stages = [];
const stageMaterials = [[], [], [], []];
function trackedMaterial(stage, color, options = {}) {
const material = standardMaterial(color, options);
material.emissive.setHex(0x000000);
stageMaterials[stage].push(material);
return material;
}
function makeStage(stage) {
const group = new THREE.Group();
group.name = `Stage ${stage + 1}`;
group.visible = false;
scene.add(group);
stages.push(group);
return group;
}
const foundationStage = makeStage(0);
const frameStage = makeStage(1);
const roofStage = makeStage(2);
const enclosureStage = makeStage(3);
const concrete = trackedMaterial(0, 0x9ca8a4, {
roughness: 0.96,
emissive: 0x18201e
});
const foundationSteel = trackedMaterial(0, 0x435158, {
roughness: 0.5,
metalness: 0.65,
emissive: 0x0d1418
});
const timber = trackedMaterial(1, 0xc78349, {
roughness: 0.72,
emissive: 0x3a1708
});
const timberDark = trackedMaterial(1, 0x805132, {
roughness: 0.78,
emissive: 0x281006
});
const connector = trackedMaterial(1, 0x526269, {
roughness: 0.4,
metalness: 0.72,
emissive: 0x0b1317
});
const roofMaterial = trackedMaterial(2, 0x2d8587, {
roughness: 0.58,
metalness: 0.15,
emissive: 0x062b2d
});
const roofMaterialAlt = trackedMaterial(2, 0x347f82, {
roughness: 0.6,
metalness: 0.14,
emissive: 0x062427
});
const roofTrim = trackedMaterial(2, 0x244e52, {
roughness: 0.48,
metalness: 0.32,
emissive: 0x06191b
});
const glass = trackedMaterial(3, 0x88d5d5, {
roughness: 0.16,
metalness: 0.05,
transparent: true,
opacity: 0.34,
depthWrite: false,
side: THREE.DoubleSide,
emissive: 0x0b3437
});
const enclosureWood = trackedMaterial(3, 0x9b6338, {
roughness: 0.74,
emissive: 0x281006
});
const enclosureMetal = trackedMaterial(3, 0x35494f, {
roughness: 0.42,
metalness: 0.62,
emissive: 0x091316
});
function addMesh(parent, geometry, material, position, order = 0, castShadow = true) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(position);
mesh.userData.order = order;
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(parent, size, position, material, order = 0, castShadow = true) {
return addMesh(
parent,
new THREE.BoxGeometry(size[0], size[1], size[2]),
material,
new THREE.Vector3(...position),
order,
castShadow
);
}
function beamBetween(parent, a, b, width, depth, material, order = 0) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const beam = addMesh(
parent,
new THREE.BoxGeometry(1, 1, 1),
material,
start.clone().add(end).multiplyScalar(0.5),
order
);
beam.scale.set(width, length, depth);
beam.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return beam;
}
const columnPositions = [
[-4.0, -2.6],
[-4.0, 2.6],
[ 0.0, -2.6],
[ 0.0, 2.6],
[ 4.0, -2.6],
[ 4.0, 2.6]
];
// Stage 1: Foundations.
columnPositions.forEach(([x, z], index) => {
addMesh(
foundationStage,
new THREE.CylinderGeometry(0.52, 0.58, 0.34, 8),
concrete,
new THREE.Vector3(x, 0.15, z),
Math.floor(index / 2)
);
addBox(
foundationStage,
[0.42, 0.06, 0.42],
[x, 0.35, z],
foundationSteel,
Math.floor(index / 2) + 1
);
const boltOffsets = [-0.15, 0.15];
boltOffsets.forEach((dx) => {
boltOffsets.forEach((dz) => {
addMesh(
foundationStage,
new THREE.CylinderGeometry(0.035, 0.035, 0.1, 6),
connector,
new THREE.Vector3(x + dx, 0.42, z + dz),
Math.floor(index / 2) + 1
);
});
});
});
// Stage 2: Structural frame.
columnPositions.forEach(([x, z], index) => {
addBox(
frameStage,
[0.25, 3.35, 0.25],
[x, 2.055, z],
timber,
Math.floor(index / 2)
);
addBox(
frameStage,
[0.36, 0.13, 0.36],
[x, 0.47, z],
connector,
Math.floor(index / 2)
);
});
[-2.6, 2.6].forEach((z, index) => {
addBox(
frameStage,
[8.35, 0.23, 0.23],
[0, 3.72, z],
timber,
2
);
});
[-4, 0, 4].forEach((x, index) => {
addBox(
frameStage,
[0.23, 0.23, 5.45],
[x, 3.72, 0],
timberDark,
2 + index
);
});
[-4, 0, 4].forEach((x, index) => {
beamBetween(
frameStage,
[x, 3.83, -3.15],
[x, 5.08, 0],
0.17,
0.17,
timber,
4 + index
);
beamBetween(
frameStage,
[x, 5.08, 0],
[x, 3.83, 3.15],
0.17,
0.17,
timber,
4 + index
);
beamBetween(
frameStage,
[x, 3.79, -2.6],
[x, 3.79, 2.6],
0.16,
0.16,
timberDark,
4 + index
);
beamBetween(
frameStage,
[x, 3.79, 0],
[x, 5.08, 0],
0.14,
0.14,
timberDark,
4 + index
);
});
beamBetween(
frameStage,
[-4.1, 5.08, 0],
[4.1, 5.08, 0],
0.19,
0.19,
timber,
7
);
const braceConnections = [
[[-4, 3.0, -2.6], [-3.3, 3.72, -2.6]],
[[-4, 3.0, 2.6], [-3.3, 3.72, 2.6]],
[[ 4, 3.0, -2.6], [ 3.3, 3.72, -2.6]],
[[ 4, 3.0, 2.6], [ 3.3, 3.72, 2.6]],
[[-4, 3.0, -2.6], [-4, 3.72, -1.95]],
[[-4, 3.0, 2.6], [-4, 3.72, 1.95]],
[[ 4, 3.0, -2.6], [ 4, 3.72, -1.95]],
[[ 4, 3.0, 2.6], [ 4, 3.72, 1.95]]
];
braceConnections.forEach(([a, b], index) => {
beamBetween(frameStage, a, b, 0.12, 0.12, timberDark, 8 + index);
});
// Stage 3: Folded roof panels.
const slopeAngle = Math.atan2(1.42, 3.3);
const slopeLength = Math.sqrt(1.42 * 1.42 + 3.3 * 3.3);
const roofX = [-3.48, -1.16, 1.16, 3.48];
roofX.forEach((x, index) => {
const front = addBox(
roofStage,
[2.28, 0.13, slopeLength + 0.08],
[x, 4.54, -1.65],
index % 2 ? roofMaterialAlt : roofMaterial,
index
);
front.rotation.x = -slopeAngle;
const back = addBox(
roofStage,
[2.28, 0.13, slopeLength + 0.08],
[x, 4.54, 1.65],
index % 2 ? roofMaterial : roofMaterialAlt,
index + 4
);
back.rotation.x = slopeAngle;
});
const ridge = addMesh(
roofStage,
new THREE.CylinderGeometry(0.17, 0.17, 9.35, 3),
roofTrim,
new THREE.Vector3(0, 5.32, 0),
8
);
ridge.rotation.z = Math.PI / 2;
beamBetween(
roofStage,
[-4.65, 3.73, -3.36],
[4.65, 3.73, -3.36],
0.16,
0.16,
roofTrim,
9
);
beamBetween(
roofStage,
[-4.65, 3.73, 3.36],
[4.65, 3.73, 3.36],
0.16,
0.16,
roofTrim,
9
);
// Stage 4: Enclosure, leaving the front-right bay open as an entry.
function backAndFrontBay(z, x, order, includeGlass = true) {
addBox(
enclosureStage,
[3.78, 0.67, 0.09],
[x, 0.79, z],
enclosureWood,
order
);
addBox(
enclosureStage,
[3.87, 0.11, 0.12],
[x, 1.09, z],
enclosureMetal,
order + 1
);
addBox(
enclosureStage,
[3.87, 0.12, 0.12],
[x, 3.42, z],
enclosureMetal,
order + 3
);
if (includeGlass) {
addBox(
enclosureStage,
[3.77, 2.20, 0.055],
[x, 2.23, z],
glass,
order + 2,
false
);
}
}
backAndFrontBay(-2.58, -2, 0);
backAndFrontBay(-2.58, 2, 3);
backAndFrontBay( 2.58, -2, 6);
backAndFrontBay( 2.58, 2, 9, false);
[-4, -2, 0, 2, 4].forEach((x, index) => {
[-2.58, 2.58].forEach((z, side) => {
addBox(
enclosureStage,
[0.1, 3.13, 0.11],
[x, 2.0, z],
enclosureMetal,
12 + index + side * 0.1
);
});
});
[-3.98, 3.98].forEach((x, index) => {
addBox(
enclosureStage,
[0.09, 0.67, 5.0],
[x, 0.79, 0],
enclosureWood,
13 + index
);
addBox(
enclosureStage,
[0.055, 2.2, 4.98],
[x, 2.23, 0],
glass,
14 + index,
false
);
[1.09, 3.42].forEach((y, rail) => {
addBox(
enclosureStage,
[0.12, 0.12, 5.05],
[x, y, 0],
enclosureMetal,
15 + index + rail * 0.1
);
});
});
addBox(
enclosureStage,
[3.82, 0.08, 0.34],
[2, 0.04, 2.58],
foundationSteel,
16
);
// Cache final transforms for non-destructive reveal animations.
stages.forEach((group) => {
group.traverse((object) => {
if (!object.isMesh) return;
object.userData.finalPosition = object.position.clone();
object.userData.finalScale = object.scale.clone();
object.userData.finalQuaternion = object.quaternion.clone();
});
});
const revealTweens = [];
function cancelReveals(group) {
for (let i = revealTweens.length - 1; i >= 0; i--) {
if (revealTweens[i].group === group) {
revealTweens.splice(i, 1);
}
}
}
function queueReveal(group, delay = 0) {
cancelReveals(group);
group.visible = true;
const meshes = [];
group.traverse((object) => {
if (object.isMesh) meshes.push(object);
});
meshes.forEach((object) => {
const finalPosition = object.userData.finalPosition;
const finalScale = object.userData.finalScale;
const finalQuaternion = object.userData.finalQuaternion;
const order = object.userData.order || 0;
const fromPosition = finalPosition.clone();
fromPosition.y -= 0.65;
const fromScale = finalScale.clone();
fromScale.x *= 0.72;
fromScale.y = Math.max(0.02, finalScale.y * 0.04);
fromScale.z *= 0.72;
object.position.copy(fromPosition);
object.scale.copy(fromScale);
object.quaternion.copy(finalQuaternion);
revealTweens.push({
group,
object,
start: performance.now() + delay + order * 48,
duration: 720,
fromPosition,
toPosition: finalPosition.clone(),
fromScale,
toScale: finalScale.clone(),
fromQuaternion: finalQuaternion.clone(),
toQuaternion: finalQuaternion.clone()
});
});
}
function updateReveals(now) {
for (let i = revealTweens.length - 1; i >= 0; i--) {
const tween = revealTweens[i];
if (now < tween.start) continue;
const raw = Math.min(1, (now - tween.start) / tween.duration);
const eased = 1 - Math.pow(1 - raw, 3);
tween.object.position.lerpVectors(
tween.fromPosition,
tween.toPosition,
eased
);
tween.object.scale.lerpVectors(
tween.fromScale,
tween.toScale,
eased
);
tween.object.quaternion
.copy(tween.fromQuaternion)
.slerp(tween.toQuaternion, eased);
if (raw >= 1) {
revealTweens.splice(i, 1);
}
}
}
// Dependency visualization: support point → dependent point.
const dependencyGroup = new THREE.Group();
scene.add(dependencyGroup);
let dependencyPulses = [];
let linksEnabled = true;
function clearDependencies() {
while (dependencyGroup.children.length) {
const child = dependencyGroup.children[0];
dependencyGroup.remove(child);
if (child.geometry) child.geometry.dispose();
if (child.material) child.material.dispose();
}
dependencyPulses = [];
}
function addDependency(startArray, endArray) {
const start = new THREE.Vector3(...startArray);
const end = new THREE.Vector3(...endArray);
const lineGeometry = new THREE.BufferGeometry().setFromPoints([start, end]);
const lineMaterial = new THREE.LineDashedMaterial({
color: 0x6de3d3,
dashSize: 0.13,
gapSize: 0.08,
transparent: true,
opacity: 0.92,
depthTest: false,
depthWrite: false
});
const line = new THREE.Line(lineGeometry, lineMaterial);
line.computeLineDistances();
line.renderOrder = 20;
dependencyGroup.add(line);
const supportMarker = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 8, 6),
new THREE.MeshBasicMaterial({
color: 0x80d99b,
transparent: true,
opacity: 0.95,
depthTest: false
})
);
supportMarker.position.copy(start);
supportMarker.renderOrder = 21;
dependencyGroup.add(supportMarker);
const dependentMarker = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 8, 6),
new THREE.MeshBasicMaterial({
color: 0xf0a45d,
transparent: true,
opacity: 0.95,
depthTest: false
})
);
dependentMarker.position.copy(end);
dependentMarker.renderOrder = 21;
dependencyGroup.add(dependentMarker);
const pulse = new THREE.Mesh(
new THREE.SphereGeometry(0.065, 8, 6),
new THREE.MeshBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.95,
depthTest: false
})
);
pulse.renderOrder = 22;
dependencyGroup.add(pulse);
dependencyPulses.push({
mesh: pulse,
start,
end,
phase: dependencyPulses.length * 0.137
});
}
function buildDependencies(stage) {
clearDependencies();
if (stage === 0) {
columnPositions.forEach(([x, z]) => {
addDependency([x, -0.18, z], [x, 0.18, z]);
});
}
if (stage === 1) {
columnPositions.forEach(([x, z]) => {
addDependency([x, 0.29, z], [x, 0.78, z]);
});
}
if (stage === 2) {
[-4, 0, 4].forEach((x) => {
[-1, 1].forEach((side) => {
const z = side * 1.15;
const supportY = 3.83 + (5.08 - 3.83) * (1 - Math.abs(z) / 3.15);
addDependency([x, supportY, z], [x, supportY + 0.31, z]);
});
});
}
if (stage === 3) {
[-2.58, 2.58].forEach((z) => {
[-4, 4].forEach((x) => {
addDependency([x, 3.83, z], [x, 3.39, z]);
});
});
[-3.98, 3.98].forEach((x) => {
addDependency([x, 3.83, 0], [x, 3.39, 0]);
});
}
dependencyGroup.visible = linksEnabled;
}
function updateDependencyPulses(now) {
dependencyPulses.forEach((pulse) => {
const t = (now * 0.00042 + pulse.phase) % 1;
pulse.mesh.position.lerpVectors(pulse.start, pulse.end, t);
const scale = 0.8 + Math.sin(t * Math.PI) * 0.75;
pulse.mesh.scale.setScalar(scale);
});
}
const stageMeta = [
{
name: 'Foundations',
subtitle: '6 isolated pad footings',
kicker: 'Stage 01 · Foundations',
title: 'A stable load path starts below grade.',
description: 'Six octagonal concrete pads and steel base plates transfer the future frame into the prepared ground.',
newAssembly: 'Pad footings + steel base plates',
support: 'Prepared ground / soil',
pathLabel: 'Ground'
},
{
name: 'Structural frame',
subtitle: 'Posts, beams & trusses',
kicker: 'Stage 02 · Structural frame',
title: 'Every post rises from a verified footing.',
description: 'Timber posts, perimeter beams, braces, and trusses form a continuous frame while the foundation geometry remains intact.',
newAssembly: 'Posts + ring beams + roof trusses',
support: 'Foundation pads + base plates',
pathLabel: 'Foundations'
},
{
name: 'Roof',
subtitle: '8 panels + ridge cap',
kicker: 'Stage 03 · Roof',
title: 'The roof lands directly on the trusses.',
description: 'Eight folded roof panels and a triangular ridge cap complete the primary weather barrier without replacing any frame members.',
newAssembly: 'Roof panels + ridge + eave trim',
support: 'Posts, ring beams & roof trusses',
pathLabel: 'Frame'
},
{
name: 'Enclosure',
subtitle: 'Glazing + lower panels',
kicker: 'Stage 04 · Enclosure',
title: 'The pavilion is skinned, not rebuilt.',
description: 'Glazing, mullions, privacy panels, and an open entry bay are added around the retained frame and completed roof.',
newAssembly: 'Glazing + mullions + lower panels',
support: 'Perimeter frame + completed roof',
pathLabel: 'Enclosure'
}
];
const timeline = document.getElementById('timeline');
timeline.innerHTML = stageMeta.map((stage, index) => `
<button class="stage-button" data-stage="${index}" aria-label="Show ${stage.name}">
<span class="step-number">${String(index + 1).padStart(2, '0')}</span>
<strong>${stage.name}</strong>
<small>${stage.subtitle}</small>
</button>
`).join('');
const stageButtons = [...document.querySelectorAll('.stage-button')];
const stageKicker = document.getElementById('stageKicker');
const stageTitle = document.getElementById('stageTitle');
const stageDescription = document.getElementById('stageDescription');
const newAssembly = document.getElementById('newAssembly');
const supportAssembly = document.getElementById('supportAssembly');
const progressNumber = document.getElementById('progressNumber');
const timelineProgress = document.getElementById('timelineProgress');
const loadPath = document.getElementById('loadPath');
loadPath.innerHTML = [
'Ground',
'Foundations',
'Frame',
'Roof',
'Enclosure'
].map((label, index) => {
const arrow = index ? '<span class="path-arrow">→</span>' : '';
return `${arrow}<span class="path-node" data-path-node="${index}">${label}</span>`;
}).join('');
const pathNodes = [...document.querySelectorAll('[data-path-node]')];
let currentStage = -1;
let autoBuild = false;
let nextAutoBuildAt = 0;
function updateInterface() {
const meta = stageMeta[currentStage];
stageKicker.textContent = meta.kicker;
stageTitle.textContent = meta.title;
stageDescription.textContent = meta.description;
newAssembly.textContent = meta.newAssembly;
supportAssembly.textContent = meta.support;
progressNumber.textContent = `${String(currentStage + 1).padStart(2, '0')} / 04`;
timelineProgress.style.width = `${(currentStage / 3) * 100}%`;
stageButtons.forEach((button, index) => {
button.classList.toggle('active', index === currentStage);
button.classList.toggle('completed', index < currentStage);
if (index === currentStage) {
button.setAttribute('aria-current', 'step');
} else {
button.removeAttribute('aria-current');
}
});
pathNodes.forEach((node, index) => {
node.classList.toggle('active', index === currentStage + 1);
node.classList.toggle('done', index <= currentStage);
});
stageMaterials.forEach((materials, index) => {
materials.forEach((material) => {
material.emissiveIntensity = index === currentStage ? 0.16 : 0;
});
});
}
function setStage(nextStage) {
nextStage = THREE.MathUtils.clamp(nextStage, 0, stages.length - 1);
const previousStage = currentStage;
currentStage = nextStage;
if (previousStage >= 0 && nextStage < previousStage) {
for (let i = nextStage + 1; i < stages.length; i++) {
cancelReveals(stages[i]);
stages[i].visible = false;
}
} else {
for (let i = Math.max(0, previousStage + 1); i <= nextStage; i++) {
const delay = (i - previousStage - 1) * 650;
queueReveal(stages[i], delay);
}
}
buildDependencies(currentStage);
updateInterface();
}
timeline.addEventListener('click', (event) => {
const button = event.target.closest('[data-stage]');
if (!button) return;
autoBuild = false;
updatePlayButton();
setStage(Number(button.dataset.stage));
});
// Custom camera controls implemented without external addons.
const controls = {
target: new THREE.Vector3(0, 2.15, 0),
theta: 0.69,
phi: 1.08,
radius: 17.5,
desiredTheta: 0.69,
desiredPhi: 1.08,
desiredRadius: 17.5,
dragging: false,
lastX: 0,
lastY: 0
};
function updateCamera(dt) {
const damping = 1 - Math.pow(0.001, dt);
controls.theta += (controls.desiredTheta - controls.theta) * damping;
controls.phi += (controls.desiredPhi - controls.phi) * damping;
controls.radius += (controls.desiredRadius - controls.radius) * damping;
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.desiredTheta = 0.69;
controls.desiredPhi = 1.08;
controls.desiredRadius = window.innerWidth < 700 ? 19.5 : 17.5;
controls.target.set(0, 2.15, 0);
}
renderer.domElement.addEventListener('pointerdown', (event) => {
controls.dragging = true;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener('pointermove', (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
if (event.shiftKey) {
const right = new THREE.Vector3();
camera.getWorldDirection(right);
right.cross(camera.up).normalize();
const panScale = controls.radius * 0.0013;
controls.target.addScaledVector(right, -dx * panScale);
controls.target.y += dy * panScale;
controls.target.y = THREE.MathUtils.clamp(controls.target.y, 0.5, 6);
} else {
controls.desiredTheta -= dx * 0.006;
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi - dy * 0.006,
0.35,
1.43
);
}
});
function endPointerDrag(event) {
controls.dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener('pointerup', endPointerDrag);
renderer.domElement.addEventListener('pointercancel', endPointerDrag);
renderer.domElement.addEventListener('contextmenu', (event) => event.preventDefault());
renderer.domElement.addEventListener('wheel', (event) => {
event.preventDefault();
controls.desiredRadius = THREE.MathUtils.clamp(
controls.desiredRadius * Math.exp(event.deltaY * 0.001),
9,
30
);
}, { passive: false });
renderer.domElement.addEventListener('dblclick', resetCamera);
const playButton = document.getElementById('playButton');
const linksButton = document.getElementById('linksButton');
function updatePlayButton() {
playButton.classList.toggle('active', autoBuild);
playButton.innerHTML = autoBuild
? '<span>Ⅱ</span><span>Pause sequence</span>'
: '<span>▶</span><span>Play sequence</span>';
}
playButton.addEventListener('click', () => {
autoBuild = !autoBuild;
nextAutoBuildAt = performance.now() + 1000;
if (autoBuild && currentStage === stages.length - 1) {
autoBuild = false;
setStage(0);
nextAutoBuildAt = performance.now() + 800;
autoBuild = true;
}
updatePlayButton();
});
linksButton.addEventListener('click', () => {
linksEnabled = !linksEnabled;
dependencyGroup.visible = linksEnabled;
linksButton.classList.toggle('active', linksEnabled);
linksButton.setAttribute('aria-pressed', String(linksEnabled));
linksButton.textContent = linksEnabled ? 'Links on' : 'Links off';
});
document.getElementById('resetView').addEventListener('click', resetCamera);
document.getElementById('zoomIn').addEventListener('click', () => {
controls.desiredRadius = Math.max(9, controls.desiredRadius * 0.86);
});
document.getElementById('zoomOut').addEventListener('click', () => {
controls.desiredRadius = Math.min(30, controls.desiredRadius * 1.16);
});
window.addEventListener('keydown', (event) => {
if (event.key === 'ArrowRight') {
autoBuild = false;
updatePlayButton();
setStage(currentStage + 1);
}
if (event.key === 'ArrowLeft') {
autoBuild = false;
updatePlayButton();
setStage(currentStage - 1);
}
});
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener('resize', resize);
let previousTime = performance.now();
function animate(now) {
const dt = Math.min(0.05, (now - previousTime) / 1000);
previousTime = now;
updateCamera(dt);
updateReveals(now);
updateDependencyPulses(now);
const pulse = 0.14 + Math.sin(now * 0.0026) * 0.05;
stageMaterials[currentStage].forEach((material) => {
material.emissiveIntensity = pulse;
});
if (autoBuild && currentStage < stages.length - 1 && now >= nextAutoBuildAt) {
setStage(currentStage + 1);
nextAutoBuildAt = now + 2800;
if (currentStage === stages.length - 1) {
autoBuild = false;
updatePlayButton();
}
}
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
resetCamera();
setStage(0);
updatePlayButton();
requestAnimationFrame(animate);
setTimeout(() => {
document.getElementById('loader').classList.add('hidden');
}, 450);
</script>
</body>
</html>
```