Prompt specification
Build or customize the Three.js 3D scene "Sequence Reconstruction From Partial Records" 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: Sequence Reconstruction From Partial Records
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/sequence-reconstruction-from-partial-records-x3440
Scene Description Prompt:
Reassemble incomplete symbol strips in a voxel archive puzzle, keeping unsupported sequences visibly unresolved. One HTML scene using Three.js from cdnjs.
Working Three.js Starter (sequence-reconstruction-from-partial-records-x3440):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Strata — Voxel Archive</title>
<style>
:root {
color-scheme: dark;
--bg: #071113;
--panel: rgba(9, 24, 27, 0.88);
--line: rgba(133, 196, 196, 0.22);
--text: #d9eeee;
--muted: #799497;
--mint: #59e1c6;
--amber: #f1b85d;
--red: #ff7777;
--blue: #6b91ff;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 44%, transparent 30%, rgba(0, 8, 10, 0.25) 72%, rgba(0, 5, 7, 0.8) 100%),
linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent 25%, transparent 75%, rgba(0, 0, 0, 0.3));
z-index: 2;
}
header {
position: fixed;
z-index: 10;
top: 0;
left: 0;
right: 0;
height: 78px;
padding: 18px 24px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
border-bottom: 1px solid var(--line);
background: linear-gradient(180deg, rgba(5, 17, 19, 0.97), rgba(5, 17, 19, 0.72));
backdrop-filter: blur(14px);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
min-width: 0;
}
.brand-mark {
width: 34px;
height: 34px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 3px;
transform: rotate(45deg);
}
.brand-mark i {
background: var(--mint);
box-shadow: 0 0 14px rgba(89, 225, 198, 0.3);
}
.brand-mark i:nth-child(2),
.brand-mark i:nth-child(4),
.brand-mark i:nth-child(8) {
opacity: 0.32;
}
h1 {
margin: 0;
font-size: 15px;
line-height: 1.2;
letter-spacing: 0.2em;
white-space: nowrap;
}
.subtitle {
margin-top: 5px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.12em;
white-space: nowrap;
}
.header-stats {
display: flex;
align-items: center;
gap: 10px;
}
.stat {
min-width: 90px;
padding: 9px 12px;
border: 1px solid var(--line);
background: rgba(13, 33, 35, 0.65);
}
.stat small {
display: block;
color: var(--muted);
font-size: 8px;
letter-spacing: 0.14em;
margin-bottom: 4px;
}
.stat strong {
font-size: 12px;
letter-spacing: 0.08em;
}
.stat.open strong {
color: var(--amber);
}
.case-tag {
color: var(--mint);
font-size: 10px;
letter-spacing: 0.12em;
white-space: nowrap;
}
.panel {
position: fixed;
z-index: 8;
top: 98px;
width: 264px;
padding: 16px;
border: 1px solid var(--line);
background: var(--panel);
backdrop-filter: blur(13px);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
}
.ledger {
left: 20px;
}
.inventory-panel {
right: 20px;
}
.panel-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
color: var(--mint);
font-size: 9px;
letter-spacing: 0.17em;
}
.panel-title span:last-child {
color: var(--muted);
}
.protocol {
margin: 0 0 16px;
padding-left: 17px;
color: #a6bcbd;
font-size: 10px;
line-height: 1.85;
}
.record {
position: relative;
margin-top: 8px;
padding: 11px 11px 11px 14px;
border: 1px solid rgba(122, 164, 165, 0.14);
background: rgba(255, 255, 255, 0.018);
}
.record::before {
content: "";
position: absolute;
top: 10px;
bottom: 10px;
left: -1px;
width: 2px;
background: var(--muted);
}
.record.ok::before {
background: var(--mint);
box-shadow: 0 0 12px var(--mint);
}
.record.bad::before {
background: var(--red);
}
.record.open::before {
background: var(--amber);
box-shadow: 0 0 10px rgba(241, 184, 93, 0.35);
}
.record-head {
display: flex;
justify-content: space-between;
gap: 8px;
font-size: 10px;
letter-spacing: 0.08em;
}
.record-head span:last-child {
color: var(--muted);
font-size: 8px;
}
.record p {
margin: 8px 0 0;
color: var(--muted);
font-size: 9px;
line-height: 1.55;
}
.record.ok .record-head span:last-child {
color: var(--mint);
}
.record.bad .record-head span:last-child {
color: var(--red);
}
.record.open .record-head span:last-child {
color: var(--amber);
}
.protocol-note {
margin-top: 13px;
padding: 10px;
border: 1px dashed rgba(241, 184, 93, 0.38);
color: #bfa777;
background: rgba(241, 184, 93, 0.035);
font-size: 9px;
line-height: 1.55;
}
.frag-list {
display: grid;
gap: 9px;
}
.frag-button {
width: 100%;
padding: 11px;
color: var(--text);
text-align: left;
border: 1px solid rgba(120, 165, 166, 0.18);
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
transition: 140ms ease;
}
.frag-button:hover,
.frag-button.selected {
border-color: var(--mint);
background: rgba(89, 225, 198, 0.08);
transform: translateX(-2px);
}
.frag-button.placed {
border-color: rgba(107, 145, 255, 0.55);
background: rgba(107, 145, 255, 0.07);
}
.frag-head {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
font-size: 9px;
letter-spacing: 0.1em;
}
.frag-head span:last-child {
color: var(--muted);
font-size: 8px;
}
.symbols {
display: flex;
align-items: center;
gap: 6px;
}
.symbol {
width: 25px;
height: 25px;
display: grid;
place-items: center;
color: #061012;
background: var(--c);
font-size: 11px;
font-weight: 900;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.symbol.missing {
color: var(--amber);
background: transparent;
border: 1px dashed var(--amber);
box-shadow: none;
}
.control-dock {
position: fixed;
z-index: 12;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 8px;
padding: 9px;
border: 1px solid var(--line);
background: rgba(7, 22, 24, 0.91);
backdrop-filter: blur(14px);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.4);
}
.control-dock button {
min-height: 36px;
padding: 0 13px;
border: 1px solid rgba(131, 180, 181, 0.25);
color: #a8c0c1;
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
font-size: 9px;
letter-spacing: 0.09em;
transition: 140ms ease;
}
.control-dock button:hover {
color: var(--text);
border-color: var(--mint);
background: rgba(89, 225, 198, 0.07);
}
.control-dock button.primary {
min-width: 138px;
color: #041211;
border-color: var(--mint);
background: var(--mint);
font-weight: 800;
}
.control-dock button.primary:hover {
background: #78f2da;
}
#toast {
position: fixed;
z-index: 20;
left: 50%;
bottom: 88px;
transform: translate(-50%, 12px);
max-width: min(520px, calc(100vw - 30px));
padding: 10px 15px;
border: 1px solid rgba(89, 225, 198, 0.45);
color: #cce9e5;
background: rgba(7, 24, 25, 0.94);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
font-size: 10px;
line-height: 1.45;
text-align: center;
opacity: 0;
pointer-events: none;
transition: 180ms ease;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
#toast.warn {
color: #e8c990;
border-color: rgba(241, 184, 93, 0.55);
}
.footer-hint {
position: fixed;
z-index: 7;
left: 24px;
bottom: 23px;
color: rgba(146, 177, 178, 0.65);
font-size: 8px;
letter-spacing: 0.11em;
pointer-events: none;
}
@media (max-width: 980px) {
.ledger {
display: none;
}
.inventory-panel {
width: 230px;
}
.case-tag {
display: none;
}
}
@media (max-width: 680px) {
header {
height: 66px;
padding: 12px;
}
h1 {
font-size: 11px;
}
.subtitle,
.stat.open,
.footer-hint {
display: none;
}
.header-stats {
gap: 5px;
}
.stat {
min-width: 70px;
padding: 7px 8px;
}
.inventory-panel {
top: auto;
right: 10px;
bottom: 80px;
width: calc(100% - 20px);
padding: 10px;
}
.inventory-panel .panel-title {
margin-bottom: 8px;
}
.frag-list {
grid-template-columns: repeat(2, 1fr);
gap: 6px;
}
.frag-button {
padding: 8px;
}
.frag-head {
margin-bottom: 5px;
}
.symbol {
width: 21px;
height: 21px;
}
.control-dock {
bottom: 10px;
gap: 4px;
padding: 6px;
}
.control-dock button {
min-height: 34px;
padding: 0 8px;
font-size: 8px;
}
.control-dock button.primary {
min-width: 110px;
}
#toast {
bottom: 225px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="vignette"></div>
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i>
</div>
<div>
<h1>STRATA // VOXEL ARCHIVE</h1>
<div class="subtitle">SEQUENCE RESTORATION TERMINAL · SHARD SET 7G-04</div>
</div>
</div>
<div class="header-stats">
<div class="case-tag">CASE 7G-04</div>
<div class="stat">
<small>ATTESTED</small>
<strong id="supported-count">0 / 2</strong>
</div>
<div class="stat open">
<small>OPEN</small>
<strong id="open-count">1</strong>
</div>
</div>
</header>
<aside class="panel ledger">
<div class="panel-title">
<span>RESTORATION PROTOCOL</span>
<span>03 RECORDS</span>
</div>
<ol class="protocol">
<li>Select a fragment from the bin.</li>
<li>Click an archive bay to stage it.</li>
<li>Scan and attest corroborated sequences.</li>
</ol>
<div id="records">
<div class="record" id="record-r12">
<div class="record-head">
<span>R-12 · TIDAL INDEX</span>
<span>AWAITING</span>
</div>
<p>Attested period A / B. Both ends survive.</p>
</div>
<div class="record" id="record-r44">
<div class="record-head">
<span>R-44 · ECHO CHAIN</span>
<span>AWAITING</span>
</div>
<p>Attested period C / D. Both ends survive.</p>
</div>
<div class="record open" id="record-r90">
<div class="record-head">
<span>R-90 · NULL LEDGER</span>
<span>UNRESOLVED</span>
</div>
<p>Prefix N survives, but no corroborating tail exists.</p>
</div>
</div>
<div class="protocol-note">
Unsupported gaps remain hollow. A plausible sequence is not an archived sequence.
</div>
</aside>
<aside class="panel inventory-panel">
<div class="panel-title">
<span>FRAGMENT BIN</span>
<span>CLICK TO SELECT</span>
</div>
<div class="frag-list" id="frag-list"></div>
</aside>
<div class="control-dock">
<button id="scan-button" class="primary">SCAN & ATTEST</button>
<button id="clear-button">CLEAR RACKS</button>
<button id="view-button">VIEW: ISO</button>
<button id="reset-button">RESET PUZZLE</button>
</div>
<div id="toast" role="status" aria-live="polite"></div>
<div class="footer-hint">DRAG TO ORBIT · SCROLL TO ZOOM · 1–4 SELECT · ENTER SCAN · ESC DESELECT</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene setup
// -------------------------------------------------------------------------
const sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071113);
scene.fog = new THREE.FogExp2(0x071113, 0.035);
const camera = new THREE.PerspectiveCamera(
40,
innerWidth / innerHeight,
0.1,
80
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Interactive voxel archive puzzle");
sceneHost.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(0x8dc9d0, 0x071013, 1.65));
const keyLight = new THREE.DirectionalLight(0xc5fff4, 2.2);
keyLight.position.set(4, 8, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
scene.add(keyLight);
const rimLight = new THREE.PointLight(0x4c83ff, 18, 18, 2);
rimLight.position.set(-5, 2, 3);
scene.add(rimLight);
const amberLight = new THREE.PointLight(0xffa53f, 8, 12, 2);
amberLight.position.set(4, -1, 2);
scene.add(amberLight);
const clock = new THREE.Clock();
// -------------------------------------------------------------------------
// Data and symbols
// -------------------------------------------------------------------------
const SYMBOLS = {
A: {
color: 0x52e0c2,
css: "#52e0c2",
pattern: ["010", "101", "111"]
},
B: {
color: 0x608eff,
css: "#608eff",
pattern: ["110", "101", "110"]
},
C: {
color: 0xf2b85c,
css: "#f2b85c",
pattern: ["101", "010", "101"]
},
D: {
color: 0xc777f0,
css: "#c777f0",
pattern: ["101", "111", "111"]
},
N: {
color: 0x8b9b9f,
css: "#8b9b9f",
pattern: ["101", "111", "111"]
}
};
const fragmentData = [
{ id: "f1", code: "VX-01", sequence: ["A", "B", "A"] },
{ id: "f2", code: "VX-08", sequence: ["C", null, "C"] },
{ id: "f3", code: "VX-13", sequence: ["N", null, "N"] },
{ id: "f4", code: "VX-22", sequence: ["A", "C", "A"] }
];
const bays = {
r12: {
id: "r12",
code: "R-12",
title: "TIDAL INDEX",
y: 2.15,
expected: ["A", "B", "A"],
fullSequence: ["A", "B", "A", "B", "A", "B", "A"],
gapIndices: [2, 3, 4],
lockedIndices: [0, 1, 5, 6],
unresolved: false
},
r44: {
id: "r44",
code: "R-44",
title: "ECHO CHAIN",
y: 1.05,
expected: ["C", "D", "C"],
fullSequence: ["C", "D", "C", "D", "C", "D", "C"],
gapIndices: [2, 3, 4],
lockedIndices: [0, 1, 5, 6],
unresolved: false
},
r90: {
id: "r90",
code: "R-90",
title: "NULL LEDGER",
y: -0.05,
expected: null,
fullSequence: null,
gapIndices: [1, 2, 3],
lockedIndices: [0],
unresolved: true
}
};
const state = {
selected: null,
placements: { r12: null, r44: null, r90: null },
scanned: false,
results: {
r12: "awaiting",
r44: "awaiting",
r90: "open"
}
};
const fragments = [];
const fragmentMap = new Map();
const bayObjects = {};
const slotSpacing = 1.08;
const firstSlotX = -3 * slotSpacing;
// -------------------------------------------------------------------------
// Reusable geometry helpers
// -------------------------------------------------------------------------
const tileBodyGeometry = new THREE.BoxGeometry(0.72, 0.72, 0.38);
const tileEdgeGeometry = new THREE.EdgesGeometry(tileBodyGeometry);
const glyphGeometry = new THREE.BoxGeometry(0.125, 0.125, 0.045);
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
function makeLabel(text, color = "#9de9df", width = 1.65) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 8, 15, 496, 98, 18);
ctx.fillStyle = "rgba(5, 19, 21, 0.88)";
ctx.fill();
ctx.strokeStyle = "rgba(130, 210, 204, 0.3)";
ctx.lineWidth = 3;
ctx.stroke();
ctx.fillStyle = color;
ctx.font = "700 37px ui-monospace, monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 65);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, width * 0.25, 1);
return sprite;
}
function makeBox(width, height, depth, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeGhost(color = 0xf1b85d, opacity = 0.58) {
const group = new THREE.Group();
const edgeMaterial = new THREE.LineDashedMaterial({
color,
transparent: true,
opacity,
dashSize: 0.075,
gapSize: 0.06
});
const edges = new THREE.LineSegments(tileEdgeGeometry, edgeMaterial);
edges.computeLineDistances();
group.add(edges);
const crossPoints = [
-0.16, -0.16, 0.205, 0.16, 0.16, 0.205,
-0.16, 0.16, 0.205, 0.16, -0.16, 0.205
];
const crossGeometry = new THREE.BufferGeometry();
crossGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(crossPoints, 3)
);
const cross = new THREE.LineSegments(
crossGeometry,
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: opacity * 0.8
})
);
group.add(cross);
group.userData.ghostMaterial = edgeMaterial;
group.userData.crossMaterial = cross.material;
return group;
}
function makeTile(symbol, options = {}) {
const definition = SYMBOLS[symbol];
const group = new THREE.Group();
const bodyMaterial = new THREE.MeshStandardMaterial({
color: definition.color,
emissive: definition.color,
emissiveIntensity: options.inferred ? 0.42 : options.locked ? 0.06 : 0.17,
roughness: 0.34,
metalness: 0.22,
transparent: Boolean(options.locked),
opacity: options.locked ? 0.48 : 1
});
const body = new THREE.Mesh(tileBodyGeometry, bodyMaterial);
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const edgeMaterial = new THREE.LineBasicMaterial({
color: options.inferred ? 0x91ffe0 : 0xb9e6df,
transparent: true,
opacity: options.locked ? 0.25 : 0.6
});
const edges = new THREE.LineSegments(tileEdgeGeometry, edgeMaterial);
group.add(edges);
const glyphMaterial = new THREE.MeshBasicMaterial({
color: options.locked ? 0x9cb9b9 : 0xf1fff9,
transparent: Boolean(options.locked),
opacity: options.locked ? 0.56 : 0.94
});
definition.pattern.forEach((row, rowIndex) => {
[...row].forEach((cell, columnIndex) => {
if (cell !== "1") return;
const glyph = new THREE.Mesh(glyphGeometry, glyphMaterial);
glyph.position.set(
(columnIndex - 1) * 0.145,
(1 - rowIndex) * 0.145,
0.215
);
group.add(glyph);
});
});
if (options.inferred) {
const marker = new THREE.Mesh(
new THREE.SphereGeometry(0.045, 10, 8),
new THREE.MeshBasicMaterial({ color: 0xa5ffe9 })
);
marker.position.set(0.29, 0.29, 0.235);
group.add(marker);
}
group.userData.bodyMaterial = bodyMaterial;
group.userData.edgeMaterial = edgeMaterial;
group.userData.symbol = symbol;
return group;
}
// -------------------------------------------------------------------------
// Archive architecture
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(36, 36),
new THREE.MeshStandardMaterial({
color: 0x081719,
roughness: 0.92,
metalness: 0.12
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.18;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(30, 30, 0x1f5558, 0x153335);
grid.position.y = -2.165;
grid.material.transparent = true;
grid.material.opacity = 0.38;
scene.add(grid);
const rackMaterial = new THREE.MeshStandardMaterial({
color: 0x10282b,
roughness: 0.62,
metalness: 0.48
});
const rackTrimMaterial = new THREE.MeshStandardMaterial({
color: 0x315355,
roughness: 0.35,
metalness: 0.72
});
makeBox(9.25, 4.72, 0.32, rackMaterial, 0, 1.05, -0.82);
makeBox(0.14, 4.9, 0.48, rackTrimMaterial, -4.55, 1.05, -0.68);
makeBox(0.14, 4.9, 0.48, rackTrimMaterial, 4.55, 1.05, -0.68);
makeBox(9.25, 0.14, 0.48, rackTrimMaterial, 0, 3.42, -0.68);
makeBox(9.25, 0.14, 0.48, rackTrimMaterial, 0, -1.32, -0.68);
const rackTitle = makeLabel("SEQUENCE BAYS // 03", "#8eddd4", 2.25);
rackTitle.position.set(0, 3.12, -0.38);
scene.add(rackTitle);
const shelfMaterial = new THREE.MeshStandardMaterial({
color: 0x173337,
roughness: 0.52,
metalness: 0.45
});
makeBox(10.15, 0.18, 2.1, shelfMaterial, 0, -1.98, 0.78);
const shelfFront = makeBox(
10.15,
0.1,
0.12,
new THREE.MeshStandardMaterial({
color: 0x3e7374,
emissive: 0x173f40,
emissiveIntensity: 0.35
}),
0,
-1.92,
1.81
);
shelfFront.castShadow = false;
function createBay(data) {
const group = new THREE.Group();
group.position.set(0, data.y, 0);
group.userData = { kind: "bay", id: data.id };
scene.add(group);
const panelMaterial = new THREE.MeshStandardMaterial({
color: data.unresolved ? 0x242820 : 0x0c2023,
roughness: 0.66,
metalness: 0.38,
emissive: data.unresolved ? 0x4a3010 : 0x071517,
emissiveIntensity: data.unresolved ? 0.2 : 0.12
});
const panel = makeBox(
8.42,
0.98,
0.16,
panelMaterial,
0,
0,
-0.57,
group
);
panel.userData.kind = "bay";
panel.userData.id = data.id;
const label = makeLabel(
`${data.code} / ${data.title}`,
data.unresolved ? "#e8b767" : "#8eddd4",
1.72
);
label.position.set(-3.45, 0.34, -0.3);
group.add(label);
const slotXs = Array.from(
{ length: 7 },
(_, index) => firstSlotX + index * slotSpacing
);
const gapGhosts = [];
for (let index = 0; index < 7; index++) {
const x = slotXs[index];
if (data.lockedIndices.includes(index) && data.fullSequence) {
const anchor = makeTile(data.fullSequence[index], { locked: true });
anchor.position.set(x, 0, -0.03);
group.add(anchor);
}
if (data.gapIndices.includes(index)) {
const ghost = makeGhost(
data.unresolved ? 0xf1b85d : 0x6a9b9d,
data.unresolved ? 0.74 : 0.34
);
ghost.position.set(x, 0, -0.02);
group.add(ghost);
gapGhosts.push(ghost);
} else if (data.unresolved && index >= 4) {
const tailGhost = makeGhost(0xf1b85d, 0.63);
tailGhost.position.set(x, 0, -0.02);
group.add(tailGhost);
gapGhosts.push(tailGhost);
}
}
if (data.unresolved) {
const outlineGeometry = new THREE.EdgesGeometry(
new THREE.BoxGeometry(8.3, 0.96, 0.06)
);
const outlineMaterial = new THREE.LineDashedMaterial({
color: 0xe7aa4d,
transparent: true,
opacity: 0.75,
dashSize: 0.14,
gapSize: 0.1
});
const outline = new THREE.LineSegments(outlineGeometry, outlineMaterial);
outline.computeLineDistances();
outline.position.z = -0.43;
group.add(outline);
const warning = makeLabel("NO TAIL / UNRESOLVED", "#edbd75", 1.82);
warning.position.set(2.83, 0.34, -0.28);
group.add(warning);
}
const lightMaterial = new THREE.MeshStandardMaterial({
color: data.unresolved ? 0xf1b85d : 0x397477,
emissive: data.unresolved ? 0xf1b85d : 0x174346,
emissiveIntensity: data.unresolved ? 0.85 : 0.3
});
const light = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 16, 12),
lightMaterial
);
light.position.set(3.94, 0, -0.2);
group.add(light);
bayObjects[data.id] = {
group,
panel,
panelMaterial,
gapGhosts,
light,
lightMaterial
};
}
Object.values(bays).forEach(createBay);
// -------------------------------------------------------------------------
// Fragment meshes and inventory
// -------------------------------------------------------------------------
function rebuildFragment(fragment, sequence = fragment.baseSequence) {
fragment.tileGroups.forEach(tile => fragment.group.remove(tile));
fragment.tileGroups = [];
fragment.sequence = sequence.slice();
fragment.sequence.forEach((symbol, index) => {
const x = (index - 1) * slotSpacing;
let tile;
if (symbol === null) {
tile = makeGhost(0xf1b85d, 0.78);
} else {
tile = makeTile(symbol, {
inferred: fragment.inferredIndices.has(index)
});
}
tile.position.x = x;
fragment.group.add(tile);
fragment.tileGroups.push(tile);
});
}
function createFragment(data, x) {
const group = new THREE.Group();
group.userData = { kind: "fragment", id: data.id };
scene.add(group);
const selectionMaterial = new THREE.MeshBasicMaterial({
color: 0x59e1c6,
transparent: true,
opacity: 0.075,
depthWrite: false,
side: THREE.DoubleSide
});
const selectionPlane = new THREE.Mesh(
new THREE.PlaneGeometry(2.55, 0.94),
selectionMaterial
);
selectionPlane.position.z = -0.29;
selectionPlane.visible = false;
group.add(selectionPlane);
const selectionEdge = new THREE.LineSegments(
new THREE.EdgesGeometry(new THREE.PlaneGeometry(2.55, 0.94)),
new THREE.LineBasicMaterial({
color: 0x59e1c6,
transparent: true,
opacity: 0.85
})
);
selectionEdge.position.z = -0.285;
selectionEdge.visible = false;
group.add(selectionEdge);
const label = makeLabel(data.code, "#b8d7d5", 1.05);
label.position.set(0, 0.64, 0.08);
group.add(label);
const fragment = {
...data,
group,
label,
selectionPlane,
selectionEdge,
selectionMaterial,
tileGroups: [],
baseSequence: data.sequence.slice(),
sequence: data.sequence.slice(),
inferredIndices: new Set(),
homePosition: new THREE.Vector3(x, -1.56, 1.06)
};
group.position.copy(fragment.homePosition);
rebuildFragment(fragment);
fragments.push(fragment);
fragmentMap.set(fragment.id, fragment);
}
const sourceXs = [-3.24, -1.08, 1.08, 3.24];
fragmentData.forEach((data, index) => createFragment(data, sourceXs[index]));
const fragList = document.getElementById("frag-list");
fragmentData.forEach((fragment, index) => {
const button = document.createElement("button");
button.className = "frag-button";
button.dataset.fragment = fragment.id;
button.setAttribute("aria-label", `Select fragment ${fragment.code}`);
const symbols = fragment.sequence
.map(symbol => {
if (symbol === null) {
return `<span class="symbol missing">?</span>`;
}
return `<span class="symbol" style="--c:${SYMBOLS[symbol].css}">${symbol}</span>`;
})
.join("");
button.innerHTML = `
<div class="frag-head">
<span>${fragment.code}</span>
<span>KEY ${index + 1}</span>
</div>
<div class="symbols">${symbols}</div>
`;
button.addEventListener("click", () => selectFragment(fragment.id));
fragList.appendChild(button);
});
// -------------------------------------------------------------------------
// Atmospheric particles
// -------------------------------------------------------------------------
const dustGeometry = new THREE.BufferGeometry();
const dustPositions = new Float32Array(180 * 3);
for (let index = 0; index < 180; index++) {
dustPositions[index * 3] = (Math.random() - 0.5) * 16;
dustPositions[index * 3 + 1] = Math.random() * 9 - 2;
dustPositions[index * 3 + 2] = (Math.random() - 0.5) * 10;
}
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0x8fc9c6,
size: 0.025,
transparent: true,
opacity: 0.35,
depthWrite: false
})
);
scene.add(dust);
// -------------------------------------------------------------------------
// Game actions and UI
// -------------------------------------------------------------------------
const toast = document.getElementById("toast");
let toastTimer;
function showToast(message, warning = false) {
clearTimeout(toastTimer);
toast.textContent = message;
toast.classList.toggle("warn", warning);
toast.classList.add("show");
toastTimer = setTimeout(() => toast.classList.remove("show"), 2800);
}
function selectFragment(id) {
state.selected = state.selected === id ? null : id;
fragments.forEach(fragment => {
const selected = state.selected === fragment.id;
fragment.selectionPlane.visible = selected;
fragment.selectionEdge.visible = selected;
});
updateUI();
if (state.selected) {
const fragment = fragmentMap.get(state.selected);
showToast(`${fragment.code} selected. Click an archive bay to stage it.`);
}
}
function returnFragmentToHome(fragment) {
fragment.group.position.copy(fragment.homePosition);
fragment.label.visible = true;
}
function clearRacks(resetFragments = false) {
Object.keys(state.placements).forEach(bayId => {
const fragment = fragmentMap.get(state.placements[bayId]);
if (fragment) returnFragmentToHome(fragment);
state.placements[bayId] = null;
});
if (resetFragments) {
fragments.forEach(fragment => {
fragment.inferredIndices.clear();
rebuildFragment(fragment, fragment.baseSequence);
});
}
state.selected = null;
state.scanned = false;
state.results = {
r12: "awaiting",
r44: "awaiting",
r90: "open"
};
fragments.forEach(fragment => {
fragment.selectionPlane.visible = false;
fragment.selectionEdge.visible = false;
});
updateUI();
showToast("Archive racks cleared.");
}
function placeFragment(fragment, bayId) {
const bay = bays[bayId];
const bayObject = bayObjects[bayId];
Object.entries(state.placements).forEach(([otherBayId, fragmentId]) => {
if (otherBayId !== bayId && fragmentId === fragment.id) {
const otherFragment = fragmentMap.get(fragmentId);
returnFragmentToHome(otherFragment);
state.placements[otherBayId] = null;
}
});
const displacedId = state.placements[bayId];
if (displacedId) {
returnFragmentToHome(fragmentMap.get(displacedId));
}
const gapCenter = bay.gapIndices.reduce((sum, index) => {
return sum + firstSlotX + index * slotSpacing;
}, 0) / bay.gapIndices.length;
fragment.group.position.set(gapCenter, bay.y, 0.13);
fragment.label.visible = false;
state.placements[bayId] = fragment.id;
state.scanned = false;
state.results[bayId] = "staged";
state.results.r90 = "open";
bayObject.gapGhosts.forEach((ghost, index) => {
if (bayId === "r90" && index >= 3) {
ghost.visible = true;
} else {
ghost.visible = false;
}
});
updateUI();
showToast(
`${fragment.code} staged in ${bay.code}. Scan to test corroboration.`
);
}
function setRowLight(bayId, status) {
const light = bayObjects[bayId].lightMaterial;
let color = 0x397477;
let intensity = 0.3;
if (status === "verified") {
color = 0x59e1c6;
intensity = 1.15;
} else if (status === "mismatch") {
color = 0xff6868;
intensity = 1.05;
} else if (status === "staged") {
color = 0x6b91ff;
intensity = 0.75;
} else if (status === "open") {
color = 0xf1b85d;
intensity = 0.85;
}
light.color.setHex(color);
light.emissive.setHex(color);
light.emissiveIntensity = intensity;
}
function scanArchive() {
state.scanned = true;
let verifiedCount = 0;
const problems = [];
["r12", "r44"].forEach(bayId => {
const bay = bays[bayId];
const fragment = fragmentMap.get(state.placements[bayId]);
if (!fragment) {
state.results[bayId] = "awaiting";
problems.push(`${bay.code} is empty`);
return;
}
const matches = fragment.sequence.every((symbol, index) => {
return symbol === null || symbol === bay.expected[index];
});
if (!matches) {
state.results[bayId] = "mismatch";
problems.push(`${bay.code} conflicts with its attested period`);
return;
}
const reconstructed = fragment.sequence.slice();
let changed = false;
reconstructed.forEach((symbol, index) => {
if (symbol === null) {
reconstructed[index] = bay.expected[index];
fragment.inferredIndices.add(index);
changed = true;
}
});
if (changed) rebuildFragment(fragment, reconstructed);
state.results[bayId] = "verified";
verifiedCount++;
});
// This record is deliberately never inferred or attested.
state.results.r90 = "open";
updateUI();
if (verifiedCount === 2) {
showToast(
"Supported set sealed: 2 corroborated strips. R-90 remains openly unresolved."
);
} else {
showToast(
`${problems.join(" · ")}. Unattested sequences were not filled.`,
true
);
}
}
function updateUI() {
const recordElements = {
r12: document.getElementById("record-r12"),
r44: document.getElementById("record-r44"),
r90: document.getElementById("record-r90")
};
const labels = {
awaiting: "AWAITING",
staged: "STAGED",
verified: "ATTESTED",
mismatch: "CONFLICT",
open: "UNRESOLVED"
};
Object.entries(state.results).forEach(([bayId, status]) => {
const element = recordElements[bayId];
element.classList.remove("ok", "bad", "open");
if (status === "verified") element.classList.add("ok");
if (status === "mismatch") element.classList.add("bad");
if (status === "open") element.classList.add("open");
element.querySelector(".record-head span:last-child").textContent =
labels[status];
setRowLight(bayId, status);
});
const verifiedCount = ["r12", "r44"].filter(
bayId => state.results[bayId] === "verified"
).length;
document.getElementById("supported-count").textContent =
`${verifiedCount} / 2`;
fragments.forEach(fragment => {
const button = fragList.querySelector(
`[data-fragment="${fragment.id}"]`
);
button.classList.toggle("selected", state.selected === fragment.id);
button.classList.toggle(
"placed",
Object.values(state.placements).includes(fragment.id)
);
});
}
document.getElementById("scan-button").addEventListener("click", scanArchive);
document.getElementById("clear-button").addEventListener("click", () => {
clearRacks(false);
});
document.getElementById("reset-button").addEventListener("click", () => {
clearRacks(true);
});
// -------------------------------------------------------------------------
// Direct camera controls — no addons
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 0.48, 0);
const cameraGoal = {
theta: 0,
phi: innerWidth < 700 ? 1.31 : 1.2,
radius: innerWidth < 700 ? 12.9 : 10.7
};
const cameraCurrent = { ...cameraGoal };
let topView = false;
function updateCamera() {
const sinPhi = Math.sin(cameraCurrent.phi);
camera.position.set(
cameraTarget.x + cameraCurrent.radius * sinPhi * Math.sin(cameraCurrent.theta),
cameraTarget.y + cameraCurrent.radius * Math.cos(cameraCurrent.phi),
cameraTarget.z + cameraCurrent.radius * sinPhi * Math.cos(cameraCurrent.theta)
);
camera.lookAt(cameraTarget);
}
document.getElementById("view-button").addEventListener("click", () => {
topView = !topView;
if (topView) {
cameraGoal.theta = 0;
cameraGoal.phi = 0.16;
cameraGoal.radius = innerWidth < 700 ? 13.6 : 11.4;
} else {
cameraGoal.theta = 0;
cameraGoal.phi = innerWidth < 700 ? 1.31 : 1.2;
cameraGoal.radius = innerWidth < 700 ? 12.9 : 10.7;
}
document.getElementById("view-button").textContent =
topView ? "VIEW: TOP" : "VIEW: ISO";
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let pointerDown = false;
let pointerMoved = false;
let pointerStartX = 0;
let pointerStartY = 0;
let previousX = 0;
let previousY = 0;
function interactiveFrom(object) {
let current = object;
while (current) {
if (current.userData.kind) return current;
current = current.parent;
}
return null;
}
function pick(clientX, clientY) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(scene.children, true);
for (const intersection of intersections) {
const interactive = interactiveFrom(intersection.object);
if (!interactive) continue;
if (interactive.userData.kind === "fragment") {
selectFragment(interactive.userData.id);
} else if (interactive.userData.kind === "bay") {
const bayId = interactive.userData.id;
if (!state.selected) {
showToast(
`${bays[bayId].code}: select a fragment before staging it.`,
true
);
} else {
placeFragment(fragmentMap.get(state.selected), bayId);
}
}
return;
}
}
renderer.domElement.addEventListener("pointerdown", event => {
pointerDown = true;
pointerMoved = false;
pointerStartX = event.clientX;
pointerStartY = event.clientY;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointerDown) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
if (
Math.abs(event.clientX - pointerStartX) +
Math.abs(event.clientY - pointerStartY) > 5
) {
pointerMoved = true;
}
cameraGoal.theta -= dx * 0.0055;
cameraGoal.phi = THREE.MathUtils.clamp(
cameraGoal.phi + dy * 0.0045,
0.1,
1.48
);
previousX = event.clientX;
previousY = event.clientY;
});
renderer.domElement.addEventListener("pointerup", event => {
if (pointerDown && !pointerMoved) {
pick(event.clientX, event.clientY);
}
pointerDown = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = false;
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraGoal.radius = THREE.MathUtils.clamp(
cameraGoal.radius + event.deltaY * 0.006,
7.4,
15.5
);
},
{ passive: false }
);
addEventListener("keydown", event => {
if (event.key >= "1" && event.key <= "4") {
const fragment = fragments[Number(event.key) - 1];
selectFragment(fragment.id);
} else if (event.key === "Enter") {
scanArchive();
} else if (event.key === "Escape") {
state.selected = null;
fragments.forEach(fragment => {
fragment.selectionPlane.visible = false;
fragment.selectionEdge.visible = false;
});
updateUI();
}
});
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
cameraCurrent.theta += (cameraGoal.theta - cameraCurrent.theta) * 0.09;
cameraCurrent.phi += (cameraGoal.phi - cameraCurrent.phi) * 0.09;
cameraCurrent.radius += (cameraGoal.radius - cameraCurrent.radius) * 0.09;
updateCamera();
dust.rotation.y = elapsed * 0.018;
dust.position.y = Math.sin(elapsed * 0.18) * 0.06;
fragments.forEach((fragment, index) => {
if (!fragment.selectionPlane.visible) return;
fragment.selectionMaterial.opacity =
0.055 + Math.sin(elapsed * 3.4 + index) * 0.018;
});
bayObjects.r90.gapGhosts.forEach((ghost, index) => {
if (!ghost.visible) return;
const material = ghost.userData.ghostMaterial;
material.opacity = 0.52 + Math.sin(elapsed * 2.2 + index * 0.7) * 0.15;
});
renderer.render(scene, camera);
}
updateUI();
updateCamera();
animate();
</script>
</body>
</html>
```