Prompt specification
Build or customize the Three.js 3D scene "Five wedge stones around an opening" 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: Five wedge stones around an opening
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/five-wedge-stones-around-an-opening-x2169
Scene Description Prompt:
Five stylized wedge stones form an arch, with a marked keystone and radial joints. Three.js from cdnjs, one HTML file.
Working Three.js Starter (five-wedge-stones-around-an-opening-x2169):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Keystone — Five Stone Arch</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #101513;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.title {
position: fixed;
top: clamp(24px, 4vw, 54px);
left: clamp(24px, 4vw, 58px);
color: #e8e0cf;
pointer-events: none;
user-select: none;
}
.title .eyebrow {
margin-bottom: 8px;
color: #c49a55;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.28em;
text-transform: uppercase;
}
.title h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4.5vw, 58px);
font-weight: 400;
letter-spacing: -0.035em;
line-height: 0.95;
}
.title p {
margin: 14px 0 0;
color: rgba(225, 224, 211, 0.55);
font-size: 11px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.controls {
position: fixed;
right: clamp(18px, 3vw, 38px);
bottom: clamp(18px, 3vw, 32px);
display: flex;
align-items: center;
gap: 14px;
color: rgba(226, 225, 212, 0.55);
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
user-select: none;
}
.controls span {
white-space: nowrap;
}
button {
border: 1px solid rgba(214, 190, 137, 0.35);
border-radius: 999px;
padding: 9px 14px;
color: #ddc899;
background: rgba(19, 24, 21, 0.65);
backdrop-filter: blur(10px);
font: inherit;
letter-spacing: inherit;
text-transform: inherit;
cursor: pointer;
transition:
color 160ms ease,
border-color 160ms ease,
background 160ms ease;
}
button:hover {
color: #fff1c9;
border-color: rgba(214, 190, 137, 0.8);
background: rgba(54, 45, 29, 0.75);
}
@media (max-width: 640px) {
.title p,
.controls span {
display: none;
}
.controls {
right: 16px;
bottom: 16px;
}
}
</style>
</head>
<body>
<header class="title">
<div class="eyebrow">Five stones · one arch</div>
<h1>The Keystone</h1>
<p>Radial joints / carved stone study</p>
</header>
<div class="controls">
<span>Drag to orbit · Scroll to zoom</span>
<button id="reset" type="button">Reset view</button>
</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 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;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x101513);
scene.fog = new THREE.Fog(0x101513, 9, 18);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
50
);
const target = new THREE.Vector3(0, 1.02, 0);
// ------------------------------------------------------------
// Procedural stone bump texture
// ------------------------------------------------------------
function makeStoneTexture() {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 256;
const ctx = canvas.getContext("2d");
const image = ctx.createImageData(256, 256);
let seed = 9137;
const random = () => {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
};
for (let i = 0; i < image.data.length; i += 4) {
const value = 112 + random() * 48;
image.data[i] = value;
image.data[i + 1] = value;
image.data[i + 2] = value;
image.data[i + 3] = 255;
}
ctx.putImageData(image, 0, 0);
for (let i = 0; i < 42; i++) {
const x = random() * 256;
const y = random() * 256;
const radius = 2 + random() * 13;
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.fillStyle = `rgba(30, 30, 30, ${0.025 + random() * 0.045})`;
ctx.fill();
}
ctx.lineCap = "round";
for (let i = 0; i < 15; i++) {
const x = random() * 256;
const y = random() * 256;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.bezierCurveTo(
x + random() * 25 - 12,
y + random() * 18,
x + random() * 38 - 19,
y + random() * 34 - 17,
x + random() * 55 - 27,
y + random() * 42 - 21
);
ctx.strokeStyle = `rgba(45, 45, 45, ${0.04 + random() * 0.05})`;
ctx.lineWidth = 0.5 + random() * 1.1;
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(0.65, 0.65);
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
const stoneTexture = makeStoneTexture();
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xdce8df, 0x25221c, 2.15));
const keyLight = new THREE.DirectionalLight(0xffe4b8, 4.2);
keyLight.position.set(-3.8, 7.5, 6.2);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 5;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 18;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x9dc8c2, 2.4);
rimLight.position.set(5, 4.5, -4);
scene.add(rimLight);
const markerLight = new THREE.PointLight(0xe4b763, 1.25, 4, 2);
markerLight.position.set(0, 2.0, 1.15);
scene.add(markerLight);
// ------------------------------------------------------------
// Ground
// ------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0x171d1a,
roughness: 0.98,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = 0.27;
floor.receiveShadow = true;
scene.add(floor);
// ------------------------------------------------------------
// Wedge geometry
// ------------------------------------------------------------
const innerRadius = 1.52;
const outerRadius = 2.32;
const keystoneRadius = 2.42;
const stoneDepth = 0.82;
const archStart = THREE.MathUtils.degToRad(8);
const archEnd = THREE.MathUtils.degToRad(172);
const sectorSize = (archEnd - archStart) / 5;
const gap = THREE.MathUtils.degToRad(0.95);
const stoneColors = [
0x68736f,
0x727b74,
0xb09a6f,
0x6d7772,
0x606b67
];
function createWedgeGeometry(angleStart, angleEnd, radius, seed) {
const shape = new THREE.Shape();
shape.moveTo(
Math.cos(angleStart) * innerRadius,
Math.sin(angleStart) * innerRadius
);
shape.lineTo(
Math.cos(angleStart) * radius,
Math.sin(angleStart) * radius
);
shape.absarc(
0,
0,
radius,
angleStart,
angleEnd,
false
);
shape.lineTo(
Math.cos(angleEnd) * innerRadius,
Math.sin(angleEnd) * innerRadius
);
shape.absarc(
0,
0,
innerRadius,
angleEnd,
angleStart,
true
);
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: stoneDepth,
steps: 1,
curveSegments: 22,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: 0.045,
bevelThickness: 0.055,
bevelOffset: 0
});
geometry.translate(0, 0, -stoneDepth * 0.5);
// Slight deterministic deformation gives the blocks a hand-cut feel.
const positions = geometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const x = positions.getX(i);
const y = positions.getY(i);
const z = positions.getZ(i);
const warp =
Math.sin(x * 8.3 + y * 5.7 + z * 3.1 + seed) * 0.010 +
Math.cos(x * 15.1 - y * 10.4 + seed * 0.7) * 0.0045;
const crossWarp =
Math.sin(y * 12.6 - x * 6.2 + z * 4.4 + seed) * 0.007;
positions.setXYZ(i, x + warp, y + crossWarp, z);
}
positions.needsUpdate = true;
geometry.computeVertexNormals();
geometry.computeBoundingBox();
return geometry;
}
const arch = new THREE.Group();
scene.add(arch);
let frontZ = 0;
for (let i = 0; i < 5; i++) {
const angleStart = archStart + i * sectorSize + gap * 0.5;
const angleEnd = archStart + (i + 1) * sectorSize - gap * 0.5;
const radius = i === 2 ? keystoneRadius : outerRadius;
const geometry = createWedgeGeometry(
angleStart,
angleEnd,
radius,
i * 1.731 + 0.42
);
const isKeystone = i === 2;
const material = new THREE.MeshStandardMaterial({
color: stoneColors[i],
bumpMap: stoneTexture,
bumpScale: isKeystone ? 0.045 : 0.06,
roughness: isKeystone ? 0.82 : 0.94,
metalness: 0.025
});
const stone = new THREE.Mesh(geometry, material);
stone.castShadow = true;
stone.receiveShadow = true;
arch.add(stone);
const edgeLines = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 36),
new THREE.LineBasicMaterial({
color: isKeystone ? 0x4c402d : 0x26302c,
transparent: true,
opacity: isKeystone ? 0.36 : 0.29
})
);
stone.add(edgeLines);
frontZ = Math.max(frontZ, geometry.boundingBox.max.z);
}
// ------------------------------------------------------------
// Radial joint inlays
// ------------------------------------------------------------
const jointMaterial = new THREE.MeshStandardMaterial({
color: 0xd0a65a,
emissive: 0x6c4214,
emissiveIntensity: 0.22,
roughness: 0.38,
metalness: 0.72
});
const jointLength = keystoneRadius - innerRadius + 0.04;
const jointMidRadius = (innerRadius + keystoneRadius) * 0.5;
function createJointLayer(backSide = false) {
const layer = new THREE.Group();
for (let i = 1; i < 4; i++) {
const angle = archStart + i * sectorSize;
const joint = new THREE.Mesh(
new THREE.BoxGeometry(jointLength, 0.026, 0.022),
jointMaterial
);
joint.position.set(
Math.cos(angle) * jointMidRadius,
Math.sin(angle) * jointMidRadius,
backSide ? -frontZ - 0.016 : frontZ + 0.016
);
joint.rotation.z = angle;
layer.add(joint);
}
return layer;
}
arch.add(createJointLayer(false));
arch.add(createJointLayer(true));
// ------------------------------------------------------------
// Marked keystone
// ------------------------------------------------------------
const markerGroup = new THREE.Group();
const inset = new THREE.Mesh(
new THREE.CircleGeometry(0.255, 64),
new THREE.MeshStandardMaterial({
color: 0x34352e,
roughness: 0.92,
metalness: 0.04,
side: THREE.DoubleSide
})
);
markerGroup.add(inset);
const gold = new THREE.MeshStandardMaterial({
color: 0xe0bd72,
emissive: 0x6b4518,
emissiveIntensity: 0.28,
roughness: 0.32,
metalness: 0.82,
side: THREE.DoubleSide
});
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.232, 0.018, 12, 64),
gold
);
ring.position.z = 0.013;
markerGroup.add(ring);
const diamondShape = new THREE.Shape();
diamondShape.moveTo(0, 0.125);
diamondShape.lineTo(0.087, 0);
diamondShape.lineTo(0, -0.125);
diamondShape.lineTo(-0.087, 0);
diamondShape.closePath();
const diamond = new THREE.Mesh(
new THREE.ShapeGeometry(diamondShape),
gold
);
diamond.position.z = 0.019;
markerGroup.add(diamond);
for (let i = 0; i < 4; i++) {
const ray = new THREE.Mesh(
new THREE.BoxGeometry(0.018, 0.062, 0.014),
gold
);
const angle = i * Math.PI * 0.5;
ray.position.set(
Math.cos(angle) * 0.29,
Math.sin(angle) * 0.29,
0.014
);
ray.rotation.z = angle - Math.PI * 0.5;
markerGroup.add(ray);
}
markerGroup.position.set(
0,
(innerRadius + keystoneRadius) * 0.5,
frontZ + 0.038
);
arch.add(markerGroup);
const rearMarker = markerGroup.clone(true);
rearMarker.rotation.y = Math.PI;
rearMarker.position.z = -frontZ - 0.038;
arch.add(rearMarker);
// A faint halo emphasizes the selected central stone.
const haloMaterial = new THREE.MeshBasicMaterial({
color: 0xd5ae64,
transparent: true,
opacity: 0.11,
depthWrite: false,
side: THREE.DoubleSide
});
const halo = new THREE.Mesh(
new THREE.RingGeometry(0.285, 0.315, 64),
haloMaterial
);
halo.position.z = 0.027;
markerGroup.add(halo);
const rearHalo = halo.clone();
rearHalo.position.z = 0.027;
rearMarker.add(rearHalo);
// ------------------------------------------------------------
// Direct camera controls
// ------------------------------------------------------------
const home = {
theta: 0.43,
phi: 1.19,
radius: 7.35
};
const desired = { ...home };
const current = { ...home };
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let activePointer = null;
const canvas = renderer.domElement;
function updateCamera() {
const sinPhi = Math.sin(current.phi);
camera.position.set(
target.x + current.radius * sinPhi * Math.sin(current.theta),
target.y + current.radius * Math.cos(current.phi),
target.z + current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(target);
}
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
activePointer = event.pointerId;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointer) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desired.theta -= dx * 0.0055;
desired.phi -= dy * 0.0045;
desired.theta = THREE.MathUtils.clamp(
desired.theta,
-1.18,
1.18
);
desired.phi = THREE.MathUtils.clamp(
desired.phi,
0.72,
1.49
);
});
function stopDragging(event) {
if (event && event.pointerId !== activePointer) return;
dragging = false;
activePointer = null;
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("lostpointercapture", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
5.1,
10.5
);
},
{ passive: false }
);
function resetView() {
desired.theta = home.theta;
desired.phi = home.phi;
desired.radius = home.radius;
}
canvas.addEventListener("dblclick", resetView);
document.getElementById("reset").addEventListener("click", resetView);
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
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);
const clock = new THREE.Clock();
function animate() {
const delta = clock.getDelta();
const elapsed = clock.elapsedTime;
const damping = 1 - Math.pow(0.001, delta);
current.theta = THREE.MathUtils.lerp(
current.theta,
desired.theta,
damping
);
current.phi = THREE.MathUtils.lerp(
current.phi,
desired.phi,
damping
);
current.radius = THREE.MathUtils.lerp(
current.radius,
desired.radius,
damping
);
updateCamera();
const pulse = 1 + Math.sin(elapsed * 1.65) * 0.025;
halo.scale.setScalar(pulse);
markerLight.intensity = 1.15 + Math.sin(elapsed * 1.65) * 0.12;
renderer.render(scene, camera);
}
updateCamera();
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```