Prompt specification
Build or customize the Three.js 3D scene "Cooperation With Imperfect Memory" 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: Cooperation With Imperfect Memory
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/cooperation-with-imperfect-memory-x3256
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts reciprocal help and remembered exchanges. Create a toy repeated-task simulation where records can be complete or missing. Compare misunderstandings under the same action sequence, avoiding claims about universal human behavior. Low-poly.
Working Three.js Starter (cooperation-with-imperfect-memory-x3256):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Same Handoffs, Different Memories</title>
<style>
:root {
color-scheme: dark;
--bg: #071018;
--panel: rgba(10, 23, 33, 0.82);
--panel-border: rgba(158, 218, 230, 0.16);
--text: #eaf8fa;
--muted: #9bb2ba;
--cyan: #67dfd0;
--blue: #68a9ff;
--amber: #ffbf69;
--rose: #ff758f;
--danger: #ff7188;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 42%, #123044 0%, #091722 42%, #050b10 100%);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
button:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 3px;
}
#stage {
position: fixed;
inset: 100px 350px 122px 330px;
min-width: 320px;
overflow: hidden;
border-radius: 22px;
background:
radial-gradient(circle at 50% 45%, rgba(62, 139, 157, 0.12), transparent 60%);
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#stage canvas:active {
cursor: grabbing;
}
header {
position: fixed;
z-index: 5;
top: 0;
left: 0;
right: 0;
min-height: 88px;
padding: 17px 24px 15px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
background: linear-gradient(
to bottom,
rgba(5, 12, 17, 0.96),
rgba(5, 12, 17, 0.72),
transparent
);
}
.title-wrap {
min-width: 0;
}
.eyebrow {
margin-bottom: 5px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(23px, 3vw, 38px);
font-weight: 750;
letter-spacing: -0.045em;
line-height: 1.03;
}
.subtitle {
margin: 7px 0 0;
max-width: 780px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.header-actions {
flex: 0 0 auto;
display: flex;
align-items: center;
gap: 10px;
}
.model-badge {
max-width: 220px;
padding: 9px 11px;
border: 1px solid rgba(255, 191, 105, 0.25);
border-radius: 10px;
background: rgba(255, 191, 105, 0.07);
color: #ffd49b;
font-size: 10px;
line-height: 1.35;
}
.ghost-button,
.primary-button,
.secondary-button {
border-radius: 10px;
cursor: pointer;
transition:
transform 140ms ease,
border-color 140ms ease,
background 140ms ease;
}
.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover {
transform: translateY(-1px);
}
.ghost-button {
padding: 9px 11px;
border: 1px solid var(--panel-border);
background: rgba(255, 255, 255, 0.035);
color: var(--text);
font-size: 11px;
}
.panel {
position: fixed;
z-index: 4;
top: 100px;
bottom: 122px;
width: 310px;
padding: 16px;
overflow: auto;
border: 1px solid var(--panel-border);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(16px);
scrollbar-width: thin;
scrollbar-color: #31505c transparent;
}
#controls {
left: 16px;
}
#readout {
right: 16px;
}
.panel h2 {
margin: 0 0 5px;
font-size: 14px;
letter-spacing: -0.015em;
}
.panel-intro {
margin: 0 0 15px;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.section-label {
margin: 17px 0 8px;
color: #c7d9df;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.record-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
}
.record-toggle {
min-width: 0;
padding: 9px 4px 8px;
border: 1px solid rgba(103, 223, 208, 0.22);
border-radius: 10px;
background: rgba(103, 223, 208, 0.07);
color: var(--text);
cursor: pointer;
text-align: center;
}
.record-toggle:hover {
border-color: rgba(103, 223, 208, 0.55);
}
.record-toggle.missing {
border-color: rgba(255, 113, 136, 0.38);
background: rgba(255, 113, 136, 0.09);
}
.record-toggle strong,
.record-toggle span {
display: block;
}
.record-toggle strong {
font-size: 11px;
}
.record-toggle span {
margin-top: 4px;
color: var(--muted);
font-size: 8px;
text-transform: uppercase;
}
.record-toggle.missing span {
color: #ff9aac;
}
.sequence-list {
display: grid;
gap: 6px;
}
.sequence-item {
display: grid;
grid-template-columns: 28px 1fr;
gap: 8px;
align-items: center;
padding: 8px 9px;
border: 1px solid rgba(255, 255, 255, 0.055);
border-radius: 9px;
background: rgba(255, 255, 255, 0.022);
color: var(--muted);
font-size: 10px;
}
.sequence-item b {
color: var(--text);
font-size: 10px;
}
.sequence-item .object-dot {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 5px;
border-radius: 2px;
vertical-align: 1px;
}
.button-row {
display: flex;
gap: 7px;
margin-top: 15px;
}
.primary-button,
.secondary-button {
flex: 1;
padding: 10px 8px;
font-size: 11px;
font-weight: 700;
}
.primary-button {
border: 1px solid rgba(103, 223, 208, 0.45);
background: var(--cyan);
color: #06201e;
}
.secondary-button {
border: 1px solid var(--panel-border);
background: rgba(255, 255, 255, 0.04);
color: var(--text);
}
.status {
min-height: 32px;
margin-top: 10px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.stat-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin: 13px 0;
}
.stat {
padding: 11px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
}
.stat-label {
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.stat-value {
margin-top: 5px;
font-size: 25px;
font-weight: 760;
letter-spacing: -0.04em;
}
.stat-value.good {
color: var(--cyan);
}
.stat-value.warn {
color: var(--danger);
}
.stat small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
line-height: 1.35;
}
.comparison-card {
padding: 12px;
border: 1px solid rgba(104, 169, 255, 0.17);
border-radius: 11px;
background: rgba(104, 169, 255, 0.055);
}
.comparison-card strong {
display: block;
margin-bottom: 5px;
font-size: 11px;
}
.comparison-card p {
margin: 0;
color: var(--muted);
font-size: 10px;
line-height: 1.5;
}
.table-wrap {
overflow-x: auto;
margin-top: 9px;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 9px;
}
th {
padding: 8px 6px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
color: var(--muted);
font-size: 8px;
line-height: 1.25;
text-align: left;
text-transform: uppercase;
}
td {
padding: 9px 6px;
border-bottom: 1px solid rgba(255, 255, 255, 0.055);
vertical-align: top;
line-height: 1.35;
}
.match {
color: var(--cyan);
font-weight: 800;
}
.mismatch {
color: var(--danger);
font-weight: 800;
}
.event-detail {
margin-top: 12px;
padding: 11px;
border-left: 2px solid var(--blue);
background: rgba(104, 169, 255, 0.055);
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
.event-detail strong {
color: var(--text);
}
.disclaimer {
margin-top: 13px;
padding: 11px;
border: 1px solid rgba(255, 191, 105, 0.16);
border-radius: 10px;
background: rgba(255, 191, 105, 0.045);
color: #cbb995;
font-size: 9px;
line-height: 1.55;
}
#timeline {
position: fixed;
z-index: 5;
left: 16px;
right: 16px;
bottom: 14px;
height: 94px;
padding: 10px 12px;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
border: 1px solid var(--panel-border);
border-radius: 17px;
background: rgba(8, 18, 26, 0.9);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(16px);
}
.timeline-button {
position: relative;
min-width: 0;
padding: 9px 11px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
color: var(--text);
cursor: pointer;
text-align: left;
transition: 140ms ease;
}
.timeline-button:hover {
border-color: rgba(103, 223, 208, 0.35);
background: rgba(103, 223, 208, 0.045);
}
.timeline-button.current {
border-color: rgba(104, 169, 255, 0.55);
background: rgba(104, 169, 255, 0.09);
}
.timeline-button .timeline-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 6px;
}
.timeline-button strong {
font-size: 11px;
}
.timeline-button small {
display: block;
margin-top: 7px;
overflow: hidden;
color: var(--muted);
font-size: 9px;
text-overflow: ellipsis;
white-space: nowrap;
}
.gap-chip {
padding: 3px 5px;
border-radius: 5px;
background: rgba(255, 113, 136, 0.13);
color: #ff9aac;
font-size: 7px;
font-weight: 800;
letter-spacing: 0.08em;
}
#loading {
position: fixed;
z-index: 10;
inset: 0;
display: grid;
place-items: center;
background: #071018;
color: var(--cyan);
font-size: 11px;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 1120px) {
#stage {
inset-right: 320px;
inset-left: 300px;
}
.panel {
width: 280px;
}
#controls {
left: 10px;
}
#readout {
right: 10px;
}
}
@media (max-width: 760px) {
html,
body {
height: auto;
min-height: 100%;
overflow: auto;
}
header {
position: relative;
min-height: 118px;
padding: 17px;
}
.header-actions {
display: none;
}
#stage {
position: relative;
inset: auto;
width: 100%;
height: 57vh;
min-height: 410px;
margin: 0;
border-radius: 0;
}
.panel {
position: relative;
inset: auto;
width: auto;
max-height: none;
margin: 10px;
}
#timeline {
position: sticky;
left: 0;
right: 0;
bottom: 0;
height: auto;
margin-top: 10px;
grid-template-columns: repeat(2, 1fr);
}
}
</style>
</head>
<body>
<div id="loading">Building the exchange archive…</div>
<header>
<div class="title-wrap">
<div class="eyebrow">Reciprocal help / remembered exchanges</div>
<h1>Same handoffs. Different memories.</h1>
<p class="subtitle">
Both agents perform four identical handoffs. Only the scenario ledger loses receipts,
revealing how a different reconstruction can emerge.
</p>
</div>
<div class="header-actions">
<div class="model-badge">
Deterministic toy model — not a claim about universal human behavior.
</div>
<button id="resetCamera" class="ghost-button">Reset camera</button>
</div>
</header>
<main id="stage" aria-label="Interactive low-poly comparison of remembered exchanges"></main>
<aside id="controls" class="panel">
<h2>Scenario records</h2>
<p class="panel-intro">
Toggle any recipient receipt in the right-hand lane. The handoffs themselves never change.
</p>
<div class="section-label">Recipient records</div>
<div id="recordGrid" class="record-grid"></div>
<div class="section-label">Fixed action sequence</div>
<div id="sequenceList" class="sequence-list"></div>
<div class="button-row">
<button id="replayButton" class="primary-button">Replay same sequence</button>
<button id="pauseButton" class="secondary-button">Pause</button>
</div>
<div id="playbackStatus" class="status" aria-live="polite"></div>
<div class="section-label">Camera</div>
<p class="panel-intro">
Drag the scene to orbit. Use the wheel or pinch gesture to zoom.
Camera controls are implemented directly in this HTML.
</p>
</aside>
<aside id="readout" class="panel">
<h2>Side-by-side reconstruction</h2>
<p class="panel-intro">
A receipt records the exact incoming item. In this toy, a missing receipt falls back to
the recipient’s most recently retained incoming item.
</p>
<div class="stat-grid">
<div class="stat">
<div class="stat-label">Complete ledger</div>
<div id="referenceMismatch" class="stat-value good">0</div>
<small>reconstructed mismatches</small>
</div>
<div class="stat">
<div class="stat-label">Gap ledger</div>
<div id="scenarioMismatch" class="stat-value warn">0</div>
<small>reconstructed mismatches</small>
</div>
</div>
<div class="comparison-card">
<strong id="comparisonTitle">Same 4 events, different ledger</strong>
<p id="comparisonCopy">
The complete ledger retains every exact receipt. The gap ledger reconstructs missing
entries with a fixed fallback rule.
</p>
</div>
<div class="section-label">Receipt comparison</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Event</th>
<th>Actual</th>
<th>Complete</th>
<th>Gap ledger</th>
<th>Outcome</th>
</tr>
</thead>
<tbody id="comparisonRows"></tbody>
</table>
</div>
<div id="eventDetail" class="event-detail">
Select an event to inspect its reconstruction.
</div>
<div class="disclaimer">
This is an illustrative bookkeeping simulation with a deterministic fallback rule.
It does not estimate how real people remember, misunderstand, or behave. The visible
difference comes only from the deliberately missing records in this toy.
</div>
</aside>
<nav id="timeline" aria-label="Shared action sequence"></nav>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const actions = [
{
id: 1,
from: "A",
to: "B",
name: "Blue cube",
key: "blue-cube",
color: 0x68a9ff,
shape: "cube",
description: "A hands B the blue cube."
},
{
id: 2,
from: "B",
to: "A",
name: "Amber block",
key: "amber-block",
color: 0xffbf69,
shape: "block",
description: "B hands A the amber block."
},
{
id: 3,
from: "A",
to: "B",
name: "Teal cylinder",
key: "teal-cylinder",
color: 0x59d8c9,
shape: "cylinder",
description: "A hands B the teal cylinder."
},
{
id: 4,
from: "B",
to: "A",
name: "Rose octahedron",
key: "rose-octahedron",
color: 0xff758f,
shape: "octahedron",
description: "B hands A the rose octahedron."
}
];
// true means the scenario ledger is missing this recipient receipt.
const missingFlags = [false, false, true, false];
const ACTION_MS = 1250;
const GAP_MS = 180;
const STEP_MS = ACTION_MS + GAP_MS;
let currentAction = -1;
let currentProgress = 0;
let actionStarted = 0;
let replayStarted = 0;
let playbackMode = "idle";
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x071018, 17, 31);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x071018, 0);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.domElement.setAttribute(
"aria-label",
"Low-poly two-lane simulation. Drag to orbit and use the wheel to zoom."
);
stage.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.25, -0.15);
const cameraState = {
theta: 0,
phi: 0.94,
distance: 16,
fitDistance: 16,
userAdjusted: false
};
const hemisphere = new THREE.HemisphereLight(0xbcefff, 0x17202a, 2.0);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff0d7, 3.4);
keyLight.position.set(-4, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x65d9ff, 2.1);
rimLight.position.set(7, 5, -8);
scene.add(rimLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
new THREE.MeshStandardMaterial({
color: 0x08141d,
roughness: 0.95,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.91;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(42, 42, 0x244754, 0x152c36);
grid.position.y = -0.895;
grid.material.transparent = true;
grid.material.opacity = 0.3;
scene.add(grid);
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function drawTextSprite(sprite, text, foreground = "#eaf8fa", background = null) {
const { canvas, ctx } = sprite.userData;
ctx.clearRect(0, 0, canvas.width, canvas.height);
if (background) {
ctx.fillStyle = background;
roundedRect(ctx, 5, 5, canvas.width - 10, canvas.height - 10, 20);
ctx.fill();
}
let fontSize = 56;
ctx.font = `800 ${fontSize}px system-ui, sans-serif`;
while (ctx.measureText(text).width > 470 && fontSize > 25) {
fontSize -= 2;
ctx.font = `800 ${fontSize}px system-ui, sans-serif`;
}
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 1);
sprite.userData.texture.needsUpdate = true;
}
function makeTextSprite(
text,
worldWidth,
foreground = "#eaf8fa",
background = null
) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(worldWidth, worldWidth / 4, 1);
sprite.renderOrder = 20;
sprite.userData = { canvas, ctx, texture };
drawTextSprite(sprite, text, foreground, background);
return sprite;
}
function colorCss(hex) {
return `#${hex.toString(16).padStart(6, "0")}`;
}
function createToken(action, ghost = false) {
const group = new THREE.Group();
let geometry;
if (action.shape === "cube") {
geometry = new THREE.BoxGeometry(0.46, 0.46, 0.46);
} else if (action.shape === "block") {
geometry = new THREE.BoxGeometry(0.66, 0.38, 0.46);
} else if (action.shape === "cylinder") {
geometry = new THREE.CylinderGeometry(0.24, 0.29, 0.58, 8);
} else {
geometry = new THREE.OctahedronGeometry(0.38, 0);
}
const material = new THREE.MeshStandardMaterial({
color: action.color,
roughness: ghost ? 0.35 : 0.62,
metalness: 0.04,
flatShading: true,
transparent: ghost,
opacity: ghost ? 0.32 : 1,
emissive: ghost ? action.color : 0x000000,
emissiveIntensity: ghost ? 0.55 : 0
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = !ghost;
mesh.receiveShadow = !ghost;
group.add(mesh);
if (ghost) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry),
new THREE.LineBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.75
})
);
group.add(edges);
}
return group;
}
function createAgent(bodyColor, label) {
const group = new THREE.Group();
const bodyMaterial = new THREE.MeshStandardMaterial({
color: bodyColor,
roughness: 0.72,
flatShading: true
});
const skinMaterial = new THREE.MeshStandardMaterial({
color: 0xe5c5a7,
roughness: 0.9,
flatShading: true
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x15212a,
roughness: 0.9,
flatShading: true
});
const body = new THREE.Mesh(
new THREE.CylinderGeometry(0.23, 0.34, 0.66, 6),
bodyMaterial
);
body.position.y = 0.66;
body.castShadow = true;
group.add(body);
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.29, 0),
skinMaterial
);
head.position.y = 1.2;
head.castShadow = true;
group.add(head);
for (const side of [-1, 1]) {
const arm = new THREE.Mesh(
new THREE.BoxGeometry(0.13, 0.5, 0.14),
bodyMaterial
);
arm.position.set(side * 0.31, 0.72, 0.01);
arm.rotation.z = side * 0.16;
arm.castShadow = true;
group.add(arm);
const leg = new THREE.Mesh(
new THREE.CylinderGeometry(0.09, 0.11, 0.38, 6),
darkMaterial
);
leg.position.set(side * 0.13, 0.19, 0);
leg.castShadow = true;
group.add(leg);
}
const name = makeTextSprite(label, 0.46, "#eaf8fa", "rgba(6, 16, 23, 0.82)");
name.position.set(0, 1.68, 0);
group.add(name);
return group;
}
function createCard(action, index, x) {
const group = new THREE.Group();
group.position.set(x, 0.42, -1.56);
const panelGeometry = new THREE.BoxGeometry(0.69, 0.83, 0.08);
const panelMaterial = new THREE.MeshStandardMaterial({
color: 0x12383a,
roughness: 0.8,
transparent: true,
opacity: 0.95,
flatShading: true,
emissive: 0x000000,
emissiveIntensity: 0.4
});
const panel = new THREE.Mesh(panelGeometry, panelMaterial);
panel.castShadow = true;
panel.receiveShadow = true;
group.add(panel);
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x67dfd0,
transparent: true,
opacity: 0.85
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(panelGeometry),
edgeMaterial
);
group.add(edges);
const number = makeTextSprite(
`E${action.id}`,
0.4,
"#dffbfa",
"rgba(7, 19, 25, 0.78)"
);
number.position.set(0, 0.72, 0.07);
group.add(number);
const state = makeTextSprite(
"REC",
0.52,
"#67dfd0",
"rgba(7, 19, 25, 0.78)"
);
state.position.set(0, -0.08, 0.07);
group.add(state);
const lamp = new THREE.Mesh(
new THREE.SphereGeometry(0.065, 8, 6),
new THREE.MeshStandardMaterial({
color: 0x67dfd0,
emissive: 0x67dfd0,
emissiveIntensity: 0.8,
roughness: 0.4
})
);
lamp.position.set(0.24, 0.29, 0.09);
group.add(lamp);
const miniToken = createToken(action, false);
miniToken.scale.setScalar(0.55);
miniToken.position.set(0, 0.3, 0.1);
group.add(miniToken);
const gapGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-0.22, 0.16, 0.08),
new THREE.Vector3(0.22, -0.16, 0.08),
new THREE.Vector3(-0.22, -0.16, 0.08),
new THREE.Vector3(0.22, 0.16, 0.08)
]);
const gapMark = new THREE.LineSegments(
gapGeometry,
new THREE.LineBasicMaterial({
color: 0xff7188,
transparent: true,
opacity: 0.95
})
);
group.add(gapMark);
return {
group,
panel,
edges,
state,
lamp,
miniToken,
gapMark
};
}
function createLane(x, title, titleColor, referenceLane) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(2.63, 2.83, 0.48, 8),
new THREE.MeshStandardMaterial({
color: referenceLane ? 0x102c31 : 0x17232f,
roughness: 0.88,
metalness: 0.05,
flatShading: true
})
);
platform.position.y = -0.65;
platform.rotation.y = Math.PI / 8;
platform.receiveShadow = true;
platform.castShadow = true;
group.add(platform);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(2.54, 0.025, 6, 64),
new THREE.MeshBasicMaterial({
color: titleColor,
transparent: true,
opacity: 0.72
})
);
rim.rotation.x = Math.PI / 2;
rim.position.y = -0.395;
group.add(rim);
const archiveBoard = new THREE.Mesh(
new THREE.BoxGeometry(4.45, 1.32, 0.15),
new THREE.MeshStandardMaterial({
color: 0x091923,
roughness: 0.9,
flatShading: true
})
);
archiveBoard.position.set(0, 0.37, -1.72);
archiveBoard.castShadow = true;
archiveBoard.receiveShadow = true;
group.add(archiveBoard);
const titleSprite = makeTextSprite(
title,
2.65,
titleColor,
"rgba(5, 15, 22, 0.84)"
);
titleSprite.position.set(0, 1.37, -1.62);
group.add(titleSprite);
const agentA = createAgent(0xe47c76, "A");
agentA.position.set(-1.28, -0.4, 0.23);
group.add(agentA);
const agentB = createAgent(0x58bca9, "B");
agentB.position.set(1.28, -0.4, 0.23);
group.add(agentB);
const cards = actions.map((action, index) => {
const card = createCard(action, index, -1.35 + index * 0.9);
group.add(card.group);
return card;
});
const exchangeGroup = new THREE.Group();
group.add(exchangeGroup);
const memoryGroup = new THREE.Group();
group.add(memoryGroup);
// Small archive lights around the plinth.
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const light = new THREE.Mesh(
new THREE.BoxGeometry(0.075, 0.075, 0.075),
new THREE.MeshBasicMaterial({
color: i % 3 === 0 ? titleColor : 0x31515c
})
);
light.position.set(
Math.cos(angle) * 2.42,
-0.26,
Math.sin(angle) * 2.42
);
light.rotation.y = angle;
group.add(light);
}
return {
group,
cards,
exchangeGroup,
memoryGroup,
referenceLane,
titleColor
};
}
const referenceLane = createLane(
-3.25,
"REFERENCE · COMPLETE",
"#67dfd0",
true
);
const scenarioLane = createLane(
3.25,
"SCENARIO · SELECTIVE GAPS",
"#68a9ff",
false
);
const lanes = [referenceLane, scenarioLane];
const sameLabel = makeTextSprite(
"SAME 4 EVENTS",
1.55,
"#bde8ef",
"rgba(6, 18, 26, 0.84)"
);
sameLabel.position.set(0, 2.05, -1.35);
scene.add(sameLabel);
const linkGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-0.73, 1.47, -1.45),
new THREE.Vector3(0.73, 1.47, -1.45)
]);
const link = new THREE.Line(
linkGeometry,
new THREE.LineDashedMaterial({
color: 0x67dfd0,
dashSize: 0.12,
gapSize: 0.08,
transparent: true,
opacity: 0.55
})
);
link.computeLineDistances();
scene.add(link);
function clearGroup(group) {
while (group.children.length) {
const child = group.children.pop();
child.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
if (Array.isArray(object.material)) {
object.material.forEach((material) => material.dispose());
} else {
object.material.dispose();
}
}
});
}
}
function inferredAction(index, useMissingFlags) {
const action = actions[index];
if (!useMissingFlags || !missingFlags[index]) {
return action;
}
const receiver = action.to;
for (let previous = index - 1; previous >= 0; previous--) {
if (
actions[previous].to === receiver &&
!missingFlags[previous]
) {
return actions[previous];
}
}
return null;
}
function buildMemory(lane, index) {
clearGroup(lane.memoryGroup);
const inferred = inferredAction(index, !lane.referenceLane);
if (inferred) {
const ghost = createToken(inferred, true);
ghost.scale.setScalar(0.78);
lane.memoryGroup.add(ghost);
} else {
const noReceipt = makeTextSprite(
"NO RECEIPT",
1.02,
"#ff9aac",
"rgba(45, 14, 24, 0.86)"
);
lane.memoryGroup.add(noReceipt);
}
const receiverX = actions[index].to === "A" ? -1.28 : 1.28;
lane.memoryGroup.position.set(receiverX, 1.66, 0.35);
lane.memoryGroup.visible = false;
}
function setCardState(card, kept, highlighted) {
card.panel.material.color.setHex(kept ? 0x12383a : 0x351927);
card.panel.material.opacity = kept ? 0.95 : 0.43;
card.panel.material.emissive.setHex(highlighted ? 0x173f47 : 0x000000);
card.panel.material.emissiveIntensity = highlighted ? 0.62 : 0;
card.edges.material.color.setHex(kept ? 0x67dfd0 : 0xff7188);
card.lamp.material.color.setHex(kept ? 0x67dfd0 : 0xff7188);
card.lamp.material.emissive.setHex(kept ? 0x67dfd0 : 0xff7188);
card.miniToken.visible = kept;
card.gapMark.visible = !kept;
drawTextSprite(
card.state,
kept ? "REC" : "GAP",
kept ? "#67dfd0" : "#ff9aac",
"rgba(7, 19, 25, 0.78)"
);
}
function refreshCards() {
referenceLane.cards.forEach((card, index) => {
setCardState(card, true, index === currentAction);
});
scenarioLane.cards.forEach((card, index) => {
setCardState(card, !missingFlags[index], index === currentAction);
});
}
function setCurrentAction(index, startedAt) {
currentAction = index;
currentProgress = 0;
actionStarted = startedAt;
for (const lane of lanes) {
clearGroup(lane.exchangeGroup);
const token = createToken(actions[index], false);
lane.exchangeGroup.add(token);
buildMemory(lane, index);
}
refreshCards();
updateTimeline();
updateReadout();
}
function animateExchange(progress) {
const action = actions[currentAction];
const fromX = action.from === "A" ? -1.28 : 1.28;
const toX = action.to === "A" ? -1.28 : 1.28;
const eased = progress * progress * (3 - 2 * progress);
const arc = Math.sin(progress * Math.PI);
for (const lane of lanes) {
lane.exchangeGroup.position.set(
THREE.MathUtils.lerp(fromX, toX, eased),
0.76 + arc * 0.78,
0.25 + arc * 0.16
);
lane.exchangeGroup.rotation.y = progress * Math.PI * 0.75;
lane.memoryGroup.visible = progress > 0.55;
}
}
function colorForAction(action) {
return colorCss(action.color);
}
function buildStaticControls() {
const recordGrid = document.getElementById("recordGrid");
const sequenceList = document.getElementById("sequenceList");
const timeline = document.getElementById("timeline");
actions.forEach((action, index) => {
const toggle = document.createElement("button");
toggle.className = "record-toggle";
toggle.dataset.index = index;
toggle.innerHTML = `<strong>E${action.id}</strong><span class="toggle-state"></span>`;
toggle.addEventListener("click", () => {
missingFlags[index] = !missingFlags[index];
refreshControls();
refreshCards();
updateReadout();
if (currentAction >= 0) {
buildMemory(referenceLane, currentAction);
buildMemory(scenarioLane, currentAction);
}
});
recordGrid.appendChild(toggle);
const item = document.createElement("div");
item.className = "sequence-item";
item.innerHTML = `
<b>E${action.id}</b>
<span>${action.from} → ${action.to} · <i class="object-dot" style="background:${colorForAction(action)}"></i>${action.name}</span>
`;
sequenceList.appendChild(item);
const timelineButton = document.createElement("button");
timelineButton.className = "timeline-button";
timelineButton.dataset.index = index;
timelineButton.innerHTML = `
<span class="timeline-top">
<strong>E${action.id} · ${action.from} → ${action.to}</strong>
<span class="gap-chip">GAP</span>
</span>
<small>${action.name}</small>
`;
timelineButton.addEventListener("click", () => {
playbackMode = "step";
actionStarted = performance.now();
setCurrentAction(index, actionStarted);
updatePlaybackStatus();
});
timeline.appendChild(timelineButton);
});
refreshControls();
updateTimeline();
}
function refreshControls() {
document.querySelectorAll(".record-toggle").forEach((button) => {
const index = Number(button.dataset.index);
const missing = missingFlags[index];
button.classList.toggle("missing", missing);
button.setAttribute("aria-pressed", String(missing));
button.setAttribute(
"aria-label",
`Event ${index + 1} receipt ${missing ? "missing" : "complete"}`
);
button.querySelector(".toggle-state").textContent = missing
? "missing"
: "complete";
});
}
function updateTimeline() {
document.querySelectorAll(".timeline-button").forEach((button) => {
const index = Number(button.dataset.index);
button.classList.toggle("current", index === currentAction);
const chip = button.querySelector(".gap-chip");
chip.style.display = missingFlags[index] ? "inline-block" : "none";
});
}
function updateReadout() {
const scenarioReconstructions = actions.map((action, index) =>
inferredAction(index, true)
);
const scenarioMismatches = scenarioReconstructions.filter(
(inferred, index) =>
!inferred || inferred.key !== actions[index].key
).length;
const retained = missingFlags.filter((missing) => !missing).length;
document.getElementById("referenceMismatch").textContent = "0";
document.getElementById("scenarioMismatch").textContent =
String(scenarioMismatches);
document.getElementById("comparisonTitle").textContent =
scenarioMismatches === 0
? "Same 4 events, no reconstructed mismatch"
: `Same 4 events, ${scenarioMismatches} reconstructed mismatch${
scenarioMismatches === 1 ? "" : "es"
}`;
document.getElementById("comparisonCopy").textContent =
`The complete ledger retains 4/4 exact receipts. The gap ledger retains ` +
`${retained}/4. The actual handoff sequence is identical in both lanes.`;
const rows = document.getElementById("comparisonRows");
rows.innerHTML = "";
actions.forEach((action, index) => {
const inferred = scenarioReconstructions[index];
const isMatch = inferred && inferred.key === action.key;
const row = document.createElement("tr");
row.innerHTML = `
<td><b>E${action.id}</b><br>${action.from} → ${action.to}</td>
<td>${action.name}</td>
<td><span class="match">✓ exact</span><br>${action.name}</td>
<td>${
inferred
? `<span class="${isMatch ? "match" : "mismatch"}">${
isMatch ? "✓ exact" : "≠ inferred"
}</span><br>${inferred.name}`
: `<span class="mismatch">≠ no receipt</span><br>Nothing retained`
}</td>
<td class="${isMatch ? "match" : "mismatch"}">${
isMatch ? "Match" : "Mismatch"
}</td>
`;
rows.appendChild(row);
});
updateEventDetail();
}
function updateEventDetail() {
const detail = document.getElementById("eventDetail");
if (currentAction < 0) {
detail.innerHTML =
"Select an event to inspect its exact receipt and toy reconstruction.";
return;
}
const action = actions[currentAction];
const inferred = inferredAction(currentAction, true);
const previous = [...actions.slice(0, currentAction)]
.reverse()
.find(
(candidate) =>
candidate.to === action.to && !missingFlags[candidate.id - 1]
);
if (!missingFlags[currentAction]) {
detail.innerHTML = `
<strong>E${action.id}: ${action.description}</strong><br>
The complete ledger retains the exact receipt.
The gap ledger also retains <strong>${action.name}</strong> here.
`;
} else if (inferred && previous) {
detail.innerHTML = `
<strong>E${action.id}: ${action.description}</strong><br>
The scenario receipt is missing. Under this toy’s fixed rule, ${action.to}
falls back to E${previous.id}: <strong>${previous.name}</strong>,
rather than the actual <strong>${action.name}</strong>.
`;
} else {
detail.innerHTML = `
<strong>E${action.id}: ${action.description}</strong><br>
The scenario receipt is missing and no earlier incoming receipt is retained.
The reconstruction is therefore <strong>no receipt</strong>.
`;
}
}
function updatePlaybackStatus() {
const status = document.getElementById("playbackStatus");
const pauseButton = document.getElementById("pauseButton");
if (playbackMode === "playing") {
status.textContent = currentAction >= 0
? `Playing E${currentAction + 1} of 4 — identical action in both lanes.`
: "Starting the shared sequence…";
pauseButton.textContent = "Pause";
} else if (playbackMode === "paused") {
status.textContent = `Paused at E${currentAction + 1}.`;
pauseButton.textContent = "Resume";
} else if (playbackMode === "step") {
status.textContent = `Inspecting E${currentAction + 1}.`;
pauseButton.textContent = "Pause";
} else {
status.textContent = "Sequence complete. Select an event to inspect it.";
pauseButton.textContent = "Pause";
}
}
function replay() {
playbackMode = "playing";
currentAction = -1;
currentProgress = 0;
replayStarted = performance.now();
for (const lane of lanes) {
clearGroup(lane.exchangeGroup);
clearGroup(lane.memoryGroup);
}
refreshCards();
updateTimeline();
updatePlaybackStatus();
}
document.getElementById("replayButton").addEventListener("click", replay);
document.getElementById("pauseButton").addEventListener("click", () => {
if (playbackMode === "playing") {
playbackMode = "paused";
} else if (playbackMode === "paused") {
replayStarted =
performance.now() -
(currentAction * STEP_MS + currentProgress * ACTION_MS);
playbackMode = "playing";
}
updatePlaybackStatus();
});
function fitCameraDistance() {
const verticalHalfFov = THREE.MathUtils.degToRad(camera.fov / 2);
return Math.max(
14.6,
6.8 / (Math.tan(verticalHalfFov) * Math.max(camera.aspect, 0.5))
);
}
function updateCamera() {
const radius = cameraState.distance;
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x + radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y + radius * Math.cos(cameraState.phi),
cameraTarget.z + radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraState.theta = 0;
cameraState.phi = 0.94;
cameraState.distance = fitCameraDistance();
cameraState.userAdjusted = false;
updateCamera();
}
document.getElementById("resetCamera").addEventListener("click", resetCamera);
let dragging = false;
let dragX = 0;
let dragY = 0;
let pointerId = null;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerId = event.pointerId;
dragX = event.clientX;
dragY = event.clientY;
renderer.domElement.setPointerCapture(pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== pointerId) return;
const dx = event.clientX - dragX;
const dy = event.clientY - dragY;
dragX = event.clientX;
dragY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.5,
1.23
);
cameraState.userAdjusted = true;
updateCamera();
});
function endDrag(event) {
if (event.pointerId !== pointerId) return;
dragging = false;
pointerId = null;
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
const factor = Math.exp(event.deltaY * 0.001);
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance * factor,
fitCameraDistance() * 0.72,
fitCameraDistance() * 1.7
);
cameraState.userAdjusted = true;
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (
event.code === "Space" &&
!["BUTTON", "INPUT", "TEXTAREA"].includes(document.activeElement?.tagName)
) {
event.preventDefault();
replay();
}
});
function resize() {
const width = Math.max(stage.clientWidth, 1);
const height = Math.max(stage.clientHeight, 1);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
if (!cameraState.userAdjusted) {
cameraState.distance = fitCameraDistance();
} else {
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance,
fitCameraDistance() * 0.72,
fitCameraDistance() * 1.7
);
}
updateCamera();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
buildStaticControls();
refreshCards();
updateReadout();
resize();
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const now = performance.now();
if (playbackMode === "playing") {
const elapsed = now - replayStarted;
const slot = Math.floor(elapsed / STEP_MS);
if (slot >= actions.length) {
currentAction = actions.length - 1;
currentProgress = 1;
playbackMode = "idle";
refreshCards();
updateTimeline();
updatePlaybackStatus();
} else {
if (slot !== currentAction) {
setCurrentAction(slot, replayStarted + slot * STEP_MS);
}
currentProgress = THREE.MathUtils.clamp(
(elapsed - slot * STEP_MS) / ACTION_MS,
0,
1
);
animateExchange(currentProgress);
}
} else if (playbackMode === "step" && currentAction >= 0) {
currentProgress = THREE.MathUtils.clamp(
(now - actionStarted) / ACTION_MS,
0,
1
);
animateExchange(currentProgress);
if (currentProgress >= 1) {
playbackMode = "idle";
updatePlaybackStatus();
}
}
// Gentle archive-light motion.
const t = clock.getElapsedTime();
scene.children.forEach((child) => {
if (child.type === "Group" && child !== referenceLane.group && child !== scenarioLane.group) {
child.position.y = 2.05 + Math.sin(t * 1.25) * 0.035;
}
});
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(replay, 240);
});
</script>
</body>
</html>
```