Prompt specification
Build or customize the Three.js 3D scene "Lost Parcel With Conflicting Reports" 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: Lost Parcel With Conflicting Reports
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/lost-parcel-with-conflicting-reports-x3274
Scene Description Prompt:
Please use Three.js from cdnjs for a stylized scene based on this idea: lost parcel with conflicting reports. Build a small depot with three witness cards and a timestamped scanning trail. Reveal evidence sequentially and update the parcel route only when records support it. Return one self-contained HTML file.
Working Three.js Starter (lost-parcel-with-conflicting-reports-x3274):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Parcel 47 — Conflicting Reports</title>
<style>
:root {
--ink: #19383b;
--ink-soft: #587073;
--paper: #f4efe4;
--panel: rgba(250, 247, 239, 0.88);
--line: rgba(25, 56, 59, 0.15);
--teal: #167b73;
--teal-light: #d7ebe5;
--coral: #d95f42;
--coral-light: #f6ddd4;
--gold: #e2a83e;
--shadow: 0 18px 50px rgba(25, 56, 59, 0.12);
--mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
--sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e3d8;
color: var(--ink);
font-family: var(--sans);
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
z-index: 0;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.grain {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
opacity: 0.2;
background-image:
radial-gradient(circle at 20% 20%, rgba(255,255,255,0.5) 0 1px, transparent 1px),
radial-gradient(circle at 80% 70%, rgba(25,56,59,0.15) 0 0.7px, transparent 0.8px);
background-size: 8px 8px, 11px 11px;
mix-blend-mode: soft-light;
}
.topbar {
position: fixed;
z-index: 10;
top: 0;
left: 0;
right: 0;
height: 66px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
color: var(--ink);
border-bottom: 1px solid rgba(25, 56, 59, 0.12);
background: rgba(244, 239, 228, 0.72);
backdrop-filter: blur(14px);
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 240px;
}
.brand-mark {
width: 34px;
height: 34px;
position: relative;
border: 2px solid var(--ink);
border-radius: 9px;
transform: rotate(-3deg);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
left: 5px;
right: 5px;
height: 2px;
background: var(--ink);
}
.brand-mark::before {
top: 9px;
}
.brand-mark::after {
bottom: 8px;
}
.brand-title {
font-size: 13px;
font-weight: 800;
letter-spacing: 0.13em;
line-height: 1.1;
}
.brand-subtitle {
margin-top: 4px;
color: var(--ink-soft);
font: 10px var(--mono);
letter-spacing: 0.08em;
text-transform: uppercase;
}
.case-strip {
display: flex;
align-items: center;
gap: 20px;
color: var(--ink-soft);
font: 11px var(--mono);
letter-spacing: 0.05em;
text-transform: uppercase;
}
.case-strip strong {
color: var(--ink);
}
.case-pill {
padding: 7px 10px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255,255,255,0.42);
}
.case-pill::before {
content: "";
display: inline-block;
width: 7px;
height: 7px;
margin-right: 7px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 4px rgba(217, 95, 66, 0.12);
}
.view-tools {
display: flex;
align-items: center;
gap: 14px;
}
.view-hint {
color: var(--ink-soft);
font: 10px var(--mono);
letter-spacing: 0.06em;
text-transform: uppercase;
}
.icon-button {
width: 34px;
height: 34px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255,255,255,0.55);
color: var(--ink);
cursor: pointer;
transition: 0.2s ease;
}
.icon-button:hover {
background: white;
transform: translateY(-1px);
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(255, 255, 255, 0.58);
border-radius: 18px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.brief {
top: 88px;
left: 24px;
width: 326px;
padding: 22px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
color: var(--coral);
font: 10px var(--mono);
font-weight: 700;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 19px;
height: 2px;
background: currentColor;
}
h1 {
margin: 14px 0 10px;
max-width: 280px;
font-size: clamp(30px, 3.1vw, 44px);
line-height: 0.98;
letter-spacing: -0.055em;
font-weight: 800;
}
.brief-copy {
margin: 0;
color: var(--ink-soft);
font-size: 13px;
line-height: 1.55;
}
.finding {
min-height: 44px;
margin: 16px 0;
padding: 12px 13px;
border-left: 3px solid var(--gold);
border-radius: 0 9px 9px 0;
background: rgba(226, 168, 62, 0.1);
color: #6e5a32;
font-size: 12px;
line-height: 1.45;
}
.stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin-bottom: 16px;
}
.stat {
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255,255,255,0.38);
}
.stat strong {
display: block;
font: 22px var(--mono);
letter-spacing: -0.05em;
}
.stat span {
display: block;
margin-top: 4px;
color: var(--ink-soft);
font-size: 10px;
line-height: 1.3;
}
.primary-button {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 13px 15px;
border: 0;
border-radius: 11px;
background: var(--ink);
color: white;
cursor: pointer;
font-size: 12px;
font-weight: 750;
letter-spacing: 0.02em;
box-shadow: 0 8px 20px rgba(25, 56, 59, 0.18);
transition: 0.2s ease;
}
.primary-button:hover {
background: var(--teal);
transform: translateY(-1px);
box-shadow: 0 10px 24px rgba(22, 123, 115, 0.22);
}
.button-arrow {
font-size: 17px;
line-height: 1;
transition: transform 0.2s ease;
}
.primary-button:hover .button-arrow {
transform: translateX(3px);
}
.brief-progress {
display: flex;
gap: 5px;
margin-top: 14px;
}
.progress-segment {
height: 3px;
flex: 1;
overflow: hidden;
border-radius: 999px;
background: rgba(25, 56, 59, 0.11);
}
.progress-segment::after {
content: "";
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--teal);
transition: width 0.45s ease;
}
.progress-segment.done::after {
width: 100%;
}
.progress-segment.conflict::after {
width: 100%;
background: var(--coral);
}
.evidence-panel {
top: 88px;
right: 24px;
width: 328px;
padding: 18px;
max-height: calc(100vh - 112px);
overflow: auto;
scrollbar-width: thin;
}
.panel-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
margin-bottom: 13px;
}
.panel-heading h2 {
margin: 0;
font-size: 15px;
letter-spacing: -0.02em;
}
.panel-heading p {
margin: 5px 0 0;
color: var(--ink-soft);
font: 10px var(--mono);
letter-spacing: 0.04em;
}
.count-badge {
padding: 5px 8px;
border-radius: 999px;
background: rgba(25, 56, 59, 0.08);
color: var(--ink-soft);
font: 10px var(--mono);
}
.witness {
position: relative;
margin-top: 9px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255,255,255,0.38);
transition: 0.35s ease;
overflow: hidden;
}
.witness::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 3px;
background: transparent;
transition: background 0.35s ease;
}
.witness.revealed {
background: rgba(255,255,255,0.72);
border-color: rgba(25, 56, 59, 0.2);
}
.witness.revealed::before {
background: var(--teal);
}
.witness.conflict::before {
background: var(--coral);
}
.witness.active {
transform: translateX(-4px);
box-shadow: 0 10px 28px rgba(25, 56, 59, 0.1);
}
.witness-top {
display: flex;
align-items: center;
gap: 10px;
}
.witness-number {
color: var(--ink-soft);
font: 10px var(--mono);
}
.avatar {
width: 31px;
height: 31px;
display: grid;
place-items: center;
border-radius: 9px;
background: var(--ink);
color: white;
font: 10px var(--mono);
font-weight: 700;
}
.witness-name {
font-size: 12px;
font-weight: 750;
}
.witness-role {
margin-top: 2px;
color: var(--ink-soft);
font-size: 9px;
}
.lock-state {
margin-left: auto;
color: var(--ink-soft);
font: 9px var(--mono);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.witness.revealed .lock-state {
color: var(--teal);
}
.witness.conflict .lock-state {
color: var(--coral);
}
.quote {
margin: 12px 0 10px;
color: #365356;
font-size: 11.5px;
font-style: italic;
line-height: 1.45;
transition: filter 0.45s ease, opacity 0.45s ease;
}
.witness:not(.revealed) .quote {
filter: blur(5px);
opacity: 0.28;
user-select: none;
}
.witness-meta {
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.meta-chip {
padding: 4px 6px;
border-radius: 6px;
background: rgba(25, 56, 59, 0.07);
color: var(--ink-soft);
font: 9px var(--mono);
}
.verdict {
display: none;
margin-top: 10px;
padding-top: 9px;
border-top: 1px dashed rgba(25, 56, 59, 0.15);
color: var(--teal);
font: 9px var(--mono);
line-height: 1.4;
text-transform: uppercase;
letter-spacing: 0.035em;
}
.conflict .verdict {
color: var(--coral);
}
.witness.revealed .verdict {
display: block;
}
.scanner-panel {
left: 50%;
bottom: 22px;
width: 650px;
transform: translateX(-50%);
padding: 15px 18px 13px;
}
.scanner-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.scanner-title {
display: flex;
align-items: center;
gap: 9px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.035em;
text-transform: uppercase;
}
.scanner-led {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(22, 123, 115, 0.12);
animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
50% { box-shadow: 0 0 0 7px rgba(22, 123, 115, 0.04); }
}
.scanner-count {
color: var(--ink-soft);
font: 9px var(--mono);
letter-spacing: 0.05em;
text-transform: uppercase;
}
.scan-table {
display: grid;
gap: 4px;
}
.scan-row {
display: grid;
grid-template-columns: 54px 1.1fr 1.2fr 112px;
align-items: center;
gap: 10px;
min-height: 26px;
padding: 4px 8px;
border-radius: 7px;
font: 9px var(--mono);
transition: 0.4s ease;
}
.scan-row.head {
padding-top: 0;
padding-bottom: 2px;
color: var(--ink-soft);
text-transform: uppercase;
letter-spacing: 0.08em;
}
.scan-row:not(.head) {
background: rgba(25, 56, 59, 0.045);
}
.scan-row.pending {
filter: blur(3px);
opacity: 0.26;
}
.scan-row.unlocked {
filter: none;
opacity: 1;
background: rgba(22, 123, 115, 0.075);
}
.scan-time {
color: var(--ink);
font-weight: 700;
}
.scan-node {
font-weight: 700;
letter-spacing: 0.025em;
}
.scan-device {
color: var(--ink-soft);
}
.scan-result {
justify-self: start;
padding: 4px 6px;
border-radius: 5px;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.scan-result.baseline {
background: rgba(25, 56, 59, 0.09);
color: var(--ink-soft);
}
.scan-result.match {
background: var(--teal-light);
color: var(--teal);
}
.scan-result.gap {
background: var(--coral-light);
color: var(--coral);
}
.toast {
position: fixed;
z-index: 20;
left: 50%;
bottom: 226px;
width: min(440px, calc(100vw - 32px));
display: flex;
align-items: center;
gap: 11px;
padding: 12px 14px;
border: 1px solid rgba(255,255,255,0.68);
border-radius: 12px;
background: rgba(250, 247, 239, 0.94);
box-shadow: var(--shadow);
opacity: 0;
pointer-events: none;
transform: translate(-50%, 12px);
transition: 0.35s ease;
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
.toast-mark {
width: 28px;
height: 28px;
display: grid;
place-items: center;
flex: 0 0 auto;
border-radius: 8px;
background: var(--teal-light);
color: var(--teal);
font-weight: 800;
}
.toast.conflict .toast-mark {
background: var(--coral-light);
color: var(--coral);
}
.toast strong {
display: block;
font-size: 11px;
}
.toast span {
display: block;
margin-top: 2px;
color: var(--ink-soft);
font-size: 10px;
line-height: 1.35;
}
.footer-note {
position: fixed;
z-index: 5;
left: 24px;
bottom: 24px;
color: rgba(25, 56, 59, 0.55);
font: 9px var(--mono);
letter-spacing: 0.04em;
text-transform: uppercase;
pointer-events: none;
}
.loading {
position: fixed;
z-index: 50;
inset: 0;
display: grid;
place-items: center;
background: #e9e3d8;
transition: opacity 0.45s ease, visibility 0.45s ease;
}
.loading.hidden {
opacity: 0;
visibility: hidden;
}
.loading-inner {
text-align: center;
color: var(--ink);
font: 11px var(--mono);
letter-spacing: 0.12em;
text-transform: uppercase;
}
.loading-box {
width: 42px;
height: 36px;
margin: 0 auto 16px;
border: 2px solid var(--ink);
border-radius: 5px;
animation: boxFloat 1.2s ease-in-out infinite;
}
@keyframes boxFloat {
50% { transform: translateY(-8px) rotate(-3deg); }
}
@media (max-width: 1120px) {
.brief {
width: 285px;
left: 16px;
}
.evidence-panel {
width: 285px;
right: 16px;
}
.scanner-panel {
width: calc(100vw - 620px);
min-width: 380px;
}
.scan-row {
grid-template-columns: 48px 1fr 1fr 94px;
gap: 7px;
}
.case-strip > span:not(.case-pill) {
display: none;
}
}
@media (max-width: 760px) {
.topbar {
height: 58px;
padding: 0 13px;
}
.brand {
min-width: 0;
}
.brand-title {
font-size: 11px;
}
.brand-subtitle,
.view-hint,
.case-strip {
display: none;
}
.brief,
.evidence-panel {
top: 69px;
width: calc(50% - 13px);
padding: 13px;
border-radius: 14px;
}
.brief {
left: 9px;
}
.evidence-panel {
right: 9px;
max-height: calc(100vh - 205px);
}
h1 {
font-size: 28px;
}
.brief-copy,
.finding {
display: none;
}
.stats {
margin-top: 14px;
}
.primary-button {
padding: 10px;
font-size: 10px;
}
.witness {
padding: 10px;
}
.witness-role,
.quote,
.verdict {
display: none !important;
}
.witness.revealed .lock-state {
display: block;
}
.scanner-panel {
left: 9px;
right: 9px;
bottom: 9px;
width: auto;
min-width: 0;
transform: none;
padding: 11px;
}
.scan-row {
grid-template-columns: 43px 1fr 82px;
}
.scan-device {
display: none;
}
.scan-row.head .scan-device {
display: none;
}
.toast {
bottom: 195px;
}
.footer-note {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive stylized parcel depot"></canvas>
<div class="grain"></div>
<div class="loading" id="loading">
<div class="loading-inner">
<div class="loading-box"></div>
Building depot evidence
</div>
</div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<div class="brand-title">LAST MILE / FIELD OFFICE</div>
<div class="brand-subtitle">Parcel route reconstruction unit</div>
</div>
</div>
<div class="case-strip">
<span class="case-pill">Case 047 · Open</span>
<span>Depot <strong>North Yard 02</strong></span>
<span>Missing at <strong>08:22</strong></span>
</div>
<div class="view-tools">
<span class="view-hint">Drag to orbit · Scroll to zoom</span>
<button class="icon-button" id="resetView" title="Reset camera" aria-label="Reset camera">↺</button>
</div>
</header>
<section class="panel brief" aria-labelledby="caseTitle">
<div class="eyebrow">Conflicting reports</div>
<h1 id="caseTitle">Where did parcel 47 go?</h1>
<p class="brief-copy">
Three witnesses remember the same parcel. One record does not agree.
Admit the statements in order; only scanner-supported claims will move the route.
</p>
<div class="finding" id="finding">
The parcel is unplaced. The first witness is waiting to be admitted.
</div>
<div class="stats">
<div class="stat">
<strong id="matchCount">0</strong>
<span>of 3 claims matched</span>
</div>
<div class="stat">
<strong id="scanCount">1</strong>
<span>scan records available</span>
</div>
</div>
<button class="primary-button" id="revealButton">
<span id="revealLabel">Reveal witness 01</span>
<span class="button-arrow">→</span>
</button>
<div class="brief-progress" aria-label="Evidence progress">
<span class="progress-segment"></span>
<span class="progress-segment"></span>
<span class="progress-segment"></span>
</div>
</section>
<aside class="panel evidence-panel" aria-labelledby="witnessHeading">
<div class="panel-heading">
<div>
<h2 id="witnessHeading">Witness statements</h2>
<p>Admitted sequentially</p>
</div>
<span class="count-badge" id="witnessCount">0 / 3</span>
</div>
<article class="witness" data-witness="0">
<div class="witness-top">
<span class="witness-number">01</span>
<span class="avatar">MC</span>
<div>
<div class="witness-name">Mara Chen</div>
<div class="witness-role">Gate attendant</div>
</div>
<span class="lock-state">Locked</span>
</div>
<p class="quote">“I handed it over at the west gate. The blue wrap was still intact.”</p>
<div class="witness-meta">
<span class="meta-chip">08:05</span>
<span class="meta-chip">West Gate</span>
<span class="meta-chip">Blue wrap</span>
</div>
<div class="verdict">Match · RFID gate and camera both record 08:05.</div>
</article>
<article class="witness" data-witness="1">
<div class="witness-top">
<span class="witness-number">02</span>
<span class="avatar">DO</span>
<div>
<div class="witness-name">Dez Okafor</div>
<div class="witness-role">Dock runner</div>
</div>
<span class="lock-state">Locked</span>
</div>
<p class="quote">“It was still waiting at Bay A at 08:12. I saw the courier set it down.”</p>
<div class="witness-meta">
<span class="meta-chip">08:12</span>
<span class="meta-chip">Bay A</span>
<span class="meta-chip">No RFID</span>
</div>
<div class="verdict">Unsupported · No Bay A scan exists; the route stays unchanged.</div>
</article>
<article class="witness" data-witness="2">
<div class="witness-top">
<span class="witness-number">03</span>
<span class="avatar">SI</span>
<div>
<div class="witness-name">Sana Iqbal</div>
<div class="witness-role">Sort supervisor</div>
</div>
<span class="lock-state">Locked</span>
</div>
<p class="quote">“Scale 2 cleared at 08:14. Bay B accepted the parcel at 08:19.”</p>
<div class="witness-meta">
<span class="meta-chip">08:14</span>
<span class="meta-chip">Scale 2</span>
<span class="meta-chip">Bay B · 08:19</span>
</div>
<div class="verdict">Match · Scale 2 and Bay B scans align with the statement.</div>
</article>
</aside>
<section class="panel scanner-panel" aria-labelledby="scannerHeading">
<div class="scanner-head">
<div class="scanner-title">
<span class="scanner-led"></span>
<span id="scannerHeading">Timestamped scanning trail</span>
</div>
<span class="scanner-count" id="trailCount">1 / 5 records available</span>
</div>
<div class="scan-table" role="table" aria-label="Parcel scanning records">
<div class="scan-row head" role="row">
<span>Time</span>
<span>Node</span>
<span class="scan-device">Device</span>
<span>Record</span>
</div>
<div class="scan-row unlocked" data-scan="0" role="row">
<span class="scan-time">08:02</span>
<span class="scan-node">INTAKE</span>
<span class="scan-device">Dock sensor 01</span>
<span class="scan-result baseline">Baseline</span>
</div>
<div class="scan-row pending" data-scan="1" role="row">
<span class="scan-time">08:05</span>
<span class="scan-node">WEST GATE</span>
<span class="scan-device">RFID gate 02</span>
<span class="scan-result match">Match</span>
</div>
<div class="scan-row pending" data-scan="2" role="row">
<span class="scan-time">08:12</span>
<span class="scan-node">BAY A</span>
<span class="scan-device">No device event</span>
<span class="scan-result gap">No scan</span>
</div>
<div class="scan-row pending" data-scan="3" role="row">
<span class="scan-time">08:14</span>
<span class="scan-node">SCALE 2</span>
<span class="scan-device">Load-cell 02</span>
<span class="scan-result match">Match</span>
</div>
<div class="scan-row pending" data-scan="4" role="row">
<span class="scan-time">08:19</span>
<span class="scan-node">BAY B</span>
<span class="scan-device">Dock scanner 04</span>
<span class="scan-result match">Match</span>
</div>
</div>
</section>
<div class="toast" id="toast" role="status" aria-live="polite">
<div class="toast-mark" id="toastMark">✓</div>
<div>
<strong id="toastTitle"></strong>
<span id="toastText"></span>
</div>
</div>
<div class="footer-note">Records are evidence, not decoration · Route changes only on a match</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// DOM references and evidence model
// -------------------------------------------------------------------------
const canvas = document.getElementById("scene");
const loading = document.getElementById("loading");
const revealButton = document.getElementById("revealButton");
const revealLabel = document.getElementById("revealLabel");
const matchCount = document.getElementById("matchCount");
const scanCount = document.getElementById("scanCount");
const trailCount = document.getElementById("trailCount");
const witnessCount = document.getElementById("witnessCount");
const finding = document.getElementById("finding");
const toast = document.getElementById("toast");
const toastMark = document.getElementById("toastMark");
const toastTitle = document.getElementById("toastTitle");
const toastText = document.getElementById("toastText");
const resetViewButton = document.getElementById("resetView");
const witnessCards = [...document.querySelectorAll(".witness")];
const scanRows = [...document.querySelectorAll(".scan-row[data-scan]")];
const progressSegments = [...document.querySelectorAll(".progress-segment")];
const evidence = [
{
rows: [1],
supported: true,
routeIndices: [1],
title: "West Gate movement confirmed",
text: "The 08:05 RFID gate event matches Mara's account. The route now extends to West Gate.",
finding: "Mara's statement is independently confirmed by the RFID gate at 08:05. The parcel's last confirmed position moves to West Gate."
},
{
rows: [2],
supported: false,
routeIndices: [],
title: "Bay A claim not supported",
text: "No scanner recorded the parcel at Bay A. The confirmed route remains at West Gate.",
finding: "Dez's 08:12 Bay A claim has no matching scan. It is marked as a disputed sighting and does not move the parcel."
},
{
rows: [3, 4],
supported: true,
routeIndices: [2, 3],
title: "Bay B route reconstructed",
text: "Scale 2 at 08:14 and Bay B at 08:19 agree with Sana. The parcel route now ends at Bay B.",
finding: "The records support Sana's account: Scale 2 at 08:14, then Bay B at 08:19. One earlier witness claim remains disputed."
}
];
const state = {
revealed: 0,
matched: 0,
availableScans: 1,
animation: null,
toastTimer: null
};
// -------------------------------------------------------------------------
// Three.js setup
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e3d8);
scene.fog = new THREE.Fog(0xe9e3d8, 22, 38);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const camera = new THREE.PerspectiveCamera(
37,
window.innerWidth / window.innerHeight,
0.1,
100
);
const controls = {
target: new THREE.Vector3(0.15, 0.6, -0.15),
theta: 0.76,
phi: 0.83,
radius: 18.1,
dragging: false,
pointerX: 0,
pointerY: 0,
moved: 0
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.theta = 0.76;
controls.phi = 0.83;
controls.radius = 18.1;
controls.target.set(0.15, 0.6, -0.15);
updateCamera();
}
resetCamera();
// Lighting
const hemi = new THREE.HemisphereLight(0xfff8e9, 0x687975, 2.15);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff1d4, 3.1);
key.position.set(-8, 14, 9);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -12;
key.shadow.camera.right = 12;
key.shadow.camera.top = 11;
key.shadow.camera.bottom = -11;
key.shadow.camera.near = 1;
key.shadow.camera.far = 35;
key.shadow.bias = -0.0003;
scene.add(key);
const fill = new THREE.DirectionalLight(0xa8d9d4, 1.0);
fill.position.set(9, 7, -8);
scene.add(fill);
// Palette
const colors = {
ink: 0x19383b,
teal: 0x167b73,
tealBright: 0x38a59a,
coral: 0xd95f42,
gold: 0xe2a83e,
cardboard: 0xc99158,
cardboardLight: 0xd7a36c,
cream: 0xeee6d6,
floor: 0xd8cebd,
base: 0xb9aa95,
wall: 0xe7dfcf,
dark: 0x233e40,
pale: 0xf1eadb
};
const materials = {
floor: new THREE.MeshStandardMaterial({ color: colors.floor, roughness: 0.95 }),
base: new THREE.MeshStandardMaterial({ color: colors.base, roughness: 1 }),
wall: new THREE.MeshStandardMaterial({ color: colors.wall, roughness: 0.9 }),
ink: new THREE.MeshStandardMaterial({ color: colors.ink, roughness: 0.7 }),
teal: new THREE.MeshStandardMaterial({ color: colors.teal, roughness: 0.62 }),
coral: new THREE.MeshStandardMaterial({ color: colors.coral, roughness: 0.68 }),
gold: new THREE.MeshStandardMaterial({ color: colors.gold, roughness: 0.72 }),
pale: new THREE.MeshStandardMaterial({ color: colors.pale, roughness: 0.85 })
};
function box(parent, w, h, d, material, x, y, z, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, top, bottom, height, material, x, y, z, segments = 16) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(top, bottom, height, segments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, w, h, r) {
const radius = Math.min(r, w / 2, h / 2);
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.arcTo(x + w, y, x + w, y + h, radius);
ctx.arcTo(x + w, y + h, x, y + h, radius);
ctx.arcTo(x, y + h, x, y, radius);
ctx.arcTo(x, y, x + w, y, radius);
ctx.closePath();
}
function billboard(text, sub = "", bg = "#19383b", fg = "#fffaf0", width = 2.5) {
const c = document.createElement("canvas");
c.width = 512;
c.height = 144;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
roundedRect(ctx, 4, 4, 504, 136, 22);
ctx.fillStyle = bg;
ctx.fill();
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = fg;
ctx.font = "800 34px Arial, sans-serif";
ctx.fillText(text.toUpperCase(), 256, sub ? 57 : 72);
if (sub) {
ctx.globalAlpha = 0.76;
ctx.font = "500 19px monospace";
ctx.fillText(sub.toUpperCase(), 256, 101);
ctx.globalAlpha = 1;
}
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.scale.set(width, width * 144 / 512, 1);
sprite.renderOrder = 8;
return sprite;
}
function wallSign(text, sub, x, y, z, width = 2.4) {
const sign = billboard(text, sub, "#19383b", "#fffaf0", width);
sign.position.set(x, y, z);
scene.add(sign);
return sign;
}
// -------------------------------------------------------------------------
// Depot environment
// -------------------------------------------------------------------------
const depot = new THREE.Group();
scene.add(depot);
box(depot, 14.8, 0.46, 10.8, materials.base, 0, -0.28, 0);
box(depot, 14.35, 0.1, 10.35, materials.floor, 0, 0.015, 0, false);
// Subtle floor grid
const gridPositions = [];
for (let x = -7; x <= 7; x += 1) {
gridPositions.push(x, 0.073, -5.1, x, 0.073, 5.1);
}
for (let z = -5; z <= 5; z += 1) {
gridPositions.push(-7.05, 0.073, z, 7.05, 0.073, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridPositions, 3)
);
const grid = new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: colors.ink,
transparent: true,
opacity: 0.085
})
);
depot.add(grid);
// Floor safety lines
const safetyMaterial = new THREE.MeshStandardMaterial({
color: 0xd8b84b,
roughness: 0.9
});
for (let i = 0; i < 8; i++) {
const stripe = box(
depot,
0.38,
0.025,
0.08,
safetyMaterial,
3.05 + i * 0.6,
0.083,
-4.06,
false
);
stripe.rotation.y = -0.65;
}
// Back wall
box(depot, 14.35, 3.8, 0.3, materials.wall, 0, 1.92, -4.95);
box(depot, 14.55, 0.18, 0.48, materials.ink, 0, 3.83, -4.87);
box(depot, 14.7, 0.2, 1.15, materials.ink, 0, 3.25, -4.38);
// Left wall with a gate opening
box(depot, 0.3, 3.55, 5.25, materials.wall, -7.02, 1.78, 1.83);
box(depot, 0.3, 3.55, 2.1, materials.wall, -7.02, 1.78, -3.82);
box(depot, 0.44, 0.2, 8.1, materials.ink, -7.02, 3.68, -0.95);
// Loading doors
function loadingDoor(x, label, sub, doorColor, accentColor) {
const group = new THREE.Group();
group.position.set(x, 0, -4.72);
depot.add(group);
const doorMaterial = new THREE.MeshStandardMaterial({
color: doorColor,
roughness: 0.68,
metalness: 0.08
});
box(group, 2.75, 2.7, 0.12, doorMaterial, 0, 1.39, 0);
box(group, 0.16, 2.94, 0.2, materials.pale, -1.46, 1.48, 0.1);
box(group, 0.16, 2.94, 0.2, materials.pale, 1.46, 1.48, 0.1);
box(group, 3.08, 0.16, 0.2, materials.pale, 0, 2.96, 0.1);
const shutterLine = new THREE.MeshStandardMaterial({
color: new THREE.Color(doorColor).offsetHSL(0, 0, 0.08),
roughness: 0.8
});
for (let i = 0; i < 8; i++) {
box(group, 2.58, 0.025, 0.035, shutterLine, 0, 0.35 + i * 0.3, 0.075, false);
}
box(group, 3.2, 0.14, 0.3, new THREE.MeshStandardMaterial({ color: accentColor }), 0, 3.08, 0.16);
const sign = billboard(label, sub, "#19383b", "#fffaf0", 2.25);
sign.position.set(0, 3.17, 0.25);
group.add(sign);
box(group, 3.25, 0.16, 1.3, materials.base, 0, 0.11, 0.7);
return group;
}
loadingDoor(-3.8, "Receiving", "Dock 01", 0x52706e, colors.gold);
loadingDoor(0.2, "Bay A", "Dock 02", 0x456968, 0xc9c0b1);
loadingDoor(4.2, "Bay B", "Dock 04", colors.ink, colors.coral);
// West gate
const gate = new THREE.Group();
gate.position.set(-6.9, 0, -0.4);
depot.add(gate);
box(gate, 0.26, 2.8, 0.26, materials.ink, 0, 1.4, -0.95);
box(gate, 0.26, 2.8, 0.26, materials.ink, 0, 1.4, 0.95);
box(gate, 0.34, 0.25, 2.2, materials.ink, 0, 2.82, 0);
box(gate, 0.32, 0.14, 2.05, materials.teal, 0, 2.68, 0);
const gateSign = billboard("West Gate", "RFID 02", "#167b73", "#fffaf0", 2.15);
gateSign.position.set(0.15, 3.1, 0);
gate.add(gateSign);
// Conveyor
const conveyor = new THREE.Group();
conveyor.position.set(-3.15, 0, 0.85);
depot.add(conveyor);
box(conveyor, 4.25, 0.3, 1.22, materials.ink, 0, 0.4, 0);
box(conveyor, 3.95, 0.12, 0.96, new THREE.MeshStandardMaterial({
color: 0x385354,
roughness: 0.82
}), 0, 0.59, 0);
const rollerMaterial = new THREE.MeshStandardMaterial({
color: 0x9ca9a1,
metalness: 0.45,
roughness: 0.48
});
for (let i = 0; i < 15; i++) {
const roller = cylinder(
conveyor,
0.11,
0.11,
1.02,
rollerMaterial,
-1.9 + i * 0.27,
0.7,
0,
12
);
roller.rotation.x = Math.PI / 2;
}
for (let i = 0; i < 4; i++) {
const leg = box(
conveyor,
0.12,
0.55,
0.12,
materials.ink,
-1.7 + i * 1.15,
0.22,
0
);
leg.castShadow = true;
}
// Scale 2
const scaleGroup = new THREE.Group();
scaleGroup.position.set(-0.35, 0, 0.85);
depot.add(scaleGroup);
box(scaleGroup, 1.8, 0.24, 1.55, materials.ink, 0, 0.19, 0);
box(scaleGroup, 1.58, 0.08, 1.34, materials.gold, 0, 0.35, 0);
box(scaleGroup, 0.1, 1.45, 0.1, materials.ink, 0.94, 0.8, -0.6);
box(scaleGroup, 0.72, 0.5, 0.12, materials.ink, 1.04, 1.48, -0.6);
box(scaleGroup, 0.52, 0.28, 0.025, materials.teal, 1.04, 1.48, -0.525, false);
const scaleSign = billboard("Scale 2", "08:14", "#e2a83e", "#19383b", 1.8);
scaleSign.position.set(0.1, 1.03, 0.1);
scaleGroup.add(scaleSign);
// Intake pallet and parcels
function makeCrate(parent, x, y, z, scale = 1, color = colors.cardboard) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
const crateMaterial = new THREE.MeshStandardMaterial({
color,
roughness: 0.92
});
box(group, 0.78, 0.62, 0.7, crateMaterial, 0, 0.31, 0);
box(group, 0.08, 0.64, 0.72, materials.pale, 0, 0.31, 0);
box(group, 0.8, 0.07, 0.08, materials.pale, 0, 0.24, 0.35);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(group.children[0].geometry),
new THREE.LineBasicMaterial({
color: colors.ink,
transparent: true,
opacity: 0.18
})
);
edges.position.copy(group.children[0].position);
group.add(edges);
return group;
}
const intake = new THREE.Group();
intake.position.set(-4.6, 0, 2.7);
depot.add(intake);
box(intake, 1.7, 0.16, 1.45, new THREE.MeshStandardMaterial({
color: 0x8d7357,
roughness: 1
}), 0, 0.16, 0);
makeCrate(intake, -0.38, 0.24, 0, 0.88, 0xb9804b);
makeCrate(intake, 0.38, 0.24, 0.18, 0.72, 0xd09a61);
const intakeSign = billboard("Intake", "08:02", "#19383b", "#fffaf0", 1.85);
intakeSign.position.set(0, 1.75, 0);
intake.add(intakeSign);
// Shelving
const shelf = new THREE.Group();
shelf.position.set(-5.35, 0, 3.75);
depot.add(shelf);
for (let i = 0; i < 4; i++) {
box(shelf, 0.11, 2.3, 0.11, materials.ink, -1.25 + i * 0.83, 1.15, 0);
}
for (let i = 0; i < 3; i++) {
box(shelf, 2.7, 0.1, 0.78, materials.ink, 0, 0.45 + i * 0.75, 0);
}
makeCrate(shelf, -0.75, 0.5, 0, 0.65, 0xb77f4c);
makeCrate(shelf, 0.55, 0.5, 0, 0.72, 0xd3a069);
makeCrate(shelf, 0.35, 1.25, 0, 0.58, 0xb9804b);
// Small parked cart
const cart = new THREE.Group();
cart.position.set(5.6, 0, 1.9);
cart.rotation.y = -0.28;
depot.add(cart);
box(cart, 1.35, 0.12, 0.88, materials.ink, 0, 0.42, 0);
box(cart, 1.25, 0.55, 0.06, materials.teal, 0, 0.73, -0.4);
for (const x of [-0.48, 0.48]) {
for (const z of [-0.28, 0.28]) {
const wheel = cylinder(cart, 0.13, 0.13, 0.1, materials.ink, x, 0.18, z, 12);
wheel.rotation.z = Math.PI / 2;
}
}
// -------------------------------------------------------------------------
// Parcel and route
// -------------------------------------------------------------------------
const routeNodes = [
new THREE.Vector3(-4.6, 0.11, 2.7), // Intake
new THREE.Vector3(-6.45, 0.11, -0.4), // West Gate
new THREE.Vector3(-0.35, 0.11, 0.85), // Scale 2
new THREE.Vector3(4.2, 0.11, -4.02) // Bay B
];
const bayAClaim = new THREE.Vector3(0.2, 0.11, -3.92);
const routeGroup = new THREE.Group();
const claimGroup = new THREE.Group();
scene.add(routeGroup, claimGroup);
const confirmedRoute = [routeNodes[0].clone()];
const routeMaterial = new THREE.MeshStandardMaterial({
color: colors.tealBright,
emissive: colors.teal,
emissiveIntensity: 0.28,
roughness: 0.45
});
const claimMaterial = new THREE.MeshStandardMaterial({
color: colors.coral,
emissive: colors.coral,
emissiveIntensity: 0.12,
roughness: 0.65
});
function segmentBetween(a, b, material, radius = 0.035, parent = routeGroup) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const midpoint = new THREE.Vector3().addVectors(a, b).multiplyScalar(0.5);
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 10),
material
);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function dashedSegment(a, b, parent = claimGroup) {
const distance = a.distanceTo(b);
const count = Math.max(5, Math.ceil(distance / 0.28));
for (let i = 0; i < count; i++) {
const start = a.clone().lerp(b, i / count);
const end = a.clone().lerp(b, (i + 0.57) / count);
segmentBetween(start, end, claimMaterial, 0.026, parent);
}
}
function addRouteArrow(a, b) {
const direction = new THREE.Vector3().subVectors(b, a).normalize();
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.11, 0.32, 12),
routeMaterial
);
arrow.position.copy(a).lerp(b, 0.69);
arrow.position.y += 0.025;
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction
);
routeGroup.add(arrow);
}
function addRouteNode(point, label, time, sub, nodeColor = "#167b73") {
const disc = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.22, 0.065, 24),
new THREE.MeshStandardMaterial({
color: nodeColor,
emissive: nodeColor,
emissiveIntensity: 0.13,
roughness: 0.5
})
);
disc.position.set(point.x, 0.105, point.z);
disc.castShadow = true;
routeGroup.add(disc);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.29, 0.025, 8, 32),
new THREE.MeshBasicMaterial({ color: nodeColor })
);
ring.rotation.x = Math.PI / 2;
ring.position.set(point.x, 0.145, point.z);
routeGroup.add(ring);
const sign = billboard(label, time, nodeColor, "#fffaf0", 1.72);
sign.position.set(point.x, 0.73, point.z);
routeGroup.add(sign);
if (sub) {
const note = billboard(sub, "", "#19383b", "#fffaf0", 1.3);
note.position.set(point.x + 0.72, 0.38, point.z + 0.18);
routeGroup.add(note);
}
}
addRouteNode(routeNodes[0], "INTAKE", "08:02", "BASELINE", "#19383b");
// Parcel
const parcel = new THREE.Group();
scene.add(parcel);
const parcelBody = new THREE.Mesh(
new THREE.BoxGeometry(0.88, 0.66, 0.72),
new THREE.MeshStandardMaterial({
color: colors.cardboard,
roughness: 0.9
})
);
parcelBody.castShadow = true;
parcelBody.receiveShadow = true;
parcel.add(parcelBody);
box(
parcel,
0.12,
0.015,
0.74,
new THREE.MeshStandardMaterial({ color: colors.pale, roughness: 0.9 }),
0,
0.337,
0,
false
);
box(
parcel,
0.12,
0.67,
0.015,
new THREE.MeshStandardMaterial({ color: colors.pale, roughness: 0.9 }),
0,
0,
0.365,
false
);
const parcelEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(parcelBody.geometry),
new THREE.LineBasicMaterial({
color: colors.ink,
transparent: true,
opacity: 0.22
})
);
parcel.add(parcelEdges);
// Parcel label
function createParcelLabel() {
const c = document.createElement("canvas");
c.width = 320;
c.height = 240;
const ctx = c.getContext("2d");
ctx.fillStyle = "#f5f0e4";
ctx.fillRect(0, 0, c.width, c.height);
ctx.strokeStyle = "#19383b";
ctx.lineWidth = 8;
ctx.strokeRect(6, 6, c.width - 12, c.height - 12);
ctx.fillStyle = "#19383b";
ctx.font = "800 29px Arial, sans-serif";
ctx.fillText("PARCEL 047", 24, 52);
ctx.font = "600 16px monospace";
ctx.fillText("NORTH YARD / 02", 24, 82);
ctx.fillText("DEST: BAY B", 24, 108);
let x = 25;
for (let i = 0; i < 37; i++) {
const width = i % 4 === 0 ? 5 : 2;
if ((i * 7) % 5 !== 0) {
ctx.fillRect(x, 126, width, 62);
}
x += width + 3;
}
ctx.font = "500 14px monospace";
ctx.fillText("047 8F2A 0091", 25, 213);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const label = new THREE.Mesh(
new THREE.PlaneGeometry(0.52, 0.39),
new THREE.MeshBasicMaterial({ map: texture })
);
label.position.set(0.14, 0.015, 0.367);
parcel.add(label);
}
createParcelLabel();
const parcelHalo = new THREE.Mesh(
new THREE.RingGeometry(0.58, 0.67, 40),
new THREE.MeshBasicMaterial({
color: colors.teal,
transparent: true,
opacity: 0.18,
side: THREE.DoubleSide,
depthWrite: false
})
);
parcelHalo.rotation.x = -Math.PI / 2;
parcelHalo.position.y = -0.37;
parcel.add(parcelHalo);
parcel.traverse((object) => {
if (object.isMesh) object.userData.isParcel = true;
});
parcel.position.set(routeNodes[0].x, 0.51, routeNodes[0].z);
parcel.rotation.y = 0.08;
// Add new confirmed route nodes and animate the parcel along them.
function addConfirmedRoute(indices) {
const waypoints = [];
for (const index of indices) {
const target = routeNodes[index];
const previous = confirmedRoute[confirmedRoute.length - 1];
segmentBetween(previous, target, routeMaterial, 0.043);
addRouteArrow(previous, target);
const labels = [
["INTAKE", "08:02"],
["WEST GATE", "08:05"],
["SCALE 2", "08:14"],
["BAY B", "08:19"]
];
addRouteNode(target, labels[index][0], labels[index][1], "", "#167b73");
confirmedRoute.push(target.clone());
waypoints.push(new THREE.Vector3(target.x, 0.51, target.z));
}
animateParcelAlong(waypoints);
}
function animateParcelAlong(waypoints) {
if (!waypoints.length) return;
const from = parcel.position.clone();
const points = [from, ...waypoints];
const lengths = [];
let totalLength = 0;
for (let i = 0; i < points.length - 1; i++) {
const length = points[i].distanceTo(points[i + 1]);
lengths.push(length);
totalLength += length;
}
state.animation = {
start: performance.now(),
duration: Math.max(1000, totalLength * 230),
points,
lengths,
totalLength
};
}
function addDisputedClaim() {
dashedSegment(routeNodes[1], bayAClaim);
const marker = new THREE.Mesh(
new THREE.OctahedronGeometry(0.19),
claimMaterial
);
marker.position.set(bayAClaim.x, 0.38, bayAClaim.z);
marker.rotation.y = Math.PI / 4;
marker.castShadow = true;
claimGroup.add(marker);
const label = billboard("08:12 · Claim", "NO SCAN", "#d95f42", "#fffaf0", 1.75);
label.position.set(bayAClaim.x, 0.88, bayAClaim.z);
claimGroup.add(label);
}
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();
}
}
});
}
}
// -------------------------------------------------------------------------
// Evidence UI logic
// -------------------------------------------------------------------------
function showToast(title, text, conflict = false) {
toastTitle.textContent = title;
toastText.textContent = text;
toastMark.textContent = conflict ? "!" : "✓";
toast.classList.toggle("conflict", conflict);
toast.classList.add("show");
clearTimeout(state.toastTimer);
state.toastTimer = setTimeout(() => {
toast.classList.remove("show");
}, 4300);
}
function unlockScanRows(indices) {
for (const index of indices) {
const row = scanRows[index];
row.classList.remove("pending");
row.classList.add("unlocked");
state.availableScans++;
}
}
function updateSummary() {
matchCount.textContent = state.matched;
scanCount.textContent = state.availableScans;
trailCount.textContent = `${state.availableScans} / 5 records available`;
witnessCount.textContent = `${state.revealed} / 3`;
progressSegments.forEach((segment, index) => {
segment.classList.remove("done", "conflict");
if (index < state.revealed) {
segment.classList.add(index === 1 ? "conflict" : "done");
}
});
}
function revealNext() {
if (state.revealed >= evidence.length) {
resetCase();
return;
}
const index = state.revealed;
const item = evidence[index];
const card = witnessCards[index];
state.revealed++;
card.classList.add("revealed");
card.classList.toggle("conflict", !item.supported);
card.querySelector(".lock-state").textContent = item.supported ? "Matched" : "Disputed";
witnessCards.forEach((witness, witnessIndex) => {
witness.classList.toggle("active", witnessIndex === index);
});
unlockScanRows(item.rows);
if (item.supported) {
state.matched++;
addConfirmedRoute(item.routeIndices);
} else {
addDisputedClaim();
}
finding.textContent = item.finding;
updateSummary();
showToast(item.title, item.text, !item.supported);
if (state.revealed < evidence.length) {
revealLabel.textContent = `Reveal witness 0${state.revealed + 1}`;
} else {
revealLabel.textContent = "Replay investigation";
}
}
function resetCase() {
state.revealed = 0;
state.matched = 0;
state.availableScans = 1;
state.animation = null;
clearGroup(routeGroup);
clearGroup(claimGroup);
confirmedRoute.length = 0;
confirmedRoute.push(routeNodes[0].clone());
addRouteNode(routeNodes[0], "INTAKE", "08:02", "BASELINE", "#19383b");
parcel.position.set(routeNodes[0].x, 0.51, routeNodes[0].z);
parcel.rotation.set(0, 0.08, 0);
witnessCards.forEach((card) => {
card.classList.remove("revealed", "conflict", "active");
card.querySelector(".lock-state").textContent = "Locked";
});
scanRows.forEach((row, index) => {
row.classList.toggle("pending", index !== 0);
row.classList.toggle("unlocked", index === 0);
});
finding.textContent = "The parcel is unplaced. The first witness is waiting to be admitted.";
revealLabel.textContent = "Reveal witness 01";
updateSummary();
showToast("Investigation reset", "The parcel route and evidence sequence have been restored.");
}
revealButton.addEventListener("click", revealNext);
resetViewButton.addEventListener("click", resetCamera);
witnessCards.forEach((card, index) => {
card.addEventListener("click", () => {
if (index < state.revealed) {
witnessCards.forEach((witness, witnessIndex) => {
witness.classList.toggle("active", witnessIndex === index);
});
}
});
});
document.addEventListener("keydown", (event) => {
if (
event.code === "Space" &&
!["INPUT", "TEXTAREA", "BUTTON"].includes(document.activeElement.tagName)
) {
event.preventDefault();
revealNext();
}
});
// -------------------------------------------------------------------------
// Custom camera controls, implemented without addons
// -------------------------------------------------------------------------
canvas.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
controls.moved = 0;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.pointerX;
const dy = event.clientY - controls.pointerY;
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
controls.moved += Math.abs(dx) + Math.abs(dy);
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi + dy * 0.005,
0.42,
1.27
);
updateCamera();
});
canvas.addEventListener("pointerup", (event) => {
controls.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (controls.moved < 5) {
inspectParcel(event);
}
});
canvas.addEventListener("pointercancel", () => {
controls.dragging = false;
});
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.012,
11.5,
24
);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function inspectParcel(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObject(parcel, true);
if (hits.length) {
const endpoint = confirmedRoute[confirmedRoute.length - 1];
let location = "Unverified position";
let detail = "The first witness has not yet established a scanner-backed location.";
if (state.revealed >= 1) {
location = "West Gate";
detail = "Last scanner-backed position: 08:05, RFID gate 02.";
}
if (state.revealed >= 3) {
location = "Bay B";
detail = "Last scanner-backed position: 08:19, Dock scanner 04.";
}
showToast(`Parcel 047 · ${location}`, detail);
parcelHalo.material.opacity = 0.55;
setTimeout(() => {
parcelHalo.material.opacity = 0.18;
}, 900);
}
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
function updateParcelAnimation(now) {
if (!state.animation) return;
const anim = state.animation;
const raw = Math.min(1, (now - anim.start) / anim.duration);
const easedGlobal = raw * raw * (3 - 2 * raw);
const targetDistance = easedGlobal * anim.totalLength;
let traversed = 0;
for (let i = 0; i < anim.lengths.length; i++) {
const length = anim.lengths[i];
if (targetDistance <= traversed + length || i === anim.lengths.length - 1) {
const localDistance = Math.max(0, targetDistance - traversed);
const u = length ? Math.min(1, localDistance / length) : 1;
const smoothU = u * u * (3 - 2 * u);
parcel.position.lerpVectors(
anim.points[i],
anim.points[i + 1],
smoothU
);
parcel.rotation.y = 0.08 + smoothU * 0.08;
break;
}
traversed += length;
}
if (raw >= 1) {
parcel.position.copy(anim.points[anim.points.length - 1]);
state.animation = null;
}
}
function animate(now) {
requestAnimationFrame(animate);
updateParcelAnimation(now);
parcelHalo.rotation.z = now * 0.00025;
parcelHalo.material.opacity +=
(0.16 + Math.sin(now * 0.002) * 0.025 - parcelHalo.material.opacity) * 0.04;
renderer.render(scene, camera);
}
updateSummary();
requestAnimationFrame(animate);
requestAnimationFrame(() => {
setTimeout(() => loading.classList.add("hidden"), 180);
});
</script>
</body>
</html>
```