Prompt specification
Build or customize the Three.js 3D scene "Museum earthquake observation room" 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: Museum earthquake observation room
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/museum-earthquake-observation-room-x1183
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts seismic waves. Compose a shaking-table exhibit, suspended pendulum recorder, and ground-section display; synchronize illustrative traces while labeling the apparatus a demonstration rather than a safety instrument. Voxel style.
Working Three.js Starter (museum-earthquake-observation-room-x1183):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voxel Seismic Waves Exhibit</title>
<style>
:root {
--cyan: #55d9ff;
--amber: #ffb347;
--panel: rgba(10, 18, 28, 0.88);
--border: rgba(120, 190, 220, 0.32);
--muted: #9cb1c4;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #0b111a;
color: #eef8ff;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
.title-panel {
position: fixed;
z-index: 10;
top: 18px;
left: 18px;
width: min(430px, calc(100vw - 36px));
padding: 14px 16px;
border: 1px solid var(--border);
border-left: 4px solid var(--cyan);
border-radius: 8px;
background: var(--panel);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
pointer-events: none;
}
.eyebrow {
margin-bottom: 5px;
color: var(--cyan);
font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(20px, 2.3vw, 31px);
line-height: 1.05;
letter-spacing: -0.03em;
}
.subtitle {
margin-top: 8px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.controls {
position: fixed;
z-index: 20;
top: 18px;
right: 18px;
display: flex;
gap: 8px;
align-items: center;
flex-wrap: wrap;
justify-content: flex-end;
max-width: min(460px, calc(100vw - 36px));
}
button {
min-height: 36px;
padding: 8px 12px;
border: 1px solid rgba(120, 190, 220, 0.34);
border-radius: 6px;
background: rgba(10, 18, 28, 0.9);
color: #eef8ff;
font: 650 12px/1 ui-sans-serif, system-ui, sans-serif;
cursor: pointer;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
button:hover,
button:focus-visible {
border-color: var(--cyan);
background: rgba(22, 43, 57, 0.96);
outline: none;
}
button.primary {
border-color: rgba(85, 217, 255, 0.75);
color: var(--cyan);
}
.hint {
width: 100%;
padding: 7px 10px;
border: 1px solid rgba(120, 190, 220, 0.2);
border-radius: 6px;
background: rgba(10, 18, 28, 0.76);
color: #afc4d5;
font: 500 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
text-align: right;
pointer-events: none;
}
.tag {
position: fixed;
z-index: 8;
display: none;
padding: 7px 10px;
border: 1px solid rgba(120, 190, 220, 0.36);
border-left: 4px solid var(--amber);
border-radius: 4px;
background: rgba(8, 15, 23, 0.84);
color: #f2f8fc;
box-shadow: 0 7px 20px rgba(0, 0, 0, 0.24);
font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
transform: translate(-50%, -100%);
}
.tag::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 15px;
background: linear-gradient(var(--amber), transparent);
}
.safety-banner {
position: fixed;
z-index: 12;
left: 50%;
bottom: 16px;
width: max-content;
max-width: calc(100vw - 32px);
padding: 10px 15px;
border: 1px solid rgba(255, 179, 71, 0.5);
border-radius: 6px;
background: rgba(25, 17, 8, 0.9);
color: #ffd9a3;
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
font: 750 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.07em;
text-align: center;
text-transform: uppercase;
pointer-events: none;
transform: translateX(-50%);
}
@media (max-width: 720px) {
.title-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 11px 13px;
}
.subtitle {
display: none;
}
.controls {
top: 105px;
right: 12px;
max-width: calc(100vw - 24px);
}
.hint {
display: none;
}
.tag {
font-size: 8px;
padding: 5px 7px;
}
.safety-banner {
bottom: 10px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive voxel seismic waves exhibit"></div>
<header class="title-panel">
<div class="eyebrow">Exhibit 04 / Wave Laboratory</div>
<h1>Seismic Motion, Made Visible</h1>
<div class="subtitle">
A synchronized voxel demonstration of table motion, pendulum response,
and traveling waves through a layered ground section.
</div>
</header>
<nav class="controls" aria-label="Exhibit controls">
<button id="pauseButton" class="primary" type="button">Pause</button>
<button id="pulseButton" type="button">Apply Pulse</button>
<button id="clearButton" type="button">Clear Traces</button>
<button id="viewButton" type="button">Reset View</button>
<div class="hint">Drag to orbit · Scroll or pinch to zoom</div>
</nav>
<div id="tableTag" class="tag">Shaking table / input motion</div>
<div id="pendulumTag" class="tag">Suspended pendulum recorder</div>
<div id="groundTag" class="tag">Ground-section display</div>
<div id="screenTag" class="tag">Synchronized illustrative traces</div>
<footer class="safety-banner">
Demonstration apparatus only — illustrative motion and traces; not a safety instrument.
</footer>
<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 stage = document.querySelector("#stage");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0b111a);
scene.fog = new THREE.Fog(0x0b111a, 22, 43);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const controls = {
target: new THREE.Vector3(0, 2.55, 0),
radius: 18.5,
theta: 0.38,
phi: 1.03,
minRadius: 11,
maxRadius: 27,
minPhi: 0.38,
maxPhi: 1.38
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xbadfff, 0x29303a, 2.1);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff0d2, 3.4);
key.position.set(-8, 15, 9);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -15;
key.shadow.camera.right = 15;
key.shadow.camera.top = 15;
key.shadow.camera.bottom = -10;
key.shadow.camera.near = 1;
key.shadow.camera.far = 40;
key.shadow.bias = -0.00025;
scene.add(key);
const rim = new THREE.DirectionalLight(0x49c9ff, 1.5);
rim.position.set(12, 8, -10);
scene.add(rim);
const palette = {
floor: new THREE.MeshStandardMaterial({
color: 0x182330,
roughness: 0.96,
flatShading: true
}),
plinth: new THREE.MeshStandardMaterial({
color: 0x263644,
roughness: 0.9,
flatShading: true
}),
dark: new THREE.MeshStandardMaterial({
color: 0x111a24,
roughness: 0.82,
flatShading: true
}),
steel: new THREE.MeshStandardMaterial({
color: 0x71889a,
roughness: 0.62,
metalness: 0.28,
flatShading: true
}),
cyan: new THREE.MeshStandardMaterial({
color: 0x39c8ef,
roughness: 0.5,
metalShading: true,
emissive: 0x0d5269,
emissiveIntensity: 0.55,
flatShading: true
}),
amber: new THREE.MeshStandardMaterial({
color: 0xffa83d,
roughness: 0.55,
emissive: 0x6d2f00,
emissiveIntensity: 0.45,
flatShading: true
}),
cream: new THREE.MeshStandardMaterial({
color: 0xe9d8b7,
roughness: 0.85,
flatShading: true
}),
paper: new THREE.MeshStandardMaterial({
color: 0xf4f0df,
roughness: 0.94,
flatShading: true
}),
soil: new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96,
flatShading: true
}),
glassDark: new THREE.MeshStandardMaterial({
color: 0x183347,
roughness: 0.45,
metalness: 0.15,
emissive: 0x061b25,
emissiveIntensity: 0.5,
flatShading: true
})
};
function addBox(parent, size, position, material, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
if (options.rotationZ) mesh.rotation.z = options.rotationZ;
if (options.rotationX) mesh.rotation.x = options.rotationX;
if (options.rotationY) mesh.rotation.y = options.rotationY;
parent.add(mesh);
return mesh;
}
function addBeam(parent, x1, y1, x2, y2, z, thickness, material) {
const dx = x2 - x1;
const dy = y2 - y1;
const length = Math.hypot(dx, dy);
const angle = Math.atan2(dy, dx);
return addBox(
parent,
[length, thickness, thickness],
[(x1 + x2) / 2, (y1 + y2) / 2, z],
material,
{ rotationZ: angle }
);
}
// Floor and subtle technical grid.
addBox(scene, [34, 0.36, 24], [0, -0.28, 0], palette.floor, {
cast: false
});
const grid = new THREE.GridHelper(30, 30, 0x335065, 0x263847);
grid.position.y = -0.085;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
// ---------------------------------------------------------------------
// Shaking table exhibit
// ---------------------------------------------------------------------
const tableAssembly = new THREE.Group();
tableAssembly.position.set(-4.35, 0, 0.55);
scene.add(tableAssembly);
addBox(
tableAssembly,
[7.1, 0.48, 4.25],
[0, 0.25, 0.25],
palette.plinth
);
addBox(
tableAssembly,
[6.75, 0.12, 3.95],
[0, 0.54, 0.25],
palette.dark
);
// Fixed legs and cross-bracing.
for (const x of [-2.75, 2.75]) {
for (const z of [-1.25, 1.75]) {
addBox(
tableAssembly,
[0.42, 0.58, 0.42],
[x, 0.78, z],
palette.steel
);
addBox(
tableAssembly,
[0.58, 0.12, 0.58],
[x, 0.52, z],
palette.dark
);
}
}
addBeam(
tableAssembly,
-2.7, 0.64, 2.7, 1.08, -1.35, 0.12, palette.steel
);
addBeam(
tableAssembly,
2.7, 0.64, -2.7, 1.08, -1.35, 0.12, palette.steel
);
// Boxy actuator housings and moving shoes.
for (const x of [-3.28, 3.28]) {
addBox(
tableAssembly,
[0.62, 0.48, 1.35],
[x, 0.87, 0.25],
palette.dark
);
addBox(
tableAssembly,
[0.22, 0.26, 0.82],
[x + (x < 0 ? 0.3 : -0.3), 0.92, 0.25],
palette.amber
);
}
const movingTable = new THREE.Group();
tableAssembly.add(movingTable);
addBox(
movingTable,
[6.3, 0.3, 3.25],
[0, 1.25, 0.25],
palette.steel
);
addBox(
movingTable,
[6.02, 0.08, 2.98],
[0, 1.44, 0.25],
palette.dark
);
// Bright alternating blocks around the moving deck.
for (let i = 0; i < 10; i++) {
addBox(
movingTable,
[0.31, 0.12, 0.16],
[-2.65 + i * 0.59, 1.44, 1.91],
i % 2 ? palette.cyan : palette.amber
);
}
// A block-built specimen on the shaking deck.
const specimen = new THREE.Group();
specimen.position.set(1.42, 1.5, 0.35);
movingTable.add(specimen);
for (let ix = 0; ix < 4; ix++) {
for (let iz = 0; iz < 4; iz++) {
const floors = 1 + ((ix * 3 + iz * 2) % 3);
for (let iy = 0; iy < floors; iy++) {
const material =
(ix + iz + iy) % 5 === 0 ? palette.amber : palette.cream;
addBox(
specimen,
[0.38, 0.38, 0.38],
[
(ix - 1.5) * 0.42,
0.2 + iy * 0.4,
(iz - 1.5) * 0.42
],
material
);
}
}
}
// Recorder body under the pendulum stylus.
const recorder = new THREE.Group();
recorder.position.set(-1, 1.43, -0.4);
movingTable.add(recorder);
addBox(recorder, [1.02, 0.3, 0.78], [0, 0.17, 0], palette.dark);
addBox(recorder, [0.84, 0.035, 0.62], [0, 0.34, 0], palette.paper);
addBox(recorder, [0.15, 0.09, 0.08], [0.35, 0.39, 0.29], palette.cyan);
// ---------------------------------------------------------------------
// Suspended pendulum recorder
// ---------------------------------------------------------------------
// Fixed gantry.
for (const x of [-3.18, 1.18]) {
addBox(
tableAssembly,
[0.34, 4.95, 0.38],
[x, 3.02, -0.4],
palette.steel
);
addBox(
tableAssembly,
[0.68, 0.18, 0.72],
[x, 0.59, -0.4],
palette.dark
);
}
addBox(
tableAssembly,
[4.75, 0.34, 0.44],
[-1, 5.48, -0.4],
palette.steel
);
addBeam(
tableAssembly,
-3.18, 4.65, -1.85, 5.34, -0.4, 0.16, palette.steel
);
addBeam(
tableAssembly,
1.18, 4.65, -0.18, 5.34, -0.4, 0.16, palette.steel
);
const pivotX = tableAssembly.position.x - 1;
const pivotY = 5.25;
const pivotZ = tableAssembly.position.z - 0.4;
const pendulum = new THREE.Group();
pendulum.position.set(pivotX, pivotY, pivotZ);
scene.add(pendulum);
addBox(pendulum, [0.52, 0.52, 0.52], [0, 0, 0], palette.dark);
addBox(pendulum, [0.16, 3, 0.16], [0, -1.5, 0], palette.steel);
addBox(pendulum, [0.68, 0.68, 0.68], [0, -2.95, 0], palette.amber);
addBox(pendulum, [0.23, 0.23, 0.23], [0, -2.95, 0.38], palette.dark);
addBox(pendulum, [0.055, 0.5, 0.055], [0, -3.23, 0], palette.cyan);
// ---------------------------------------------------------------------
// Layered ground-section display
// ---------------------------------------------------------------------
const groundSection = new THREE.Group();
groundSection.position.set(4.7, 0, 0.2);
scene.add(groundSection);
addBox(
groundSection,
[7.25, 0.34, 3.45],
[0, 0.15, 0],
palette.plinth
);
const sectionWidth = 12 * 0.55;
const sectionDepth = 4 * 0.68;
const cellWidth = 0.55;
const cellDepth = 0.68;
const columns = 12;
const depthRows = 4;
function createLayer(y, height, baseHex, rowOffset = 0) {
const material = palette.soil.clone();
material.color.set(0xffffff);
const mesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(cellWidth - 0.04, height - 0.035, cellDepth - 0.04),
material,
columns * depthRows
);
mesh.castShadow = true;
mesh.receiveShadow = true;
const dummy = new THREE.Object3D();
const color = new THREE.Color();
const baseColor = new THREE.Color(baseHex);
let index = 0;
for (let ix = 0; ix < columns; ix++) {
for (let iz = 0; iz < depthRows; iz++) {
const x = (ix - (columns - 1) / 2) * cellWidth;
const z = (iz - (depthRows - 1) / 2) * cellDepth;
const row = iz + rowOffset;
dummy.position.set(x, y, z);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
color.copy(baseColor);
color.offsetHSL(
(((ix * 7 + iz * 11 + row * 3) % 9) - 4) * 0.0025,
(((ix + iz + row) % 3) - 1) * 0.018,
(((ix * 5 + iz * 2 + row) % 7) - 3) * 0.012
);
mesh.setColorAt(index, color);
index++;
}
}
mesh.instanceMatrix.needsUpdate = true;
mesh.instanceColor.needsUpdate = true;
groundSection.add(mesh);
return mesh;
}
createLayer(0.73, 0.9, 0x536579);
createLayer(1.43, 0.62, 0xb47c4c, 1);
createLayer(2.05, 0.56, 0xd1a466, 2);
createLayer(2.43, 0.16, 0x6f8d5e, 3);
// Dark, jagged fault trace across the exposed face.
const faultMaterial = new THREE.MeshStandardMaterial({
color: 0x2b1816,
roughness: 1,
flatShading: true
});
for (let i = 0; i < 8; i++) {
addBox(
groundSection,
[0.095, 0.38, 0.055],
[
1.03 + Math.sin(i * 1.7) * 0.12,
0.47 + i * 0.27,
sectionDepth / 2 + 0.025
],
faultMaterial,
{ rotationZ: Math.sin(i * 2.1) * 0.23 }
);
}
// Thin frame posts emphasize that this is a display model.
for (const x of [-sectionWidth / 2 - 0.08, sectionWidth / 2 + 0.08]) {
addBox(
groundSection,
[0.14, 2.5, 0.18],
[x, 1.38, -sectionDepth / 2 - 0.08],
palette.dark
);
}
// Surface building that responds to the illustrated ground signal.
const groundHouse = new THREE.Group();
groundHouse.position.set(-0.78, 2.55, -0.25);
groundSection.add(groundHouse);
for (let ix = 0; ix < 3; ix++) {
for (let iz = 0; iz < 3; iz++) {
const h = 0.28 + ((ix + iz) % 2) * 0.18;
addBox(
groundHouse,
[0.3, h, 0.3],
[
(ix - 1) * 0.34,
h / 2,
(iz - 1) * 0.34
],
ix === 1 && iz === 1 ? palette.amber : palette.cream
);
}
}
addBox(
groundHouse,
[0.12, 0.6, 0.12],
[0, 0.72, 0],
palette.steel
);
// Animated voxel wave markers visible on the cutaway face.
const waveCount = 36;
const waveMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.13, 0.13, 0.13),
new THREE.MeshBasicMaterial({
color: 0xffffff,
toneMapped: false
}),
waveCount
);
waveMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
waveMesh.frustumCulled = false;
groundSection.add(waveMesh);
const waveDummy = new THREE.Object3D();
const waveColor = new THREE.Color();
const warmWave = new THREE.Color(0xff9d3d);
const coolWave = new THREE.Color(0x42d9ff);
// ---------------------------------------------------------------------
// Trace monitor
// ---------------------------------------------------------------------
const traceCanvas = document.createElement("canvas");
traceCanvas.width = 1024;
traceCanvas.height = 512;
const traceContext = traceCanvas.getContext("2d");
const traceTexture = new THREE.CanvasTexture(traceCanvas);
traceTexture.colorSpace = THREE.SRGBColorSpace;
traceTexture.minFilter = THREE.LinearFilter;
traceTexture.magFilter = THREE.LinearFilter;
const monitor = new THREE.Group();
monitor.position.set(4.65, 4.78, -2.08);
scene.add(monitor);
addBox(monitor, [7.05, 3.55, 0.28], [0, 0, -0.12], palette.dark);
addBox(monitor, [6.65, 3.16, 0.07], [0, 0, 0.055], palette.steel);
const screen = new THREE.Mesh(
new THREE.PlaneGeometry(6.42, 2.92),
new THREE.MeshBasicMaterial({
map: traceTexture,
toneMapped: false
})
);
screen.position.z = 0.101;
monitor.add(screen);
addBox(monitor, [0.34, 3.0, 0.34], [0, -3.0, -0.1], palette.steel);
addBox(monitor, [2.15, 0.18, 0.72], [0, -4.43, -0.1], palette.dark);
addBox(monitor, [1.35, 0.08, 0.42], [0, -4.3, 0], palette.amber);
const historyLength = 230;
const tableHistory = new Array(historyLength).fill(0);
const pendulumHistory = new Array(historyLength).fill(0);
const groundHistory = new Array(historyLength).fill(0);
function drawTraceScreen() {
const ctx = traceContext;
const width = traceCanvas.width;
const height = traceCanvas.height;
const left = 178;
const right = 24;
const plotWidth = width - left - right;
const top = 77;
const laneHeight = 130;
const colors = ["#55d9ff", "#ffb347", "#ff744f"];
const data = [tableHistory, pendulumHistory, groundHistory];
const labels = ["SHAKING TABLE", "PENDULUM", "SUBSURFACE"];
ctx.fillStyle = "#07121d";
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "#dff7ff";
ctx.font = "700 28px monospace";
ctx.fillText("SEISMIC MOTION / SYNCHRONIZED TRACE", 26, 38);
ctx.fillStyle = "#ffbf73";
ctx.font = "700 15px monospace";
ctx.fillText("ILLUSTRATIVE ONLY — NOT A SAFETY INSTRUMENT", 27, 61);
for (let lane = 0; lane < 3; lane++) {
const y0 = top + lane * laneHeight;
const mid = y0 + 62;
ctx.fillStyle = lane % 2 ? "#0b1925" : "#0a1722";
ctx.fillRect(left, y0 + 5, plotWidth, 116);
ctx.strokeStyle = "rgba(104, 148, 171, 0.22)";
ctx.lineWidth = 1;
ctx.setLineDash([5, 6]);
for (let g = 0; g <= 6; g++) {
const gx = left + (g / 6) * plotWidth;
ctx.beginPath();
ctx.moveTo(gx, y0 + 7);
ctx.lineTo(gx, y0 + 119);
ctx.stroke();
}
ctx.beginPath();
ctx.moveTo(left, mid);
ctx.lineTo(left + plotWidth, mid);
ctx.stroke();
ctx.setLineDash([]);
ctx.fillStyle = colors[lane];
ctx.font = "700 17px monospace";
ctx.fillText(labels[lane], 26, mid + 5);
ctx.fillStyle = "#6f8b9e";
ctx.font = "13px monospace";
ctx.fillText("NORMALIZED", 26, mid + 25);
ctx.strokeStyle = colors[lane];
ctx.lineWidth = 3;
ctx.beginPath();
for (let i = 0; i < data[lane].length; i++) {
const x = left + (i / (historyLength - 1)) * plotWidth;
const y = mid - data[lane][i] * 41;
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.stroke();
}
ctx.fillStyle = "#7693a7";
ctx.font = "13px monospace";
ctx.fillText("COMMON TIME BASE / UNCALIBRATED / EXHIBIT VALUES", 27, 493);
traceTexture.needsUpdate = true;
}
drawTraceScreen();
// ---------------------------------------------------------------------
// Direct camera controls: orbit, wheel zoom, and touch pinch zoom.
// ---------------------------------------------------------------------
const pointers = new Map();
let lastX = 0;
let lastY = 0;
let lastPinchDistance = 0;
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
lastX = event.clientX;
lastY = event.clientY;
} else if (pointers.size === 2) {
const points = [...pointers.values()];
lastPinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
controls.minPhi,
controls.maxPhi
);
lastX = event.clientX;
lastY = event.clientY;
} else if (pointers.size === 2) {
const points = [...pointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (lastPinchDistance > 0 && distance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (lastPinchDistance / distance),
controls.minRadius,
controls.maxRadius
);
}
lastPinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) lastPinchDistance = 0;
if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
lastX = remaining.x;
lastY = remaining.y;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("lostpointercapture", releasePointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.012,
controls.minRadius,
controls.maxRadius
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
function resetView() {
controls.target.set(0, 2.55, 0);
controls.radius = 18.5;
controls.theta = 0.38;
controls.phi = 1.03;
}
// ---------------------------------------------------------------------
// Projected apparatus labels
// ---------------------------------------------------------------------
const tableTag = document.querySelector("#tableTag");
const pendulumTag = document.querySelector("#pendulumTag");
const groundTag = document.querySelector("#groundTag");
const screenTag = document.querySelector("#screenTag");
const projected = new THREE.Vector3();
function placeLabel(element, worldPosition) {
projected.copy(worldPosition).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.2 &&
Math.abs(projected.y) < 1.2;
element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
// ---------------------------------------------------------------------
// UI actions
// ---------------------------------------------------------------------
let paused = false;
let pulseAge = 100;
let simTime = 0;
const pauseButton = document.querySelector("#pauseButton");
const pulseButton = document.querySelector("#pulseButton");
const clearButton = document.querySelector("#clearButton");
const viewButton = document.querySelector("#viewButton");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
pauseButton.setAttribute("aria-pressed", String(paused));
});
pulseButton.addEventListener("click", () => {
pulseAge = 0;
});
clearButton.addEventListener("click", () => {
tableHistory.fill(0);
pendulumHistory.fill(0);
groundHistory.fill(0);
drawTraceScreen();
});
viewButton.addEventListener("click", resetView);
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
let previousTime = performance.now();
let traceAccumulator = 0;
function animate(now) {
requestAnimationFrame(animate);
const dt = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (!paused) {
simTime += dt;
pulseAge += dt;
}
const twoPi = Math.PI * 2;
const baseFrequency = 1.02;
// A shared illustrative excitation drives all three readouts.
const primaryMotion =
Math.sin(twoPi * baseFrequency * simTime) * 0.48 +
Math.sin(twoPi * 2.31 * simTime + 0.8) * 0.075;
const pulse =
pulseAge < 4.5
? Math.exp(-2.25 * pulseAge) * Math.sin(pulseAge * 10.5) * 0.24
: 0;
const tableOffset = primaryMotion + pulse;
const pendulumAngle =
Math.sin(twoPi * baseFrequency * simTime - 0.48) * 0.135 +
Math.sin(twoPi * 0.54 * simTime + 0.4) * 0.032 +
pulse * 0.42;
const groundSignal =
Math.sin(twoPi * baseFrequency * simTime - 0.1) * 0.11 +
Math.sin(twoPi * 1.63 * simTime + 0.35) * 0.025 +
pulse * 0.45;
movingTable.position.x = tableOffset;
pendulum.rotation.z = pendulumAngle;
// Ground house responds with a smaller, delayed motion.
groundHouse.position.y = 2.55 + groundSignal * 0.26;
groundHouse.position.x = -0.78 + groundSignal * 0.18;
// Animated wave packets crossing the section face.
for (let i = 0; i < waveCount; i++) {
const phase = (simTime * 0.34 + i / waveCount) % 1;
const level = i % 3;
const y = [0.73, 1.43, 2.05][level];
const x = -sectionWidth / 2 + phase * sectionWidth;
const z = sectionDepth / 2 + 0.075 + (i % 2) * 0.018;
const scale = 0.68 + Math.sin(phase * Math.PI) * 0.75;
waveDummy.position.set(x, y, z);
waveDummy.scale.setScalar(scale);
waveDummy.rotation.set(0, 0, phase * Math.PI * 2);
waveDummy.updateMatrix();
waveMesh.setMatrixAt(i, waveDummy.matrix);
waveColor.copy(warmWave).lerp(coolWave, phase);
waveColor.multiplyScalar(0.75 + Math.sin(phase * Math.PI) * 0.45);
waveMesh.setColorAt(i, waveColor);
}
waveMesh.instanceMatrix.needsUpdate = true;
waveMesh.instanceColor.needsUpdate = true;
// Sample all traces on one common time base.
if (!paused) {
traceAccumulator += dt;
if (traceAccumulator >= 0.05) {
traceAccumulator %= 0.05;
tableHistory.push(THREE.MathUtils.clamp(tableOffset / 0.65, -1, 1));
pendulumHistory.push(
THREE.MathUtils.clamp(pendulumAngle / 0.22, -1, 1)
);
groundHistory.push(
THREE.MathUtils.clamp(groundSignal / 0.19, -1, 1)
);
tableHistory.shift();
pendulumHistory.shift();
groundHistory.shift();
drawTraceScreen();
}
}
updateCamera();
placeLabel(
tableTag,
new THREE.Vector3(
tableAssembly.position.x + movingTable.position.x + 1.42,
3.05,
tableAssembly.position.z + 0.45
)
);
placeLabel(
pendulumTag,
new THREE.Vector3(pivotX, 5.82, pivotZ)
);
placeLabel(
groundTag,
new THREE.Vector3(
groundSection.position.x - 0.6,
3.25,
groundSection.position.z + sectionDepth / 2
)
);
placeLabel(
screenTag,
new THREE.Vector3(
monitor.position.x,
monitor.position.y + 1.9,
monitor.position.z
)
);
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
```