Prompt specification
Build or customize the Three.js 3D scene "Reconstruct an Event From Partial Views" 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: Reconstruct an Event From Partial Views
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/reconstruct-an-event-from-partial-views-x3752
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts different observers' partial knowledge of events. Create a puzzle combining two camera records of one fictional event. Accept reconstructions consistent with both views and show ambiguity where neither view provides evidence. Low-poly.
Working Three.js Starter (reconstruct-an-event-from-partial-views-x3752):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Sun Key — Evidence Reconstruction</title>
<style>
:root {
--paper: #eee9dc;
--panel: #f8f4e9;
--ink: #23313a;
--muted: #68747a;
--line: #cec7b7;
--yellow: #f1b72c;
--teal: #1d8a84;
--red: #ba4a3f;
--green: #28785e;
--shadow: 0 14px 40px rgba(38, 48, 52, 0.09);
}
* {
box-sizing: border-box;
}
[hidden] {
display: none !important;
}
body {
margin: 0;
min-width: 320px;
color: var(--ink);
background:
linear-gradient(rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.25)),
var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
.masthead {
display: flex;
justify-content: space-between;
gap: 24px;
align-items: flex-end;
padding: 28px 32px 22px;
border-bottom: 1px solid var(--line);
}
.eyebrow {
margin: 0 0 7px;
color: var(--teal);
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(2rem, 4vw, 3.6rem);
line-height: 0.95;
letter-spacing: -0.055em;
}
.masthead-copy {
max-width: 610px;
margin: 12px 0 0;
color: var(--muted);
line-height: 1.55;
}
.case-badge {
flex: 0 0 auto;
padding: 11px 14px;
border: 1px solid var(--ink);
border-radius: 999px;
background: #fff8dc;
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
box-shadow: 4px 4px 0 var(--ink);
}
.layout {
display: grid;
grid-template-columns: 280px minmax(480px, 1fr) 300px;
gap: 18px;
align-items: start;
padding: 20px;
}
.panel {
overflow: hidden;
border: 1px solid var(--line);
border-radius: 18px;
background: rgba(248, 244, 233, 0.93);
box-shadow: var(--shadow);
}
.panel-header {
padding: 17px 18px 14px;
border-bottom: 1px solid var(--line);
}
.panel-header h2 {
margin: 0;
font-size: 1rem;
letter-spacing: -0.02em;
}
.panel-header p {
margin: 5px 0 0;
color: var(--muted);
font-size: 0.82rem;
line-height: 1.45;
}
.panel-body {
padding: 16px;
}
.record-card {
position: relative;
margin-bottom: 12px;
padding: 14px 14px 13px 17px;
border: 1px solid var(--line);
border-radius: 13px;
background: #fffdf7;
}
.record-card::before {
position: absolute;
top: 12px;
bottom: 12px;
left: 0;
width: 4px;
border-radius: 0 5px 5px 0;
background: var(--record-color, var(--teal));
content: "";
}
.record-top {
display: flex;
justify-content: space-between;
gap: 8px;
align-items: center;
margin-bottom: 8px;
}
.record-name {
font-size: 0.82rem;
font-weight: 850;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.timecode {
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.69rem;
}
.record-card ul {
margin: 0;
padding-left: 17px;
color: #45545b;
font-size: 0.81rem;
line-height: 1.5;
}
.record-card li + li {
margin-top: 5px;
}
.blind-note {
padding: 12px;
border: 1px dashed #b9ad95;
border-radius: 12px;
background: #f3ecda;
color: #665c4b;
font-size: 0.79rem;
line-height: 1.5;
}
.blind-note strong {
display: block;
margin-bottom: 3px;
color: var(--ink);
}
.workspace {
min-width: 0;
}
.workspace-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
padding: 10px 12px;
border-bottom: 1px solid var(--line);
}
.segmented {
display: inline-flex;
gap: 3px;
padding: 3px;
border: 1px solid var(--line);
border-radius: 10px;
background: #e6dfd1;
}
.segmented button {
border: 0;
border-radius: 7px;
padding: 8px 11px;
color: var(--muted);
background: transparent;
cursor: pointer;
font-size: 0.76rem;
font-weight: 800;
}
.segmented button.active {
color: var(--ink);
background: #fffdf7;
box-shadow: 0 2px 8px rgba(35, 49, 58, 0.1);
}
.toolbar-hint {
color: var(--muted);
font-size: 0.73rem;
}
#viewport {
position: relative;
height: 650px;
overflow: hidden;
background: #dbe2d9;
isolation: isolate;
}
#viewport canvas {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.split-line {
position: absolute;
top: 0;
bottom: 0;
left: 50%;
z-index: 4;
width: 2px;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 0 0 1px rgba(35, 49, 58, 0.2);
pointer-events: none;
}
.view-label {
position: absolute;
top: 14px;
z-index: 5;
max-width: calc(50% - 30px);
padding: 10px 12px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 10px;
color: #fff;
background: rgba(26, 39, 44, 0.78);
backdrop-filter: blur(8px);
pointer-events: none;
}
#viewA {
left: 14px;
}
#viewB {
left: calc(50% + 14px);
}
.view-label strong {
display: block;
margin-bottom: 3px;
font-size: 0.73rem;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.view-label span {
display: block;
color: #dce7e6;
font-size: 0.7rem;
line-height: 1.35;
}
.view-label em {
display: inline-block;
margin-top: 7px;
padding: 4px 6px;
border-radius: 5px;
color: #172126;
background: #f1b72c;
font-size: 0.63rem;
font-style: normal;
font-weight: 900;
letter-spacing: 0.04em;
text-transform: uppercase;
}
#reconLabel {
position: absolute;
top: 14px;
left: 14px;
z-index: 5;
padding: 9px 11px;
border-radius: 9px;
color: #fff;
background: rgba(26, 39, 44, 0.78);
font-size: 0.7rem;
font-weight: 800;
letter-spacing: 0.05em;
text-transform: uppercase;
pointer-events: none;
}
.scan-fx {
position: absolute;
inset: 0;
z-index: 3;
opacity: 0.24;
background:
repeating-linear-gradient(
to bottom,
rgba(255, 255, 255, 0.08) 0,
rgba(255, 255, 255, 0.08) 1px,
transparent 1px,
transparent 4px
),
radial-gradient(circle at center, transparent 52%, rgba(12, 24, 29, 0.22));
pointer-events: none;
}
.viewport-footer {
display: flex;
justify-content: space-between;
gap: 14px;
padding: 11px 14px;
border-top: 1px solid var(--line);
color: var(--muted);
background: #f7f1e4;
font-size: 0.73rem;
line-height: 1.4;
}
.viewport-footer strong {
color: var(--ink);
}
.step-title {
display: flex;
align-items: center;
gap: 8px;
margin: 2px 0 9px;
font-size: 0.78rem;
font-weight: 900;
letter-spacing: 0.03em;
text-transform: uppercase;
}
.step-number {
display: grid;
width: 22px;
height: 22px;
place-items: center;
border-radius: 50%;
color: white;
background: var(--ink);
font-size: 0.69rem;
}
.choice-list {
display: grid;
gap: 7px;
margin-bottom: 19px;
}
.choice {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
gap: 10px;
padding: 10px 11px;
border: 1px solid var(--line);
border-radius: 10px;
color: var(--ink);
background: #fffdf7;
cursor: pointer;
text-align: left;
transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}
.choice:hover {
transform: translateY(-1px);
border-color: #9f9582;
}
.choice.selected {
border-color: var(--teal);
background: #e4f0e8;
box-shadow: inset 0 0 0 1px var(--teal);
}
.choice-main {
display: grid;
gap: 2px;
}
.choice-main strong {
font-size: 0.83rem;
}
.choice-main small {
color: var(--muted);
font-size: 0.69rem;
}
.choice-tag {
flex: 0 0 auto;
padding: 4px 6px;
border-radius: 5px;
color: #756b59;
background: #eee6d7;
font-size: 0.57rem;
font-weight: 850;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.choice.selected .choice-tag {
color: #0e5d59;
background: #cce4d9;
}
.actor-dot {
display: inline-block;
width: 8px;
height: 8px;
margin-right: 6px;
border-radius: 50%;
vertical-align: 1px;
background: var(--dot, #888);
}
.primary,
.secondary {
width: 100%;
border-radius: 10px;
padding: 11px 12px;
cursor: pointer;
font-size: 0.79rem;
font-weight: 850;
}
.primary {
border: 1px solid var(--ink);
color: white;
background: var(--ink);
box-shadow: 3px 3px 0 #b7ad99;
}
.primary:hover {
transform: translateY(-1px);
}
.secondary {
margin-top: 8px;
border: 1px solid var(--line);
color: var(--ink);
background: transparent;
}
.status {
min-height: 69px;
margin-top: 14px;
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 11px;
color: var(--muted);
background: #eee7d9;
font-size: 0.76rem;
line-height: 1.45;
}
.status strong {
display: block;
margin-bottom: 3px;
color: var(--ink);
font-size: 0.8rem;
}
.status.error {
border-color: #d2a29c;
color: #7e3931;
background: #f6e2dd;
}
.status.error strong {
color: #7e3931;
}
.status.success {
border-color: #9ac4ae;
color: #275d49;
background: #e0efe4;
}
.status.success strong {
color: #275d49;
}
.outcome {
margin-top: 12px;
padding: 13px;
border: 1px solid #9fbea8;
border-radius: 12px;
background: #f1f8ee;
}
.outcome-head {
display: flex;
justify-content: space-between;
gap: 8px;
margin-bottom: 9px;
font-size: 0.76rem;
font-weight: 900;
text-transform: uppercase;
}
.outcome-head span:last-child {
color: var(--green);
}
.outcome ol {
margin: 0;
padding-left: 19px;
color: #3d5748;
font-size: 0.75rem;
line-height: 1.55;
}
.ambiguity {
margin-top: 10px;
padding-top: 9px;
border-top: 1px solid #bdd1bd;
color: #52675a;
font-size: 0.7rem;
line-height: 1.45;
}
.ambiguity strong {
color: #294a37;
}
.case-note {
margin-top: 14px;
padding-top: 13px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 0.72rem;
line-height: 1.5;
}
@media (max-width: 1120px) {
.layout {
grid-template-columns: 1fr 1fr;
}
.workspace {
grid-column: 1 / -1;
grid-row: 1;
}
#viewport {
height: 620px;
}
}
@media (max-width: 700px) {
.masthead {
align-items: flex-start;
flex-direction: column;
padding: 23px 18px 18px;
}
.layout {
grid-template-columns: 1fr;
padding: 10px;
}
.workspace {
grid-column: auto;
}
#viewport {
height: 570px;
}
.toolbar-hint {
display: none;
}
.view-label {
padding: 8px;
}
.view-label span {
display: none;
}
.view-label em {
margin-top: 4px;
}
.viewport-footer {
flex-direction: column;
gap: 4px;
}
}
</style>
</head>
<body>
<header class="masthead">
<div>
<p class="eyebrow">Evidence Lab / Case 07</p>
<h1>The Sun Key</h1>
<p class="masthead-copy">
At 21:07, a courier removed the triangular Sun Key from the central plinth.
Two cameras captured fragments of the same person. Identify the courier, then
place the key. Some details survive; others are mathematically underdetermined.
</p>
</div>
<div class="case-badge">Low-poly reconstruction</div>
</header>
<main class="layout">
<aside class="panel">
<div class="panel-header">
<h2>Camera records</h2>
<p>Two partial observations of one continuous event.</p>
</div>
<div class="panel-body">
<article class="record-card" style="--record-color: #1d8a84">
<div class="record-top">
<span class="record-name">Camera A · South</span>
<span class="timecode">21:07:12</span>
</div>
<ul>
<li>The figure is <strong>tall</strong>: the head clears a 2.35 m privacy screen.</li>
<li>Only the head and shoulders enter the frame.</li>
<li>The Sun Key is absent from the plinth after this frame.</li>
</ul>
</article>
<article class="record-card" style="--record-color: #d29a1b">
<div class="record-top">
<span class="record-name">Camera B · East</span>
<span class="timecode">21:07:41</span>
</div>
<ul>
<li>A <strong>yellow, square</strong> pack appears through the east-jamb opening.</li>
<li>Only 1.1 seconds of the figure is visible.</li>
<li>The east exit occurs after the key has left the plinth.</li>
</ul>
</article>
<div class="blind-note">
<strong>Shared coverage ends.</strong>
Neither camera sees the key after the east jamb. The final placement must be
reconstructed from physical possibility, not visual evidence.
</div>
<div class="case-note">
<strong>Courier roster:</strong> three staff members were in the gallery.
Combine both records; one attribute from each is enough.
</div>
</div>
</aside>
<section class="panel workspace">
<div class="workspace-toolbar">
<div class="segmented" role="group" aria-label="Viewer mode">
<button id="recordsMode" class="active" type="button">Camera records</button>
<button id="reconstructionMode" type="button">Reconstruction bay</button>
</div>
<div class="toolbar-hint">Drag to orbit · Wheel to zoom in reconstruction mode</div>
</div>
<div id="viewport" class="records-mode">
<div id="viewA" class="view-label">
<strong>Camera A · South gallery</strong>
<span>21:07:12 · head above privacy screen</span>
<em>Tall silhouette</em>
</div>
<div id="viewB" class="view-label">
<strong>Camera B · East jamb</strong>
<span>21:07:41 · square pack through opening</span>
<em>Yellow pack</em>
</div>
<div id="reconLabel" hidden>Reconstruction bay · select a hiding place</div>
<div id="splitLine" class="split-line"></div>
<div id="scanFX" class="scan-fx"></div>
</div>
<div class="viewport-footer">
<span><strong>Scene:</strong> central plinth, east exit, archive drawer, service safe</span>
<span id="viewerState">Showing synchronized evidence frames</span>
</div>
</section>
<aside class="panel">
<div class="panel-header">
<h2>Build the reconstruction</h2>
<p>Choose the courier and the key's final location.</p>
</div>
<div class="panel-body">
<div class="step-title">
<span class="step-number">1</span>
Courier identity
</div>
<div class="choice-list">
<button class="choice actor-choice" data-actor="ada" type="button" aria-pressed="false">
<span class="choice-main">
<strong><span class="actor-dot" style="--dot:#c56645"></span>Ada</strong>
<small>Tall · yellow square pack</small>
</span>
<span class="choice-tag">Staff</span>
</button>
<button class="choice actor-choice" data-actor="bram" type="button" aria-pressed="false">
<span class="choice-main">
<strong><span class="actor-dot" style="--dot:#5b846e"></span>Bram</strong>
<small>Short · yellow square pack</small>
</span>
<span class="choice-tag">Staff</span>
</button>
<button class="choice actor-choice" data-actor="cleo" type="button" aria-pressed="false">
<span class="choice-main">
<strong><span class="actor-dot" style="--dot:#73639b"></span>Cleo</strong>
<small>Tall · teal square pack</small>
</span>
<span class="choice-tag">Staff</span>
</button>
</div>
<div class="step-title">
<span class="step-number">2</span>
Final key placement
</div>
<div class="choice-list">
<button class="choice destination-choice" data-destination="satchel" type="button" aria-pressed="false">
<span class="choice-main">
<strong>Inside the courier's pack</strong>
<small>Concealed immediately after collection</small>
</span>
<span class="choice-tag">Unobserved</span>
</button>
<button class="choice destination-choice" data-destination="archive" type="button" aria-pressed="false">
<span class="choice-main">
<strong>North archive drawer</strong>
<small>Hidden after leaving the gallery</small>
</span>
<span class="choice-tag">Unobserved</span>
</button>
<button class="choice destination-choice" data-destination="safe" type="button" aria-pressed="false">
<span class="choice-main">
<strong>Service safe</strong>
<small>Concealed beside the east exit</small>
</span>
<span class="choice-tag">Unobserved</span>
</button>
</div>
<button id="testButton" class="primary" type="button">Test reconstruction</button>
<button id="resetButton" class="secondary" type="button">Reset case</button>
<div id="status" class="status" role="status" aria-live="polite">
<strong>Awaiting reconstruction</strong>
Combine the tall silhouette from Camera A with the yellow pack from Camera B.
</div>
<div id="outcome" class="outcome" hidden>
<div class="outcome-head">
<span>Surviving set</span>
<span>3 reconstructions</span>
</div>
<ol>
<li>Ada → inside the yellow pack</li>
<li>Ada → north archive drawer</li>
<li>Ada → service safe</li>
</ol>
<div class="ambiguity">
<strong>Why the answer is not unique:</strong>
the cameras agree on Ada, but neither observes the key after the east jamb.
All three placements remain equally consistent with the evidence.
</div>
</div>
</div>
</aside>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.querySelector("#viewport");
const statusBox = document.querySelector("#status");
const outcomeBox = document.querySelector("#outcome");
const viewerState = document.querySelector("#viewerState");
const state = {
mode: "records",
actor: null,
destination: null,
accepted: false
};
const actorSpecs = {
ada: {
name: "Ada",
tall: true,
coat: 0xb75f43,
pack: 0xf1b72c
},
bram: {
name: "Bram",
tall: false,
coat: 0x5b846e,
pack: 0xf1b72c
},
cleo: {
name: "Cleo",
tall: true,
coat: 0x73639b,
pack: 0x277f86
}
};
// ------------------------------------------------------------
// Three.js scene
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdde4dc);
scene.fog = new THREE.Fog(0xdde4dc, 20, 38);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
viewport.prepend(renderer.domElement);
const evidenceCamera = new THREE.PerspectiveCamera(48, 1, 0.1, 80);
evidenceCamera.position.set(0, 4.2, 13);
evidenceCamera.lookAt(1.6, 1.35, 0);
const secondEvidenceCamera = new THREE.PerspectiveCamera(48, 1, 0.1, 80);
secondEvidenceCamera.position.set(12, 2.6, 1.4);
secondEvidenceCamera.lookAt(1.9, 1.4, 0);
const reconstructionCamera = new THREE.PerspectiveCamera(43, 1, 0.1, 80);
const orbit = {
theta: -0.74,
phi: 0.92,
radius: 20,
target: new THREE.Vector3(0, 0.75, 0)
};
const hemisphere = new THREE.HemisphereLight(0xfff4d9, 0x667671, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe9bf, 3.2);
sun.position.set(-6, 13, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0008;
scene.add(sun);
const coolFill = new THREE.DirectionalLight(0x9ecbd0, 0.8);
coolFill.position.set(9, 6, -7);
scene.add(coolFill);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
}
function addMesh(parent, geometry, mat, position = [0, 0, 0], cast = true) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(...position);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const room = new THREE.Group();
scene.add(room);
const floorMaterial = material(0xbcb5a3);
const wallMaterial = material(0xe7e0d0);
const wallAccentMaterial = material(0xc8bda8);
const darkMaterial = material(0x35434a);
const stoneMaterial = material(0xd8d1bf);
addMesh(room, new THREE.BoxGeometry(17, 0.35, 13), floorMaterial, [0, -0.22, 0], false);
// Gallery floor grid.
const gridPositions = [];
for (let x = -8; x <= 8; x += 2) {
gridPositions.push(x, -0.025, -6.4, x, -0.025, 6.4);
}
for (let z = -6; z <= 6; z += 2) {
gridPositions.push(-8.4, -0.025, z, 8.4, -0.025, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridPositions, 3)
);
room.add(
new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({ color: 0x8e897d, transparent: true, opacity: 0.3 })
)
);
// North and west walls; south/east remain open for the two camera records.
addMesh(room, new THREE.BoxGeometry(17, 4.4, 0.28), wallMaterial, [0, 2.05, -6.45]);
addMesh(room, new THREE.BoxGeometry(0.28, 4.4, 13), wallMaterial, [-8.45, 2.05, 0]);
for (let x = -6; x <= 6; x += 4) {
addMesh(room, new THREE.BoxGeometry(2.6, 2.6, 0.08), wallAccentMaterial, [x, 2.1, -6.27], false);
}
// Central plinth.
const plinth = new THREE.Group();
plinth.position.set(0, 0, 0);
room.add(plinth);
addMesh(plinth, new THREE.CylinderGeometry(0.95, 1.12, 1.4, 6), stoneMaterial, [0, 0.7, 0]);
addMesh(plinth, new THREE.CylinderGeometry(0.66, 0.82, 0.18, 6), material(0xeee8da), [0, 1.49, 0]);
addMesh(plinth, new THREE.CylinderGeometry(0.22, 0.22, 0.05, 6), material(0x8f7651), [0, 1.61, 0]);
// Archive cabinet and drawers.
const archive = new THREE.Group();
archive.position.set(-5.15, 0, -4.85);
room.add(archive);
addMesh(archive, new THREE.BoxGeometry(3.3, 2.8, 1.4), material(0x66746b), [0, 1.4, 0]);
addMesh(archive, new THREE.BoxGeometry(3.55, 0.18, 1.55), material(0x435149), [0, 2.88, 0]);
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 2; col++) {
addMesh(
archive,
new THREE.BoxGeometry(1.46, 0.66, 0.13),
material(row === 1 && col === 0 ? 0xc8a45c : 0x869087),
[-0.78 + col * 1.56, 0.52 + row * 0.83, 0.75]
);
addMesh(
archive,
new THREE.BoxGeometry(0.35, 0.08, 0.1),
darkMaterial,
[-0.78 + col * 1.56, 0.52 + row * 0.83, 0.84]
);
}
}
// Service safe beside the east exit.
const safe = new THREE.Group();
safe.position.set(4.45, 0, 3.45);
room.add(safe);
addMesh(safe, new THREE.BoxGeometry(2.1, 0.3, 1.6), material(0x46535a), [0, 0.11, 0]);
addMesh(safe, new THREE.BoxGeometry(1.82, 0.12, 1.32), material(0x68767a), [0, 0.3, 0]);
addMesh(safe, new THREE.BoxGeometry(0.4, 0.08, 0.12), material(0xd4aa43), [0.55, 0.4, 0.2]);
// East exit arch.
const arch = new THREE.Group();
arch.position.set(7, 0, 1.1);
room.add(arch);
addMesh(arch, new THREE.BoxGeometry(0.32, 3.7, 0.38), darkMaterial, [0, 1.85, -1.55]);
addMesh(arch, new THREE.BoxGeometry(0.32, 3.7, 0.38), darkMaterial, [0, 1.85, 1.55]);
addMesh(arch, new THREE.BoxGeometry(0.38, 0.35, 3.5), darkMaterial, [0, 3.7, 0]);
// A faint floor route from plinth toward the east exit.
const routeGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0.65, 0.015, 0.1),
new THREE.Vector3(6.5, 0.015, 0.8)
]);
const route = new THREE.Line(
routeGeometry,
new THREE.LineDashedMaterial({
color: 0xd5a829,
dashSize: 0.28,
gapSize: 0.18,
transparent: true,
opacity: 0.65
})
);
route.computeLineDistances();
room.add(route);
// Camera-specific sight blockers. Hidden in the reconstruction bay.
const sightBlockers = new THREE.Group();
scene.add(sightBlockers);
const screenMaterial = material(0xc5bda9);
addMesh(
sightBlockers,
new THREE.BoxGeometry(7.25, 2.35, 0.2),
screenMaterial,
[0.2, 1.175, 2.5]
);
addMesh(
sightBlockers,
new THREE.BoxGeometry(7.4, 0.12, 0.34),
material(0x6c7772),
[0.2, 2.41, 2.5]
);
// East wall with a square observation opening at bag height.
const jambMaterial = material(0xa79f8c);
addMesh(sightBlockers, new THREE.BoxGeometry(0.2, 0.95, 6), jambMaterial, [4.7, 0.475, 0]);
addMesh(sightBlockers, new THREE.BoxGeometry(0.2, 1.8, 6), jambMaterial, [4.7, 2.9, 0]);
addMesh(sightBlockers, new THREE.BoxGeometry(0.2, 1.05, 2.85), jambMaterial, [4.7, 1.475, -1.575]);
addMesh(sightBlockers, new THREE.BoxGeometry(0.2, 1.05, 2.2), jambMaterial, [4.7, 1.475, 1.9]);
// ------------------------------------------------------------
// Low-poly courier
// ------------------------------------------------------------
function buildCourier(spec) {
const group = new THREE.Group();
const legHeight = spec.tall ? 0.82 : 0.61;
const bodyHeight = spec.tall ? 1.03 : 0.88;
const coatMaterial = material(spec.coat);
const darkCloth = material(0x344047);
const skinMaterial = material(0xc99570);
const packMaterial = material(spec.pack, {
emissive: spec.pack,
emissiveIntensity: 0.12
});
const leftLeg = addMesh(
group,
new THREE.BoxGeometry(0.25, legHeight, 0.28),
darkCloth,
[-0.19, legHeight / 2, 0]
);
const rightLeg = addMesh(
group,
new THREE.BoxGeometry(0.25, legHeight, 0.28),
darkCloth,
[0.19, legHeight / 2, 0]
);
leftLeg.rotation.z = -0.04;
rightLeg.rotation.z = 0.04;
addMesh(
group,
new THREE.CylinderGeometry(0.39, 0.31, bodyHeight, 6),
coatMaterial,
[0, legHeight + bodyHeight / 2, 0]
);
const headY = legHeight + bodyHeight + 0.3;
addMesh(
group,
new THREE.IcosahedronGeometry(spec.tall ? 0.31 : 0.27, 0),
skinMaterial,
[0, headY, 0]
);
addMesh(
group,
new THREE.BoxGeometry(0.2, 0.78, 0.22),
coatMaterial,
[-0.47, legHeight + bodyHeight * 0.48, 0]
);
addMesh(
group,
new THREE.BoxGeometry(0.2, 0.78, 0.22),
coatMaterial,
[0.47, legHeight + bodyHeight * 0.48, 0]
);
// Square pack is on the camera-B-facing side.
addMesh(
group,
new THREE.BoxGeometry(0.22, 0.66, 0.56),
packMaterial,
[0.45, legHeight + bodyHeight * 0.53, 0]
);
addMesh(
group,
new THREE.BoxGeometry(0.06, 0.23, 0.25),
material(0xe6dfc9),
[0.575, legHeight + bodyHeight * 0.66, 0]
);
return group;
}
const evidenceCourier = buildCourier({
tall: true,
coat: 0x34444a,
pack: 0xf1b72c
});
evidenceCourier.position.set(2, 0, 0);
scene.add(evidenceCourier);
const reconstructionCourier = new THREE.Group();
reconstructionCourier.position.set(2, 0, 0);
scene.add(reconstructionCourier);
// ------------------------------------------------------------
// Sun Key and destination markers
// ------------------------------------------------------------
function makeKey(isGhost = false) {
const group = new THREE.Group();
const gold = material(0xe5b72f, {
metalness: 0.55,
roughness: 0.32,
transparent: isGhost,
opacity: isGhost ? 0.42 : 1,
emissive: isGhost ? 0x8d6715 : 0x3b2600,
emissiveIntensity: isGhost ? 0.22 : 0.08
});
const ring = addMesh(
group,
new THREE.TorusGeometry(0.18, 0.055, 3, 3),
gold,
[0, 0.12, 0],
!isGhost
);
ring.rotation.z = Math.PI;
addMesh(
group,
new THREE.BoxGeometry(0.07, 0.38, 0.07),
gold,
[0, -0.18, 0],
!isGhost
);
addMesh(
group,
new THREE.BoxGeometry(0.19, 0.07, 0.07),
gold,
[0.06, -0.3, 0],
!isGhost
);
addMesh(
group,
new THREE.BoxGeometry(0.14, 0.07, 0.07),
gold,
[0.035, -0.39, 0],
!isGhost
);
if (isGhost) {
group.traverse((object) => {
if (object.material) {
object.material.depthWrite = false;
}
});
}
return group;
}
const selectedKey = makeKey();
selectedKey.position.set(0, 1.82, 0);
scene.add(selectedKey);
const keyTarget = new THREE.Vector3(0, 1.82, 0);
function makeLabel(text, color = "#314147") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 112;
const context = canvas.getContext("2d");
context.fillStyle = "rgba(248,244,233,0.94)";
context.beginPath();
context.roundRect(8, 8, 496, 96, 24);
context.fill();
context.strokeStyle = color;
context.lineWidth = 6;
context.stroke();
context.fillStyle = color;
context.font = "700 30px system-ui";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 256, 57);
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(2.55, 0.56, 1);
sprite.renderOrder = 10;
return sprite;
}
const destinationLabels = new THREE.Group();
scene.add(destinationLabels);
const archiveLabel = makeLabel("ARCHIVE DRAWER", "#586a5f");
archiveLabel.position.set(-4.25, 2.3, -3.7);
destinationLabels.add(archiveLabel);
const safeLabel = makeLabel("SERVICE SAFE", "#586a5f");
safeLabel.position.set(4.45, 0.95, 3.45);
destinationLabels.add(safeLabel);
const satchelLabel = makeLabel("COURIER PACK", "#9a761a");
satchelLabel.position.set(2.2, 2.75, 0);
destinationLabels.add(satchelLabel);
const destinationMeshes = {};
const hitTargets = [];
const archiveMarkerMaterial = material(0x2d958b, {
emissive: 0x1b5d58,
emissiveIntensity: 0.3,
transparent: true,
opacity: 0.9
});
const archiveMarker = addMesh(
scene,
new THREE.OctahedronGeometry(0.22, 0),
archiveMarkerMaterial,
[-4.25, 1.25, -3.75]
);
archiveMarker.userData.destination = "archive";
destinationMeshes.archive = archiveMarker;
hitTargets.push(archiveMarker);
const safeMarkerMaterial = material(0x2d958b, {
emissive: 0x1b5d58,
emissiveIntensity: 0.3,
transparent: true,
opacity: 0.9
});
const safeMarker = addMesh(
scene,
new THREE.RingGeometry(0.32, 0.47, 6),
safeMarkerMaterial,
[4.45, 0.405, 3.45]
);
safeMarker.rotation.x = -Math.PI / 2;
safeMarker.userData.destination = "safe";
destinationMeshes.safe = safeMarker;
hitTargets.push(safeMarker);
const satchelMarkerMaterial = material(0xf1b72c, {
emissive: 0x7e5b08,
emissiveIntensity: 0.25,
transparent: true,
opacity: 0.9
});
const satchelMarker = addMesh(
scene,
new THREE.TorusGeometry(0.39, 0.055, 4, 6),
satchelMarkerMaterial,
[2.48, 1.25, 0]
);
satchelMarker.rotation.y = Math.PI / 2;
satchelMarker.userData.destination = "satchel";
destinationMeshes.satchel = satchelMarker;
hitTargets.push(satchelMarker);
const ghostKeys = [
{ id: "satchel", group: makeKey(true), position: new THREE.Vector3(2.48, 1.25, 0) },
{ id: "archive", group: makeKey(true), position: new THREE.Vector3(-4.25, 1.25, -3.75) },
{ id: "safe", group: makeKey(true), position: new THREE.Vector3(4.45, 0.55, 3.45) }
];
ghostKeys.forEach(({ group, position }) => {
group.position.copy(position);
group.visible = false;
scene.add(group);
});
const destinationPositions = {
satchel: new THREE.Vector3(2.48, 1.25, 0),
archive: new THREE.Vector3(-4.25, 1.25, -3.75),
safe: new THREE.Vector3(4.45, 0.55, 3.45)
};
// ------------------------------------------------------------
// Custom camera controls — no external controls addon
// ------------------------------------------------------------
let dragging = false;
let dragDistance = 0;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (state.mode !== "reconstruction") return;
dragging = true;
dragDistance = 0;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || state.mode !== "reconstruction") return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
dragDistance += Math.abs(dx) + Math.abs(dy);
previousX = event.clientX;
previousY = event.clientY;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - dy * 0.005, 0.42, 1.38);
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (state.mode === "reconstruction" && dragDistance < 6) {
selectFromScene(event);
}
dragging = false;
renderer.domElement.style.cursor = state.mode === "reconstruction" ? "grab" : "default";
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
renderer.domElement.style.cursor = state.mode === "reconstruction" ? "grab" : "default";
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
if (state.mode !== "reconstruction") return;
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.012,
11,
28
);
},
{ passive: false }
);
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function selectFromScene(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, reconstructionCamera);
const intersections = raycaster.intersectObjects(hitTargets, true);
if (!intersections.length) return;
let object = intersections[0].object;
while (object && !object.userData.destination) {
object = object.parent;
}
if (object?.userData.destination) {
chooseDestination(object.userData.destination);
}
}
function updateReconstructionCamera() {
const sinPhi = Math.sin(orbit.phi);
reconstructionCamera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
reconstructionCamera.lookAt(orbit.target);
}
// ------------------------------------------------------------
// UI logic
// ------------------------------------------------------------
const actorButtons = [...document.querySelectorAll(".actor-choice")];
const destinationButtons = [...document.querySelectorAll(".destination-choice")];
function setStatus(kind, title, message) {
statusBox.className = `status ${kind}`;
statusBox.innerHTML = `<strong>${title}</strong>${message}`;
}
function clearActorModel() {
while (reconstructionCourier.children.length) {
const child = reconstructionCourier.children[0];
reconstructionCourier.remove(child);
child.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) object.material.dispose();
});
}
}
function updateKeyTarget() {
if (state.mode === "records") {
keyTarget.set(0, 1.82, 0);
return;
}
if (state.destination) {
keyTarget.copy(destinationPositions[state.destination]);
return;
}
if (state.actor) {
const spec = actorSpecs[state.actor];
keyTarget.set(2.47, spec.tall ? 1.28 : 1.02, 0);
return;
}
keyTarget.set(0, 1.82, 0);
}
function chooseActor(actorId) {
state.actor = actorId;
state.accepted = false;
clearActorModel();
if (actorId) {
const model = buildCourier(actorSpecs[actorId]);
reconstructionCourier.add(model);
const spec = actorSpecs[actorId];
satchelMarker.position.set(2.48, spec.tall ? 1.25 : 0.98, 0);
satchelLabel.position.set(2.2, spec.tall ? 2.75 : 2.45, 0);
} else {
satchelMarker.position.set(2.48, 1.25, 0);
}
actorButtons.forEach((button) => {
const selected = button.dataset.actor === actorId;
button.classList.toggle("selected", selected);
button.setAttribute("aria-pressed", String(selected));
});
outcomeBox.hidden = true;
ghostKeys.forEach(({ group }) => (group.visible = false));
updateKeyTarget();
setStatus(
"idle",
"Courier selected",
`${actorSpecs[actorId].name} is the proposed courier. Now select where the Sun Key was placed.`
);
}
function chooseDestination(destinationId) {
state.destination = destinationId;
state.accepted = false;
destinationButtons.forEach((button) => {
const selected = button.dataset.destination === destinationId;
button.classList.toggle("selected", selected);
button.setAttribute("aria-pressed", String(selected));
});
Object.entries(destinationMeshes).forEach(([id, mesh]) => {
mesh.material.color.set(id === destinationId ? 0xf1b72c : 0x2d958b);
mesh.material.emissive.set(id === destinationId ? 0x8b650c : 0x1b5d58);
});
outcomeBox.hidden = true;
ghostKeys.forEach(({ group }) => (group.visible = false));
updateKeyTarget();
setStatus(
"idle",
"Placement selected",
"The reconstruction is ready to test against both camera records."
);
}
function testReconstruction() {
if (!state.actor) {
setStatus(
"error",
"Courier missing",
"Choose one of the three staff members before testing the reconstruction."
);
return;
}
if (!state.destination) {
setStatus(
"error",
"Placement missing",
"Choose where the Sun Key ended up. All three marked locations are possible."
);
return;
}
if (state.actor === "bram") {
state.accepted = false;
outcomeBox.hidden = true;
ghostKeys.forEach(({ group }) => (group.visible = false));
setStatus(
"error",
"Rejected by Camera A",
"Bram's yellow pack matches Camera B, but his short silhouette does not clear the privacy screen."
);
return;
}
if (state.actor === "cleo") {
state.accepted = false;
outcomeBox.hidden = true;
ghostKeys.forEach(({ group }) => (group.visible = false));
setStatus(
"error",
"Rejected by Camera B",
"Cleo's tall silhouette matches Camera A, but her pack is teal rather than yellow."
);
return;
}
state.accepted = true;
outcomeBox.hidden = false;
ghostKeys.forEach(({ group }) => {
group.visible = true;
});
setStatus(
"success",
"Accepted — but not uniquely determined",
"Ada is the only courier consistent with both records. The selected placement is accepted, and the viewer marks the two other placements that are equally consistent."
);
}
function resetCase() {
state.actor = null;
state.destination = null;
state.accepted = false;
clearActorModel();
actorButtons.forEach((button) => {
button.classList.remove("selected");
button.setAttribute("aria-pressed", "false");
});
destinationButtons.forEach((button) => {
button.classList.remove("selected");
button.setAttribute("aria-pressed", "false");
});
Object.values(destinationMeshes).forEach((mesh) => {
mesh.material.color.set(0x2d958b);
mesh.material.emissive.set(0x1b5d58);
});
ghostKeys.forEach(({ group }) => (group.visible = false));
outcomeBox.hidden = true;
keyTarget.set(0, 1.82, 0);
setStatus(
"idle",
"Awaiting reconstruction",
"Combine the tall silhouette from Camera A with the yellow pack from Camera B."
);
}
actorButtons.forEach((button) => {
button.addEventListener("click", () => chooseActor(button.dataset.actor));
});
destinationButtons.forEach((button) => {
button.addEventListener("click", () => chooseDestination(button.dataset.destination));
});
document.querySelector("#testButton").addEventListener("click", testReconstruction);
document.querySelector("#resetButton").addEventListener("click", resetCase);
// ------------------------------------------------------------
// Viewer modes
// ------------------------------------------------------------
function updateVisibility() {
const records = state.mode === "records";
evidenceCourier.visible = records;
sightBlockers.visible = records;
destinationLabels.visible = !records;
reconstructionCourier.visible = !records;
selectedKey.visible = !records;
Object.values(destinationMeshes).forEach((mesh) => {
mesh.visible = !records;
});
ghostKeys.forEach(({ group }) => {
group.visible = !records && state.accepted;
});
document.querySelector("#viewA").hidden = !records;
document.querySelector("#viewB").hidden = !records;
document.querySelector("#splitLine").hidden = !records;
document.querySelector("#scanFX").hidden = !records;
document.querySelector("#reconLabel").hidden = records;
viewport.classList.toggle("records-mode", records);
document.querySelector("#recordsMode").classList.toggle("active", records);
document.querySelector("#reconstructionMode").classList.toggle("active", !records);
viewerState.textContent = records
? "Showing synchronized evidence frames"
: "Interactive reconstruction · gold key marks the selected placement";
renderer.domElement.style.cursor = records ? "default" : "grab";
updateKeyTarget();
}
document.querySelector("#recordsMode").addEventListener("click", () => {
state.mode = "records";
updateVisibility();
});
document.querySelector("#reconstructionMode").addEventListener("click", () => {
state.mode = "reconstruction";
updateVisibility();
});
// ------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------
function resize() {
const width = Math.max(1, viewport.clientWidth);
const height = Math.max(1, viewport.clientHeight);
renderer.setSize(width, height, false);
evidenceCamera.aspect = (width / 2) / height;
evidenceCamera.updateProjectionMatrix();
secondEvidenceCamera.aspect = (width / 2) / height;
secondEvidenceCamera.updateProjectionMatrix();
reconstructionCamera.aspect = width / height;
reconstructionCamera.updateProjectionMatrix();
}
if ("ResizeObserver" in window) {
new ResizeObserver(resize).observe(viewport);
} else {
window.addEventListener("resize", resize);
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
updateReconstructionCamera();
const smoothing = 1 - Math.exp(-6 * delta);
selectedKey.position.lerp(keyTarget, smoothing);
selectedKey.rotation.y += delta * 0.8;
const pulse = 1 + Math.sin(time * 3.2) * 0.08;
archiveMarker.scale.setScalar(pulse);
safeMarker.scale.setScalar(pulse);
satchelMarker.scale.setScalar(pulse);
if (state.accepted) {
ghostKeys.forEach(({ group }, index) => {
group.rotation.y += delta * (0.55 + index * 0.12);
group.position.y += Math.sin(time * 2.2 + index * 1.8) * 0.0014;
});
}
if (state.mode === "records") {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
const half = Math.floor(width / 2);
renderer.setScissorTest(true);
renderer.setViewport(0, 0, half, height);
renderer.setScissor(0, 0, half, height);
renderer.render(scene, evidenceCamera);
renderer.setViewport(half, 0, width - half, height);
renderer.setScissor(half, 0, width - half, height);
renderer.render(scene, secondEvidenceCamera);
renderer.setScissorTest(false);
} else {
renderer.setViewport(0, 0, viewport.clientWidth, viewport.clientHeight);
renderer.render(scene, reconstructionCamera);
}
}
resize();
updateVisibility();
animate();
</script>
</body>
</html>
```