Prompt specification
Build or customize the Three.js 3D scene "Choose the Discriminating Test" 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: Choose the Discriminating Test
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/choose-the-discriminating-test-x3380
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: choose the discriminating test. Create a bounded puzzle with two mechanisms producing similar outcomes. Let users select an intervention that distinguishes them and show when a test remains inconclusive. Return one self-contained HTML file.
Working Three.js Starter (choose-the-discriminating-test-x3380):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Twin Signal — Choose the Discriminating Test</title>
<style>
:root {
--bg: #07111b;
--panel: rgba(12, 25, 38, 0.88);
--panel-soft: rgba(255, 255, 255, 0.045);
--line: rgba(181, 215, 232, 0.16);
--text: #edf7fb;
--muted: #91a9b7;
--cyan: #65e5dc;
--amber: #ffb55f;
--green: #7be6a1;
--red: #ff7d86;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body { overflow: hidden; }
button {
font: inherit;
}
button:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 3px;
}
#stage {
position: fixed;
inset: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 35%, rgba(45, 96, 117, 0.22), transparent 42%),
linear-gradient(145deg, #08131e 0%, #06101a 65%, #091723 100%);
}
#canvasHost {
position: absolute;
inset: 0;
}
#canvasHost canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.header {
position: fixed;
top: 24px;
left: 28px;
z-index: 3;
pointer-events: none;
}
.brand-row {
display: flex;
align-items: center;
gap: 11px;
}
.brand-mark {
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 18px var(--cyan);
}
.brand {
font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.18em;
color: #d9f4f3;
}
.scope {
margin-top: 10px;
color: var(--muted);
font-size: 12px;
letter-spacing: 0.05em;
}
.scope strong {
color: var(--text);
font-weight: 600;
}
#panel {
position: fixed;
z-index: 5;
top: 18px;
right: 18px;
bottom: 18px;
width: 390px;
overflow-y: auto;
overscroll-behavior: contain;
padding: 25px;
border: 1px solid var(--line);
border-radius: 22px;
background:
linear-gradient(160deg, rgba(255, 255, 255, 0.045), transparent 40%),
var(--panel);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
backdrop-filter: blur(18px);
scrollbar-width: thin;
scrollbar-color: rgba(101, 229, 220, 0.35) transparent;
}
.eyebrow {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
color: var(--cyan);
font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.status-chip {
padding: 6px 8px;
border: 1px solid rgba(101, 229, 220, 0.24);
border-radius: 999px;
color: #b9f4ef;
background: rgba(101, 229, 220, 0.07);
letter-spacing: 0.08em;
}
.status-chip.solved {
color: #bff8d2;
border-color: rgba(123, 230, 161, 0.35);
background: rgba(123, 230, 161, 0.09);
}
h1 {
margin: 17px 0 9px;
max-width: 320px;
font-size: clamp(28px, 3vw, 39px);
line-height: 1.02;
letter-spacing: -0.045em;
font-weight: 720;
}
.intro {
margin: 0;
color: var(--muted);
font-size: 13.5px;
line-height: 1.55;
}
.divider {
height: 1px;
margin: 22px 0;
background: var(--line);
}
.step-heading {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 11px;
color: #c7d9e1;
font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.step-number {
display: grid;
place-items: center;
width: 22px;
height: 22px;
border: 1px solid rgba(101, 229, 220, 0.3);
border-radius: 7px;
color: var(--cyan);
background: rgba(101, 229, 220, 0.06);
}
.baseline-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 13px 14px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.035);
}
.baseline-card strong {
display: block;
margin-bottom: 3px;
font-size: 13px;
font-weight: 650;
}
.baseline-card span {
color: var(--muted);
font-size: 11.5px;
}
.small-button,
.secondary-button {
border: 1px solid rgba(101, 229, 220, 0.25);
border-radius: 9px;
color: #d9f4f3;
background: rgba(101, 229, 220, 0.07);
cursor: pointer;
transition: 160ms ease;
}
.small-button {
flex: 0 0 auto;
padding: 8px 10px;
font-size: 11px;
font-weight: 650;
}
.small-button:hover,
.secondary-button:hover {
border-color: rgba(101, 229, 220, 0.55);
background: rgba(101, 229, 220, 0.12);
}
button:disabled {
cursor: not-allowed;
opacity: 0.42;
}
.test-list {
display: grid;
gap: 8px;
}
.test-option {
display: grid;
grid-template-columns: 32px 1fr;
gap: 11px;
width: 100%;
padding: 12px;
border: 1px solid var(--line);
border-radius: 13px;
color: var(--text);
text-align: left;
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
transition: 160ms ease;
}
.test-option:hover {
border-color: rgba(181, 215, 232, 0.34);
transform: translateY(-1px);
}
.test-option.selected {
border-color: rgba(101, 229, 220, 0.68);
background: linear-gradient(90deg, rgba(101, 229, 220, 0.12), rgba(101, 229, 220, 0.035));
box-shadow: inset 3px 0 0 var(--cyan);
}
.test-icon {
display: grid;
place-items: center;
width: 30px;
height: 30px;
border-radius: 9px;
color: var(--cyan);
background: rgba(101, 229, 220, 0.08);
font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.test-title {
display: block;
margin-bottom: 4px;
font-size: 13px;
font-weight: 650;
}
.test-description {
display: block;
color: var(--muted);
font-size: 11.5px;
line-height: 1.4;
}
.primary-button {
width: 100%;
margin-top: 11px;
padding: 13px 15px;
border: 0;
border-radius: 11px;
color: #041317;
background: linear-gradient(135deg, #7af0e6, #52cfc9);
box-shadow: 0 8px 25px rgba(101, 229, 220, 0.15);
font-size: 12.5px;
font-weight: 750;
cursor: pointer;
transition: 160ms ease;
}
.primary-button:hover:not(:disabled) {
transform: translateY(-1px);
filter: brightness(1.06);
}
#result {
margin-top: 16px;
padding: 15px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(255, 255, 255, 0.032);
transition: 180ms ease;
}
#result.valid {
border-color: rgba(123, 230, 161, 0.4);
background: linear-gradient(145deg, rgba(123, 230, 161, 0.11), rgba(123, 230, 161, 0.025));
}
#result.inconclusive {
border-color: rgba(255, 181, 95, 0.4);
background: linear-gradient(145deg, rgba(255, 181, 95, 0.11), rgba(255, 181, 95, 0.025));
}
#result.running {
border-color: rgba(101, 229, 220, 0.38);
}
.result-kicker {
color: var(--muted);
font: 700 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#result.valid .result-kicker { color: var(--green); }
#result.inconclusive .result-kicker { color: var(--amber); }
#result.running .result-kicker { color: var(--cyan); }
.result-title {
margin: 7px 0 6px;
font-size: 17px;
letter-spacing: -0.02em;
}
.result-copy {
margin: 0;
color: #b5c7d0;
font-size: 12px;
line-height: 1.5;
}
.metrics {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 12px;
}
.metric {
padding: 10px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 10px;
background: rgba(0, 0, 0, 0.14);
}
.metric-unit {
color: var(--muted);
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.11em;
}
.metric-value {
margin: 6px 0 3px;
font-size: 18px;
font-weight: 750;
}
.metric-detail {
color: var(--muted);
font-size: 10px;
line-height: 1.3;
}
.reason {
margin-top: 11px;
padding-top: 11px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
color: #9fb5c0;
font-size: 11px;
line-height: 1.48;
}
.reason strong { color: #d9e8ed; }
.panel-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 10px;
}
.secondary-button {
padding: 10px;
font-size: 11px;
font-weight: 650;
}
#audit {
margin-top: 12px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.025);
}
#audit summary {
padding: 12px;
color: #c9dce4;
font-size: 11px;
font-weight: 650;
cursor: pointer;
}
.audit-body {
padding: 0 11px 12px;
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 10px;
}
th, td {
padding: 7px 5px;
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
text-align: left;
vertical-align: top;
}
th {
color: var(--muted);
font-weight: 600;
}
td.different { color: var(--green); }
.audit-note {
margin: 10px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.readouts {
position: absolute;
z-index: 2;
left: 24px;
bottom: 24px;
display: grid;
grid-template-columns: repeat(2, 145px);
gap: 8px;
pointer-events: none;
}
.readout {
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(7, 17, 27, 0.72);
backdrop-filter: blur(10px);
}
.readout-label {
display: flex;
align-items: center;
gap: 7px;
color: var(--muted);
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.12em;
}
.unit-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 10px rgba(101, 229, 220, 0.55);
}
.unit-dot.b {
background: var(--amber);
box-shadow: 0 0 10px rgba(255, 181, 95, 0.55);
}
.readout-value {
margin-top: 7px;
font-size: 17px;
font-weight: 740;
}
.readout-detail {
margin-top: 2px;
color: var(--muted);
font-size: 9.5px;
}
.scene-hint {
position: absolute;
z-index: 2;
left: 50%;
bottom: 23px;
transform: translateX(-50%);
color: rgba(185, 207, 216, 0.58);
font: 600 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
pointer-events: none;
white-space: nowrap;
}
.loading {
position: absolute;
inset: 0;
display: grid;
place-items: center;
color: var(--muted);
font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.12em;
}
[hidden] { display: none !important; }
@media (max-width: 900px) {
body { overflow: auto; }
#stage {
position: relative;
height: 64vh;
min-height: 500px;
}
.header {
position: absolute;
top: 18px;
left: 18px;
}
#panel {
position: relative;
top: auto;
right: auto;
bottom: auto;
width: auto;
margin: 14px;
padding: 21px;
overflow: visible;
}
.readouts {
left: 14px;
right: 14px;
bottom: 14px;
grid-template-columns: 1fr 1fr;
}
.scene-hint {
display: none;
}
}
@media (max-width: 430px) {
#stage { height: 58vh; min-height: 450px; }
h1 { font-size: 30px; }
.readout { padding: 9px 10px; }
.readout-value { font-size: 15px; }
.panel-actions { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div id="stage">
<div id="canvasHost">
<div class="loading">INITIALIZING TEST BENCH…</div>
</div>
<header class="header">
<div class="brand-row">
<span class="brand-mark"></span>
<span class="brand">TWIN SIGNAL / 01</span>
</div>
<div class="scope">Bounded comparison · <strong>2 mechanisms · 4 interventions</strong></div>
</header>
<div class="readouts" aria-label="Live machine readouts">
<div class="readout">
<div class="readout-label"><span class="unit-dot"></span>UNIT A</div>
<div class="readout-value" id="readoutAValue">—</div>
<div class="readout-detail" id="readoutADetail">Awaiting baseline</div>
</div>
<div class="readout">
<div class="readout-label"><span class="unit-dot b"></span>UNIT B</div>
<div class="readout-value" id="readoutBValue">—</div>
<div class="readout-detail" id="readoutBDetail">Awaiting baseline</div>
</div>
</div>
<div class="scene-hint">DRAG TO ORBIT · WHEEL TO ZOOM · DOUBLE-CLICK TO RESET VIEW</div>
</div>
<aside id="panel" aria-label="Puzzle controls">
<div class="eyebrow">
<span>Choose the discriminating test</span>
<span class="status-chip" id="statusChip">BASELINE</span>
</div>
<h1>Two drives.<br>One signal.</h1>
<p class="intro">
Two sealed mechanisms produce the same visible output. Select one intervention.
A useful test must make their outcomes differ; a test that leaves both unchanged
is inconclusive.
</p>
<div class="divider"></div>
<section>
<div class="step-heading">
<span class="step-number">1</span>
Establish similarity
</div>
<div class="baseline-card">
<div>
<strong>Common baseline</strong>
<span>One drive pulse · one dial step</span>
</div>
<button class="small-button" id="baselineButton">Replay</button>
</div>
</section>
<div class="divider"></div>
<section>
<div class="step-heading">
<span class="step-number">2</span>
Select an intervention
</div>
<div class="test-list" id="testList"></div>
<button class="primary-button" id="runButton" disabled>Select an intervention</button>
</section>
<section id="result" class="running" aria-live="polite">
<div class="result-kicker" id="resultKicker">Common baseline</div>
<h2 class="result-title" id="resultTitle">Preparing the bench</h2>
<p class="result-copy" id="resultCopy">
The first run establishes what is already known about the two mechanisms.
</p>
<div class="metrics">
<div class="metric">
<div class="metric-unit">UNIT A</div>
<div class="metric-value" id="metricAValue">—</div>
<div class="metric-detail" id="metricADetail">Waiting</div>
</div>
<div class="metric">
<div class="metric-unit">UNIT B</div>
<div class="metric-value" id="metricBValue">—</div>
<div class="metric-detail" id="metricBDetail">Waiting</div>
</div>
</div>
<div class="reason" id="reasonText">
A discriminating intervention changes the observation for one mechanism but not the other.
</div>
</section>
<details id="audit" hidden>
<summary>Solution audit — prediction matrix</summary>
<div class="audit-body">
<table>
<thead>
<tr>
<th>Intervention</th>
<th>Unit A</th>
<th>Unit B</th>
</tr>
</thead>
<tbody id="auditBody"></tbody>
</table>
<p class="audit-note">
Only the added-load intervention makes the two predicted observations differ.
The other interventions are valid tests, but this bounded system does not
distinguish the mechanisms with them.
</p>
</div>
</details>
<div class="panel-actions">
<button class="secondary-button" id="revealButton" disabled>Reveal mechanisms</button>
<button class="secondary-button" id="resetButton">Reset puzzle</button>
</div>
</aside>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (id) => document.getElementById(id);
const tests = {
load: {
icon: "2×",
title: "Attach a 2× load",
description: "Place the same added load on both output shafts."
},
polarity: {
icon: "±",
title: "Swap the input polarity",
description: "Reverse the power leads at the shared controller."
},
tap: {
icon: "↔",
title: "Tap both housings",
description: "Apply the same brief mechanical disturbance."
},
repeat: {
icon: "↺",
title: "Repeat the baseline",
description: "Run the original stimulus without changing anything."
}
};
const state = {
selected: null,
baselineComplete: false,
solved: false,
revealed: false,
animation: null
};
// ----- UI -----
function renderTests() {
$("testList").innerHTML = "";
for (const [id, test] of Object.entries(tests)) {
const button = document.createElement("button");
button.className = "test-option";
button.dataset.test = id;
button.setAttribute("aria-pressed", "false");
button.innerHTML = `
<span class="test-icon">${test.icon}</span>
<span>
<span class="test-title">${test.title}</span>
<span class="test-description">${test.description}</span>
</span>
`;
button.addEventListener("click", () => selectTest(id));
$("testList").appendChild(button);
}
}
function selectTest(id) {
if (state.animation) return;
state.selected = id;
document.querySelectorAll(".test-option").forEach((button) => {
const active = button.dataset.test === id;
button.classList.toggle("selected", active);
button.setAttribute("aria-pressed", String(active));
});
$("runButton").disabled = false;
$("runButton").textContent = `Run: ${tests[id].title}`;
$("result").className = "";
$("resultKicker").textContent = "Intervention selected";
$("resultTitle").textContent = "Ready to intervene";
$("resultCopy").textContent = "Run the selected intervention and compare the two visible responses.";
$("metricAValue").textContent = "—";
$("metricBValue").textContent = "—";
$("metricADetail").textContent = "Awaiting result";
$("metricBDetail").textContent = "Awaiting result";
$("reasonText").textContent = "The useful question is whether the observation differs between Unit A and Unit B.";
}
function setStatus(text, solved = false) {
$("statusChip").textContent = text;
$("statusChip").classList.toggle("solved", solved);
}
function setReadouts(a, b, detailA = "Drive response", detailB = "Drive response") {
$("readoutAValue").textContent = a;
$("readoutBValue").textContent = b;
$("readoutADetail").textContent = detailA;
$("readoutBDetail").textContent = detailB;
}
function showResult(kind, title, copy, a, b, detailA, detailB, reason) {
$("result").className = kind;
$("resultKicker").textContent =
kind === "valid" ? "Discriminating test" :
kind === "inconclusive" ? "Inconclusive test" :
kind === "running" ? "Test running" : "Common baseline";
$("resultTitle").textContent = title;
$("resultCopy").textContent = copy;
$("metricAValue").textContent = a;
$("metricBValue").textContent = b;
$("metricADetail").textContent = detailA;
$("metricBDetail").textContent = detailB;
$("reasonText").innerHTML = reason;
}
function buildAudit() {
const rows = [
["Common baseline", "1 pulse", "1 pulse", false],
["Attach 2× load", "62% · 1 pulse", "96% · 2 pulses", true],
["Swap input polarity", "1 pulse", "1 pulse", false],
["Tap both housings", "1 pulse", "1 pulse", false],
["Repeat the baseline", "1 pulse", "1 pulse", false]
];
$("auditBody").innerHTML = rows.map(([label, a, b, different]) => `
<tr>
<td>${label}</td>
<td class="${different ? "different" : ""}">${a}</td>
<td class="${different ? "different" : ""}">${b}</td>
</tr>
`).join("");
}
renderTests();
buildAudit();
// ----- Three.js scene -----
const host = $("canvasHost");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111b);
scene.fog = new THREE.FogExp2(0x07111b, 0.034);
const camera = new THREE.PerspectiveCamera(43, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
host.appendChild(renderer.domElement);
const loading = host.querySelector(".loading");
if (loading) loading.remove();
const ambient = new THREE.HemisphereLight(0xb8e9ff, 0x16202a, 1.55);
scene.add(ambient);
const key = new THREE.DirectionalLight(0xe9f8ff, 3.2);
key.position.set(4, 8, 6);
key.castShadow = true;
key.shadow.mapSize.set(1024, 1024);
key.shadow.camera.left = -8;
key.shadow.camera.right = 8;
key.shadow.camera.top = 8;
key.shadow.camera.bottom = -6;
key.shadow.bias = -0.0005;
scene.add(key);
const cyanLight = new THREE.PointLight(0x4fe7df, 12, 9, 2);
cyanLight.position.set(-4, 3, 3);
scene.add(cyanLight);
const amberLight = new THREE.PointLight(0xffa64d, 10, 8, 2);
amberLight.position.set(4, 2.5, 2);
scene.add(amberLight);
const rimLight = new THREE.PointLight(0x427dff, 14, 10, 2);
rimLight.position.set(0, 5, -4);
scene.add(rimLight);
const mats = {
platform: new THREE.MeshStandardMaterial({ color: 0x122536, roughness: 0.76, metalness: 0.28 }),
platformEdge: new THREE.MeshStandardMaterial({ color: 0x28475b, roughness: 0.58, metalness: 0.48 }),
dark: new THREE.MeshStandardMaterial({ color: 0x08131d, roughness: 0.72, metalness: 0.38 }),
rubber: new THREE.MeshStandardMaterial({ color: 0x050b10, roughness: 0.95 }),
steel: new THREE.MeshStandardMaterial({ color: 0x7b95a4, roughness: 0.35, metalness: 0.78 }),
cyan: new THREE.MeshStandardMaterial({ color: 0x42d9d1, roughness: 0.36, metalness: 0.52 }),
amber: new THREE.MeshStandardMaterial({ color: 0xf2a54e, roughness: 0.43, metalness: 0.42 }),
orange: new THREE.MeshStandardMaterial({ color: 0xf4863d, roughness: 0.46, metalness: 0.38 }),
teal: new THREE.MeshStandardMaterial({ color: 0x2aa99f, roughness: 0.4, metalness: 0.5 }),
white: new THREE.MeshStandardMaterial({ color: 0xd7e6eb, roughness: 0.5, metalness: 0.3 })
};
function addMesh(geometry, material, parent, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(w, h, d, material, parent, x = 0, y = 0, z = 0) {
return addMesh(new THREE.BoxGeometry(w, h, d), material, parent, x, y, z);
}
function addCylinder(radius, height, material, parent, x = 0, y = 0, z = 0, segments = 12) {
return addMesh(
new THREE.CylinderGeometry(radius, radius, height, segments),
material,
parent,
x,
y,
z
);
}
function makePlaque(unit) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 200;
const context = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false
}));
sprite.scale.set(1.22, 0.38, 1);
function draw(title, subtitle, accent) {
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "rgba(7, 17, 27, 0.92)";
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = accent;
context.fillRect(0, 0, 12, canvas.height);
context.strokeStyle = "rgba(185, 218, 232, 0.28)";
context.strokeRect(1, 1, canvas.width - 2, canvas.height - 2);
context.fillStyle = "#eef8fb";
context.font = "700 52px ui-monospace, monospace";
context.fillText(title, 34, 83);
context.fillStyle = accent;
context.font = "700 27px ui-monospace, monospace";
context.fillText(subtitle, 36, 139);
texture.needsUpdate = true;
}
draw(`UNIT ${unit}`, "SEALED CASE", unit === "A" ? "#65e5dc" : "#ffb55f");
return {
sprite,
reveal() {
draw(
`UNIT ${unit}`,
unit === "A" ? "INERTIAL FLYWHEEL" : "CLOSED-LOOP SERVO",
unit === "A" ? "#65e5dc" : "#ffb55f"
);
},
seal() {
draw(`UNIT ${unit}`, "SEALED CASE", unit === "A" ? "#65e5dc" : "#ffb55f");
}
};
}
function makeGear(radius, colorMaterial) {
const group = new THREE.Group();
const rim = addMesh(
new THREE.TorusGeometry(radius, radius * 0.15, 6, 18),
colorMaterial,
group
);
rim.castShadow = true;
for (let i = 0; i < 10; i++) {
const angle = (i / 10) * Math.PI * 2;
const tooth = addBox(radius * 0.22, radius * 0.22, 0.14, colorMaterial, group);
tooth.position.set(
Math.cos(angle) * radius * 1.08,
Math.sin(angle) * radius * 1.08,
0
);
tooth.rotation.z = angle;
}
const hub = addCylinder(radius * 0.22, 0.2, mats.steel, group);
hub.rotation.x = Math.PI / 2;
return group;
}
function createMachine(index, xPosition, unit) {
const group = new THREE.Group();
group.position.set(xPosition, 0, 0);
scene.add(group);
const housingMaterial = new THREE.MeshStandardMaterial({
color: 0x172b3a,
roughness: 0.62,
metalness: 0.38,
transparent: true,
opacity: 1
});
const accentMaterial = unit === "A" ? mats.cyan : mats.amber;
addBox(2.7, 0.28, 1.9, mats.dark, group, 0, 0.41, 0);
addBox(2.45, 2.14, 1.64, housingMaterial, group, 0, 1.65, 0);
addBox(2.56, 0.13, 1.76, mats.platformEdge, group, 0, 2.76, 0);
addBox(2.56, 0.11, 1.76, mats.platformEdge, group, 0, 0.57, 0);
addBox(0.08, 1.88, 0.08, accentMaterial, group, -1.18, 1.68, 0.87);
addBox(0.08, 1.88, 0.08, accentMaterial, group, 1.18, 1.68, 0.87);
for (const footX of [-0.98, 0.98]) {
for (const footZ of [-0.62, 0.62]) {
addCylinder(0.13, 0.16, mats.rubber, group, footX, 0.21, footZ, 8);
}
}
for (let i = 0; i < 5; i++) {
addBox(0.46, 0.045, 0.05, mats.dark, group, 0.76, 2.08 - i * 0.1, 0.84);
}
const output = new THREE.Group();
output.position.set(-0.55, 1.52, 0.91);
group.add(output);
addMesh(new THREE.CircleGeometry(0.34, 24), mats.dark, output);
addMesh(new THREE.TorusGeometry(0.36, 0.045, 6, 24), accentMaterial, output);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const tick = addBox(0.035, 0.09, 0.025, mats.white, output);
tick.position.set(Math.sin(angle) * 0.29, Math.cos(angle) * 0.29, 0.02);
tick.rotation.z = -angle;
}
const needlePivot = new THREE.Group();
needlePivot.position.z = 0.035;
output.add(needlePivot);
addBox(0.035, 0.25, 0.03, accentMaterial, needlePivot, 0, 0.09, 0);
const needleHub = addCylinder(0.055, 0.045, mats.steel, needlePivot);
needleHub.rotation.x = Math.PI / 2;
const lampMaterial = new THREE.MeshStandardMaterial({
color: unit === "A" ? 0x65e5dc : 0xffb55f,
emissive: unit === "A" ? 0x65e5dc : 0xffb55f,
emissiveIntensity: 0.25,
roughness: 0.28
});
const lamp = addMesh(new THREE.SphereGeometry(0.095, 8, 6), lampMaterial, group, 0.65, 1.52, 0.91);
addCylinder(0.14, 0.07, mats.dark, group, 0.65, 1.38, 0.88).rotation.x = Math.PI / 2;
const plaque = makePlaque(unit);
plaque.sprite.position.set(0.48, 2.34, 0.99);
group.add(plaque.sprite);
const load = new THREE.Group();
load.position.set(-0.55, 2.35, 1.03);
load.visible = false;
group.add(load);
addBox(0.48, 0.26, 0.36, mats.orange, load);
addMesh(new THREE.TorusGeometry(0.13, 0.035, 6, 14), mats.steel, load, 0, 0.19, 0);
const interior = new THREE.Group();
group.add(interior);
const rotors = [];
if (index === 0) {
const flywheel = new THREE.Group();
flywheel.position.set(-0.32, 1.54, 0.12);
interior.add(flywheel);
addMesh(new THREE.TorusGeometry(0.64, 0.13, 6, 20), mats.orange, flywheel);
for (let i = 0; i < 6; i++) {
const spoke = addBox(0.07, 1.03, 0.08, mats.steel, flywheel);
spoke.rotation.z = (i / 6) * Math.PI;
}
const hub = addCylinder(0.18, 0.22, mats.dark, flywheel);
hub.rotation.x = Math.PI / 2;
rotors.push(flywheel);
} else {
const motor = addCylinder(0.32, 0.58, mats.teal, interior, 0.36, 1.54, 0.08, 12);
motor.rotation.x = Math.PI / 2;
const rearCap = addCylinder(0.34, 0.08, mats.dark, interior, 0.36, 1.54, -0.23, 12);
rearCap.rotation.x = Math.PI / 2;
const sensor = addBox(0.19, 0.18, 0.15, mats.orange, interior, 0.63, 1.92, 0.18);
sensor.rotation.z = -0.25;
const gear = makeGear(0.43, mats.teal);
gear.position.set(-0.27, 1.54, 0.21);
interior.add(gear);
rotors.push(gear);
}
return {
group,
baseX: xPosition,
housingMaterial,
needlePivot,
rotors,
lamp,
lampMaterial,
load,
plaque
};
}
// Platform and environment.
addBox(7.15, 0.3, 3.25, mats.platform, scene, 0, 0.12, 0);
addBox(7.28, 0.08, 3.38, mats.platformEdge, scene, 0, 0.01, 0);
addBox(6.65, 0.035, 0.06, mats.cyan, scene, 0, 0.285, 1.5).material =
new THREE.MeshStandardMaterial({ color: 0x42d9d1, emissive: 0x164c49, emissiveIntensity: 0.5 });
const floor = addMesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({ color: 0x07111b, roughness: 1 }),
scene,
0,
-0.045,
0
);
floor.rotation.x = -Math.PI / 2;
floor.castShadow = false;
const machineA = createMachine(0, -1.72, "A");
const machineB = createMachine(1, 1.72, "B");
const machines = [machineA, machineB];
// Central controller.
const console = new THREE.Group();
console.position.set(0, 0.28, -0.76);
scene.add(console);
addBox(1.08, 0.7, 0.72, mats.dark, console, 0, 0.36, 0);
addBox(0.82, 0.05, 0.5, mats.platformEdge, console, 0, 0.74, 0.03);
const consoleLightMaterial = new THREE.MeshStandardMaterial({
color: 0x65e5dc,
emissive: 0x65e5dc,
emissiveIntensity: 0.75
});
addBox(0.35, 0.05, 0.12, consoleLightMaterial, console, 0, 0.78, 0.18);
function addCable(points, material) {
const curve = new THREE.CatmullRomCurve3(points);
const mesh = new THREE.Mesh(new THREE.TubeGeometry(curve, 24, 0.035, 6, false), material);
mesh.castShadow = true;
scene.add(mesh);
}
addCable([
new THREE.Vector3(-1.72, 0.73, -0.76),
new THREE.Vector3(-0.95, 0.55, -1.02),
new THREE.Vector3(-0.42, 0.55, -0.88)
], mats.cyan);
addCable([
new THREE.Vector3(1.72, 0.73, -0.76),
new THREE.Vector3(0.95, 0.55, -1.02),
new THREE.Vector3(0.42, 0.55, -0.88)
], mats.amber);
// Decorative low-poly halo behind the bench.
const haloMaterial = new THREE.MeshBasicMaterial({
color: 0x244b5c,
transparent: true,
opacity: 0.33
});
const halo = addMesh(new THREE.TorusGeometry(3.35, 0.025, 4, 42), haloMaterial, scene, 0, 2.35, -1.65);
halo.castShadow = false;
const halo2 = addMesh(new THREE.TorusGeometry(2.8, 0.018, 4, 36), haloMaterial, scene, 0, 2.35, -1.66);
halo2.castShadow = false;
// ----- Camera controls implemented directly -----
const cameraState = {
target: new THREE.Vector3(0.45, 1.35, 0),
azimuth: 0.04,
polar: 1.16,
radius: 9.7
};
function updateCamera() {
const sinPolar = Math.sin(cameraState.polar);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPolar * Math.sin(cameraState.azimuth),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.polar),
cameraState.target.z + cameraState.radius * sinPolar * Math.cos(cameraState.azimuth)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.azimuth = 0.04;
cameraState.polar = 1.16;
cameraState.radius = 9.7;
updateCamera();
}
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
cameraState.azimuth = THREE.MathUtils.clamp(cameraState.azimuth - dx * 0.005, -0.78, 0.78);
cameraState.polar = THREE.MathUtils.clamp(cameraState.polar - dy * 0.004, 0.68, 1.43);
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => { dragging = false; });
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.007,
7.2,
13.2
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
function resize() {
const width = host.clientWidth;
const height = host.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(height, 1);
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// ----- Test animation -----
const clamp01 = (value) => THREE.MathUtils.clamp(value, 0, 1);
const smooth = (value) => {
const x = clamp01(value);
return x * x * (3 - 2 * x);
};
const mix = (a, b, amount) => a + (b - a) * amount;
function beginAnimation(type, testId = null) {
if (state.animation) return;
state.animation = {
type,
testId,
start: performance.now(),
duration: type === "load" ? 5200 : 3300,
done: false
};
$("runButton").disabled = true;
$("baselineButton").disabled = true;
$("result").className = "running";
$("resultKicker").textContent = "Test running";
$("resultTitle").textContent = type === "baseline" ? "Repeating the baseline" : tests[testId].title;
$("resultCopy").textContent = "Recording both visible outputs…";
$("metricAValue").textContent = "RUN";
$("metricBValue").textContent = "RUN";
$("metricADetail").textContent = "Measuring";
$("metricBDetail").textContent = "Measuring";
setReadouts("RUN", "RUN", "Measuring", "Measuring");
}
function runBaseline() {
beginAnimation("baseline");
}
function runSelected() {
if (!state.selected || state.animation) return;
beginAnimation(state.selected, state.selected);
}
function applyMotion(machine, revolutions, progress, type) {
machine.needlePivot.rotation.z = -revolutions * Math.PI * 2;
machine.rotors.forEach((rotor, index) => {
rotor.rotation.z = revolutions * Math.PI * 2 * (index === 0 ? -1 : 1);
});
const pulse = 0.35 + 0.65 * Math.pow(Math.sin(progress * Math.PI * 5), 2);
machine.lampMaterial.emissiveIntensity = 0.2 + pulse * 1.9;
if (type === "load") {
machine.load.visible = true;
const descent = smooth((progress - 0.08) / 0.16);
machine.load.position.y = mix(2.35, 2.04, descent);
} else {
machine.load.visible = false;
}
if (type === "tap") {
const envelope = Math.sin(clamp01(progress / 0.32) * Math.PI);
machine.group.position.x = machine.baseX + Math.sin(progress * 95) * 0.055 * envelope;
machine.group.position.y = Math.abs(Math.sin(progress * 120)) * 0.025 * envelope;
} else {
machine.group.position.x = machine.baseX;
machine.group.position.y = 0;
}
}
function completeAnimation(animation) {
state.animation = null;
$("runButton").disabled = !state.selected;
$("baselineButton").disabled = false;
if (animation.type === "baseline") {
state.baselineComplete = true;
setStatus("BASELINE");
setReadouts("1 pulse", "1 pulse", "100% drive speed", "100% drive speed");
showResult(
"",
"Similar outcome established",
"Both mechanisms emit one drive pulse and advance one dial step. The baseline cannot distinguish them.",
"1 pulse",
"1 pulse",
"100% drive speed",
"100% drive speed",
"<strong>Baseline:</strong> the observations overlap. A new intervention is required to separate the hypotheses."
);
return;
}
if (animation.type === "load") {
state.solved = true;
setStatus("SOLVED", true);
setReadouts("62% · 1 pulse", "96% · 2 pulses", "Flywheel slowed", "Servo held speed");
showResult(
"valid",
"The outcomes now differ",
"Unit A slowed to 62% and completed one pulse. Unit B held 96% and completed two pulses. This observation distinguishes the mechanisms.",
"62%",
"96%",
"1 pulse · slowed",
"2 pulses · held speed",
"<strong>Why it works:</strong> Unit A’s inertial flywheel stores momentum but cannot actively compensate for added torque. Unit B’s closed-loop servo detects the speed loss and increases drive torque."
);
$("audit").hidden = false;
$("audit").open = true;
$("revealButton").disabled = false;
return;
}
const reasons = {
polarity:
"<strong>Why it is inconclusive:</strong> both input stages accept either polarity, so both mechanisms still produce the same pulse and dial step.",
tap:
"<strong>Why it is inconclusive:</strong> the brief tap does not transfer enough energy to alter either output. Both observations remain identical.",
repeat:
"<strong>Why it is inconclusive:</strong> repeating the baseline reproduces the original evidence without creating a new difference."
};
setStatus("INCONCLUSIVE");
setReadouts("1 pulse", "1 pulse", "100% drive speed", "100% drive speed");
showResult(
"inconclusive",
"The test did not separate them",
"Unit A and Unit B produced the same visible result. This intervention is possible, but it does not distinguish the mechanisms.",
"1 pulse",
"1 pulse",
"100% drive speed",
"100% drive speed",
reasons[animation.testId]
);
}
$("baselineButton").addEventListener("click", runBaseline);
$("runButton").addEventListener("click", runSelected);
$("revealButton").addEventListener("click", () => {
state.revealed = !state.revealed;
for (const machine of machines) {
machine.housingMaterial.opacity = state.revealed ? 0.14 : 1;
machine.housingMaterial.depthWrite = !state.revealed;
if (state.revealed) machine.plaque.reveal();
else machine.plaque.seal();
}
$("revealButton").textContent = state.revealed ? "Seal mechanisms" : "Reveal mechanisms";
});
$("resetButton").addEventListener("click", () => {
state.animation = null;
state.selected = null;
state.baselineComplete = false;
state.solved = false;
state.revealed = false;
document.querySelectorAll(".test-option").forEach((button) => {
button.classList.remove("selected");
button.setAttribute("aria-pressed", "false");
});
$("runButton").disabled = true;
$("runButton").textContent = "Select an intervention";
$("baselineButton").disabled = false;
$("revealButton").disabled = true;
$("revealButton").textContent = "Reveal mechanisms";
$("audit").hidden = true;
$("audit").open = false;
setStatus("BASELINE");
for (const machine of machines) {
machine.housingMaterial.opacity = 1;
machine.housingMaterial.depthWrite = true;
machine.plaque.seal();
machine.load.visible = false;
machine.group.position.set(machine.baseX, 0, 0);
machine.needlePivot.rotation.z = 0;
machine.rotors.forEach((rotor) => { rotor.rotation.z = 0; });
}
setReadouts("—", "—", "Awaiting baseline", "Awaiting baseline");
showResult(
"",
"Preparing the bench",
"The first run establishes what is already known about the two mechanisms.",
"—",
"—",
"Waiting",
"Waiting",
"A discriminating intervention changes the observation for one mechanism but not the other."
);
setTimeout(runBaseline, 450);
});
// ----- Render loop -----
function animate(now) {
requestAnimationFrame(animate);
if (state.animation) {
const animation = state.animation;
const progress = clamp01((now - animation.start) / animation.duration);
let revolutionA = progress;
let revolutionB = progress;
let speedA = 100;
let speedB = 100;
if (animation.type === "load") {
const q = clamp01((progress - 0.15) / 0.85);
const response = smooth((progress - 0.15) / 0.36);
speedA = mix(100, 62, response);
speedB = mix(100, 96, response);
revolutionA = 0.15 + 0.85 * 1.057 * (q - 0.19 * q * q);
revolutionB = 0.15 + 0.85 * 2.20 * (q - 0.02 * q * q);
}
applyMotion(machineA, revolutionA, progress, animation.type);
applyMotion(machineB, revolutionB, progress, animation.type);
if (animation.type === "load") {
setReadouts(
`${Math.round(speedA)}%`,
`${Math.round(speedB)}%`,
"Loaded drive speed",
"Loaded drive speed"
);
} else {
setReadouts("RUN", "RUN", "Recording", "Recording");
}
if (progress >= 1 && !animation.done) {
animation.done = true;
completeAnimation(animation);
}
}
const glow = 0.7 + Math.sin(now * 0.002) * 0.12;
consoleLightMaterial.emissiveIntensity = glow;
halo.rotation.z = now * 0.000025;
halo2.rotation.z = -now * 0.000018;
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
// Establish the common baseline shortly after the scene loads.
setTimeout(() => {
if (!state.animation && !state.selected) runBaseline();
}, 700);
</script>
</body>
</html>
```