Prompt specification
Build or customize the Three.js 3D scene "Reconstructing a Community Event" 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: Reconstructing a Community Event
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/reconstructing-a-community-event-x3212
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing community memory from partial and differing accounts. Create a puzzle assembling a fictional event sequence from timestamped records and uncertain recollections. Allow multiple compatible interpretations when the available evidence cannot resolve the order. Low-poly.
Working Three.js Starter (reconstructing-a-community-event-x3212):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Lantern Walk — Community Memory Puzzle</title>
<style>
:root {
--bg: #0b1014;
--panel: rgba(20, 27, 31, 0.92);
--panel-soft: rgba(27, 36, 40, 0.76);
--line: rgba(221, 228, 216, 0.13);
--line-strong: rgba(221, 228, 216, 0.25);
--text: #e9ece3;
--muted: #99a39d;
--gold: #e5ae52;
--cyan: #64cbd2;
--green: #9fc47a;
--red: #de7d70;
--blue: #7899d2;
--shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
}
* {
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,
[tabindex]:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 3px;
}
#app {
height: 100dvh;
display: flex;
flex-direction: column;
background:
radial-gradient(circle at 52% 12%, rgba(76, 102, 102, 0.14), transparent 35%),
linear-gradient(180deg, #10171b 0%, #0b1014 100%);
}
header {
min-height: 86px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 15px 24px;
border-bottom: 1px solid var(--line);
background: rgba(10, 15, 18, 0.8);
backdrop-filter: blur(18px);
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 42px;
height: 47px;
flex: 0 0 auto;
background: linear-gradient(145deg, var(--gold), #9b6738);
clip-path: polygon(50% 0, 94% 24%, 94% 76%, 50% 100%, 6% 76%, 6% 24%);
box-shadow: 0 0 34px rgba(229, 174, 82, 0.18);
}
.brand-mark::before {
content: "";
position: absolute;
inset: 7px;
background: #11171a;
clip-path: inherit;
}
.brand-mark::after {
content: "";
position: absolute;
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--gold);
left: 17px;
top: 18px;
box-shadow:
0 0 0 4px rgba(229, 174, 82, 0.12),
0 0 18px rgba(229, 174, 82, 0.85);
}
.eyebrow {
margin: 0 0 4px;
color: var(--gold);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(23px, 2.2vw, 34px);
font-weight: 500;
letter-spacing: -0.025em;
}
.header-meta {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
flex-wrap: wrap;
}
.meta-pill {
padding: 8px 11px;
border: 1px solid var(--line-strong);
border-radius: 999px;
color: #c9d0c9;
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
background: rgba(255, 255, 255, 0.025);
}
.meta-pill.accent {
color: var(--gold);
border-color: rgba(229, 174, 82, 0.3);
background: rgba(229, 174, 82, 0.06);
}
main {
flex: 1;
min-height: 0;
display: grid;
grid-template-columns: 300px minmax(380px, 1fr) 350px;
gap: 12px;
padding: 12px;
}
.panel {
min-height: 0;
overflow: auto;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: var(--shadow);
scrollbar-width: thin;
scrollbar-color: #39443f transparent;
}
.panel::-webkit-scrollbar {
width: 7px;
}
.panel::-webkit-scrollbar-thumb {
background: #39443f;
border-radius: 20px;
}
.panel-heading {
position: sticky;
top: 0;
z-index: 3;
padding: 18px 18px 14px;
background: linear-gradient(180deg, rgba(20, 27, 31, 0.98) 72%, rgba(20, 27, 31, 0.88));
border-bottom: 1px solid var(--line);
backdrop-filter: blur(12px);
}
.panel-kicker {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.panel-heading h2 {
margin: 6px 0 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 22px;
font-weight: 500;
}
.panel-content {
padding: 14px;
}
.group-label {
display: flex;
align-items: center;
gap: 9px;
margin: 7px 2px 11px;
color: #bbc3bd;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.group-label .index {
display: grid;
place-items: center;
width: 22px;
height: 22px;
border: 1px solid var(--line-strong);
border-radius: 50%;
color: var(--gold);
font-size: 9px;
}
.group-label small {
margin-left: auto;
color: #78837d;
font-size: 9px;
letter-spacing: 0.06em;
}
.evidence-card {
position: relative;
margin-bottom: 9px;
padding: 13px 13px 12px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
}
.evidence-card::before {
content: "";
position: absolute;
top: 13px;
bottom: 13px;
left: 0;
width: 2px;
border-radius: 2px;
background: #60706a;
}
.evidence-card.hard::before {
background: var(--gold);
}
.evidence-card.disputed::before {
background: var(--red);
}
.evidence-card.unresolved::before {
background: var(--cyan);
}
.evidence-meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 8px;
}
.evidence-meta time {
color: var(--gold);
font-size: 12px;
font-weight: 800;
font-variant-numeric: tabular-nums;
letter-spacing: 0.08em;
}
.source {
color: #7f8b85;
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
text-align: right;
}
.evidence-card h3 {
margin: 0 0 5px;
font-size: 13px;
font-weight: 750;
line-height: 1.35;
}
.evidence-card p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.certainty {
display: inline-flex;
align-items: center;
gap: 5px;
margin-top: 10px;
padding: 4px 7px;
border-radius: 5px;
color: #aeb8b1;
background: rgba(255, 255, 255, 0.045);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.certainty::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: currentColor;
}
.certainty.strong {
color: var(--gold);
background: rgba(229, 174, 82, 0.08);
}
.certainty.disputed {
color: var(--red);
background: rgba(222, 125, 112, 0.08);
}
.certainty.open {
color: var(--cyan);
background: rgba(100, 203, 210, 0.08);
}
.account-head {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
}
.avatar {
display: grid;
place-items: center;
width: 27px;
height: 27px;
flex: 0 0 auto;
border: 1px solid var(--line-strong);
border-radius: 50%;
color: #d7ddd6;
background: #26302f;
font-family: Georgia, serif;
font-size: 12px;
}
.account-name {
font-size: 11px;
font-weight: 800;
}
.account-type {
margin-left: auto;
color: #758079;
font-size: 8px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.archive-note {
margin: 16px 3px 4px;
padding-top: 15px;
border-top: 1px solid var(--line);
color: #929e97;
font-family: Georgia, serif;
font-size: 12px;
font-style: italic;
line-height: 1.55;
}
#stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 16px;
background:
radial-gradient(circle at 50% 30%, rgba(85, 111, 110, 0.16), transparent 55%),
#11181c;
box-shadow: var(--shadow);
}
#canvasWrap,
#scene {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
#scene {
display: block;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.stage-top {
position: absolute;
top: 15px;
left: 15px;
right: 15px;
z-index: 3;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 14px;
pointer-events: none;
}
.stage-label {
padding: 9px 11px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(12, 18, 21, 0.67);
backdrop-filter: blur(9px);
}
.stage-label small {
display: block;
margin-bottom: 3px;
color: #7d8983;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.stage-label strong {
color: #d8ddd5;
font-size: 11px;
font-weight: 700;
}
.stage-controls {
position: absolute;
right: 15px;
bottom: 15px;
z-index: 4;
display: flex;
gap: 6px;
}
.icon-button {
display: grid;
place-items: center;
width: 34px;
height: 34px;
padding: 0;
border: 1px solid var(--line-strong);
border-radius: 8px;
color: #d4d9d2;
background: rgba(12, 18, 21, 0.78);
backdrop-filter: blur(10px);
cursor: pointer;
}
.icon-button:hover {
border-color: rgba(100, 203, 210, 0.55);
color: var(--cyan);
}
.stage-help {
position: absolute;
left: 15px;
bottom: 15px;
z-index: 3;
padding: 8px 10px;
border: 1px solid var(--line);
border-radius: 7px;
color: #78847e;
background: rgba(12, 18, 21, 0.62);
font-size: 9px;
letter-spacing: 0.04em;
pointer-events: none;
}
.scene-message {
position: absolute;
left: 50%;
bottom: 58px;
z-index: 4;
width: min(420px, calc(100% - 34px));
padding: 14px 16px;
border: 1px solid rgba(100, 203, 210, 0.3);
border-radius: 12px;
background: rgba(12, 20, 22, 0.88);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
backdrop-filter: blur(14px);
text-align: center;
transform: translate(-50%, 12px);
opacity: 0;
pointer-events: none;
transition: opacity 220ms ease, transform 220ms ease;
}
.scene-message.visible {
opacity: 1;
transform: translate(-50%, 0);
}
.scene-message span {
display: block;
margin-bottom: 4px;
color: var(--cyan);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.scene-message strong {
display: block;
font-family: Georgia, serif;
font-size: 16px;
font-weight: 500;
}
.scene-message small {
display: block;
margin-top: 5px;
color: var(--muted);
font-size: 10px;
}
.constraint-map {
margin-bottom: 15px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 11px;
background:
linear-gradient(135deg, rgba(229, 174, 82, 0.055), transparent 55%),
rgba(255, 255, 255, 0.02);
}
.constraint-map > small {
color: #7f8b84;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.chain {
display: flex;
align-items: center;
gap: 6px;
margin-top: 10px;
color: #d6dbd4;
font-size: 10px;
font-weight: 700;
flex-wrap: wrap;
}
.chain .arrow {
color: #62706a;
}
.fork {
display: flex;
align-items: center;
gap: 7px;
margin-top: 10px;
color: var(--cyan);
font-size: 10px;
}
.fork::before {
content: "";
width: 20px;
height: 1px;
background: rgba(100, 203, 210, 0.5);
}
.slot-list {
display: grid;
gap: 8px;
}
.slot {
position: relative;
min-height: 62px;
display: grid;
grid-template-columns: 30px minmax(0, 1fr) 24px;
align-items: center;
gap: 9px;
padding: 10px 9px 10px 10px;
border: 1px dashed rgba(218, 225, 215, 0.23);
border-radius: 10px;
background: rgba(255, 255, 255, 0.018);
cursor: pointer;
transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.slot:hover,
.slot.drag-over {
border-color: rgba(100, 203, 210, 0.7);
background: rgba(100, 203, 210, 0.045);
transform: translateX(2px);
}
.slot.filled {
border-style: solid;
border-color: color-mix(in srgb, var(--slot-color) 45%, transparent);
background: linear-gradient(90deg, color-mix(in srgb, var(--slot-color) 8%, transparent), transparent);
}
.slot-number {
display: grid;
place-items: center;
width: 28px;
height: 28px;
border: 1px solid var(--line-strong);
border-radius: 50%;
color: #8e9993;
font-size: 10px;
font-weight: 800;
font-variant-numeric: tabular-nums;
}
.slot.filled .slot-number {
color: var(--slot-color);
border-color: color-mix(in srgb, var(--slot-color) 55%, transparent);
}
.slot-copy {
min-width: 0;
}
.slot-copy small {
display: block;
margin-bottom: 3px;
color: #707c76;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.slot-copy strong {
display: block;
overflow: hidden;
color: #d9ded7;
font-size: 12px;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
}
.slot.empty .slot-copy strong {
color: #626e68;
font-weight: 500;
}
.remove-button {
display: grid;
place-items: center;
width: 23px;
height: 23px;
padding: 0;
border: 0;
border-radius: 6px;
color: #78837d;
background: transparent;
cursor: pointer;
}
.remove-button:hover {
color: var(--red);
background: rgba(222, 125, 112, 0.08);
}
.placed-event {
cursor: grab;
}
.placed-event:active {
cursor: grabbing;
}
.fragment-title {
display: flex;
align-items: center;
justify-content: space-between;
margin: 17px 1px 8px;
color: #b7c0ba;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.fragment-title span {
color: #68746e;
font-size: 8px;
letter-spacing: 0.04em;
text-transform: none;
}
.fragment-list {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.fragment {
position: relative;
min-height: 58px;
padding: 10px 9px 9px 13px;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 9px;
color: #d8ddd6;
background: rgba(255, 255, 255, 0.025);
text-align: left;
cursor: grab;
transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.fragment::before {
content: "";
position: absolute;
top: 9px;
bottom: 9px;
left: 0;
width: 3px;
border-radius: 0 3px 3px 0;
background: var(--event-color);
}
.fragment:hover,
.fragment.selected {
border-color: color-mix(in srgb, var(--event-color) 55%, transparent);
background: color-mix(in srgb, var(--event-color) 7%, transparent);
transform: translateY(-1px);
}
.fragment small {
display: block;
margin-bottom: 4px;
color: var(--event-color);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.fragment strong {
display: block;
font-size: 10px;
line-height: 1.3;
}
.action-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 15px;
}
.button {
min-height: 40px;
padding: 9px 12px;
border: 1px solid var(--line-strong);
border-radius: 9px;
color: #d6dcd5;
background: rgba(255, 255, 255, 0.035);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.05em;
cursor: pointer;
transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.button:hover:not(:disabled) {
border-color: rgba(100, 203, 210, 0.5);
background: rgba(100, 203, 210, 0.055);
transform: translateY(-1px);
}
.button.primary {
grid-column: 1 / -1;
border-color: rgba(229, 174, 82, 0.42);
color: #15120c;
background: linear-gradient(135deg, #edbd68, #c7893e);
}
.button.primary:hover {
border-color: #f1ca84;
background: linear-gradient(135deg, #f4ca82, #d0964b);
}
.button:disabled {
opacity: 0.36;
cursor: not-allowed;
}
.status-box {
min-height: 78px;
margin-top: 12px;
padding: 12px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.02);
}
.status-box.good {
border-color: rgba(159, 196, 122, 0.28);
background: rgba(159, 196, 122, 0.045);
}
.status-box.warn {
border-color: rgba(229, 174, 82, 0.25);
background: rgba(229, 174, 82, 0.035);
}
.status-box strong {
display: block;
margin-bottom: 4px;
color: #dce1da;
font-size: 11px;
}
.status-box p {
margin: 0;
color: #929d96;
font-size: 10px;
line-height: 1.5;
}
.status-box.good strong {
color: var(--green);
}
.status-box.warn strong {
color: var(--gold);
}
.sequence-footer {
margin-top: 10px;
color: #66726c;
font-size: 9px;
line-height: 1.45;
text-align: center;
}
@media (max-width: 1120px) {
main {
grid-template-columns: 260px minmax(330px, 1fr) 315px;
}
.fragment-list {
grid-template-columns: 1fr;
}
}
@media (max-width: 900px) {
body {
overflow: auto;
}
#app {
height: auto;
min-height: 100dvh;
}
header {
align-items: flex-start;
padding: 14px 16px;
}
.header-meta {
display: none;
}
main {
display: flex;
flex-direction: column;
padding: 8px;
}
#stage {
order: -1;
min-height: 56dvh;
}
.panel {
overflow: visible;
}
.panel-heading {
position: relative;
}
.fragment-list {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 520px) {
.brand-mark {
width: 34px;
height: 39px;
}
.brand-mark::after {
left: 13px;
top: 15px;
}
.eyebrow {
font-size: 8px;
}
h1 {
font-size: 24px;
}
.stage-help {
display: none;
}
.stage-label {
padding: 7px 8px;
}
.fragment-list {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div id="app">
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<p class="eyebrow">Common Ground · Community Memory Archive</p>
<h1>The Lantern Walk</h1>
</div>
</div>
<div class="header-meta">
<span class="meta-pill">Old Market · 18:12—18:24</span>
<span class="meta-pill accent">2 possible readings</span>
</div>
</header>
<main>
<aside class="panel" aria-label="Evidence archive">
<div class="panel-heading">
<div class="panel-kicker">Evidence ledger</div>
<h2>What the record knows</h2>
</div>
<div class="panel-content">
<section>
<div class="group-label">
<span class="index">01</span>
Timestamped records
<small>CLOCK ALIGNED</small>
</div>
<article class="evidence-card hard">
<div class="evidence-meta">
<time>18:12</time>
<span class="source">Municipal bell archive</span>
</div>
<h3>The bell rings</h3>
<p>A calibrated tower recorder captures three clear strikes.</p>
<span class="certainty strong">Hard timestamp</span>
</article>
<article class="evidence-card hard">
<div class="evidence-meta">
<time>18:15</time>
<span class="source">Original photo metadata</span>
</div>
<h3>The blue lantern rounds the corner</h3>
<p>An untouched camera file places the lantern at the turn.</p>
<span class="certainty strong">Hard timestamp</span>
</article>
<article class="evidence-card hard">
<div class="evidence-meta">
<time>18:17</time>
<span class="source">Transit depot log</span>
</div>
<h3>The last tram passes the square</h3>
<p>The tram clears the market before the walking group arrives.</p>
<span class="certainty strong">Hard timestamp</span>
</article>
<article class="evidence-card hard">
<div class="evidence-meta">
<time>18:18</time>
<span class="source">Gate camera sweep</span>
</div>
<h3>The fountain and gathering square are still empty</h3>
<p>Both later moments must occur after the tram has passed.</p>
<span class="certainty strong">Ordering constraint</span>
</article>
<article class="evidence-card hard">
<div class="evidence-meta">
<time>18:24</time>
<span class="source">Single market photograph</span>
</div>
<h3>Lanterns and people are both at the fountain</h3>
<p>The photograph proves both final moments occurred, but cannot show which came first.</p>
<span class="certainty strong">Shared endpoint</span>
</article>
</section>
<section>
<div class="group-label">
<span class="index">02</span>
Community recollections
<small>MEMORY, NOT CLOCKS</small>
</div>
<article class="evidence-card">
<div class="account-head">
<span class="avatar">L</span>
<span class="account-name">Leila</span>
<span class="account-type">Consistent</span>
</div>
<p>“We heard the bell first. The blue lantern came around the corner afterward.”</p>
</article>
<article class="evidence-card disputed">
<div class="account-head">
<span class="avatar">A</span>
<span class="account-name">Ada</span>
<span class="account-type">Differing</span>
</div>
<p>“The lantern was already around the corner before the bell rang.”</p>
<span class="certainty disputed">Contradicted by timestamps</span>
</article>
<article class="evidence-card unresolved">
<div class="account-head">
<span class="avatar">Y</span>
<span class="account-name">Yara</span>
<span class="account-type">Unresolved</span>
</div>
<p>“People were already waiting at the fountain when the lanterns arrived.”</p>
<span class="certainty open">Crowd before lanterns</span>
</article>
<article class="evidence-card unresolved">
<div class="account-head">
<span class="avatar">M</span>
<span class="account-name">Malik</span>
<span class="account-type">Unresolved</span>
</div>
<p>“The lanterns reached the fountain first. People joined them afterward.”</p>
<span class="certainty open">Lanterns before crowd</span>
</article>
</section>
<p class="archive-note">
“A timestamp can settle an order. It cannot always settle a meaning.”
</p>
</div>
</aside>
<section id="stage" aria-label="Low-poly reconstruction stage">
<div id="canvasWrap">
<canvas id="scene" aria-label="Interactive low-poly timeline. Drag to rotate and scroll to zoom."></canvas>
</div>
<div class="stage-top">
<div class="stage-label">
<small>Reconstruction</small>
<strong id="sceneReadout">Unplaced fragments</strong>
</div>
<div class="stage-label">
<small>Evidence state</small>
<strong>One unresolved fork</strong>
</div>
</div>
<div id="readingOverlay" class="scene-message" aria-live="polite">
<span id="readingLabel">Supported reading A</span>
<strong id="readingTitle">Lanterns → Crowd</strong>
<small>A second reading remains equally compatible with the evidence.</small>
</div>
<div class="stage-help">Drag scene to orbit · Scroll to zoom</div>
<div class="stage-controls" aria-label="Camera controls">
<button class="icon-button" id="zoomOut" type="button" aria-label="Zoom out">−</button>
<button class="icon-button" id="zoomIn" type="button" aria-label="Zoom in">+</button>
<button class="icon-button" id="orbitReset" type="button" aria-label="Reset camera">↺</button>
</div>
</section>
<aside class="panel" aria-label="Sequence builder">
<div class="panel-heading">
<div class="panel-kicker">Sequence builder</div>
<h2>Reconstruct the walk</h2>
</div>
<div class="panel-content">
<div class="constraint-map">
<small>What the evidence establishes</small>
<div class="chain">
<span>Bell</span><span class="arrow">→</span>
<span>Blue lantern</span><span class="arrow">→</span>
<span>Tram</span>
</div>
<div class="fork">Crowd / Lanterns at fountain</div>
</div>
<div id="slotList" class="slot-list"></div>
<div class="fragment-title">
Unplaced fragments
<span>Drag or click to place</span>
</div>
<div id="fragmentList" class="fragment-list"></div>
<div class="action-row">
<button class="button primary" id="checkBtn" type="button">Check this sequence</button>
<button class="button" id="clueBtn" type="button">Reveal proven order</button>
<button class="button" id="resetBtn" type="button">Reset</button>
<button class="button" id="otherBtn" type="button" disabled>Show other reading</button>
</div>
<div id="statusBox" class="status-box" aria-live="polite">
<strong id="statusTitle">A shared memory, not a single fact.</strong>
<p id="statusText">
Place all five fragments. The final two moments may have more than one valid order.
</p>
</div>
<div class="sequence-footer">
Both final orders are accepted. A reconstruction is “supported,” never proven.
</div>
</div>
</aside>
</main>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const eventDefs = {
bell: {
id: "bell",
title: "Bell rings",
label: "BELL",
color: "#e5ae52",
colorHex: 0xe5ae52
},
corner: {
id: "corner",
title: "Blue lantern rounds corner",
label: "BLUE LANTERN",
color: "#64cbd2",
colorHex: 0x64cbd2
},
tram: {
id: "tram",
title: "Tram passes square",
label: "TRAM",
color: "#de7d70",
colorHex: 0xde7d70
},
fountain: {
id: "fountain",
title: "Lanterns reach fountain",
label: "AT FOUNTAIN",
color: "#7899d2",
colorHex: 0x7899d2
},
crowd: {
id: "crowd",
title: "Crowd gathers",
label: "CROWD",
color: "#9fc47a",
colorHex: 0x9fc47a
}
};
const expectedStart = ["bell", "corner", "tram"];
const finalPair = ["fountain", "crowd"];
/* ----------------------------------------------------------
Three.js scene
---------------------------------------------------------- */
const canvas = document.getElementById("scene");
const canvasWrap = document.getElementById("canvasWrap");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x11181c);
scene.fog = new THREE.Fog(0x11181c, 15, 31);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.25, 0);
let azimuth = 0.08;
let elevation = 0.96;
let cameraRadius = 15.8;
function updateCamera() {
const horizontal = cameraRadius * Math.sin(elevation);
camera.position.set(
cameraTarget.x + horizontal * Math.sin(azimuth),
cameraTarget.y + cameraRadius * Math.cos(elevation),
cameraTarget.z + horizontal * Math.cos(azimuth)
);
camera.lookAt(cameraTarget);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xbfd8d7, 0x25201a, 1.8);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffe1ad, 3.0);
keyLight.position.set(5, 9, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x69bdc7, 1.3);
rimLight.position.set(-7, 4, -5);
scene.add(rimLight);
const warmPoint = new THREE.PointLight(0xe5ae52, 11, 12, 2);
warmPoint.position.set(-3, 2.5, 2);
scene.add(warmPoint);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.74,
metalness: 0.04,
flatShading: true,
...options
});
}
function addMesh(geometry, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const groundMaterial = standardMaterial(0x111719);
const ground = addMesh(
new THREE.PlaneGeometry(70, 70),
groundMaterial,
0,
-0.8,
0
);
ground.rotation.x = -Math.PI / 2;
ground.castShadow = false;
const plinthMaterial = standardMaterial(0x20292b);
const plinth = addMesh(
new THREE.CylinderGeometry(6.65, 6.9, 0.52, 8),
plinthMaterial,
0,
-0.52,
0
);
plinth.scale.z = 0.62;
const topMaterial = standardMaterial(0x293234);
const top = addMesh(
new THREE.CylinderGeometry(6.45, 6.63, 0.18, 8),
topMaterial,
0,
-0.17,
0
);
top.scale.z = 0.62;
const slotPositions = [
{ x: -4.2, z: 0.22 },
{ x: -2.1, z: -0.14 },
{ x: 0.0, z: 0.2 },
{ x: 2.1, z: -0.14 },
{ x: 4.2, z: 0.22 }
];
const pathCurve = new THREE.CatmullRomCurve3(
slotPositions.map((position) =>
new THREE.Vector3(position.x, 0.015, position.z)
)
);
const path = addMesh(
new THREE.TubeGeometry(pathCurve, 80, 0.025, 5, false),
new THREE.MeshBasicMaterial({ color: 0x61716b, transparent: true, opacity: 0.55 }),
0,
0,
0
);
path.castShadow = false;
const slotBases = [];
const slotRings = [];
const ghosts = [];
for (let i = 0; i < slotPositions.length; i++) {
const position = slotPositions[i];
const base = addMesh(
new THREE.CylinderGeometry(0.61, 0.72, 0.16, 6),
standardMaterial(0x303a39),
position.x,
0.01,
position.z
);
const ring = addMesh(
new THREE.TorusGeometry(0.54, 0.025, 4, 28),
new THREE.MeshBasicMaterial({
color: 0x72817b,
transparent: true,
opacity: 0.5
}),
position.x,
0.105,
position.z
);
ring.rotation.x = Math.PI / 2;
ring.castShadow = false;
const ghostMaterial = new THREE.MeshBasicMaterial({
color: 0x83918a,
transparent: true,
opacity: 0.11,
wireframe: true
});
const ghost = addMesh(
new THREE.IcosahedronGeometry(0.23, 0),
ghostMaterial,
position.x,
0.34,
position.z
);
ghost.castShadow = false;
slotBases.push(base);
slotRings.push(ring);
ghosts.push(ghost);
}
function createBellToken() {
const group = new THREE.Group();
const gold = standardMaterial(0xe5ae52, {
emissive: 0x7a4812,
emissiveIntensity: 0.12,
metalness: 0.16
});
const dark = standardMaterial(0x3d3020);
addMesh(
new THREE.CylinderGeometry(0.21, 0.36, 0.42, 8),
gold,
0,
0.65,
0,
group
);
const handle = addMesh(
new THREE.TorusGeometry(0.16, 0.035, 4, 12),
dark,
0,
0.9,
0,
group
);
handle.rotation.x = Math.PI / 2;
addMesh(
new THREE.IcosahedronGeometry(0.075, 0),
dark,
0,
0.37,
0,
group
);
return group;
}
function createLanternToken() {
const group = new THREE.Group();
const frame = standardMaterial(0x4c3b2e);
const glow = new THREE.MeshBasicMaterial({
color: 0x64cbd2,
transparent: true,
opacity: 0.78
});
addMesh(new THREE.BoxGeometry(0.3, 0.43, 0.3), glow, 0, 0.62, 0, group);
addMesh(
new THREE.BoxGeometry(0.06, 0.53, 0.06),
frame,
-0.18,
0.62,
-0.18,
group
);
addMesh(
new THREE.BoxGeometry(0.06, 0.53, 0.06),
frame,
0.18,
0.62,
-0.18,
group
);
addMesh(
new THREE.BoxGeometry(0.06, 0.53, 0.06),
frame,
-0.18,
0.62,
0.18,
group
);
addMesh(
new THREE.BoxGeometry(0.06, 0.53, 0.06),
frame,
0.18,
0.62,
0.18,
group
);
addMesh(
new THREE.ConeGeometry(0.24, 0.18, 6),
frame,
0,
0.94,
0,
group
);
return group;
}
function createTramToken() {
const group = new THREE.Group();
const body = standardMaterial(0xde7d70);
const dark = standardMaterial(0x253239);
const windowMaterial = standardMaterial(0x94cad0, {
emissive: 0x315b63,
emissiveIntensity: 0.18
});
addMesh(
new THREE.BoxGeometry(0.82, 0.38, 0.36),
body,
0,
0.52,
0,
group
);
addMesh(
new THREE.BoxGeometry(0.84, 0.12, 0.38),
dark,
0,
0.36,
0,
group
);
for (let i = -1; i <= 1; i++) {
addMesh(
new THREE.BoxGeometry(0.17, 0.15, 0.02),
windowMaterial,
i * 0.22,
0.58,
0.19,
group
);
}
for (const x of [-0.27, 0.27]) {
for (const z of [-0.18, 0.18]) {
const wheel = addMesh(
new THREE.CylinderGeometry(0.075, 0.075, 0.035, 8),
dark,
x,
0.23,
z,
group
);
wheel.rotation.x = Math.PI / 2;
}
}
return group;
}
function createFountainToken() {
const group = new THREE.Group();
const stone = standardMaterial(0x7899d2);
const water = new THREE.MeshBasicMaterial({
color: 0x8ad9e3,
transparent: true,
opacity: 0.72
});
addMesh(
new THREE.CylinderGeometry(0.52, 0.57, 0.2, 6),
stone,
0,
0.3,
0,
group
);
addMesh(
new THREE.CylinderGeometry(0.35, 0.4, 0.05, 8),
water,
0,
0.43,
0,
group
);
addMesh(
new THREE.CylinderGeometry(0.08, 0.14, 0.35, 6),
stone,
0,
0.62,
0,
group
);
addMesh(
new THREE.ConeGeometry(0.2, 0.28, 6),
water,
0,
0.86,
0,
group
);
return group;
}
function createCrowdToken() {
const group = new THREE.Group();
const people = [
[-0.28, 0.38, 0.08, 0x9fc47a],
[0.02, 0.45, -0.08, 0xe1b66f],
[0.29, 0.36, 0.07, 0x76a9bd],
[-0.04, 0.35, 0.22, 0xc48675]
];
for (const [x, y, z, color] of people) {
addMesh(
new THREE.CylinderGeometry(0.08, 0.11, 0.3, 5),
standardMaterial(color),
x,
y,
z,
group
);
addMesh(
new THREE.DodecahedronGeometry(0.075, 0),
standardMaterial(0xe1c3a3),
x,
y + 0.21,
z,
group
);
}
return group;
}
const tokenFactories = {
bell: createBellToken,
corner: createLanternToken,
tram: createTramToken,
fountain: createFountainToken,
crowd: createCrowdToken
};
const tokens = {};
for (const [id, definition] of Object.entries(eventDefs)) {
const token = tokenFactories[id]();
token.visible = false;
token.scale.setScalar(0.92);
scene.add(token);
tokens[id] = token;
}
function roundedRect(context, x, y, width, height, radius) {
context.beginPath();
context.moveTo(x + radius, y);
context.lineTo(x + width - radius, y);
context.quadraticCurveTo(x + width, y, x + width, y + radius);
context.lineTo(x + width, y + height - radius);
context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
context.lineTo(x + radius, y + height);
context.quadraticCurveTo(x, y + height, x, y + height - radius);
context.lineTo(x, y + radius);
context.quadraticCurveTo(x, y, x + radius, y);
context.closePath();
}
const slotLabels = [];
function createSlotLabel(index) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 512;
labelCanvas.height = 128;
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(2.28, 0.57, 1);
sprite.renderOrder = 10;
const position = slotPositions[index];
sprite.position.set(position.x, -0.01, position.z + 1.22);
scene.add(sprite);
return { sprite, canvas: labelCanvas, texture };
}
for (let i = 0; i < slotPositions.length; i++) {
slotLabels.push(createSlotLabel(i));
}
function updateSlotLabels() {
slotLabels.forEach((label, index) => {
const context = label.canvas.getContext("2d");
const id = assignments[index];
const definition = eventDefs[id];
context.clearRect(0, 0, label.canvas.width, label.canvas.height);
roundedRect(
context,
5,
8,
502,
112,
18
);
context.fillStyle = "rgba(13, 19, 21, 0.88)";
context.fill();
context.strokeStyle = definition ? definition.color : "#4d5a54";
context.lineWidth = 4;
context.stroke();
context.fillStyle = definition ? definition.color : "#87928c";
context.font = "700 25px system-ui, sans-serif";
context.textBaseline = "middle";
context.textAlign = "left";
context.fillText(String(index + 1).padStart(2, "0"), 28, 64);
context.fillStyle = "#d7ddd5";
context.font = "700 27px system-ui, sans-serif";
let title = definition ? definition.title.toUpperCase() : "EMPTY MOMENT";
if (title.length > 23) title = title.slice(0, 22) + "…";
context.fillText(title, 88, 64);
label.texture.needsUpdate = true;
});
}
const ambientFragments = [];
const fragmentGeometry = new THREE.TetrahedronGeometry(0.075, 0);
const fragmentMaterials = [
new THREE.MeshBasicMaterial({ color: 0x60706a, transparent: true, opacity: 0.24 }),
new THREE.MeshBasicMaterial({ color: 0xe5ae52, transparent: true, opacity: 0.2 }),
new THREE.MeshBasicMaterial({ color: 0x64cbd2, transparent: true, opacity: 0.18 })
];
for (let i = 0; i < 34; i++) {
const particle = new THREE.Mesh(
fragmentGeometry,
fragmentMaterials[i % fragmentMaterials.length]
);
particle.position.set(
(Math.random() - 0.5) * 15,
0.5 + Math.random() * 5,
(Math.random() - 0.5) * 8
);
particle.rotation.set(
Math.random() * Math.PI,
Math.random() * Math.PI,
Math.random() * Math.PI
);
particle.userData.speed = 0.06 + Math.random() * 0.12;
scene.add(particle);
ambientFragments.push(particle);
}
const confetti = [];
const confettiGeometry = new THREE.TetrahedronGeometry(0.07, 0);
for (let i = 0; i < 34; i++) {
const definition = eventDefs[Object.keys(eventDefs)[i % Object.keys(eventDefs).length]];
const piece = new THREE.Mesh(
confettiGeometry,
new THREE.MeshBasicMaterial({ color: definition.colorHex })
);
piece.visible = false;
scene.add(piece);
confetti.push({
mesh: piece,
velocity: new THREE.Vector3(),
spin: new THREE.Vector3()
});
}
let confettiAge = 100;
function burstConfetti() {
confettiAge = 0;
confetti.forEach((piece, index) => {
piece.mesh.visible = true;
piece.mesh.position.set(
(Math.random() - 0.5) * 3,
2.2 + Math.random() * 2.5,
(Math.random() - 0.5) * 1.8
);
piece.velocity.set(
(Math.random() - 0.5) * 3.5,
1.5 + Math.random() * 2.2,
(Math.random() - 0.5) * 2.8
);
piece.spin.set(
Math.random() * 0.15,
Math.random() * 0.15,
Math.random() * 0.15
);
});
}
function resizeScene() {
const width = Math.max(1, canvasWrap.clientWidth);
const height = Math.max(1, canvasWrap.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resizeScene);
resizeObserver.observe(canvasWrap);
resizeScene();
/* ----------------------------------------------------------
Direct camera controls — no external controls addon
---------------------------------------------------------- */
let draggingCamera = false;
let previousPointerX = 0;
let previousPointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
draggingCamera = true;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!draggingCamera) return;
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
azimuth -= deltaX * 0.006;
elevation = THREE.MathUtils.clamp(elevation + deltaY * 0.004, 0.58, 1.24);
updateCamera();
});
canvas.addEventListener("pointerup", (event) => {
draggingCamera = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
draggingCamera = false;
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius + event.deltaY * 0.008,
9.5,
21
);
updateCamera();
},
{ passive: false }
);
document.getElementById("zoomIn").addEventListener("click", () => {
cameraRadius = Math.max(9.5, cameraRadius - 1.2);
updateCamera();
});
document.getElementById("zoomOut").addEventListener("click", () => {
cameraRadius = Math.min(21, cameraRadius + 1.2);
updateCamera();
});
document.getElementById("orbitReset").addEventListener("click", () => {
azimuth = 0.08;
elevation = 0.96;
cameraRadius = 15.8;
updateCamera();
});
/* ----------------------------------------------------------
Puzzle state and UI
---------------------------------------------------------- */
let assignments = Array(5).fill(null);
let selectedEvent = null;
let draggingEventId = null;
let draggingSourceSlot = null;
let solved = false;
let currentReading = "";
const slotList = document.getElementById("slotList");
const fragmentList = document.getElementById("fragmentList");
const statusBox = document.getElementById("statusBox");
const statusTitle = document.getElementById("statusTitle");
const statusText = document.getElementById("statusText");
const otherBtn = document.getElementById("otherBtn");
const readingOverlay = document.getElementById("readingOverlay");
const readingLabel = document.getElementById("readingLabel");
const readingTitle = document.getElementById("readingTitle");
const sceneReadout = document.getElementById("sceneReadout");
function setStatus(kind, title, text) {
statusBox.className = `status-box ${kind}`;
statusTitle.textContent = title;
statusText.textContent = text;
}
function renderBuilder() {
slotList.innerHTML = assignments
.map((id, index) => {
const definition = eventDefs[id];
const filled = Boolean(definition);
const color = definition ? definition.color : "#53605a";
return `
<div
class="slot ${filled ? "filled" : "empty"}"
data-slot="${index}"
style="--slot-color: ${color}"
role="button"
tabindex="0"
aria-label="${filled ? `Moment ${index + 1}: ${definition.title}` : `Empty moment ${index + 1}`}"
>
<span class="slot-number">${index + 1}</span>
<span class="slot-copy">
<small>${filled ? "Placed moment" : "Open moment"}</small>
<strong class="${filled ? "placed-event" : ""}"
${filled ? `data-drag-event="${id}" data-source-slot="${index}" draggable="true"` : ""}
>
${filled ? definition.title : "Place a fragment"}
</strong>
</span>
${filled
? `<button class="remove-button" data-remove="${index}" type="button" aria-label="Remove ${definition.title}">×</button>`
: `<span class="remove-button" aria-hidden="true">·</span>`}
</div>
`;
})
.join("");
const unused = Object.values(eventDefs).filter(
(definition) => !assignments.includes(definition.id)
);
fragmentList.innerHTML = unused
.map(
(definition) => `
<button
class="fragment ${selectedEvent === definition.id ? "selected" : ""}"
type="button"
style="--event-color: ${definition.color}"
data-drag-event="${definition.id}"
draggable="true"
aria-label="Select ${definition.title}"
>
<small>${definition.label}</small>
<strong>${definition.title}</strong>
</button>
`
)
.join("");
updateSlotLabels();
}
function selectEvent(id) {
selectedEvent = selectedEvent === id ? null : id;
renderBuilder();
if (selectedEvent) {
setStatus(
"warn",
"Fragment selected.",
`Choose a moment for “${eventDefs[id].title}”. Clicking a placed fragment also lets you drag it into a new position.`
);
}
}
function markChanged() {
solved = false;
currentReading = "";
readingOverlay.classList.remove("visible");
otherBtn.disabled = true;
otherBtn.textContent = "Show other reading";
sceneReadout.textContent = "Unplaced fragments";
const placed = assignments.filter(Boolean).length;
sceneReadout.textContent = `${placed} of 5 moments placed`;
setStatus(
"neutral",
"Sequence changed.",
"Check the reading again, or continue arranging the remaining fragments."
);
}
function placeEvent(id, targetIndex) {
if (!eventDefs[id]) return;
const sourceIndex = assignments.indexOf(id);
if (sourceIndex === targetIndex) {
selectedEvent = null;
renderBuilder();
return;
}
const displaced = assignments[targetIndex];
assignments[targetIndex] = id;
if (sourceIndex >= 0) {
assignments[sourceIndex] = displaced || null;
}
selectedEvent = null;
markChanged();
renderBuilder();
}
function checkSequence() {
if (assignments.some((id) => !id)) {
const missing = assignments.filter((id) => !id).length;
setStatus(
"warn",
`${missing} ${missing === 1 ? "fragment remains" : "fragments remain"}.`,
"Place every fragment before checking the sequence."
);
return;
}
const firstThreeCorrect = expectedStart.every(
(id, index) => assignments[index] === id
);
const finalMomentsCorrect = finalPair.every((id) =>
assignments.slice(3).includes(id)
);
if (!firstThreeCorrect || !finalMomentsCorrect) {
setStatus(
"warn",
"This reading conflicts with the calibrated record.",
"The timestamps establish Bell → Blue lantern → Tram. The 18:18 sweep places both fountain moments after the tram."
);
return;
}
solved = true;
currentReading = assignments[3] === "fountain" ? "A" : "B";
const isA = currentReading === "A";
readingLabel.textContent = `Supported reading ${currentReading}`;
readingTitle.textContent = isA
? "Lanterns reach fountain → Crowd gathers"
: "Crowd gathers → Lanterns reach fountain";
readingOverlay.classList.add("visible");
sceneReadout.textContent = `Reading ${currentReading} · final order unresolved`;
otherBtn.disabled = false;
otherBtn.textContent = isA ? "Show reading B" : "Show reading A";
setStatus(
"good",
`Reading ${currentReading} is supported.`,
"Both final orders are equally compatible with the evidence. This sequence is supported, not proven."
);
burstConfetti();
}
function revealProvenOrder() {
const rememberedFinals = assignments.filter(
(id) => id === "fountain" || id === "crowd"
);
assignments = [
"bell",
"corner",
"tram",
rememberedFinals[0] || null,
rememberedFinals[1] || null
];
selectedEvent = null;
markChanged();
renderBuilder();
setStatus(
"warn",
"The proven order is now visible.",
"The timestamped records settle the first three moments. The final two still depend on which recollection you accept."
);
}
function resetPuzzle() {
assignments = Array(5).fill(null);
selectedEvent = null;
solved = false;
currentReading = "";
readingOverlay.classList.remove("visible");
otherBtn.disabled = true;
otherBtn.textContent = "Show other reading";
sceneReadout.textContent = "Unplaced fragments";
confetti.forEach((piece) => {
piece.mesh.visible = false;
});
renderBuilder();
setStatus(
"neutral",
"A shared memory, not a single fact.",
"Place all five fragments. The final two moments may have more than one valid order."
);
}
function showOtherReading() {
if (!solved) return;
const last = assignments[3];
assignments[3] = assignments[4];
assignments[4] = last;
currentReading = assignments[3] === "fountain" ? "A" : "B";
const isA = currentReading === "A";
readingLabel.textContent = `Supported reading ${currentReading}`;
readingTitle.textContent = isA
? "Lanterns reach fountain → Crowd gathers"
: "Crowd gathers → Lanterns reach fountain";
sceneReadout.textContent = `Reading ${currentReading} · final order unresolved`;
otherBtn.textContent = isA ? "Show reading B" : "Show reading A";
renderBuilder();
setStatus(
"good",
`Reading ${currentReading} is also supported.`,
"The same records and recollections permit this alternative. The community archive cannot distinguish between the two final orders."
);
}
document.addEventListener("click", (event) => {
const removeButton = event.target.closest("[data-remove]");
if (removeButton) {
event.stopPropagation();
const index = Number(removeButton.dataset.remove);
assignments[index] = null;
selectedEvent = null;
markChanged();
renderBuilder();
return;
}
const fragment = event.target.closest(".fragment");
if (fragment) {
selectEvent(fragment.dataset.dragEvent);
return;
}
const placed = event.target.closest(".placed-event");
if (placed) {
selectEvent(placed.dataset.dragEvent);
return;
}
const slot = event.target.closest(".slot");
if (slot && selectedEvent) {
placeEvent(selectedEvent, Number(slot.dataset.slot));
}
});
document.addEventListener("keydown", (event) => {
const slot = event.target.closest(".slot");
if (slot && (event.key === "Enter" || event.key === " ")) {
event.preventDefault();
if (selectedEvent) {
placeEvent(selectedEvent, Number(slot.dataset.slot));
}
}
});
document.addEventListener("dragstart", (event) => {
const draggable = event.target.closest("[data-drag-event]");
if (!draggable) return;
draggingEventId = draggable.dataset.dragEvent;
draggingSourceSlot = draggable.hasAttribute("data-source-slot")
? Number(draggable.dataset.sourceSlot)
: null;
event.dataTransfer.effectAllowed = "move";
event.dataTransfer.setData("text/plain", draggingEventId);
});
document.addEventListener("dragover", (event) => {
const slot = event.target.closest(".slot");
if (!slot) return;
event.preventDefault();
event.dataTransfer.dropEffect = "move";
slot.classList.add("drag-over");
});
document.addEventListener("dragleave", (event) => {
const slot = event.target.closest(".slot");
if (slot && !slot.contains(event.relatedTarget)) {
slot.classList.remove("drag-over");
}
});
document.addEventListener("drop", (event) => {
const slot = event.target.closest(".slot");
if (!slot) return;
event.preventDefault();
slot.classList.remove("drag-over");
const id =
event.dataTransfer.getData("text/plain") || draggingEventId;
const targetIndex = Number(slot.dataset.slot);
if (!id || !eventDefs[id]) return;
if (
draggingSourceSlot !== null &&
draggingSourceSlot !== targetIndex
) {
const temporary = assignments[draggingSourceSlot];
assignments[draggingSourceSlot] = assignments[targetIndex];
assignments[targetIndex] = temporary;
selectedEvent = null;
markChanged();
renderBuilder();
} else if (draggingSourceSlot === null) {
placeEvent(id, targetIndex);
}
draggingEventId = null;
draggingSourceSlot = null;
});
document.addEventListener("dragend", () => {
draggingEventId = null;
draggingSourceSlot = null;
document.querySelectorAll(".drag-over").forEach((element) => {
element.classList.remove("drag-over");
});
});
document.getElementById("checkBtn").addEventListener("click", checkSequence);
document.getElementById("clueBtn").addEventListener("click", revealProvenOrder);
document.getElementById("resetBtn").addEventListener("click", resetPuzzle);
document.getElementById("otherBtn").addEventListener("click", showOtherReading);
renderBuilder();
/* ----------------------------------------------------------
Animation
---------------------------------------------------------- */
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
for (const [id, token] of Object.entries(tokens)) {
token.visible = assignments.includes(id);
}
assignments.forEach((id, index) => {
const token = tokens[id];
const position = slotPositions[index];
if (id) {
token.position.x += (position.x - token.position.x) * 0.12;
token.position.z += (position.z - token.position.z) * 0.12;
token.position.y = 0.09 + Math.sin(elapsed * 1.7 + index * 0.8) * 0.024;
token.rotation.y = Math.sin(elapsed * 0.55 + index) * 0.08;
}
const occupied = Boolean(id);
const targetOpacity = occupied ? 0 : 0.11;
ghosts[index].material.opacity +=
(targetOpacity - ghosts[index].material.opacity) * 0.12;
ghosts[index].rotation.y += 0.006;
ghosts[index].position.y = 0.34 + Math.sin(elapsed * 1.4 + index) * 0.025;
slotRings[index].material.opacity +=
((occupied ? 0.9 : 0.42) - slotRings[index].material.opacity) * 0.1;
if (id) {
slotRings[index].material.color.lerp(
new THREE.Color(eventDefs[id].colorHex),
0.08
);
}
});
ambientFragments.forEach((fragment, index) => {
fragment.rotation.x += fragment.userData.speed * 0.012;
fragment.rotation.y += fragment.userData.speed * 0.018;
fragment.position.y += Math.sin(elapsed * 0.45 + index) * 0.0012;
});
confettiAge += 0.016;
confetti.forEach((piece) => {
if (!piece.mesh.visible) return;
piece.velocity.y -= 0.018;
piece.mesh.position.addScaledVector(piece.velocity, 0.016);
piece.mesh.rotation.x += piece.spin.x;
piece.mesh.rotation.y += piece.spin.y;
piece.mesh.rotation.z += piece.spin.z;
if (piece.mesh.position.y < -0.3 || confettiAge > 5) {
piece.mesh.visible = false;
}
});
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```