Prompt specification
Build or customize the Three.js 3D scene "Science Fair Evidence Table" 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: Science Fair Evidence Table
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/science-fair-evidence-table-x3379
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: science fair evidence table. Build a fictional experiment display with apparatus, recorded observations, and proposed explanations. Mark controlled comparisons and missing observations without presenting hypotheses as established results. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (science-fair-evidence-table-x3379):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Bridge Lab — Fictional Evidence Table</title>
<style>
:root {
--ink: #10252a;
--paper: #f4eedc;
--cyan: #49e0d0;
--coral: #ff6f61;
--amber: #ffc857;
--pink: #ef73b4;
--blue: #69a9ff;
--panel: rgba(10, 28, 32, 0.93);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #08171c;
color: var(--paper);
font-family: "Courier New", Courier, monospace;
}
body {
background:
radial-gradient(circle at 25% 20%, rgba(73, 224, 208, 0.10), transparent 30%),
radial-gradient(circle at 80% 75%, rgba(239, 115, 180, 0.09), transparent 35%),
#08171c;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene.dragging { cursor: grabbing; }
#scene.pickable { cursor: pointer; }
.header {
position: fixed;
top: 22px;
left: 22px;
z-index: 5;
width: min(570px, calc(100vw - 44px));
pointer-events: none;
filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35));
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border: 2px solid var(--cyan);
background: rgba(8, 23, 28, 0.88);
color: var(--cyan);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
background: var(--coral);
box-shadow: 3px 3px 0 rgba(255, 111, 97, 0.25);
}
h1 {
margin: 10px 0 5px;
font-size: clamp(27px, 3.5vw, 45px);
line-height: 0.95;
letter-spacing: -0.06em;
text-transform: uppercase;
color: #fff9e9;
text-shadow: 4px 4px 0 #15383d;
}
.question {
max-width: 530px;
margin: 0;
color: #c6d8d2;
font-size: 13px;
line-height: 1.45;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 12px;
}
.chip {
padding: 6px 8px;
border: 1px solid currentColor;
background: rgba(8, 23, 28, 0.78);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.chip.observation { color: var(--cyan); }
.chip.comparison { color: var(--blue); }
.chip.missing { color: var(--amber); }
.chip.hypothesis { color: var(--pink); }
.inspector {
position: fixed;
top: 22px;
right: 22px;
z-index: 6;
width: 350px;
max-height: calc(100vh - 44px);
overflow: auto;
padding: 18px;
border: 2px solid #426269;
background: var(--panel);
box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.34);
backdrop-filter: blur(10px);
transition: width 180ms ease, transform 180ms ease;
}
.inspector::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 6px;
background: var(--accent, var(--cyan));
}
.inspector-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.type {
color: var(--accent, var(--cyan));
font-size: 10px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#closeInspector {
width: 26px;
height: 26px;
border: 1px solid #527077;
background: transparent;
color: #bcd0ca;
font: 700 16px "Courier New", monospace;
cursor: pointer;
}
#closeInspector:hover {
border-color: var(--accent, var(--cyan));
color: var(--accent, var(--cyan));
}
#inspectorTitle {
margin: 11px 0 4px;
color: #fff8e8;
font-size: 21px;
line-height: 1.12;
}
#inspectorStatus {
margin: 0 0 14px;
color: var(--accent, var(--cyan));
font-size: 10px;
line-height: 1.4;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.rule {
height: 2px;
margin: 13px 0;
background: repeating-linear-gradient(
90deg,
#3e5b60 0,
#3e5b60 9px,
transparent 9px,
transparent 13px
);
}
#facts {
margin: 0;
padding: 0;
list-style: none;
}
#facts li {
position: relative;
margin: 0 0 10px;
padding: 0 0 0 17px;
color: #d6e2dc;
font-size: 12px;
line-height: 1.48;
}
#facts li::before {
content: "";
position: absolute;
top: 5px;
left: 0;
width: 7px;
height: 7px;
background: var(--accent, var(--cyan));
}
.boundary {
margin-top: 16px;
padding: 12px;
border: 1px dashed var(--amber);
background: rgba(255, 200, 87, 0.055);
}
.boundary strong {
display: block;
margin-bottom: 6px;
color: var(--amber);
font-size: 10px;
letter-spacing: 0.09em;
}
.boundary p {
margin: 0;
color: #d9dfd6;
font-size: 11px;
line-height: 1.5;
}
body.inspector-closed .inspector {
width: 190px;
}
body.inspector-closed .inspector-content,
body.inspector-closed .rule,
body.inspector-closed .boundary {
display: none;
}
.toolbar {
position: fixed;
left: 50%;
bottom: 22px;
z-index: 6;
display: flex;
gap: 7px;
padding: 7px;
transform: translateX(-50%);
border: 2px solid #36545a;
background: rgba(8, 23, 28, 0.91);
box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.32);
}
.toolbar button {
min-width: 88px;
padding: 9px 11px;
border: 1px solid #58767b;
background: #142d32;
color: #e9f2e9;
font: 700 10px "Courier New", monospace;
letter-spacing: 0.06em;
text-transform: uppercase;
cursor: pointer;
}
.toolbar button:hover,
.toolbar button:focus-visible {
border-color: var(--cyan);
background: #1a3c40;
color: var(--cyan);
outline: none;
}
.hint {
position: fixed;
left: 22px;
bottom: 22px;
z-index: 5;
max-width: 270px;
color: #91aaa7;
font-size: 10px;
line-height: 1.5;
pointer-events: none;
}
.hint b {
color: var(--cyan);
}
.notice {
position: fixed;
left: 50%;
top: 19px;
z-index: 4;
transform: translateX(-50%);
padding: 7px 10px;
border: 1px solid rgba(255, 200, 87, 0.65);
background: rgba(24, 31, 27, 0.82);
color: var(--amber);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #08171c;
color: var(--cyan);
font-size: 12px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.loading.hidden { display: none; }
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 1050px) {
.header { width: 470px; }
.inspector { width: 310px; }
.notice { display: none; }
}
@media (max-width: 760px) {
.header {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
}
h1 { font-size: 28px; }
.question { font-size: 11px; max-width: 90%; }
.chips { gap: 4px; margin-top: 8px; }
.chip { font-size: 8px; padding: 4px 5px; }
.inspector {
top: auto;
right: 14px;
bottom: 74px;
width: min(330px, calc(100vw - 28px));
max-height: 45vh;
padding: 14px;
}
body.inspector-closed .inspector { width: 175px; }
.toolbar { bottom: 14px; }
.toolbar button { min-width: 72px; padding: 8px; }
.hint { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel science fair evidence table"></canvas>
<header class="header">
<div class="eyebrow">Science fair / evidence table 04</div>
<h1>Voxel Bridge Lab</h1>
<p class="question">
Fictional question: does one center support change how a voxel bridge bends
under a six-block load?
</p>
<div class="chips" aria-label="Evidence counts">
<span class="chip observation">2 recorded observations</span>
<span class="chip comparison">1 controlled comparison</span>
<span class="chip missing">3 missing observations</span>
<span class="chip hypothesis">2 proposed explanations</span>
</div>
</header>
<aside class="inspector" id="inspector" style="--accent:#49e0d0">
<div class="inspector-top">
<div class="type" id="inspectorType">Recorded observation</div>
<button id="closeInspector" aria-label="Collapse evidence panel">−</button>
</div>
<div class="inspector-content">
<h2 id="inspectorTitle"></h2>
<p id="inspectorStatus"></p>
<div class="rule"></div>
<ul id="facts"></ul>
<div class="boundary">
<strong>Evidence boundary</strong>
<p id="inspectorBoundary"></p>
</div>
</div>
</aside>
<div class="notice">Fictional data · Hypotheses are not established results</div>
<div class="toolbar" aria-label="Camera controls">
<button id="resetView">Reset view</button>
<button id="planView">Plan view</button>
<button id="frontView">Front view</button>
</div>
<div class="hint">
<b>Drag</b> to orbit · <b>Scroll</b> to zoom · <b>Click</b> a card for its evidence boundary.
</div>
<div class="loading" id="loading">Assembling voxel evidence table…</div>
<div class="sr-only" id="accessibleSummary">
This fictional experiment compares two identical voxel bridges under a six-block load.
Setup A has no center support and its middle block was observed about one block lower.
Setup B has one center support and its middle block was observed level.
Repeated trials, exact failure loads, and placement records are missing.
Support-related bending and alignment-related explanations remain hypotheses.
</div>
<noscript>This interactive display requires JavaScript.</noscript>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Core scene
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x08171c);
scene.fog = new THREE.Fog(0x08171c, 25, 49);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
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.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 1.65, -0.15);
const desired = { theta: 0.48, phi: 0.98, radius: 21.7 };
const current = { ...desired };
const hemi = new THREE.HemisphereLight(0xc9fff2, 0x17232b, 2.1);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xfff0cf, 4.4);
keyLight.position.set(6, 12, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -14;
keyLight.shadow.camera.right = 14;
keyLight.shadow.camera.top = 14;
keyLight.shadow.camera.bottom = -12;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const cyanLight = new THREE.PointLight(0x49e0d0, 32, 18, 2);
cyanLight.position.set(-8, 5, 4);
scene.add(cyanLight);
const pinkLight = new THREE.PointLight(0xef73b4, 24, 17, 2);
pinkLight.position.set(8, 4, -2);
scene.add(pinkLight);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.76,
metalness: 0.04,
flatShading: true
})
);
}
return materialCache.get(color);
}
function box(w, h, d, color, x, y, z, parent = scene, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
typeof color === "number" ? material(color) : color
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeLineBox(w, h, d, color, x, y, z, parent = scene, dashed = false) {
const geometry = new THREE.EdgesGeometry(new THREE.BoxGeometry(w, h, d));
const options = {
color,
transparent: true,
opacity: dashed ? 0.72 : 0.95,
depthTest: true
};
const lineMaterial = dashed
? new THREE.LineDashedMaterial({ ...options, dashSize: 0.12, gapSize: 0.08 })
: new THREE.LineBasicMaterial(options);
const edges = new THREE.LineSegments(geometry, lineMaterial);
edges.position.set(x, y, z);
if (dashed) edges.computeLineDistances();
parent.add(edges);
return edges;
}
// -------------------------------------------------------------------------
// Floor, table, and evidence board
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
new THREE.MeshStandardMaterial({ color: 0x0c2228, roughness: 0.95 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.58;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(42, 42, 0x315058, 0x173239);
grid.position.y = -2.56;
grid.material.transparent = true;
grid.material.opacity = 0.42;
scene.add(grid);
// Table top and edge voxels.
box(17.4, 0.42, 10.2, 0x29474a, 0, -0.21, 0);
box(17.0, 0.12, 9.8, 0x34575a, 0, 0.01, 0);
for (const x of [-7.4, 7.4]) {
for (const z of [-4.15, 4.15]) {
box(0.62, 2.18, 0.62, 0x1b3539, x, -1.38, z);
box(0.78, 0.16, 0.78, 0x42666a, x, -2.42, z);
}
}
for (let i = 0; i < 18; i++) {
const color = i % 3 === 0 ? 0x49e0d0 : i % 3 === 1 ? 0xff6f61 : 0x304e52;
box(0.91, 0.15, 0.13, color, -7.75 + i * 0.91, 0.05, 5.13);
}
// Back board.
box(18.1, 7.55, 0.34, 0x071215, 0, 3.43, -5.38);
box(17.7, 7.18, 0.12, 0x102a2f, 0, 3.43, -5.16);
box(17.8, 0.12, 0.16, 0x49e0d0, 0, 7.04, -5.02);
box(17.8, 0.12, 0.16, 0xef73b4, 0, -0.18, -5.02);
// Decorative specimen blocks.
const decorative = [
[-7.9, 0.34, -4.35, 0x49e0d0],
[-7.4, 0.34, -4.35, 0x3c686c],
[-7.9, 0.77, -4.35, 0x34575a],
[7.85, 0.34, -4.35, 0xff6f61],
[7.4, 0.34, -4.35, 0x3c686c],
[7.85, 0.77, -4.35, 0x34575a]
];
decorative.forEach(([x, y, z, c]) => box(0.46, 0.46, 0.46, c, x, y, z));
// -------------------------------------------------------------------------
// Panel textures and selectable evidence cards
// -------------------------------------------------------------------------
const pickables = [];
const selectionOutlines = new Map();
const evidence = {
O1: {
type: "Recorded observation",
accent: "#49e0d0",
title: "Setup A / six-block snapshot",
status: "Recorded once · fictional snapshot · not a causal result",
facts: [
"No center support was used under the bridge.",
"The middle deck block sat about one block lower than adjacent blocks.",
"The exact load at failure and the number of repeated trials were not recorded."
],
boundary:
"This is one observed configuration. The record does not establish why the middle block moved or whether the outcome would repeat."
},
O2: {
type: "Recorded observation",
accent: "#49e0d0",
title: "Setup B / six-block snapshot",
status: "Recorded once · fictional snapshot · not a causal result",
facts: [
"One center support was used under the bridge.",
"The middle deck block was observed level in this trial.",
"The exact load at failure and the number of repeated trials were not recorded."
],
boundary:
"The level middle block is an observation, not proof that the support caused it. Repetition and controlled measurement are still needed."
},
C: {
type: "Controlled comparison",
accent: "#69a9ff",
title: "Setup A compared with setup B",
status: "Controlled setup · comparison is not itself an outcome",
facts: [
"Both setups use the same span length, block type, and six-block load.",
"The visible setup difference is one center support: absent in A and present in B.",
"The display marks the comparison, but it does not claim which setup performed better."
],
boundary:
"Unmeasured variation such as block alignment, placement, or surface condition may still affect the observations."
},
M: {
type: "Missing observations",
accent: "#ffc857",
title: "Evidence still needed",
status: "Gap in the record · not yet observed",
facts: [
"Repeat each setup with at least three additional trials.",
"Record the exact number of blocks present at the first failure.",
"Log block placement, alignment, and material batch for every trial."
],
boundary:
"Without these observations, the display cannot reliably distinguish a repeatable effect from chance or setup variation."
},
H1: {
type: "Proposed explanation",
accent: "#ef73b4",
title: "Support may reduce mid-span bending",
status: "Hypothesis only · not established",
facts: [
"A support under the middle could reduce the span that must bend between supports.",
"This proposed mechanism is compatible with the two recorded snapshots.",
"Repeated controlled trials would be needed to evaluate it."
],
boundary:
"Compatibility with an observation is not confirmation. This explanation must remain labeled as a hypothesis."
},
H2: {
type: "Proposed explanation",
accent: "#ef73b4",
title: "Alignment may explain the difference",
status: "Alternative hypothesis · not established",
facts: [
"Small differences in block placement may change how the deck settles or bends.",
"Alignment was not recorded in the displayed snapshots.",
"This alternative could be tested by standardizing placement across trials."
],
boundary:
"This is a competing possibility, not a result. More trials and placement records are required."
}
};
function wrapText(ctx, text, maxWidth) {
const words = text.split(/\s+/);
const lines = [];
let line = "";
for (const word of words) {
const test = line ? `${line} ${word}` : word;
if (ctx.measureText(test).width > maxWidth && line) {
lines.push(line);
line = word;
} else {
line = test;
}
}
if (line) lines.push(line);
return lines;
}
function createPanelTexture({
kind,
title,
subtitle,
lines = [],
accent = "#49e0d0",
dark = false
}) {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 512;
const ctx = c.getContext("2d");
const bg = dark ? "#10272c" : "#f4eedc";
const fg = dark ? "#f6f2df" : "#132a2e";
const muted = dark ? "#9eb7b3" : "#52686a";
ctx.fillStyle = bg;
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, c.width, 18);
ctx.fillStyle = dark ? "#071316" : "#173236";
ctx.fillRect(0, 0, 22, c.height);
ctx.fillRect(c.width - 22, 0, 22, c.height);
ctx.fillRect(0, c.height - 22, c.width, 22);
ctx.fillRect(0, 0, 22, 22);
ctx.fillRect(c.width - 22, 0, 22, 22);
ctx.textBaseline = "top";
ctx.fillStyle = accent;
ctx.font = "700 24px monospace";
ctx.fillText(kind.toUpperCase(), 62, 48);
ctx.fillStyle = fg;
ctx.font = "700 43px monospace";
let titleY = 91;
const titleLines = wrapText(ctx, title, 900);
titleLines.forEach(line => {
ctx.fillText(line, 60, titleY);
titleY += 47;
});
ctx.fillStyle = muted;
ctx.font = "700 23px monospace";
ctx.fillText(subtitle.toUpperCase(), 62, titleY + 4);
let y = titleY + 55;
ctx.font = "26px monospace";
for (const line of lines) {
const wrapped = wrapText(ctx, line, 870);
for (const part of wrapped) {
ctx.fillStyle = accent;
ctx.fillRect(62, y + 8, 8, 8);
ctx.fillStyle = fg;
ctx.fillText(part, 86, y);
y += 34;
}
}
// Pixel registration marks.
ctx.fillStyle = accent;
for (const [x, yy] of [[36, 38], [958, 38], [36, 445], [958, 445]]) {
ctx.fillRect(x, yy, 24, 5);
}
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
texture.needsUpdate = true;
return texture;
}
function createPanel({
x,
y,
z,
w,
h,
kind,
title,
subtitle,
lines = [],
accent = "#49e0d0",
key = null,
dark = false,
rotationY = 0.28
}) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotationY;
const backing = box(
w + 0.16,
h + 0.16,
0.18,
dark ? 0x061619 : 0x0a2024,
0,
0,
-0.08,
group
);
backing.receiveShadow = true;
const texture = createPanelTexture({
kind,
title,
subtitle,
lines,
accent,
dark
});
const face = new THREE.Mesh(
new THREE.PlaneGeometry(w, h),
new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false,
side: THREE.DoubleSide
})
);
face.position.z = 0.02;
group.add(face);
const outlineGeometry = new THREE.EdgesGeometry(
new THREE.BoxGeometry(w + 0.27, h + 0.27, 0.25)
);
const outline = new THREE.LineSegments(
outlineGeometry,
new THREE.LineBasicMaterial({
color: new THREE.Color(accent),
transparent: true,
opacity: 0.95
})
);
outline.position.z = 0.04;
outline.visible = false;
group.add(outline);
if (key) {
face.userData.evidenceKey = key;
pickables.push(face);
selectionOutlines.set(key, outline);
}
scene.add(group);
return group;
}
function addCardStand(x, z, height, accent) {
box(0.17, height, 0.17, 0x29484d, x, height / 2, z);
box(0.78, 0.10, 0.60, accent, x, 0.06, z);
}
function makeSpriteLabel(lines, accent, width = 3.25) {
const c = document.createElement("canvas");
c.width = 768;
c.height = 224;
const ctx = c.getContext("2d");
ctx.fillStyle = "#0b2024";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, c.width, 14);
ctx.fillRect(0, c.height - 14, c.width, 14);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = accent;
ctx.font = "700 34px monospace";
ctx.fillText(lines[0], c.width / 2, 72);
ctx.fillStyle = "#eaf2e8";
ctx.font = "700 30px monospace";
ctx.fillText(lines[1], c.width / 2, 132);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
toneMapped: false
})
);
sprite.scale.set(width, width * (224 / 768), 1);
return sprite;
}
// Board heading.
createPanel({
x: -0.1,
y: 5.88,
z: -4.96,
w: 12.9,
h: 1.56,
kind: "Fictional classroom experiment",
title: "VOXEL BRIDGE LAB",
subtitle: "Question: does a center support change mid-span dip under a 6-block load?",
accent: "#49e0d0",
dark: true,
rotationY: 0
});
// Proposed explanations live on the back board and are explicitly marked.
createPanel({
x: -6.05,
y: 3.83,
z: -4.94,
w: 3.65,
h: 1.78,
kind: "Proposed explanation · H-01",
title: "SUPPORT & BENDING",
subtitle: "Hypothesis only · not established",
lines: ["A support may reduce bending at mid-span."],
accent: "#ef73b4",
key: "H1",
rotationY: 0
});
createPanel({
x: -1.85,
y: 3.83,
z: -4.94,
w: 3.65,
h: 1.78,
kind: "Proposed explanation · H-02",
title: "ALIGNMENT ALTERNATIVE",
subtitle: "Hypothesis only · not established",
lines: ["Placement or alignment may explain the difference."],
accent: "#ef73b4",
key: "H2",
rotationY: 0
});
createPanel({
x: 4.8,
y: 3.83,
z: -4.94,
w: 6.3,
h: 1.78,
kind: "Evidence wall",
title: "OBSERVE → COMPARE → CHECK GAPS",
subtitle: "Explanations stay separate from recorded observations",
lines: ["Select a card to inspect its evidence boundary."],
accent: "#69a9ff",
dark: true,
rotationY: 0
});
// -------------------------------------------------------------------------
// Voxel bridge apparatus
// -------------------------------------------------------------------------
function buildRig(z, hasSupport, dipCenter) {
const rig = new THREE.Group();
rig.position.set(-4.7, 0, z);
box(4.85, 0.15, 1.78, 0x10282c, 0, 0.075, 0, rig);
box(4.55, 0.08, 1.50, 0x28484d, 0, 0.17, 0, rig);
// Two stacked end towers.
for (const x of [-2.0, 2.0]) {
for (let i = 0; i < 4; i++) {
const alternating = i % 2 === 0 ? 0x668284 : 0x4d6b6f;
box(0.46, 0.42, 1.02, alternating, x, 0.40 + i * 0.44, 0, rig);
}
}
// Seven-block deck. Center block is lower only in the recorded A snapshot.
for (let i = 0; i < 7; i++) {
const x = -1.68 + i * 0.56;
const isCenter = i === 3;
const y = isCenter && dipCenter ? 1.78 : 2.12;
const color = isCenter && dipCenter ? 0xd7a86e : 0xe1bd82;
box(0.50, 0.36, 0.94, color, x, y, 0, rig);
}
if (hasSupport) {
for (let i = 0; i < 3; i++) {
box(
0.46,
0.43,
0.72,
i === 2 ? 0x49e0d0 : 0x318f89,
0,
0.41 + i * 0.45,
0,
rig
);
}
} else {
// Dashed ghost marks the intentionally absent support in setup A.
const ghostMaterial = new THREE.MeshBasicMaterial({
color: 0xffc857,
transparent: true,
opacity: 0.07,
depthWrite: false
});
const ghost = new THREE.Mesh(
new THREE.BoxGeometry(0.46, 1.35, 0.72),
ghostMaterial
);
ghost.position.set(0, 0.88, 0);
rig.add(ghost);
makeLineBox(0.46, 1.35, 0.72, 0xffc857, 0, 0.88, 0, rig, true);
}
// Six identical load blocks, placed in two rows so the center stays visible.
const loadPositions = [
[-0.43, -0.36], [0.43, -0.36],
[-0.43, 0], [0.43, 0],
[-0.43, 0.36], [0.43, 0.36]
];
loadPositions.forEach(([x, localZ], index) => {
box(
0.31,
0.31,
0.31,
index % 2 === 0 ? 0xff6f61 : 0xff927c,
x,
2.48,
localZ,
rig
);
});
// Small load count marker.
box(0.08, 0.34, 0.08, 0xffc857, -1.15, 2.43, 0.52, rig);
box(0.08, 0.08, 0.58, 0xffc857, -1.15, 2.58, 0.23, rig);
scene.add(rig);
const label = makeSpriteLabel(
hasSupport
? ["SETUP B · CENTER SUPPORT", "OBSERVED: CENTER LEVEL"]
: ["SETUP A · NO SUPPORT", "OBSERVED: CENTER ~1 BLOCK LOW"],
hasSupport ? "#49e0d0" : "#ff6f61",
3.45
);
label.position.set(-7.25, 2.78, z + 0.88);
scene.add(label);
}
buildRig(1.35, false, true);
buildRig(-1.35, true, false);
// Controlled comparison card in front of the apparatus.
createPanel({
x: -4.7,
y: 0.98,
z: 3.52,
w: 5.75,
h: 1.54,
kind: "Controlled comparison · A vs B",
title: "SAME SPAN · SAME LOAD",
subtitle: "Visible setup difference: one center support",
lines: [
"Both use 8 deck blocks and the same 6-block load.",
"A has no center support; B has one."
],
accent: "#69a9ff",
key: "C",
rotationY: 0.22
});
// Evidence rack: recorded observations and missing observations.
addCardStand(4.05, 3.0, 0.34, 0x49e0d0);
createPanel({
x: 4.05,
y: 1.34,
z: 3.0,
w: 5.75,
h: 2.0,
kind: "O-01 · Recorded observation",
title: "SETUP A / SIX BLOCKS",
subtitle: "One trial shown · fictional snapshot",
lines: [
"Middle deck block sat about one block lower.",
"Failure point and repeat count: not recorded."
],
accent: "#49e0d0",
key: "O1"
});
addCardStand(4.18, 0.35, 1.03, 0x49e0d0);
createPanel({
x: 4.18,
y: 2.03,
z: 0.35,
w: 5.75,
h: 2.0,
kind: "O-02 · Recorded observation",
title: "SETUP B / SIX BLOCKS",
subtitle: "One trial shown · fictional snapshot",
lines: [
"Middle deck block was observed level.",
"Failure point and repeat count: not recorded."
],
accent: "#49e0d0",
key: "O2"
});
addCardStand(4.31, -2.25, 1.74, 0xffc857);
createPanel({
x: 4.31,
y: 2.74,
z: -2.25,
w: 5.75,
h: 2.0,
kind: "M-01 · Missing observations",
title: "WHAT STILL NEEDS CHECKING",
subtitle: "Gaps in the record · not yet observed",
lines: [
"Repeat both setups at least 3 more times.",
"Record exact failure load, alignment, and placement."
],
accent: "#ffc857",
key: "M"
});
// A second gap marker built from amber voxel blocks.
for (let i = 0; i < 5; i++) {
box(
0.24,
0.24,
0.24,
i % 2 ? 0xffc857 : 0x8b6b25,
7.0 + i * 0.29,
0.18 + i * 0.04,
3.65,
scene,
false
);
}
// -------------------------------------------------------------------------
// Inspector
// -------------------------------------------------------------------------
const inspector = document.querySelector("#inspector");
const inspectorType = document.querySelector("#inspectorType");
const inspectorTitle = document.querySelector("#inspectorTitle");
const inspectorStatus = document.querySelector("#inspectorStatus");
const factsList = document.querySelector("#facts");
const inspectorBoundary = document.querySelector("#inspectorBoundary");
const closeInspector = document.querySelector("#closeInspector");
function selectEvidence(key) {
const item = evidence[key];
if (!item) return;
inspector.style.setProperty("--accent", item.accent);
inspectorType.textContent = item.type;
inspectorTitle.textContent = item.title;
inspectorStatus.textContent = item.status;
inspectorBoundary.textContent = item.boundary;
factsList.innerHTML = "";
item.facts.forEach(fact => {
const li = document.createElement("li");
li.textContent = fact;
factsList.appendChild(li);
});
selectionOutlines.forEach((outline, outlineKey) => {
outline.visible = outlineKey === key;
});
document.body.classList.remove("inspector-closed");
}
closeInspector.addEventListener("click", () => {
document.body.classList.toggle("inspector-closed");
closeInspector.textContent = document.body.classList.contains("inspector-closed")
? "+"
: "−";
});
selectEvidence("O1");
// -------------------------------------------------------------------------
// Direct camera controls, ray picking, and UI
// -------------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let dragging = false;
let moved = false;
let pointerX = 0;
let pointerY = 0;
let activePointer = null;
function setPointerFromEvent(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pickAtPointer(event) {
setPointerFromEvent(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickables, false);
return hits.length ? hits[0].object.userData.evidenceKey : null;
}
canvas.addEventListener("pointerdown", event => {
dragging = true;
moved = false;
activePointer = event.pointerId;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", event => {
if (dragging) {
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
if (Math.abs(dx) + Math.abs(dy) > 2) moved = true;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(desired.phi - dy * 0.005, 0.42, 1.42);
pointerX = event.clientX;
pointerY = event.clientY;
} else {
const key = pickAtPointer(event);
canvas.classList.toggle("pickable", Boolean(key));
}
});
canvas.addEventListener("pointerup", event => {
if (activePointer === event.pointerId) {
dragging = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
activePointer = null;
}
if (!moved) {
const key = pickAtPointer(event);
if (key) selectEvidence(key);
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
activePointer = null;
canvas.classList.remove("dragging");
});
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
13.5,
29
);
},
{ passive: false }
);
window.addEventListener("keydown", event => {
const step = 0.12;
if (event.key === "ArrowLeft") desired.theta += step;
if (event.key === "ArrowRight") desired.theta -= step;
if (event.key === "ArrowUp") desired.phi = Math.max(0.42, desired.phi - step);
if (event.key === "ArrowDown") desired.phi = Math.min(1.42, desired.phi + step);
if (event.key.toLowerCase() === "r") resetView();
});
function resetView() {
desired.theta = 0.48;
desired.phi = 0.98;
desired.radius = 21.7;
}
document.querySelector("#resetView").addEventListener("click", resetView);
document.querySelector("#planView").addEventListener("click", () => {
desired.theta = 0;
desired.phi = 0.22;
desired.radius = 22;
});
document.querySelector("#frontView").addEventListener("click", () => {
desired.theta = 0;
desired.phi = 1.12;
desired.radius = 20.5;
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
function animate() {
const smoothing = 0.11;
current.theta = THREE.MathUtils.lerp(current.theta, desired.theta, smoothing);
current.phi = THREE.MathUtils.lerp(current.phi, desired.phi, smoothing);
current.radius = THREE.MathUtils.lerp(current.radius, desired.radius, smoothing);
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);
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
document.querySelector("#loading").classList.add("hidden");
</script>
</body>
</html>
```