Prompt specification
Build or customize the Three.js 3D scene "Centering removal demonstration" 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: Centering removal demonstration
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/centering-removal-demonstration-x0390
Scene Description Prompt:
Assemble a voxel block arch, lower its curved support, and show schematic compression arrows in a simplified model. One HTML; Three.js from cdnjs.
Working Three.js Starter (centering-removal-demonstration-x0390):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Arch Lab</title>
<style>
:root {
--bg: #081116;
--panel: rgba(13, 24, 31, 0.82);
--line: rgba(176, 219, 226, 0.17);
--text: #e7f2f3;
--muted: #91a7ad;
--cyan: #72e6df;
--amber: #f2ad58;
}
* { 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;
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.panel {
pointer-events: auto;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 14px;
box-shadow: 0 16px 50px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
header {
position: absolute;
top: 22px;
left: 22px;
padding: 17px 19px;
min-width: 290px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 7px;
height: 7px;
border-radius: 2px;
background: var(--cyan);
box-shadow: 0 0 15px rgba(114, 230, 223, 0.8);
}
h1 {
margin: 8px 0 4px;
font-size: 25px;
font-weight: 760;
letter-spacing: -0.035em;
}
.subtitle {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.status {
position: absolute;
top: 22px;
right: 22px;
width: 245px;
padding: 16px 17px;
}
.status-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
}
.label {
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#phase {
margin-top: 12px;
color: var(--text);
font-size: 14px;
font-weight: 750;
}
#phase-note {
min-height: 32px;
margin-top: 4px;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.progress {
height: 3px;
margin-top: 13px;
overflow: hidden;
border-radius: 3px;
background: rgba(255, 255, 255, 0.08);
}
#progress-fill {
width: 0;
height: 100%;
background: linear-gradient(90deg, var(--cyan), #d5fffa);
box-shadow: 0 0 12px rgba(114, 230, 223, 0.55);
}
.controls {
position: absolute;
left: 50%;
bottom: 25px;
display: flex;
align-items: center;
gap: 7px;
padding: 8px;
transform: translateX(-50%);
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 9px;
padding: 9px 12px;
background: rgba(255, 255, 255, 0.055);
color: var(--text);
font: inherit;
font-size: 11px;
font-weight: 720;
cursor: pointer;
white-space: nowrap;
transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
button:hover {
border-color: rgba(114, 230, 223, 0.45);
background: rgba(114, 230, 223, 0.1);
transform: translateY(-1px);
}
button.primary {
border-color: rgba(114, 230, 223, 0.5);
background: rgba(114, 230, 223, 0.14);
color: #c8fffb;
}
button.active {
border-color: rgba(114, 230, 223, 0.65);
background: rgba(114, 230, 223, 0.18);
color: #d7fffc;
}
.legend {
position: absolute;
left: 22px;
bottom: 25px;
width: 245px;
padding: 15px 16px;
}
.legend-item {
display: flex;
align-items: center;
gap: 10px;
margin-top: 11px;
color: var(--muted);
font-size: 11px;
}
.swatch {
width: 27px;
height: 4px;
border-radius: 4px;
flex: 0 0 auto;
}
.swatch.arch { background: #c89a67; }
.swatch.support { background: var(--amber); }
.swatch.force { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.help {
position: absolute;
right: 22px;
bottom: 30px;
color: rgba(215, 232, 235, 0.55);
font-size: 10px;
letter-spacing: 0.04em;
text-align: right;
line-height: 1.6;
}
.timeline {
position: absolute;
left: 22px;
right: 22px;
bottom: 89px;
display: flex;
align-items: center;
gap: 13px;
padding: 10px 14px;
}
.timeline span {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
white-space: nowrap;
}
input[type="range"] {
width: 100%;
height: 3px;
margin: 0;
appearance: none;
border-radius: 4px;
background: rgba(255, 255, 255, 0.13);
outline: none;
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 14px;
height: 14px;
appearance: none;
border: 2px solid #092026;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 0 3px rgba(114, 230, 223, 0.14);
}
input[type="range"]::-moz-range-thumb {
width: 12px;
height: 12px;
border: 2px solid #092026;
border-radius: 50%;
background: var(--cyan);
}
@media (max-width: 760px) {
header {
top: 12px;
left: 12px;
min-width: 0;
padding: 13px 15px;
}
h1 { font-size: 19px; }
.subtitle { display: none; }
.status {
top: 12px;
right: 12px;
width: 175px;
padding: 12px;
}
#phase-note { display: none; }
.legend { display: none; }
.timeline {
left: 12px;
right: 12px;
bottom: 76px;
}
.controls {
bottom: 13px;
width: calc(100% - 24px);
justify-content: center;
overflow-x: auto;
}
button { padding: 8px 10px; }
.help { display: none; }
}
</style>
</head>
<body>
<div id="stage"></div>
<div class="hud">
<header class="panel">
<div class="eyebrow">Structural model 01</div>
<h1>Voxel Arch Lab</h1>
<p class="subtitle">Assembly, centering release, and schematic compression flow.</p>
</header>
<section class="panel status">
<div class="status-row">
<span class="label">Current phase</span>
<span class="label" id="time">00.0 s</span>
</div>
<div id="phase">Foundation</div>
<div id="phase-note">Preparing the voxel abutments.</div>
<div class="progress"><div id="progress-fill"></div></div>
</section>
<section class="panel timeline">
<span>Timeline</span>
<input id="scrub" type="range" min="0" max="10.5" step="0.01" value="0"
aria-label="Animation timeline" />
</section>
<section class="panel legend">
<div class="label">Model key</div>
<div class="legend-item">
<span class="swatch arch"></span>
<span>Voxel masonry / arch ring</span>
</div>
<div class="legend-item">
<span class="swatch support"></span>
<span>Lowerable curved centering</span>
</div>
<div class="legend-item">
<span class="swatch force"></span>
<span>Compression force path</span>
</div>
</section>
<section class="panel controls">
<button id="replay" class="primary">Replay</button>
<button id="play">Pause</button>
<button id="lower">Lower support</button>
<button id="arrows" class="active">Arrows on</button>
<button id="view">Reset view</button>
</section>
<div class="help">
Drag to orbit · Scroll to zoom<br />
Scrub the timeline to inspect each stage
</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 stage = document.getElementById("stage");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x081116);
scene.fog = new THREE.Fog(0x081116, 14, 30);
const camera = new THREE.PerspectiveCamera(43, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
// Lighting
scene.add(new THREE.HemisphereLight(0xc7e9f2, 0x172029, 1.75));
const key = new THREE.DirectionalLight(0xffdfb2, 3.2);
key.position.set(-5, 9, 7);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -8;
key.shadow.camera.right = 8;
key.shadow.camera.top = 9;
key.shadow.camera.bottom = -5;
key.shadow.camera.near = 1;
key.shadow.camera.far = 25;
key.shadow.normalBias = 0.025;
scene.add(key);
const rim = new THREE.PointLight(0x59d9df, 28, 18, 2);
rim.position.set(5, 4, -3);
scene.add(rim);
// Ground and graphic grid
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0x0c171d,
roughness: 0.93,
metalness: 0.03
});
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.04;
ground.receiveShadow = true;
scene.add(ground);
const plinth = new THREE.Mesh(
new THREE.BoxGeometry(7.2, 0.16, 3.4),
new THREE.MeshStandardMaterial({
color: 0x14232b,
roughness: 0.7,
metalness: 0.15
})
);
plinth.position.y = -0.13;
plinth.receiveShadow = true;
scene.add(plinth);
const grid = new THREE.GridHelper(22, 44, 0x35606a, 0x213841);
grid.position.y = 0.005;
grid.material.transparent = true;
grid.material.opacity = 0.23;
scene.add(grid);
// Model dimensions
const RADIUS = 2.55;
const SPRING_Y = 2.35;
const BLOCK_COUNT = 19;
const ARCH_DEPTH = 1.25;
const RADIAL_THICKNESS = 0.7;
const palette = [
0xb98255,
0xc79567,
0xd0a173,
0xba895d,
0xc99a6c
];
function createVoxel(width, height, depth, color, accent = false) {
const group = new THREE.Group();
const material = new THREE.MeshStandardMaterial({
color,
roughness: accent ? 0.55 : 0.8,
metalness: accent ? 0.12 : 0.025,
emissive: 0x092a2c,
emissiveIntensity: 0
});
const geometry = new THREE.BoxGeometry(width, height, depth);
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry),
new THREE.LineBasicMaterial({
color: 0x33261f,
transparent: true,
opacity: 0.58
})
);
group.add(mesh, edges);
return { group, mesh, material };
}
// Abutments assembled from stacked voxel courses
const pierEntries = [];
const pierTop = SPRING_Y - 0.08;
const pierBase = 0.06;
const courseGap = 0.035;
const courseCount = 4;
const courseHeight = (pierTop - pierBase - courseGap * 3) / courseCount;
for (const side of [-1, 1]) {
for (let course = 0; course < courseCount; course++) {
const entry = createVoxel(
1.02,
courseHeight,
1.36,
palette[(course + (side > 0 ? 1 : 0)) % palette.length]
);
const x = side * RADIUS;
const y = pierBase + courseHeight * 0.5 +
course * (courseHeight + courseGap);
entry.target = new THREE.Vector3(x, y, 0);
entry.group.position.copy(entry.target);
scene.add(entry.group);
pierEntries.push({ ...entry, course });
}
// Wider footing blocks
const foot = createVoxel(1.35, 0.22, 1.58, 0x86684e);
foot.group.position.set(side * RADIUS, 0.02, 0);
foot.group.receiveShadow = true;
scene.add(foot.group);
}
// Semicircular ring of tangential voxel blocks
const archEntries = [];
const angleStep = Math.PI / (BLOCK_COUNT - 1);
const tangentLength = RADIUS * angleStep * 0.91;
for (let i = 0; i < BLOCK_COUNT; i++) {
const theta = i * angleStep;
const isKey = i === Math.floor(BLOCK_COUNT / 2);
const entry = createVoxel(
isKey ? tangentLength * 1.26 : tangentLength,
RADIAL_THICKNESS,
isKey ? ARCH_DEPTH * 1.06 : ARCH_DEPTH,
isKey ? 0xe0b477 : palette[i % palette.length],
isKey
);
const target = new THREE.Vector3(
RADIUS * Math.cos(theta),
SPRING_Y + RADIUS * Math.sin(theta),
0
);
const rotation = theta + Math.PI * 0.5;
const radial = new THREE.Vector3(
Math.cos(theta),
Math.sin(theta),
0
);
const start = target.clone()
.addScaledVector(radial, 1.65)
.add(new THREE.Vector3(0, 1.15, -1.15));
entry.group.position.copy(start);
entry.group.rotation.z = rotation + 0.45 * (i % 2 ? 1 : -1);
scene.add(entry.group);
archEntries.push({
...entry,
theta,
target,
start,
rotation,
isKey
});
}
// Lowerable curved centering support
const supportRadius = 2.13;
const supportArc = new THREE.Group();
const supportProps = [];
const supportArcMaterial = new THREE.MeshStandardMaterial({
color: 0xf2ad58,
roughness: 0.46,
metalness: 0.42,
transparent: true,
opacity: 0.55
});
for (let i = 0; i < BLOCK_COUNT; i++) {
const theta = i * angleStep;
const segment = new THREE.Mesh(
new THREE.BoxGeometry(tangentLength * 0.82, 0.12, 1.02),
supportArcMaterial
);
segment.position.set(
supportRadius * Math.cos(theta),
SPRING_Y + supportRadius * Math.sin(theta),
0
);
segment.rotation.z = theta + Math.PI * 0.5;
segment.castShadow = true;
supportArc.add(segment);
}
scene.add(supportArc);
const propMaterial = new THREE.MeshStandardMaterial({
color: 0xd98a38,
roughness: 0.5,
metalness: 0.35,
transparent: true,
opacity: 0.72
});
for (const theta of [
Math.PI / 6,
Math.PI / 3,
Math.PI / 2,
Math.PI * 2 / 3,
Math.PI * 5 / 6
]) {
const x = supportRadius * Math.cos(theta);
const top = SPRING_Y + supportRadius * Math.sin(theta);
const bottom = 0.08;
const height = top - bottom;
const prop = new THREE.Mesh(
new THREE.BoxGeometry(0.13, 1, 0.13),
propMaterial
);
prop.scale.y = height;
prop.position.set(x, bottom + height * 0.5, 0);
prop.castShadow = true;
scene.add(prop);
supportProps.push({ mesh: prop, x, bottom, top });
}
// Schematic compression arrows, drawn in front of the masonry
const arrowObjects = [];
const forceColor = 0x72e6df;
function addArrow(origin, direction, length = 0.58) {
const arrow = new THREE.ArrowHelper(
direction.clone().normalize(),
origin.clone(),
length,
forceColor,
0.16,
0.11
);
for (const part of [arrow.line, arrow.cone]) {
part.material.transparent = true;
part.material.opacity = 0;
part.material.depthTest = false;
part.renderOrder = 20;
}
scene.add(arrow);
arrowObjects.push(arrow);
return arrow;
}
const arrowLength = 0.58;
const arrowRadius = RADIUS - 0.02;
const arrowZ = ARCH_DEPTH * 0.5 + 0.11;
// Right half: crown toward right springing.
for (let k = 0; k < 6; k++) {
const theta = Math.PI * 0.5 -
k * (Math.PI * 0.5 - 0.13) / 5;
const position = new THREE.Vector3(
arrowRadius * Math.cos(theta),
SPRING_Y + arrowRadius * Math.sin(theta),
arrowZ
);
const direction = new THREE.Vector3(
Math.sin(theta),
-Math.cos(theta),
0
);
addArrow(
position.clone().addScaledVector(direction, -arrowLength * 0.5),
direction,
arrowLength
);
}
// Left half: crown toward left springing.
for (let k = 0; k < 6; k++) {
const theta = Math.PI * 0.5 +
k * (Math.PI * 0.5 - 0.13) / 5;
const position = new THREE.Vector3(
arrowRadius * Math.cos(theta),
SPRING_Y + arrowRadius * Math.sin(theta),
arrowZ
);
const direction = new THREE.Vector3(
-Math.sin(theta),
Math.cos(theta),
0
);
addArrow(
position.clone().addScaledVector(direction, -arrowLength * 0.5),
direction,
arrowLength
);
}
// Downward arrows into the abutments
for (const side of [-1, 1]) {
addArrow(
new THREE.Vector3(side * RADIUS, SPRING_Y - 0.42, arrowZ),
new THREE.Vector3(0, -1, 0),
1.12
);
}
// Moving force pulses
const pulseMaterial = new THREE.MeshBasicMaterial({
color: 0xc8fffb,
transparent: true,
opacity: 0,
depthTest: false
});
const pulses = [];
for (const side of [-1, 1]) {
const pulse = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 14, 10),
pulseMaterial.clone()
);
pulse.renderOrder = 25;
scene.add(pulse);
pulses.push({ mesh: pulse, side });
}
// Direct camera controls, implemented without add-ons
const orbit = {
theta: 0.56,
phi: 1.12,
radius: 11.8,
target: new THREE.Vector3(0, 2.35, 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);
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi + dy * 0.005, 0.48, 1.43);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
7.2,
18
);
updateCamera();
}, { passive: false });
// Animation state
const DURATION = 10.5;
let timeline = 0;
let playing = true;
let arrowsEnabled = true;
let scrubbing = false;
let lastTime = performance.now();
const scrub = document.getElementById("scrub");
const playButton = document.getElementById("play");
const arrowsButton = document.getElementById("arrows");
const phaseElement = document.getElementById("phase");
const phaseNote = document.getElementById("phase-note");
const timeElement = document.getElementById("time");
const progressFill = document.getElementById("progress-fill");
function smoothstep(value, min, max) {
const x = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return x * x * (3 - 2 * x);
}
function updateAssembly(time) {
for (const entry of pierEntries) {
const delay = 0.08 + entry.course * 0.13;
const p = smoothstep(time, delay, delay + 0.72);
const eased = 1 - Math.pow(1 - p, 3);
entry.group.visible = p > 0.001;
entry.group.scale.setScalar(Math.max(0.001, eased));
entry.group.position.set(
entry.target.x,
entry.target.y - 0.34 * (1 - eased),
0
);
}
for (const entry of archEntries) {
const rank = Math.min(
entry.theta / angleStep,
(BLOCK_COUNT - 1) - entry.theta / angleStep
);
const delay = 0.72 + rank * 0.27;
const p = THREE.MathUtils.clamp((time - delay) / 0.98, 0, 1);
const eased = 1 - Math.pow(1 - p, 3);
entry.group.visible = p > 0.001;
entry.group.scale.setScalar(Math.max(0.001, eased));
entry.group.position.lerpVectors(entry.start, entry.target, eased);
entry.group.rotation.z =
entry.rotation + (1 - eased) * 0.45 * (entry.isKey ? -1 : 1);
const glow = arrowsEnabled
? smoothstep(time, 8.15, 9.15) * 0.12
: 0;
entry.material.emissiveIntensity = glow;
}
}
function updateSupport(time) {
const lowering = smoothstep(time, 5.15, 8.15);
const drop = lowering * 1.35;
const appearance = smoothstep(time, 0.15, 1.1);
supportArcMaterial.opacity = appearance * 0.55;
propMaterial.opacity = appearance * 0.72;
for (const child of supportArc.children) {
child.position.y = child.userData.baseY ?? child.position.y;
}
// Store base heights once, then lower each segment smoothly.
if (!supportArc.userData.initialized) {
supportArc.children.forEach(child => {
child.userData.baseY = child.position.y;
});
supportArc.userData.initialized = true;
}
for (const child of supportArc.children) {
child.position.y = child.userData.baseY - drop;
}
for (const prop of supportProps) {
const top = prop.top - drop;
const height = Math.max(0.12, top - prop.bottom);
prop.mesh.scale.y = height;
prop.mesh.position.y = prop.bottom + height * 0.5;
}
}
function updateArrows(time, now) {
const reveal = smoothstep(time, 8.15, 9.15) * (arrowsEnabled ? 1 : 0);
for (const arrow of arrowObjects) {
arrow.visible = reveal > 0.005;
arrow.line.material.opacity = reveal * 0.92;
arrow.cone.material.opacity = reveal;
}
const pulsePhase = (now * 0.00019) % 1;
for (const pulse of pulses) {
const u = (pulsePhase + (pulse.side > 0 ? 0 : 0.48)) % 1;
const theta = pulse.side > 0
? Math.PI * 0.5 * (1 - u) + 0.035
: Math.PI * 0.5 * (1 + u) - 0.035;
pulse.mesh.position.set(
arrowRadius * Math.cos(theta),
SPRING_Y + arrowRadius * Math.sin(theta),
arrowZ + 0.035
);
pulse.mesh.material.opacity = reveal * 0.92;
pulse.mesh.visible = reveal > 0.005;
}
}
function updateHUD(time) {
scrub.value = time;
progressFill.style.width = `${(time / DURATION) * 100}%`;
timeElement.textContent = `${time.toFixed(1).padStart(4, "0")} s`;
if (time < 1.2) {
phaseElement.textContent = "Foundation";
phaseNote.textContent = "Preparing the voxel abutments.";
} else if (time < 5.15) {
phaseElement.textContent = "Voxel assembly";
phaseNote.textContent = "Masonry courses rise symmetrically toward the crown.";
} else if (time < 8.15) {
phaseElement.textContent = "Centering release";
phaseNote.textContent = "The curved falsework is lowered below the arch.";
} else if (time < 9.15) {
phaseElement.textContent = "Load path";
phaseNote.textContent = "Revealing the schematic compression route.";
} else {
phaseElement.textContent = "Compression state";
phaseNote.textContent = "Force flows from the crown toward both supports.";
}
}
function syncPlayButton() {
playButton.textContent = playing ? "Pause" : "Play";
}
document.getElementById("replay").addEventListener("click", () => {
timeline = 0;
playing = true;
syncPlayButton();
});
playButton.addEventListener("click", () => {
if (timeline >= DURATION) timeline = 0;
playing = !playing;
syncPlayButton();
});
document.getElementById("lower").addEventListener("click", () => {
timeline = Math.max(timeline, 5.05);
playing = true;
syncPlayButton();
});
arrowsButton.addEventListener("click", () => {
arrowsEnabled = !arrowsEnabled;
arrowsButton.textContent = arrowsEnabled ? "Arrows on" : "Arrows off";
arrowsButton.classList.toggle("active", arrowsEnabled);
});
document.getElementById("view").addEventListener("click", () => {
orbit.theta = 0.56;
orbit.phi = 1.12;
orbit.radius = 11.8;
orbit.target.set(0, 2.35, 0);
updateCamera();
});
scrub.addEventListener("pointerdown", () => {
scrubbing = true;
playing = false;
syncPlayButton();
});
scrub.addEventListener("input", () => {
timeline = Number(scrub.value);
playing = false;
syncPlayButton();
});
window.addEventListener("pointerup", () => {
scrubbing = false;
});
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
updateCamera();
resize();
function animate(now) {
const delta = Math.min((now - lastTime) / 1000, 0.05);
lastTime = now;
if (playing && !scrubbing) {
timeline = Math.min(DURATION, timeline + delta);
if (timeline >= DURATION) {
playing = false;
syncPlayButton();
}
}
updateAssembly(timeline);
updateSupport(timeline);
updateArrows(timeline, now);
updateHUD(timeline);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```