Prompt specification
Build or customize the Three.js 3D scene "Intersecting vault bays on supports" 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: Intersecting vault bays on supports
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/intersecting-vault-bays-on-supports-x2234
Scene Description Prompt:
Two low-poly barrel vaults intersect above four supports; highlight their intersection edges. One self-contained HTML file using Three.js from cdnjs.
Working Three.js Starter (intersecting-vault-bays-on-supports-x2234):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Intersecting Barrel Vaults</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #10181c;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
color: #eef5f3;
}
.panel {
position: absolute;
top: 24px;
left: 24px;
width: min(360px, calc(100vw - 48px));
padding: 18px 20px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 14px;
background: linear-gradient(
145deg,
rgba(15, 23, 27, 0.9),
rgba(15, 23, 27, 0.68)
);
box-shadow: 0 16px 50px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(14px);
}
.eyebrow {
margin: 0 0 8px;
color: #f4c65f;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 4vw, 31px);
line-height: 1.04;
letter-spacing: -0.035em;
}
.subtitle {
margin: 10px 0 16px;
color: #aebcbc;
font-size: 13px;
line-height: 1.5;
}
.legend {
display: grid;
gap: 8px;
padding-top: 14px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
font-size: 12px;
color: #cbd5d4;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 18px;
height: 5px;
border-radius: 10px;
box-shadow: 0 0 12px currentColor;
}
.controls {
position: absolute;
right: 24px;
bottom: 24px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 9px;
padding: 10px 13px;
color: #eef5f3;
background: rgba(17, 25, 29, 0.84);
font: inherit;
font-size: 12px;
cursor: pointer;
backdrop-filter: blur(10px);
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
button:hover {
border-color: rgba(244, 198, 95, 0.65);
background: rgba(32, 42, 45, 0.94);
transform: translateY(-1px);
}
.hint {
position: absolute;
left: 24px;
bottom: 24px;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.09);
border-radius: 9px;
color: #91a09f;
background: rgba(15, 23, 27, 0.6);
font-size: 11px;
letter-spacing: 0.02em;
backdrop-filter: blur(10px);
}
@media (max-width: 700px) {
.panel {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
.subtitle,
.legend {
display: none;
}
.hint {
left: 14px;
bottom: 70px;
}
.controls {
right: 14px;
bottom: 14px;
}
}
</style>
</head>
<body>
<div class="hud">
<section class="panel">
<p class="eyebrow">Structural Geometry</p>
<h1>Intersecting<br />Barrel Vaults</h1>
<p class="subtitle">
Two low-poly half-cylinder shells cross above four corner supports.
Their four groin edges are emphasized in gold.
</p>
<div class="legend">
<div class="legend-row">
<span class="swatch" style="color:#c87350;background:#c87350"></span>
<span>East–west barrel vault</span>
</div>
<div class="legend-row">
<span class="swatch" style="color:#418f91;background:#418f91"></span>
<span>North–south barrel vault</span>
</div>
<div class="legend-row">
<span class="swatch" style="color:#ffd166;background:#ffd166"></span>
<span>Highlighted intersection edges</span>
</div>
</div>
</section>
<div class="hint">Drag to orbit · Wheel to zoom · Shift-drag to pan</div>
<div class="controls">
<button id="reset" type="button">Reset view</button>
<button id="toggle-edges" type="button">Hide groin edges</button>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x10181c);
scene.fog = new THREE.Fog(0x10181c, 15, 31);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
// -------------------------------------------------------------------------
// Geometry dimensions
// -------------------------------------------------------------------------
const HALF_SPAN = 3.6;
const SPRING_HEIGHT = 2.15;
const OUTER_RADIUS = HALF_SPAN;
const SHELL_THICKNESS = 0.18;
const RADIAL_SEGMENTS = 12;
const LENGTH_SEGMENTS = 4;
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xc8ecff, 0x44352a, 2.1));
const keyLight = new THREE.DirectionalLight(0xffefd3, 3.4);
keyLight.position.set(8, 13, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -9;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x77d9e4, 1.45);
fillLight.position.set(-9, 6, -7);
scene.add(fillLight);
const rimLight = new THREE.PointLight(0xffc85c, 20, 14, 2);
rimLight.position.set(0, 5.2, 0);
scene.add(rimLight);
// -------------------------------------------------------------------------
// Ground
// -------------------------------------------------------------------------
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0x20292d,
roughness: 0.94,
metalness: 0.02
});
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(24, 24, 0x667579, 0x354146);
grid.position.y = 0.012;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
// -------------------------------------------------------------------------
// Custom barrel-vault geometry
//
// Each shell is a faceted half-cylinder with:
// - an outer curved surface,
// - an inner curved surface,
// - two springing strips,
// - two curved end caps.
// -------------------------------------------------------------------------
function vaultPoint(axis, radius, u, angle) {
const vertical = SPRING_HEIGHT + radius * Math.sin(angle);
if (axis === "x") {
return new THREE.Vector3(
u,
vertical,
radius * Math.cos(angle)
);
}
return new THREE.Vector3(
-radius * Math.cos(angle),
vertical,
u
);
}
function createVault(axis, material, edgeMaterial) {
const positions = [];
function addTriangle(a, b, c) {
positions.push(
a.x, a.y, a.z,
b.x, b.y, b.z,
c.x, c.y, c.z
);
}
function addQuad(a, b, c, d) {
addTriangle(a, b, c);
addTriangle(a, c, d);
}
const outerRadius = OUTER_RADIUS;
const innerRadius = OUTER_RADIUS - SHELL_THICKNESS;
// Outer and inner curved surfaces.
for (let i = 0; i < LENGTH_SEGMENTS; i++) {
const u0 = -HALF_SPAN + (2 * HALF_SPAN * i) / LENGTH_SEGMENTS;
const u1 =
-HALF_SPAN + (2 * HALF_SPAN * (i + 1)) / LENGTH_SEGMENTS;
for (let j = 0; j < RADIAL_SEGMENTS; j++) {
const a0 = (Math.PI * j) / RADIAL_SEGMENTS;
const a1 = (Math.PI * (j + 1)) / RADIAL_SEGMENTS;
const o00 = vaultPoint(axis, outerRadius, u0, a0);
const o10 = vaultPoint(axis, outerRadius, u1, a0);
const o11 = vaultPoint(axis, outerRadius, u1, a1);
const o01 = vaultPoint(axis, outerRadius, u0, a1);
addQuad(o00, o10, o11, o01);
const i00 = vaultPoint(axis, innerRadius, u0, a0);
const i10 = vaultPoint(axis, innerRadius, u1, a0);
const i11 = vaultPoint(axis, innerRadius, u1, a1);
const i01 = vaultPoint(axis, innerRadius, u0, a1);
addQuad(i00, i01, i11, i10);
}
}
// Springing strips at angle 0 and angle PI.
for (let i = 0; i < LENGTH_SEGMENTS; i++) {
const u0 = -HALF_SPAN + (2 * HALF_SPAN * i) / LENGTH_SEGMENTS;
const u1 =
-HALF_SPAN + (2 * HALF_SPAN * (i + 1)) / LENGTH_SEGMENTS;
for (const angle of [0, Math.PI]) {
const o0 = vaultPoint(axis, outerRadius, u0, angle);
const o1 = vaultPoint(axis, outerRadius, u1, angle);
const i0 = vaultPoint(axis, innerRadius, u0, angle);
const i1 = vaultPoint(axis, innerRadius, u1, angle);
addQuad(o0, o1, i1, i0);
}
}
// Curved end caps at both ends of the barrel.
for (const u of [-HALF_SPAN, HALF_SPAN]) {
for (let j = 0; j < RADIAL_SEGMENTS; j++) {
const a0 = (Math.PI * j) / RADIAL_SEGMENTS;
const a1 = (Math.PI * (j + 1)) / RADIAL_SEGMENTS;
const o0 = vaultPoint(axis, outerRadius, u, a0);
const o1 = vaultPoint(axis, outerRadius, u, a1);
const i0 = vaultPoint(axis, innerRadius, u, a0);
const i1 = vaultPoint(axis, innerRadius, u, a1);
addQuad(o0, o1, i1, i0);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.computeVertexNormals();
geometry.computeBoundingSphere();
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 8),
edgeMaterial
);
edges.renderOrder = 2;
const group = new THREE.Group();
group.add(mesh, edges);
return group;
}
const vaultAMaterial = new THREE.MeshStandardMaterial({
color: 0xc87350,
roughness: 0.7,
metalness: 0.035,
flatShading: true,
side: THREE.DoubleSide
});
const vaultBMaterial = new THREE.MeshStandardMaterial({
color: 0x418f91,
roughness: 0.7,
metalness: 0.035,
flatShading: true,
side: THREE.DoubleSide
});
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x182b2f,
transparent: true,
opacity: 0.38,
depthWrite: false
});
const vaultA = createVault("x", vaultAMaterial, edgeMaterial);
const vaultB = createVault("z", vaultBMaterial, edgeMaterial);
scene.add(vaultA, vaultB);
// -------------------------------------------------------------------------
// Four stone supports at the corners of the square bay
// -------------------------------------------------------------------------
const stoneMaterial = new THREE.MeshStandardMaterial({
color: 0xbdae93,
roughness: 0.92,
metalness: 0.01,
flatShading: true
});
const stoneDarkMaterial = new THREE.MeshStandardMaterial({
color: 0x81765f,
roughness: 0.95,
metalness: 0,
flatShading: true
});
const supportPositions = [
[-HALF_SPAN, -HALF_SPAN],
[-HALF_SPAN, HALF_SPAN],
[HALF_SPAN, -HALF_SPAN],
[HALF_SPAN, HALF_SPAN]
];
const baseGeometry = new THREE.BoxGeometry(1.28, 0.22, 1.28);
const shaftGeometry = new THREE.CylinderGeometry(
0.43,
0.52,
SPRING_HEIGHT - 0.46,
8
);
const capitalGeometry = new THREE.CylinderGeometry(
0.62,
0.47,
0.24,
8
);
for (const [x, z] of supportPositions) {
const support = new THREE.Group();
support.position.set(x, 0, z);
const base = new THREE.Mesh(baseGeometry, stoneDarkMaterial);
base.position.y = 0.11;
base.castShadow = true;
base.receiveShadow = true;
const shaft = new THREE.Mesh(shaftGeometry, stoneMaterial);
shaft.position.y = 0.22 + (SPRING_HEIGHT - 0.46) / 2;
shaft.castShadow = true;
shaft.receiveShadow = true;
const capital = new THREE.Mesh(capitalGeometry, stoneMaterial);
capital.position.y = SPRING_HEIGHT - 0.12;
capital.castShadow = true;
capital.receiveShadow = true;
support.add(base, shaft, capital);
scene.add(support);
}
// -------------------------------------------------------------------------
// Intersection / groin edges
//
// The two outer barrel surfaces satisfy:
// y = spring + sqrt(R² - z²)
// y = spring + sqrt(R² - x²)
//
// They intersect where |x| = |z|, producing four curves from the
// crown to the four corner supports.
// -------------------------------------------------------------------------
const groinGroup = new THREE.Group();
const groinMaterial = new THREE.MeshBasicMaterial({
color: 0xffd166
});
const groinGlowMaterial = new THREE.MeshBasicMaterial({
color: 0xffb52e,
transparent: true,
opacity: 0.16,
depthWrite: false,
blending: THREE.AdditiveBlending
});
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
const points = [];
for (let i = 0; i <= 28; i++) {
const t = i / 28;
const x = sx * HALF_SPAN * t;
const z = sz * HALF_SPAN * t;
const root = Math.sqrt(
Math.max(0, OUTER_RADIUS * OUTER_RADIUS - z * z)
);
const point = new THREE.Vector3(
x,
SPRING_HEIGHT + root,
z
);
// Offset slightly along the average surface normal so the
// highlighted edge sits cleanly above the faceted shells.
const normalA = new THREE.Vector3(0, z, root).normalize();
const normalB = new THREE.Vector3(x, root, 0).normalize();
const offset = normalA.add(normalB).normalize().multiplyScalar(0.035);
point.add(offset);
points.push(point);
}
const curve = new THREE.CatmullRomCurve3(points);
const glow = new THREE.Mesh(
new THREE.TubeGeometry(curve, 64, 0.105, 6, false),
groinGlowMaterial
);
glow.renderOrder = 4;
const seam = new THREE.Mesh(
new THREE.TubeGeometry(curve, 64, 0.043, 6, false),
groinMaterial
);
seam.renderOrder = 5;
groinGroup.add(glow, seam);
}
}
const crownMarker = new THREE.Mesh(
new THREE.OctahedronGeometry(0.115),
groinMaterial
);
crownMarker.position.set(
0,
SPRING_HEIGHT + OUTER_RADIUS + 0.075,
0
);
crownMarker.renderOrder = 6;
groinGroup.add(crownMarker);
for (const [x, z] of supportPositions) {
const marker = new THREE.Mesh(
new THREE.OctahedronGeometry(0.075),
groinMaterial
);
marker.position.set(x, SPRING_HEIGHT + 0.065, z);
marker.renderOrder = 6;
groinGroup.add(marker);
}
scene.add(groinGroup);
// -------------------------------------------------------------------------
// Camera controls implemented directly, without external addons
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 2.35, 0),
radius: 14.2,
theta: 0.78,
phi: 0.97
};
const spherical = new THREE.Spherical();
const cameraOffset = new THREE.Vector3();
const cameraRight = new THREE.Vector3();
const cameraUp = new THREE.Vector3();
function updateCamera() {
spherical.set(
controls.radius,
controls.phi,
controls.theta
);
cameraOffset.setFromSpherical(spherical);
camera.position.copy(controls.target).add(cameraOffset);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
function resetCamera() {
controls.target.set(0, 2.35, 0);
controls.radius = 14.2;
controls.theta = 0.78;
controls.phi = 0.97;
updateCamera();
}
function panCamera(dx, dy) {
cameraRight.setFromMatrixColumn(camera.matrix, 0);
cameraUp.setFromMatrixColumn(camera.matrix, 1);
const scale = controls.radius * 0.00125;
controls.target
.addScaledVector(cameraRight, -dx * scale)
.addScaledVector(cameraUp, dy * scale);
controls.target.x = THREE.MathUtils.clamp(
controls.target.x,
-6,
6
);
controls.target.y = THREE.MathUtils.clamp(
controls.target.y,
0.5,
5.5
);
controls.target.z = THREE.MathUtils.clamp(
controls.target.z,
-6,
6
);
}
const pointers = new Map();
const gesture = {
mode: "orbit",
lastX: 0,
lastY: 0,
pinchDistance: 0
};
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
gesture.mode =
event.shiftKey || event.button === 2 ? "pan" : "orbit";
gesture.lastX = event.clientX;
gesture.lastY = event.clientY;
} else if (pointers.size === 2) {
gesture.mode = "pinch";
gesture.pinchDistance = pointerDistance();
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
const pointer = pointers.get(event.pointerId);
if (!pointer) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (pointers.size === 1) {
if (gesture.mode === "orbit") {
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.006,
0.2,
1.48
);
} else if (gesture.mode === "pan") {
panCamera(dx, dy);
}
} else if (pointers.size === 2) {
const distance = pointerDistance();
if (gesture.pinchDistance > 0 && distance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (gesture.pinchDistance / distance),
8.5,
24
);
}
gesture.pinchDistance = distance;
}
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
gesture.mode = "orbit";
gesture.lastX = remaining.x;
gesture.lastY = remaining.y;
} else if (pointers.size === 0) {
gesture.mode = "orbit";
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
8.5,
24
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
document.getElementById("reset").addEventListener("click", resetCamera);
const edgeButton = document.getElementById("toggle-edges");
edgeButton.addEventListener("click", () => {
groinGroup.visible = !groinGroup.visible;
edgeButton.textContent = groinGroup.visible
? "Hide groin edges"
: "Show groin edges";
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
groinGlowMaterial.opacity =
0.13 + Math.sin(elapsed * 2.1) * 0.035;
renderer.render(scene, camera);
});
resetCamera();
</script>
</body>
</html>
```