Prompt specification
Build or customize the Three.js 3D scene "Bastille key and labeled document stand" 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: Bastille key and labeled document stand
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/bastille-key-and-labeled-document-stand-x2409
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a Bastille key and document stand dated 1789. Display a stylized large key beside a neutral document stand labeled with the 1789 event. Avoid inventing the text or claiming an exact surviving artifact replica. Stylized solid forms.
Working Three.js Starter (bastille-key-and-labeled-document-stand-x2409):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bastille Key — 1789</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, "Helvetica Neue", Arial, sans-serif;
background: #181915;
color: #eee5d3;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
background:
radial-gradient(circle at 50% 38%, #303028 0%, #181915 68%);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas.dragging {
cursor: grabbing;
}
.heading {
position: fixed;
top: 30px;
left: 34px;
z-index: 2;
pointer-events: none;
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}
.heading .year {
margin: 0 0 5px;
color: #b69a65;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.32em;
text-transform: uppercase;
}
.heading h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 3vw, 40px);
font-weight: 500;
letter-spacing: 0.015em;
}
.disclaimer {
position: fixed;
left: 34px;
bottom: 28px;
z-index: 2;
max-width: 360px;
margin: 0;
color: rgba(238, 229, 211, 0.62);
font-size: 11px;
line-height: 1.55;
letter-spacing: 0.035em;
pointer-events: none;
}
.controls-hint {
position: fixed;
right: 34px;
bottom: 30px;
z-index: 2;
margin: 0;
color: rgba(238, 229, 211, 0.5);
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
pointer-events: none;
transition: opacity 0.5s ease;
}
.controls-hint.hidden {
opacity: 0;
}
#reset-view {
position: fixed;
top: 30px;
right: 32px;
z-index: 3;
border: 1px solid rgba(224, 204, 160, 0.3);
border-radius: 999px;
padding: 9px 15px;
color: #d9ccb0;
background: rgba(24, 25, 21, 0.48);
font: 600 10px/1 Inter, "Helvetica Neue", Arial, sans-serif;
letter-spacing: 0.12em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
transition:
color 0.2s ease,
border-color 0.2s ease,
background 0.2s ease;
}
#reset-view:hover {
color: #fff5df;
border-color: rgba(224, 204, 160, 0.65);
background: rgba(48, 48, 40, 0.7);
}
#loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
color: #cdbd99;
background: #181915;
font-size: 11px;
letter-spacing: 0.25em;
text-transform: uppercase;
transition: opacity 0.6s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.heading {
top: 22px;
left: 22px;
}
.disclaimer {
left: 22px;
bottom: 22px;
max-width: 260px;
}
.controls-hint {
display: none;
}
#reset-view {
top: 22px;
right: 20px;
}
}
</style>
</head>
<body>
<header class="heading">
<p class="year">1789</p>
<h1>Bastille Key</h1>
</header>
<button id="reset-view" type="button" aria-label="Reset camera view">
Reset view
</button>
<p class="disclaimer">
Stylized interpretation; not presented as an exact artifact replica.
</p>
<p class="controls-hint" id="controls-hint">
Drag to orbit · Scroll to zoom
</p>
<div id="loading">Preparing the exhibit</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const loading = document.getElementById("loading");
const resetButton = document.getElementById("reset-view");
const controlsHint = document.getElementById("controls-hint");
// ------------------------------------------------------------
// Renderer, scene and camera
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
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",
"A stylized large brass key beside a document stand identifying the storming of the Bastille in 1789."
);
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x181915);
scene.fog = new THREE.Fog(0x181915, 9, 22);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
40
);
const target = new THREE.Vector3(0.22, 1.85, 0);
const desired = {
theta: 0.025,
phi: 1.405,
radius: 8.25
};
const current = {
theta: desired.theta,
phi: desired.phi,
radius: desired.radius
};
function updateCamera() {
current.theta = THREE.MathUtils.lerp(
current.theta,
desired.theta,
0.085
);
current.phi = THREE.MathUtils.lerp(
current.phi,
desired.phi,
0.085
);
current.radius = THREE.MathUtils.lerp(
current.radius,
desired.radius,
0.085
);
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);
}
function responsiveRadius() {
const aspect = window.innerWidth / window.innerHeight;
if (aspect < 0.72) return 11.4;
if (aspect < 1.0) return 9.8;
if (aspect < 1.3) return 8.9;
return 8.25;
}
desired.radius = responsiveRadius();
current.radius = desired.radius;
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(
0xfff0d3,
0x182019,
1.7
);
scene.add(hemisphere);
const mainLight = new THREE.DirectionalLight(0xffe0ad, 3.4);
mainLight.position.set(-4.5, 7, 5.5);
mainLight.castShadow = true;
mainLight.shadow.mapSize.set(2048, 2048);
mainLight.shadow.camera.left = -5;
mainLight.shadow.camera.right = 5;
mainLight.shadow.camera.top = 6;
mainLight.shadow.camera.bottom = -2;
mainLight.shadow.camera.near = 0.5;
mainLight.shadow.camera.far = 18;
mainLight.shadow.normalBias = 0.025;
scene.add(mainLight);
const coolRim = new THREE.DirectionalLight(0xc7d6e8, 1.6);
coolRim.position.set(4, 4.5, -2.5);
scene.add(coolRim);
const warmFill = new THREE.PointLight(0xffc878, 24, 12, 2);
warmFill.position.set(2.8, 3.2, 3.8);
scene.add(warmFill);
const lowFill = new THREE.PointLight(0xe5d4b4, 8, 8, 2);
lowFill.position.set(-3, 1.2, 2.5);
scene.add(lowFill);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const brass = new THREE.MeshStandardMaterial({
color: 0x9d7335,
metalness: 0.74,
roughness: 0.34
});
const brassLight = new THREE.MeshStandardMaterial({
color: 0xc19a52,
metalness: 0.68,
roughness: 0.28
});
const brassDark = new THREE.MeshStandardMaterial({
color: 0x684821,
metalness: 0.72,
roughness: 0.42
});
const standMaterial = new THREE.MeshStandardMaterial({
color: 0x292a25,
metalness: 0.24,
roughness: 0.72
});
const stageMaterial = new THREE.MeshStandardMaterial({
color: 0x22231e,
metalness: 0.05,
roughness: 0.9
});
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x151612,
metalness: 0.02,
roughness: 0.96
});
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0x292a24,
metalness: 0,
roughness: 0.94
});
// ------------------------------------------------------------
// Room and display platform
// ------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.065;
floor.receiveShadow = true;
scene.add(floor);
const backWall = new THREE.Mesh(
new THREE.PlaneGeometry(30, 13),
wallMaterial
);
backWall.position.set(0, 5.1, -3.35);
backWall.receiveShadow = true;
scene.add(backWall);
const platform = new THREE.Mesh(
new THREE.BoxGeometry(7.25, 0.13, 3.25),
stageMaterial
);
platform.position.set(0.2, -0.065, 0.05);
platform.receiveShadow = true;
platform.castShadow = true;
scene.add(platform);
// Subtle wall seams provide scale without adding narrative text.
[-3.5, 0, 3.5].forEach((x) => {
const seam = new THREE.Mesh(
new THREE.BoxGeometry(0.025, 9, 0.025),
new THREE.MeshStandardMaterial({
color: 0x20211c,
roughness: 1
})
);
seam.position.set(x, 4.1, -3.32);
scene.add(seam);
});
// ------------------------------------------------------------
// Helper functions
// ------------------------------------------------------------
function rodBetween(start, end, radius, material) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
radius,
radius,
length,
20
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function makeLabelTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 672;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#ddd5c1";
ctx.fillRect(0, 0, canvas.width, canvas.height);
const paperGradient = ctx.createLinearGradient(
0,
0,
canvas.width,
canvas.height
);
paperGradient.addColorStop(0, "rgba(255,255,255,0.16)");
paperGradient.addColorStop(0.5, "rgba(255,255,255,0)");
paperGradient.addColorStop(1, "rgba(70,60,40,0.08)");
ctx.fillStyle = paperGradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = "rgba(78, 67, 47, 0.3)";
ctx.lineWidth = 2;
ctx.strokeRect(38, 38, canvas.width - 76, canvas.height - 76);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#373228";
ctx.font = "600 61px Georgia, 'Times New Roman', serif";
ctx.fillText("STORMING OF", 512, 242);
ctx.font = "700 84px Georgia, 'Times New Roman', serif";
ctx.fillText("THE BASTILLE", 512, 342);
ctx.strokeStyle = "rgba(94, 76, 46, 0.55)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(315, 414);
ctx.lineTo(709, 414);
ctx.stroke();
ctx.fillStyle = "#5c513d";
ctx.font = "600 40px Arial, Helvetica, sans-serif";
ctx.fillText("14 JULY 1789", 512, 492);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
texture.minFilter = THREE.LinearMipmapLinearFilter;
texture.magFilter = THREE.LinearFilter;
return texture;
}
// ------------------------------------------------------------
// Stylized large key
// ------------------------------------------------------------
const key = new THREE.Group();
key.position.set(-1.55, 0.1, 0.1);
key.rotation.set(0.015, -0.12, -0.1);
scene.add(key);
// Low display plinth beneath the key.
const keyPlinth = new THREE.Mesh(
new THREE.CylinderGeometry(1.08, 1.14, 0.14, 64),
standMaterial
);
keyPlinth.position.set(-1.55, 0.07, 0.1);
keyPlinth.castShadow = true;
keyPlinth.receiveShadow = true;
scene.add(keyPlinth);
const keyPlinthTop = new THREE.Mesh(
new THREE.CylinderGeometry(1.035, 1.035, 0.025, 64),
new THREE.MeshStandardMaterial({
color: 0x33342e,
roughness: 0.68,
metalness: 0.16
})
);
keyPlinthTop.position.set(-1.55, 0.151, 0.1);
keyPlinthTop.receiveShadow = true;
scene.add(keyPlinthTop);
// Solid oval bow with a cut-through opening.
const bowShape = new THREE.Shape();
bowShape.absellipse(
0,
0,
0.76,
0.96,
0,
Math.PI * 2,
false,
0
);
const bowHole = new THREE.Path();
bowHole.absellipse(
0,
0.07,
0.35,
0.53,
0,
Math.PI * 2,
true,
0
);
bowShape.holes.push(bowHole);
const bowGeometry = new THREE.ExtrudeGeometry(bowShape, {
depth: 0.24,
steps: 1,
curveSegments: 64,
bevelEnabled: true,
bevelSegments: 4,
bevelSize: 0.065,
bevelThickness: 0.055
});
bowGeometry.translate(0, 0, -0.12);
const bow = new THREE.Mesh(bowGeometry, brass);
bow.position.set(0, 3.02, 0);
bow.castShadow = true;
bow.receiveShadow = true;
key.add(bow);
// Long shaft.
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.125, 0.145, 1.55, 32),
brass
);
shaft.position.set(0, 1.46, 0);
shaft.castShadow = true;
shaft.receiveShadow = true;
key.add(shaft);
// Collar rings around the shaft.
[
{ y: 2.10, radius: 0.205, tube: 0.045 },
{ y: 1.91, radius: 0.18, tube: 0.035 },
{ y: 1.08, radius: 0.18, tube: 0.035 }
].forEach(({ y, radius, tube }) => {
const collar = new THREE.Mesh(
new THREE.TorusGeometry(radius, tube, 12, 36),
brassLight
);
collar.rotation.x = Math.PI / 2;
collar.position.set(0, y, 0);
collar.castShadow = true;
key.add(collar);
});
// Stepped solid key bit.
const bitShape = new THREE.Shape();
bitShape.moveTo(-0.16, 0.48);
bitShape.lineTo(0.78, 0.48);
bitShape.lineTo(0.78, 0.18);
bitShape.lineTo(0.58, 0.18);
bitShape.lineTo(0.58, 0.36);
bitShape.lineTo(0.28, 0.36);
bitShape.lineTo(0.28, 0.12);
bitShape.lineTo(0.86, 0.12);
bitShape.lineTo(0.86, 0.82);
bitShape.lineTo(-0.16, 0.82);
bitShape.closePath();
const bitGeometry = new THREE.ExtrudeGeometry(bitShape, {
depth: 0.22,
steps: 1,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.035,
bevelThickness: 0.035
});
bitGeometry.translate(0, 0, -0.11);
const bit = new THREE.Mesh(bitGeometry, brass);
bit.position.set(0, 0.55, 0);
bit.castShadow = true;
bit.receiveShadow = true;
key.add(bit);
// Restrained decorative studs on the bow.
[
[-0.52, 0.35],
[0.52, 0.35],
[-0.34, 0.76],
[0.34, 0.76]
].forEach(([x, y]) => {
const stud = new THREE.Mesh(
new THREE.CylinderGeometry(0.061, 0.061, 0.075, 20),
brassLight
);
stud.rotation.x = Math.PI / 2;
stud.position.set(x, y + 3.02, 0.17);
stud.castShadow = true;
key.add(stud);
});
// Small rear support, intentionally quiet and neutral.
const keySupport = new THREE.Mesh(
new THREE.BoxGeometry(0.32, 0.36, 0.18),
standMaterial
);
keySupport.position.set(-1.62, 0.31, -0.06);
keySupport.rotation.z = -0.1;
keySupport.castShadow = true;
scene.add(keySupport);
// ------------------------------------------------------------
// Neutral document stand
// ------------------------------------------------------------
const stand = new THREE.Group();
stand.position.set(1.48, 0, 0.05);
scene.add(stand);
const standBase = new THREE.Mesh(
new THREE.BoxGeometry(2.5, 0.18, 1.28),
standMaterial
);
standBase.position.set(0, 0.09, 0);
standBase.castShadow = true;
standBase.receiveShadow = true;
stand.add(standBase);
const baseInset = new THREE.Mesh(
new THREE.BoxGeometry(2.26, 0.025, 1.04),
new THREE.MeshStandardMaterial({
color: 0x34352f,
metalness: 0.12,
roughness: 0.75
})
);
baseInset.position.set(0, 0.192, 0);
baseInset.receiveShadow = true;
stand.add(baseInset);
stand.add(
rodBetween(
new THREE.Vector3(0, 0.19, -0.02),
new THREE.Vector3(0, 1.24, -0.02),
0.105,
standMaterial
)
);
stand.add(
rodBetween(
new THREE.Vector3(0, 0.19, -0.39),
new THREE.Vector3(0, 1.30, -0.10),
0.075,
standMaterial
)
);
const board = new THREE.Group();
board.position.set(0, 2.02, 0.1);
board.rotation.x = 0.115;
stand.add(board);
const boardBack = new THREE.Mesh(
new THREE.BoxGeometry(2.48, 1.76, 0.16),
standMaterial
);
boardBack.castShadow = true;
boardBack.receiveShadow = true;
board.add(boardBack);
const documentMaterial = new THREE.MeshStandardMaterial({
map: makeLabelTexture(),
color: 0xffffff,
roughness: 0.96,
metalness: 0
});
const documentPanel = new THREE.Mesh(
new THREE.PlaneGeometry(2.14, 1.405),
documentMaterial
);
documentPanel.position.z = 0.091;
documentPanel.receiveShadow = true;
board.add(documentPanel);
// Thin muted-gold frame around the document.
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0x80673b,
metalness: 0.56,
roughness: 0.45
});
const topFrame = new THREE.Mesh(
new THREE.BoxGeometry(2.22, 0.025, 0.025),
frameMaterial
);
topFrame.position.set(0, 0.73, 0.105);
board.add(topFrame);
const bottomFrame = topFrame.clone();
bottomFrame.position.y = -0.73;
board.add(bottomFrame);
const sideFrame = new THREE.Mesh(
new THREE.BoxGeometry(0.025, 1.46, 0.025),
frameMaterial
);
sideFrame.position.set(-1.11, 0, 0.105);
board.add(sideFrame);
const otherSideFrame = sideFrame.clone();
otherSideFrame.position.x = 1.11;
board.add(otherSideFrame);
// ------------------------------------------------------------
// Custom orbit and zoom controls
// ------------------------------------------------------------
const pointers = new Map();
let previousPinchDistance = 0;
let userHasMovedCamera = false;
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
);
}
function hideHint() {
controlsHint.classList.add("hidden");
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
previousPinchDistance = pointerDistance();
}
userHasMovedCamera = true;
hideHint();
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi - dy * 0.005,
0.92,
1.50
);
} else if (pointers.size === 2) {
const newDistance = pointerDistance();
if (previousPinchDistance > 0 && newDistance > 0) {
desired.radius = THREE.MathUtils.clamp(
desired.radius * (previousPinchDistance / newDistance),
5.6,
13.5
);
}
previousPinchDistance = newDistance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) {
previousPinchDistance = 0;
}
if (pointers.size === 0) {
renderer.domElement.classList.remove("dragging");
}
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("lostpointercapture", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
5.6,
13.5
);
userHasMovedCamera = true;
hideHint();
},
{ passive: false }
);
function resetView() {
desired.theta = 0.025;
desired.phi = 1.405;
desired.radius = responsiveRadius();
userHasMovedCamera = false;
}
resetButton.addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
window.addEventListener("keydown", (event) => {
const keyName = event.key.toLowerCase();
if (keyName === "arrowleft") desired.theta += 0.08;
else if (keyName === "arrowright") desired.theta -= 0.08;
else if (keyName === "arrowup") {
desired.phi = THREE.MathUtils.clamp(desired.phi - 0.06, 0.92, 1.5);
} else if (keyName === "arrowdown") {
desired.phi = THREE.MathUtils.clamp(desired.phi + 0.06, 0.92, 1.5);
} else if (keyName === "+" || keyName === "=") {
desired.radius = Math.max(5.6, desired.radius - 0.35);
} else if (keyName === "-") {
desired.radius = Math.min(13.5, desired.radius + 0.35);
} else {
return;
}
userHasMovedCamera = true;
hideHint();
});
// ------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
if (!userHasMovedCamera) {
desired.radius = responsiveRadius();
}
});
updateCamera();
renderer.render(scene, camera);
loading.classList.add("hidden");
renderer.setAnimationLoop(() => {
updateCamera();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```