Prompt specification
Build or customize the Three.js 3D scene "Change arch span and support position" 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: Change arch span and support position
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/change-arch-span-and-support-position-x2172
Scene Description Prompt:
Let users adjust an arch's rise and span in a teaching model. Update geometric force arrows from a stated simplified model and distinguish illustration from engineering design. Build this with Three.js from cdnjs as a low-poly scene in one self-contained HTML file.
Working Three.js Starter (change-arch-span-and-support-position-x2172):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Parabolic Arch Teaching Model</title>
<style>
:root {
color-scheme: dark;
--bg: #08111c;
--panel: rgba(12, 22, 35, 0.92);
--line: rgba(255, 255, 255, 0.13);
--text: #eef5ff;
--muted: #a9b8c9;
--cyan: #55d6ff;
--green: #70e08b;
--orange: #ffb45c;
--gold: #ffd166;
--white: #f7fbff;
}
* {
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,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 5;
top: 18px;
left: 18px;
width: min(370px, calc(100vw - 36px));
max-height: calc(100vh - 36px);
overflow: auto;
padding: 20px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
backdrop-filter: blur(14px);
}
.eyebrow {
margin-bottom: 5px;
color: var(--gold);
font-size: 0.73rem;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 1.55rem;
line-height: 1.12;
letter-spacing: -0.025em;
}
.intro {
margin: 9px 0 19px;
color: var(--muted);
font-size: 0.89rem;
line-height: 1.45;
}
.control {
margin: 15px 0;
}
.control-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 8px;
}
.control label {
font-size: 0.91rem;
font-weight: 700;
}
output {
color: var(--gold);
font-variant-numeric: tabular-nums;
font-size: 0.94rem;
font-weight: 800;
}
input[type="range"] {
width: 100%;
height: 6px;
margin: 0;
border-radius: 99px;
outline: none;
background: linear-gradient(90deg, #34516b, #d6a761);
cursor: pointer;
accent-color: var(--gold);
}
.range-ends {
display: flex;
justify-content: space-between;
margin-top: 5px;
color: #718397;
font-size: 0.69rem;
}
.readouts {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 19px;
}
.readout {
min-height: 64px;
padding: 10px 11px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.035);
}
.readout span {
display: block;
margin-bottom: 5px;
color: var(--muted);
font-size: 0.72rem;
line-height: 1.15;
}
.readout strong {
font-size: 1rem;
font-variant-numeric: tabular-nums;
}
.readout.horizontal strong {
color: var(--cyan);
}
.readout.vertical strong {
color: var(--green);
}
.readout.resultant strong {
color: var(--orange);
}
.readout.angle strong {
color: var(--gold);
}
details {
margin-top: 16px;
padding-top: 14px;
border-top: 1px solid var(--line);
}
summary {
cursor: pointer;
font-size: 0.86rem;
font-weight: 800;
}
.model-copy {
margin: 11px 0 0;
color: var(--muted);
font-size: 0.79rem;
line-height: 1.5;
}
.formula {
margin: 11px 0;
padding: 10px 11px;
border-radius: 9px;
background: #07111c;
color: #dce9f7;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.76rem;
line-height: 1.65;
}
.disclaimer {
margin-top: 16px;
padding: 12px 13px;
border: 1px solid rgba(255, 181, 92, 0.48);
border-radius: 11px;
background: rgba(98, 55, 19, 0.28);
}
.disclaimer strong {
display: block;
margin-bottom: 5px;
color: #ffc47a;
font-size: 0.76rem;
letter-spacing: 0.075em;
}
.disclaimer p {
margin: 0;
color: #d7c3ad;
font-size: 0.75rem;
line-height: 1.45;
}
.toolbar {
position: fixed;
z-index: 6;
top: 18px;
right: 18px;
display: flex;
gap: 8px;
}
button {
padding: 9px 13px;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 10px;
background: rgba(12, 22, 35, 0.86);
color: var(--text);
cursor: pointer;
backdrop-filter: blur(10px);
}
button:hover {
border-color: rgba(255, 209, 102, 0.65);
color: var(--gold);
}
.legend {
position: fixed;
z-index: 5;
right: 18px;
bottom: 18px;
width: 245px;
padding: 14px 16px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(12, 22, 35, 0.84);
color: var(--muted);
font-size: 0.74rem;
line-height: 1.42;
backdrop-filter: blur(12px);
}
.legend-title {
margin-bottom: 9px;
color: var(--text);
font-weight: 800;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin: 6px 0;
}
.swatch {
width: 25px;
height: 3px;
flex: 0 0 auto;
border-radius: 4px;
}
.swatch.load {
background: var(--white);
}
.swatch.horizontal {
background: var(--cyan);
}
.swatch.vertical {
background: var(--green);
}
.swatch.resultant {
background: var(--orange);
}
.swatch.compression {
background: var(--gold);
}
.legend-note {
margin-top: 9px;
padding-top: 9px;
border-top: 1px solid var(--line);
color: #8496a8;
}
.hint {
position: fixed;
z-index: 4;
left: 50%;
bottom: 19px;
transform: translateX(-50%);
padding: 8px 13px;
border: 1px solid var(--line);
border-radius: 99px;
background: rgba(7, 16, 27, 0.7);
color: #aab9ca;
font-size: 0.72rem;
pointer-events: none;
backdrop-filter: blur(10px);
}
@media (max-width: 760px) {
.panel {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
max-height: 52vh;
padding: 15px;
border-radius: 14px;
}
h1 {
font-size: 1.25rem;
}
.intro {
margin-bottom: 12px;
}
.legend,
.hint {
display: none;
}
.toolbar {
top: auto;
right: 10px;
bottom: 10px;
}
}
</style>
</head>
<body>
<div
id="scene"
role="img"
aria-label="Interactive three-dimensional parabolic arch with adjustable rise and span, force arrows, and support reactions."
></div>
<section class="panel" aria-label="Arch controls and model results">
<div class="eyebrow">Structural intuition / interactive model</div>
<h1>Parabolic Arch Lab</h1>
<p class="intro">
Change the span and rise. The support reactions, local compression,
and thrust line are recalculated from the stated idealization.
</p>
<div class="control">
<div class="control-head">
<label for="rise">Arch rise, h</label>
<output id="riseOut" for="rise">4.0 m</output>
</div>
<input id="rise" type="range" min="1.5" max="7" step="0.1" value="4">
<div class="range-ends">
<span>1.5 m</span>
<span>7.0 m</span>
</div>
</div>
<div class="control">
<div class="control-head">
<label for="span">Clear span, L</label>
<output id="spanOut" for="span">12.0 m</output>
</div>
<input id="span" type="range" min="8" max="18" step="0.1" value="12">
<div class="range-ends">
<span>8.0 m</span>
<span>18.0 m</span>
</div>
</div>
<div class="readouts" aria-live="polite">
<div class="readout">
<span>Total vertical load W</span>
<strong id="WValue">120.0 kN</strong>
</div>
<div class="readout">
<span>Load intensity w</span>
<strong>10.0 kN/m</strong>
</div>
<div class="readout vertical">
<span>Vertical reaction V</span>
<strong id="VValue">60.0 kN</strong>
</div>
<div class="readout horizontal">
<span>Horizontal thrust H</span>
<strong id="HValue">45.0 kN</strong>
</div>
<div class="readout resultant">
<span>Support resultant R</span>
<strong id="RValue">75.0 kN</strong>
</div>
<div class="readout angle">
<span>Reaction angle α</span>
<strong id="alphaValue">53.1°</strong>
</div>
</div>
<details open>
<summary>Simplified teaching model</summary>
<div class="model-copy">
A pin-ended parabolic arch carries a uniform load
<strong>w = 10 kN/m per metre of horizontal projection</strong>.
The parabola is funicular for that load, so the ideal arch has zero
bending moment and the compression resultant follows the arch tangent.
Each white arrow represents the tributary load at one station.
</div>
<div class="formula">
W = wL<br>
V = W / 2<br>
H = wL² / (8h)<br>
R = √(V² + H²)<br>
N(s) = √(H² + [w(L/2 − s)]²)
</div>
<div class="model-copy">
In the last expression, s is measured from the left springing and
N(s) is the local axial compression. Arch self-weight, deformation,
cracking, buckling, soil interaction, construction tolerances, and
load combinations are omitted. Arrow lengths are schematic rather
than physical dimensions.
</div>
</details>
<div class="disclaimer">
<strong>ILLUSTRATION — NOT ENGINEERING DESIGN</strong>
<p>
This model is for teaching geometric and force-flow concepts only.
It must not be used for member sizing, structural safety, serviceability,
foundations, construction design, or code compliance.
</p>
</div>
</section>
<div class="toolbar">
<button id="frameButton" type="button">Frame arch</button>
</div>
<aside class="legend" aria-label="Force arrow legend">
<div class="legend-title">Force diagram</div>
<div class="legend-row">
<span class="swatch load"></span>
<span>White: distributed vertical load</span>
</div>
<div class="legend-row">
<span class="swatch horizontal"></span>
<span>Cyan: horizontal thrust H</span>
</div>
<div class="legend-row">
<span class="swatch vertical"></span>
<span>Green: vertical reaction V</span>
</div>
<div class="legend-row">
<span class="swatch resultant"></span>
<span>Orange: support resultant R</span>
</div>
<div class="legend-row">
<span class="swatch compression"></span>
<span>Gold: tangent compression / thrust line</span>
</div>
<div class="legend-note">
The gold curve is the compression path for this idealized loading.
It is not a capacity or stability check.
</div>
</aside>
<div class="hint">Drag to orbit · Shift-drag to pan · Scroll to zoom · Double-click to frame</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneElement = document.getElementById("scene");
const riseInput = document.getElementById("rise");
const spanInput = document.getElementById("span");
const riseOutput = document.getElementById("riseOut");
const spanOutput = document.getElementById("spanOut");
const state = {
span: Number(spanInput.value),
rise: Number(riseInput.value),
loadIntensity: 10, // kN per metre of horizontal span
springY: 0.85,
archDepth: 2.0,
blockThickness: 0.46
};
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x08111c);
scene.fog = new THREE.Fog(0x08111c, 32, 78);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
160
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneElement.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xb9d8ff, 0x4c3928, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe2b8, 3.25);
sun.position.set(9, 19, 13);
sun.target.position.set(0, 2.4, 0);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 19;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.00025;
scene.add(sun, sun.target);
const rim = new THREE.DirectionalLight(0x76baff, 1.3);
rim.position.set(-12, 8, -12);
scene.add(rim);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(90, 90),
new THREE.MeshStandardMaterial({
color: 0x142130,
roughness: 0.96,
metalness: 0.02
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.08;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(70, 70, 0x36526a, 0x25384a);
grid.position.y = -0.065;
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
const cameraState = {
radius: 24,
phi: 1.08,
theta: 0.16,
target: new THREE.Vector3(0, 2.7, 0)
};
function applyCamera() {
camera.position.setFromSphericalCoords(
cameraState.radius,
cameraState.phi,
cameraState.theta
);
camera.position.add(cameraState.target);
camera.lookAt(cameraState.target);
camera.updateMatrixWorld();
}
function frameArch() {
const verticalFov = THREE.MathUtils.degToRad(camera.fov);
const horizontalFov = 2 * Math.atan(
Math.tan(verticalFov / 2) * camera.aspect
);
const horizontalExtent = state.span / 2 + 2.6;
const verticalExtent = state.rise + 2.5;
const distanceForWidth =
horizontalExtent / Math.tan(horizontalFov / 2);
const distanceForHeight =
verticalExtent / Math.tan(verticalFov / 2);
cameraState.radius = THREE.MathUtils.clamp(
Math.max(distanceForWidth * 1.1, distanceForHeight * 1.18, 14),
14,
85
);
cameraState.phi = 1.08;
cameraState.theta = 0.16;
cameraState.target.set(0, state.springY + state.rise * 0.46, 0);
applyCamera();
}
// Direct camera controls: no examples or addons are imported.
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.pointerType === "mouse" && event.button !== 0) return;
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (event.shiftKey) {
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
0
);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const panScale = cameraState.radius * 0.0012;
cameraState.target.addScaledVector(right, -dx * panScale);
cameraState.target.addScaledVector(up, dy * panScale);
cameraState.target.x = THREE.MathUtils.clamp(
cameraState.target.x,
-12,
12
);
cameraState.target.y = THREE.MathUtils.clamp(
cameraState.target.y,
-1,
12
);
} else {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.38,
1.48
);
}
applyCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerType !== "mouse" &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
9,
85
);
applyCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", frameArch);
document.getElementById("frameButton").addEventListener("click", frameArch);
let dynamicGroup = null;
function disposeGroup(group) {
group.traverse((object) => {
if (object.geometry) object.geometry.dispose();
const materials = object.material
? Array.isArray(object.material)
? object.material
: [object.material]
: [];
for (const material of materials) {
if (material.map) material.map.dispose();
material.dispose();
}
});
}
function createLabel(text, color = "#ffffff", worldWidth = 2.2) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const context = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.renderOrder = 30;
sprite.scale.set(worldWidth, worldWidth * 0.25, 1);
sprite.userData.canvas = canvas;
sprite.userData.context = context;
sprite.userData.texture = texture;
sprite.userData.color = color;
drawLabel(sprite, text);
return sprite;
}
function drawLabel(sprite, text) {
const canvas = sprite.userData.canvas;
const context = sprite.userData.context;
const color = sprite.userData.color;
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "rgba(5, 12, 21, 0.84)";
context.fillRect(8, 14, 496, 100);
context.strokeStyle = color;
context.lineWidth = 4;
context.strokeRect(8, 14, 496, 100);
context.fillStyle = color;
context.font = "700 47px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 256, 65);
sprite.userData.texture.needsUpdate = true;
}
function addLabel(group, text, color, width, x, y, z) {
const label = createLabel(text, color, width);
label.position.set(x, y, z);
group.add(label);
return label;
}
function addLine(group, points, color, opacity = 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map((point) => new THREE.Vector3(...point))
);
const material = new THREE.LineBasicMaterial({
color,
transparent: opacity < 1,
opacity
});
const line = new THREE.Line(geometry, material);
group.add(line);
return line;
}
function addArrow(
group,
direction,
origin,
length,
color,
headLength = 0.32,
headWidth = 0.19
) {
const arrow = new THREE.ArrowHelper(
direction.clone().normalize(),
origin.clone(),
length,
color,
headLength,
headWidth
);
group.add(arrow);
return arrow;
}
function pointAt(s) {
const L = state.span;
const h = state.rise;
const x = -L / 2 + s;
const y =
state.springY + 4 * h * s * (L - s) / (L * L);
return new THREE.Vector3(x, y, 0);
}
function tangentAt(s) {
const x = -state.span / 2 + s;
const slope =
(-8 * state.rise * x) / (state.span * state.span);
return new THREE.Vector3(1, slope, 0).normalize();
}
function buildArchSegment(s1, s2, material) {
const p1 = pointAt(s1);
const p2 = pointAt(s2);
const t1 = tangentAt(s1);
const t2 = tangentAt(s2);
const n1 = new THREE.Vector3(-t1.y, t1.x, 0);
const n2 = new THREE.Vector3(-t2.y, t2.x, 0);
const halfThickness = state.blockThickness / 2;
const front = state.archDepth / 2;
const back = -state.archDepth / 2;
const inner1 = p1.clone().addScaledVector(n1, -halfThickness);
const outer1 = p1.clone().addScaledVector(n1, halfThickness);
const inner2 = p2.clone().addScaledVector(n2, -halfThickness);
const outer2 = p2.clone().addScaledVector(n2, halfThickness);
const vertices = [
inner1.x, inner1.y, front,
outer1.x, outer1.y, front,
inner1.x, inner1.y, back,
outer1.x, outer1.y, back,
inner2.x, inner2.y, front,
outer2.x, outer2.y, front,
inner2.x, inner2.y, back,
outer2.x, outer2.y, back
];
const indices = [
0, 4, 5, 1,
2, 3, 7, 6,
0, 2, 6, 4,
1, 5, 7, 3,
0, 1, 3, 2,
4, 6, 7, 5
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 24),
new THREE.LineBasicMaterial({
color: 0x5d4939,
transparent: true,
opacity: 0.48
})
);
mesh.add(edges);
return mesh;
}
function addBox(group, dimensions, position, color) {
const geometry = new THREE.BoxGeometry(...dimensions);
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.9,
metalness: 0.02,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
return mesh;
}
function formatNumber(value) {
return value.toLocaleString(undefined, {
minimumFractionDigits: 1,
maximumFractionDigits: 1
});
}
function updateReadouts(H, V, R, alpha) {
const W = state.loadIntensity * state.span;
document.getElementById("WValue").textContent =
`${formatNumber(W)} kN`;
document.getElementById("HValue").textContent =
`${formatNumber(H)} kN`;
document.getElementById("VValue").textContent =
`${formatNumber(V)} kN`;
document.getElementById("RValue").textContent =
`${formatNumber(R)} kN`;
document.getElementById("alphaValue").textContent =
`${formatNumber(THREE.MathUtils.radToDeg(alpha))}°`;
riseOutput.textContent = `${formatNumber(state.rise)} m`;
spanOutput.textContent = `${formatNumber(state.span)} m`;
}
function rebuildModel() {
if (dynamicGroup) {
scene.remove(dynamicGroup);
disposeGroup(dynamicGroup);
}
dynamicGroup = new THREE.Group();
dynamicGroup.name = "Arch and force diagram";
scene.add(dynamicGroup);
const L = state.span;
const h = state.rise;
const w = state.loadIntensity;
const W = w * L;
const V = W / 2;
const H = (w * L * L) / (8 * h);
const R = Math.hypot(H, V);
const alpha = Math.atan2(V, H);
updateReadouts(H, V, R, alpha);
// Abutments and foundations.
addBox(
dynamicGroup,
[1.75, 1.08, 2.8],
[-L / 2, 0.43, 0],
0x60717e
);
addBox(
dynamicGroup,
[1.75, 1.08, 2.8],
[L / 2, 0.43, 0],
0x60717e
);
addBox(
dynamicGroup,
[2.35, 0.24, 3.35],
[-L / 2, 0.08, 0],
0x415363
);
addBox(
dynamicGroup,
[2.35, 0.24, 3.35],
[L / 2, 0.08, 0],
0x415363
);
// Low-poly voussoir blocks.
const blockCount = 19;
const blockStep = L / blockCount;
const joint = Math.min(0.055, blockStep * 0.025);
const colors = [
0xb8885d,
0xc49367,
0xad7b55,
0xc99a6e,
0xb98760
];
for (let i = 0; i < blockCount; i++) {
const s1 = i * blockStep + joint / 2;
const s2 = (i + 1) * blockStep - joint / 2;
const isKeystone = i === Math.floor(blockCount / 2);
const color = isKeystone
? 0xe0b66f
: colors[i % colors.length];
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.83,
metalness: 0.015,
flatShading: true,
side: THREE.DoubleSide
});
dynamicGroup.add(buildArchSegment(s1, s2, material));
}
// Gold compression/thrust path on the visible face.
const thrustPoints = [];
for (let i = 0; i <= 60; i++) {
const p = pointAt((i / 60) * L);
p.z = state.archDepth / 2 + 0.045;
thrustPoints.push(p);
}
const thrustCurve = new THREE.CatmullRomCurve3(
thrustPoints,
false,
"centripetal"
);
const thrustGeometry = new THREE.TubeGeometry(
thrustCurve,
90,
0.038,
6,
false
);
const thrustMaterial = new THREE.MeshStandardMaterial({
color: 0xffd166,
emissive: 0x704600,
emissiveIntensity: 0.42,
roughness: 0.48,
metalness: 0.05
});
const thrustMesh = new THREE.Mesh(
thrustGeometry,
thrustMaterial
);
dynamicGroup.add(thrustMesh);
// Distributed load arrows. Each represents one tributary panel.
const loadStations = 9;
const tributaryLength = L / loadStations;
const tributaryForce = w * tributaryLength;
for (let i = 0; i < loadStations; i++) {
const s = (i + 0.5) * tributaryLength;
const p = pointAt(s);
const arrowLength =
0.65 + 1.35 * Math.min(1, tributaryForce / R);
addArrow(
dynamicGroup,
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(
p.x,
p.y + 0.2 + arrowLength,
0.18
),
arrowLength,
0xf7fbff,
0.28,
0.17
);
}
// Support component and resultant arrows.
const visibleH = 0.62 + 1.35 * (H / R);
const visibleV = 0.62 + 1.35 * (V / R);
const visibleR = 2.65;
const arrowZ = state.archDepth / 2 + 0.38;
const resultantZ = arrowZ + 0.25;
const leftHOrigin = new THREE.Vector3(
-L / 2 - 1.9,
state.springY + 0.14,
arrowZ
);
const rightHOrigin = new THREE.Vector3(
L / 2 + 1.9,
state.springY + 0.14,
arrowZ
);
addArrow(
dynamicGroup,
new THREE.Vector3(1, 0, 0),
leftHOrigin,
visibleH,
0x55d6ff,
0.3,
0.18
);
addArrow(
dynamicGroup,
new THREE.Vector3(0, 1, 0),
leftHOrigin,
visibleV,
0x70e08b,
0.3,
0.18
);
addArrow(
dynamicGroup,
new THREE.Vector3(-1, 0, 0),
rightHOrigin,
visibleH,
0x55d6ff,
0.3,
0.18
);
addArrow(
dynamicGroup,
new THREE.Vector3(0, 1, 0),
rightHOrigin,
visibleV,
0x70e08b,
0.3,
0.18
);
const leftResultantDirection = new THREE.Vector3(
Math.cos(alpha),
Math.sin(alpha),
0
);
const rightResultantDirection = new THREE.Vector3(
-Math.cos(alpha),
Math.sin(alpha),
0
);
const leftResultantOrigin = new THREE.Vector3(
-L / 2,
state.springY + 0.16,
resultantZ
);
const rightResultantOrigin = new THREE.Vector3(
L / 2,
state.springY + 0.16,
resultantZ
);
addArrow(
dynamicGroup,
leftResultantDirection,
leftResultantOrigin,
visibleR,
0xffb45c,
0.36,
0.21
);
addArrow(
dynamicGroup,
rightResultantDirection,
rightResultantOrigin,
visibleR,
0xffb45c,
0.36,
0.21
);
// Local compression arrows along the tangent.
const compressionLocations = [0.1, 0.36, 0.64, 0.9];
for (const fraction of compressionLocations) {
const s = fraction * L;
const p = pointAt(s);
const tangent = tangentAt(s);
const outward = new THREE.Vector3(
-tangent.y,
tangent.x,
0
);
const direction =
s < L / 2
? tangent.clone()
: tangent.clone().negate();
const verticalComponent = w * (L / 2 - s);
const N = Math.hypot(H, verticalComponent);
const arrowLength = 0.65 + 1.05 * (N / R);
const origin = p
.clone()
.addScaledVector(outward, 0.3)
.setZ(state.archDepth / 2 + 0.17);
addArrow(
dynamicGroup,
direction,
origin,
arrowLength,
0xffd166,
0.27,
0.16
);
}
// Compact labels for the force components.
addLabel(
dynamicGroup,
"H",
"#55d6ff",
0.72,
-L / 2 - visibleH - 0.28,
state.springY + 0.14,
arrowZ + 0.25
);
addLabel(
dynamicGroup,
"V",
"#70e08b",
0.72,
-L / 2 - 1.95,
state.springY + visibleV + 0.18,
arrowZ + 0.25
);
addLabel(
dynamicGroup,
"R",
"#ffb45c",
0.72,
-L / 2 + Math.cos(alpha) * (visibleR + 0.25),
state.springY + 0.16 + Math.sin(alpha) * (visibleR + 0.25),
resultantZ + 0.25
);
addLabel(
dynamicGroup,
"H",
"#55d6ff",
0.72,
L / 2 + visibleH + 0.28,
state.springY + 0.14,
arrowZ + 0.25
);
addLabel(
dynamicGroup,
"V",
"#70e08b",
0.72,
L / 2 + 1.95,
state.springY + visibleV + 0.18,
arrowZ + 0.25
);
addLabel(
dynamicGroup,
"R",
"#ffb45c",
0.72,
L / 2 - Math.cos(alpha) * (visibleR + 0.25),
state.springY + 0.16 + Math.sin(alpha) * (visibleR + 0.25),
resultantZ + 0.25
);
// Span and rise dimensions.
const dimensionZ = 0.7;
addLine(
dynamicGroup,
[
[-L / 2, 0.22, dimensionZ],
[L / 2, 0.22, dimensionZ]
],
0xb7c9db,
0.8
);
for (const x of [-L / 2, L / 2]) {
addLine(
dynamicGroup,
[
[x, 0.06, dimensionZ],
[x, 0.38, dimensionZ]
],
0xb7c9db,
0.8
);
}
const riseDimensionX = L / 2 + 0.62;
addLine(
dynamicGroup,
[
[riseDimensionX, state.springY, dimensionZ],
[riseDimensionX, state.springY + h, dimensionZ]
],
0xb7c9db,
0.8
);
for (const y of [state.springY, state.springY + h]) {
addLine(
dynamicGroup,
[
[riseDimensionX - 0.16, y, dimensionZ],
[riseDimensionX + 0.16, y, dimensionZ]
],
0xb7c9db,
0.8
);
}
addLabel(
dynamicGroup,
`L = ${formatNumber(L)} m`,
"#dce9f7",
3.7,
0,
0.28,
dimensionZ + 0.2
);
addLabel(
dynamicGroup,
`h = ${formatNumber(h)} m`,
"#dce9f7",
3.35,
riseDimensionX + 1.55,
state.springY + h / 2,
dimensionZ + 0.2
);
addLabel(
dynamicGroup,
"UDL: 10 kN/m",
"#f7fbff",
3.5,
0,
state.springY + h + 1.78,
0.5
);
}
riseInput.addEventListener("input", () => {
state.rise = Number(riseInput.value);
rebuildModel();
});
spanInput.addEventListener("input", () => {
state.span = Number(spanInput.value);
rebuildModel();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
rebuildModel();
frameArch();
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```