Prompt specification
Build or customize the Three.js 3D scene "Rumor and Verified Notice Network" 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: Rumor and Verified Notice Network
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/rumor-and-verified-notice-network-x3276
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring claims, evidence, and verification. Animate messages moving through a fictional village network. Add source labels and correction notices, tracking dissemination without equating repetition or popularity with factual accuracy. Voxel style.
Working Three.js Starter (rumor-and-verified-notice-network-x3276):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Traceline — Village Claim Network</title>
<style>
:root {
color-scheme: dark;
--bg: #07131b;
--panel: rgba(10, 25, 34, 0.91);
--panel-strong: rgba(12, 31, 41, 0.97);
--line: rgba(164, 205, 216, 0.16);
--text: #ecf6f5;
--muted: #91a9b0;
--verified: #58dfa8;
--unverified: #f5c45b;
--corrected: #ff716d;
--accent: #7de1d4;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 15%, #173341 0%, #091821 48%, #061018 100%);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
select,
input {
font: inherit;
}
button,
select {
color: var(--text);
background: rgba(255, 255, 255, 0.055);
border: 1px solid var(--line);
border-radius: 4px;
}
button {
cursor: pointer;
}
button:hover,
select:hover {
background: rgba(125, 225, 212, 0.1);
border-color: rgba(125, 225, 212, 0.45);
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
#viewport {
position: fixed;
inset: 0;
overflow: hidden;
}
#viewport::after {
content: "";
position: absolute;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(5, 14, 20, 0.18), transparent 25%, transparent 75%, rgba(5, 14, 20, 0.34)),
radial-gradient(circle at center, transparent 45%, rgba(3, 9, 13, 0.32) 100%);
z-index: 1;
}
#viewport canvas {
position: absolute;
inset: 0;
display: block;
z-index: 0;
}
.topbar {
position: fixed;
z-index: 20;
top: 0;
left: 0;
right: 0;
height: 72px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 0 22px;
background: linear-gradient(180deg, rgba(5, 15, 21, 0.97), rgba(5, 15, 21, 0.78));
border-bottom: 1px solid var(--line);
backdrop-filter: blur(14px);
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 245px;
}
.brand-mark {
position: relative;
width: 31px;
height: 31px;
}
.brand-mark i {
position: absolute;
display: block;
width: 13px;
height: 13px;
background: var(--accent);
box-shadow: 0 0 18px rgba(125, 225, 212, 0.24);
}
.brand-mark i:nth-child(1) {
left: 1px;
top: 17px;
}
.brand-mark i:nth-child(2) {
left: 17px;
top: 17px;
}
.brand-mark i:nth-child(3) {
left: 9px;
top: 2px;
background: #f5f5e9;
}
.brand h1 {
margin: 0;
font-size: 15px;
line-height: 1.05;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.brand p {
margin: 5px 0 0;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.top-stats {
display: flex;
align-items: stretch;
justify-content: center;
gap: 1px;
border: 1px solid var(--line);
background: var(--line);
overflow: hidden;
}
.top-stat {
min-width: 92px;
padding: 8px 14px;
background: rgba(8, 23, 31, 0.94);
}
.top-stat strong {
display: block;
font-size: 16px;
line-height: 1;
font-variant-numeric: tabular-nums;
}
.top-stat span {
display: block;
margin-top: 5px;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.09em;
text-transform: uppercase;
white-space: nowrap;
}
.fiction-badge {
flex: 0 0 auto;
padding: 8px 10px;
border: 1px solid rgba(245, 196, 91, 0.32);
color: #f6d989;
background: rgba(245, 196, 91, 0.07);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.panel {
position: fixed;
z-index: 15;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 5px;
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(16px);
}
.feed-panel {
top: 88px;
left: 18px;
bottom: 102px;
width: 328px;
display: flex;
flex-direction: column;
overflow: hidden;
}
.panel-heading {
padding: 15px 16px 12px;
border-bottom: 1px solid var(--line);
}
.eyebrow {
margin: 0 0 6px;
color: var(--accent);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.panel-heading h2 {
margin: 0;
font-size: 15px;
font-weight: 720;
}
.panel-heading p {
margin: 7px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.filters {
display: flex;
flex-wrap: wrap;
gap: 6px;
padding: 11px 12px;
border-bottom: 1px solid var(--line);
}
.filter {
padding: 6px 8px;
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.filter.active {
color: #07151b;
background: var(--accent);
border-color: var(--accent);
}
#feedList {
flex: 1;
min-height: 0;
overflow: auto;
padding: 8px;
scrollbar-width: thin;
scrollbar-color: #31505b transparent;
}
.message-card {
width: 100%;
display: block;
text-align: left;
padding: 12px;
margin-bottom: 7px;
background: rgba(255, 255, 255, 0.035);
border: 1px solid transparent;
border-radius: 4px;
}
.message-card:hover {
background: rgba(255, 255, 255, 0.065);
}
.message-card.selected {
background: rgba(125, 225, 212, 0.07);
border-color: rgba(125, 225, 212, 0.42);
}
.card-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 8px;
}
.status-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 6px;
border: 1px solid currentColor;
border-radius: 3px;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.status-badge::before {
content: "";
width: 5px;
height: 5px;
background: currentColor;
box-shadow: 0 0 8px currentColor;
}
.verified {
color: var(--verified);
}
.unverified {
color: var(--unverified);
}
.corrected {
color: var(--corrected);
}
.card-id {
color: #6f8a93;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
}
.message-card h3 {
margin: 0;
font-size: 12px;
font-weight: 680;
line-height: 1.38;
}
.card-source {
margin-top: 8px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.card-source strong {
color: #bcd0d4;
font-weight: 650;
}
.card-metrics {
display: flex;
gap: 12px;
margin-top: 9px;
color: #78939b;
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.feed-foot {
padding: 11px 13px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 9px;
line-height: 1.5;
}
.feed-foot strong {
color: #c7d8db;
}
.inspector {
top: 88px;
right: 18px;
bottom: 102px;
width: 380px;
overflow: auto;
scrollbar-width: thin;
scrollbar-color: #31505b transparent;
}
.inspector-inner {
padding: 17px;
}
.claim-id {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 12px;
}
.claim-id code {
color: #83a2aa;
font-size: 10px;
}
.claim-quote {
margin: 0 0 17px;
font-size: 20px;
font-weight: 710;
line-height: 1.27;
letter-spacing: -0.025em;
}
.source-box {
padding: 12px;
margin-bottom: 17px;
background: rgba(125, 225, 212, 0.055);
border: 1px solid rgba(125, 225, 212, 0.18);
border-left: 3px solid var(--accent);
}
.source-box .label {
margin-bottom: 5px;
color: var(--accent);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.source-box strong {
display: block;
font-size: 12px;
line-height: 1.35;
}
.source-box small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 18px 0 9px;
}
.section-title h3 {
margin: 0;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.section-title span {
color: #6f8a93;
font-size: 8px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.metric-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
}
.metric {
padding: 10px;
background: rgba(255, 255, 255, 0.035);
border: 1px solid var(--line);
}
.metric strong {
display: block;
font-size: 18px;
font-variant-numeric: tabular-nums;
}
.metric span {
display: block;
margin-top: 5px;
color: var(--muted);
font-size: 8px;
line-height: 1.3;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.evidence-list {
display: grid;
gap: 7px;
}
.evidence-item {
display: grid;
grid-template-columns: 22px 1fr;
gap: 9px;
padding: 10px;
background: rgba(255, 255, 255, 0.032);
border: 1px solid var(--line);
}
.evidence-icon {
width: 22px;
height: 22px;
display: grid;
place-items: center;
color: var(--accent);
border: 1px solid rgba(125, 225, 212, 0.32);
font-size: 10px;
}
.evidence-item strong {
display: block;
font-size: 10px;
line-height: 1.35;
}
.evidence-item p {
margin: 4px 0 0;
color: var(--muted);
font-size: 9px;
line-height: 1.48;
}
.verification-box {
padding: 12px;
background: rgba(88, 223, 168, 0.055);
border: 1px solid rgba(88, 223, 168, 0.2);
}
.verification-box.unverified {
background: rgba(245, 196, 91, 0.055);
border-color: rgba(245, 196, 91, 0.22);
}
.verification-box.corrected {
background: rgba(255, 113, 109, 0.055);
border-color: rgba(255, 113, 109, 0.22);
}
.verification-box p {
margin: 0;
color: #b7c9cc;
font-size: 10px;
line-height: 1.55;
}
.correction-notice {
margin-top: 9px;
padding: 12px;
background: rgba(255, 113, 109, 0.09);
border: 1px solid rgba(255, 113, 109, 0.35);
border-left: 4px solid var(--corrected);
}
.correction-notice h4 {
margin: 0 0 6px;
color: #ffaaa7;
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.correction-notice p {
margin: 0;
color: #d8c2c0;
font-size: 10px;
line-height: 1.5;
}
.guardrail {
display: grid;
grid-template-columns: 7px 1fr;
gap: 10px;
margin-top: 16px;
padding: 11px;
color: #a8bdc1;
background: rgba(245, 196, 91, 0.055);
border: 1px solid rgba(245, 196, 91, 0.17);
font-size: 9px;
line-height: 1.5;
}
.guardrail::before {
content: "";
width: 7px;
height: 7px;
margin-top: 3px;
background: var(--unverified);
box-shadow: 0 0 10px rgba(245, 196, 91, 0.38);
}
.event-log {
display: grid;
gap: 7px;
}
.event-row {
display: grid;
grid-template-columns: 54px 1fr;
gap: 8px;
color: var(--muted);
font-size: 9px;
line-height: 1.4;
}
.event-row time {
color: #6f8a93;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.inspector-actions {
display: flex;
gap: 7px;
margin-top: 18px;
}
.small-button {
padding: 8px 10px;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.control-dock {
position: fixed;
z-index: 18;
left: 362px;
right: 414px;
bottom: 18px;
display: flex;
align-items: center;
gap: 8px;
min-height: 65px;
padding: 10px 12px;
background: rgba(7, 20, 28, 0.91);
border: 1px solid var(--line);
border-radius: 5px;
backdrop-filter: blur(14px);
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.24);
}
.control-dock button,
.control-dock select {
height: 34px;
padding: 0 10px;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.control-label {
display: flex;
align-items: center;
gap: 6px;
color: var(--muted);
font-size: 9px;
white-space: nowrap;
}
.control-label input {
accent-color: var(--accent);
}
.gesture-hint {
margin-left: auto;
color: #718b93;
font-size: 8px;
text-align: right;
line-height: 1.4;
}
.live-ticker {
position: fixed;
z-index: 17;
left: 362px;
right: 414px;
bottom: 88px;
min-height: 22px;
padding: 5px 9px;
overflow: hidden;
color: #8ca8af;
background: rgba(7, 20, 28, 0.72);
border-left: 2px solid var(--accent);
font-size: 9px;
white-space: nowrap;
text-overflow: ellipsis;
}
.scene-label {
position: absolute;
z-index: 4;
pointer-events: none;
transform: translate(-50%, -100%);
white-space: nowrap;
will-change: left, top;
}
.node-label {
padding: 5px 8px;
color: #eef8f7;
background: rgba(6, 19, 26, 0.86);
border: 1px solid rgba(164, 205, 216, 0.23);
border-bottom: 2px solid #7de1d4;
border-radius: 2px;
box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.node-label small {
display: block;
margin-top: 3px;
color: #79949c;
font-size: 7px;
font-weight: 600;
letter-spacing: 0.06em;
}
.source-label {
max-width: 220px;
padding: 6px 8px 6px 9px;
color: #dcebea;
background: rgba(6, 18, 24, 0.91);
border: 1px solid rgba(164, 205, 216, 0.22);
border-left: 3px solid var(--status-color, #7de1d4);
border-radius: 2px;
box-shadow: 0 7px 22px rgba(0, 0, 0, 0.3);
transform: translate(-50%, calc(-100% - 10px));
}
.source-label .source-kicker {
display: block;
margin-bottom: 3px;
color: var(--status-color, #7de1d4);
font-size: 7px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.source-label strong {
display: block;
overflow: hidden;
font-size: 8px;
line-height: 1.3;
text-overflow: ellipsis;
}
.correction-mini {
display: inline-block;
margin-top: 5px;
padding: 3px 4px;
color: #ffaaa7;
background: rgba(255, 113, 109, 0.13);
border: 1px solid rgba(255, 113, 109, 0.38);
font-size: 6px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 1120px) {
.top-stat {
min-width: 75px;
padding-inline: 9px;
}
.fiction-badge {
display: none;
}
.feed-panel {
width: 294px;
}
.inspector {
width: 340px;
}
.control-dock,
.live-ticker {
left: 326px;
right: 372px;
}
.gesture-hint {
display: none;
}
}
@media (max-width: 880px) {
.top-stats {
display: none;
}
.feed-panel {
top: 82px;
bottom: auto;
max-height: 43vh;
width: 275px;
}
.inspector {
top: auto;
left: 12px;
right: 12px;
bottom: 92px;
width: auto;
max-height: 48vh;
}
.control-dock {
left: 12px;
right: 12px;
bottom: 12px;
overflow-x: auto;
}
.live-ticker {
left: 12px;
right: 12px;
bottom: 78px;
}
}
@media (max-width: 560px) {
.topbar {
height: 66px;
padding: 0 13px;
}
.brand h1 {
font-size: 13px;
}
.feed-panel {
display: none;
}
.inspector {
bottom: 96px;
max-height: 55vh;
}
.control-label span {
display: none;
}
.control-dock {
gap: 6px;
}
}
</style>
</head>
<body>
<div id="viewport" aria-label="Interactive voxel village network visualization"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"><i></i><i></i><i></i></div>
<div>
<h1>Traceline</h1>
<p>Village claim network</p>
</div>
</div>
<div class="top-stats" aria-label="Network summary">
<div class="top-stat">
<strong id="statVillages">7</strong>
<span>Villages</span>
</div>
<div class="top-stat">
<strong id="statSupported">4/6</strong>
<span>Supported claims</span>
</div>
<div class="top-stat">
<strong id="statTouches">0</strong>
<span>Unique touches</span>
</div>
<div class="top-stat">
<strong id="statSightings">0</strong>
<span>Packet sightings</span>
</div>
</div>
<div class="fiction-badge">Fictional simulation</div>
</header>
<section class="panel feed-panel" aria-labelledby="feedTitle">
<div class="panel-heading">
<p class="eyebrow">Live network</p>
<h2 id="feedTitle">Messages in motion</h2>
<p>Follow claims through the village network. Source and verification state travel with each packet.</p>
</div>
<div class="filters" role="group" aria-label="Filter messages">
<button class="filter active" data-filter="all">All</button>
<button class="filter" data-filter="supported">Supported</button>
<button class="filter" data-filter="review">Needs review</button>
<button class="filter" data-filter="corrected">Corrected</button>
</div>
<div id="feedList"></div>
<div class="feed-foot">
<strong>Reading the scene:</strong> packet size stays constant. Color represents verification state, not popularity. More sightings do not make a claim true.
</div>
</section>
<aside class="panel inspector" id="inspector" aria-label="Claim dossier"></aside>
<div class="live-ticker" id="liveTicker" aria-live="polite">
Monitoring fictional village traffic…
</div>
<nav class="control-dock" aria-label="Scene controls">
<button id="playButton" type="button">Pause</button>
<button id="restartButton" type="button">Restart</button>
<label class="control-label">
<span>Speed</span>
<select id="speedSelect" aria-label="Animation speed">
<option value="0.5">0.5×</option>
<option value="1" selected>1×</option>
<option value="1.8">1.8×</option>
<option value="3">3×</option>
</select>
</label>
<label class="control-label">
<input id="routeToggle" type="checkbox" checked />
<span>Selected route</span>
</label>
<label class="control-label">
<input id="labelToggle" type="checkbox" checked />
<span>Labels</span>
</label>
<button id="overviewButton" type="button">Overview</button>
<div class="gesture-hint">
Drag to orbit · Shift-drag to pan<br />
Scroll to zoom · Click a packet
</div>
</nav>
<noscript>This visualization requires JavaScript.</noscript>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (selector) => document.querySelector(selector);
const viewport = $("#viewport");
const STATUS = {
verified: {
label: "Verified",
color: "#58dfa8",
filter: "supported"
},
unverified: {
label: "Needs review",
color: "#f5c45b",
filter: "review"
},
corrected: {
label: "Corrected",
color: "#ff716d",
filter: "corrected"
}
};
const villages = [
{ id: "northgate", name: "Northgate", region: "Upper terraces", x: -7.0, z: -5.2 },
{ id: "pinehill", name: "Pine Hill", region: "West ridge", x: -0.5, z: -8.0 },
{ id: "eastmarket", name: "East Market", region: "Trading quarter", x: 7.0, z: -4.6 },
{ id: "riverbend", name: "Riverbend", region: "Central ford", x: 8.0, z: 3.0 },
{ id: "oldforge", name: "Old Forge", region: "South workshop", x: 2.0, z: 8.2 },
{ id: "southfield", name: "Southfield", region: "Farm belt", x: -5.0, z: 7.2 },
{ id: "hillcrest", name: "Hillcrest", region: "Upper school", x: -9.0, z: 1.8 }
];
const villageById = new Map(villages.map((village) => [village.id, village]));
const links = [
["northgate", "pinehill"],
["northgate", "hillcrest"],
["pinehill", "eastmarket"],
["pinehill", "hillcrest"],
["eastmarket", "riverbend"],
["hillcrest", "riverbend"],
["hillcrest", "southfield"],
["riverbend", "oldforge"],
["riverbend", "southfield"],
["southfield", "oldforge"]
];
const messages = [
{
id: "BR-17",
claim: "The Mill Bridge is open to carts.",
source: "Northgate Works Board",
sourceKind: "Public works bulletin",
status: "verified",
path: ["northgate", "pinehill", "eastmarket"],
evidence: [
{
title: "Bridge inspection BR-17",
detail: "Independent inspection covers the deck, rails, and load path; all checks passed."
},
{
title: "Load-test log",
detail: "A test cart completed the crossing at 09:10 and the result is attached to the public record."
}
],
verification:
"Two traceable records support the claim. The source is accountable and the evidence can be reviewed independently.",
correction: null
},
{
id: "WQ-04",
claim: "The east well water is unsafe to drink.",
source: "Anonymous market post",
sourceKind: "Anonymous social post",
status: "unverified",
path: ["eastmarket", "riverbend", "oldforge"],
evidence: [
{
title: "Household report",
detail: "One resident reported a change in water odor. This establishes a concern, not a general result."
},
{
title: "Water sample pending",
detail: "A sample has been submitted. No completed laboratory result is available in this simulation."
}
],
verification:
"The safety question is legitimate, but the broad claim has no completed test. Uncertainty is not disproof, and repetition adds no evidence.",
correction: null
},
{
id: "MK-22",
claim: "Grain prices will double by Friday.",
source: "Trader forum thread",
sourceKind: "Anonymous forum",
status: "corrected",
path: ["oldforge", "southfield", "riverbend", "hillcrest"],
evidence: [
{
title: "Two-day market receipts",
detail: "Receipts show a modest week-on-week rise, not a doubling."
},
{
title: "Official price index",
detail: "The published index remains within its normal seasonal range."
}
],
verification:
"The available records do not support the forecast. The claim is treated as false and a correction is attached to the packet.",
correction: {
title: "Correction issued at 14:20",
body: "The original thread treated a temporary quote as a citywide price. The forecast was withdrawn and this notice was added to every onward copy."
}
},
{
id: "SC-09",
claim: "Hillcrest school has spare sleeping cots.",
source: "Hillcrest School Desk",
sourceKind: "Institutional inventory notice",
status: "verified",
path: ["hillcrest", "southfield", "riverbend"],
evidence: [
{
title: "School inventory count",
detail: "The signed count lists eleven available cots and their storage location."
},
{
title: "Volunteer roster",
detail: "The roster confirms the equipment is reserved for the current shelter plan."
}
],
verification:
"The inventory count and roster independently match the claim. The record identifies who checked the count and when.",
correction: null
},
{
id: "RF-12",
claim: "The south road is flooded and impassable.",
source: "Road crew radio log",
sourceKind: "Operational radio log",
status: "verified",
path: ["southfield", "oldforge", "riverbend"],
evidence: [
{
title: "Road crew photo log",
detail: "Timestamped images show standing water across the southern lane."
},
{
title: "Depth sensor record",
detail: "The sensor measured 18 centimeters, exceeding the posted cart threshold."
}
],
verification:
"The photographs and sensor measurement agree. The claim is supported as a time-stamped description of that road condition.",
correction: null
},
{
id: "PD-03",
claim: "The village meeting moved to the Old Forge.",
source: "Old Forge notice board",
sourceKind: "Posted public notice",
status: "verified",
path: ["oldforge", "riverbend", "hillcrest"],
evidence: [
{
title: "Meeting notice",
detail: "The notice lists the Old Forge and the revised start time."
},
{
title: "Hall booking sheet",
detail: "The booking sheet independently confirms the room reservation."
}
],
verification:
"The public notice and the booking record agree. This verifies the announced venue and time, not every detail in the meeting.",
correction: null
}
];
const state = {
paused: window.matchMedia("(prefers-reduced-motion: reduce)").matches,
speed: 1,
filter: "all",
showRoute: true,
showLabels: true,
selection: { type: "message", id: "BR-17" },
globalEvents: []
};
const scene = new THREE.Scene();
scene.background = new THREE.Color("#091821");
scene.fog = new THREE.Fog("#091821", 34, 62);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.domElement.setAttribute(
"aria-label",
"Voxel village network. Drag to orbit, shift-drag to pan, scroll to zoom, and click packets."
);
viewport.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-15, 15, 10.5, -10.5, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0, 0);
let cameraTheta = 0.72;
let cameraPhi = 0.76;
let cameraRadius = 25;
scene.add(new THREE.HemisphereLight(0xb8e6e5, 0x263329, 2.1));
const sun = new THREE.DirectionalLight(0xffefd1, 3.1);
sun.position.set(-11, 19, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.0005;
scene.add(sun);
const rimLight = new THREE.DirectionalLight(0x6ed8e6, 1.2);
rimLight.position.set(14, 9, -12);
scene.add(rimLight);
const world = new THREE.Group();
scene.add(world);
const roads = new THREE.Group();
const routeHighlight = new THREE.Group();
const villageGroup = new THREE.Group();
const packetGroup = new THREE.Group();
world.add(roads, routeHighlight, villageGroup, packetGroup);
const pickables = [];
const labelItems = [];
const nodeObjects = new Map();
const messageObjects = new Map();
function makeBox(parent, width, height, depth, x, y, z, color, options = {}) {
const geometry = new THREE.BoxGeometry(width, height, depth);
const material = new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.82,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
if (options.rotationY) mesh.rotation.y = options.rotationY;
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
function random(index) {
const value = Math.sin(index * 12.9898 + 78.233) * 43758.5453;
return value - Math.floor(value);
}
function riverX(z) {
return 1.6 + Math.sin(z * 0.48) * 1.25;
}
function buildTerrain() {
const tileSize = 1.05;
const count = 25 * 25;
const tiles = new THREE.InstancedMesh(
new THREE.BoxGeometry(1.025, 0.48, 1.025),
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.98
}),
count
);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
let instance = 0;
for (let gx = -12; gx <= 12; gx++) {
for (let gz = -12; gz <= 12; gz++) {
const x = gx * tileSize;
const z = gz * tileSize;
const water = Math.abs(gx - riverX(gz)) < 1.18;
const variation = random(gx * 31 + gz * 17);
dummy.position.set(x, water ? -0.31 : -0.24, z);
dummy.rotation.y = 0;
dummy.scale.set(1, water ? 0.65 : 1, 1);
dummy.updateMatrix();
tiles.setMatrixAt(instance, dummy.matrix);
if (water) {
color.set("#347d92");
} else if (variation > 0.84) {
color.set("#58715b");
} else if (variation > 0.62) {
color.set("#6c815f");
} else if (variation > 0.35) {
color.set("#748d65");
} else {
color.set("#81966a");
}
tiles.setColorAt(instance, color);
instance++;
}
}
tiles.instanceMatrix.needsUpdate = true;
if (tiles.instanceColor) tiles.instanceColor.needsUpdate = true;
tiles.receiveShadow = true;
world.add(tiles);
makeBox(
world,
28,
0.75,
28,
0,
-0.78,
0,
"#173138",
{ castShadow: false }
);
// Blocky perimeter mountains.
const mountainColors = ["#4d5b58", "#56615b", "#42514f"];
const mountainPositions = [
[-11.8, -10.5, 2.7],
[-7.5, -11.3, 3.8],
[6.2, -11.1, 2.9],
[11.6, -7.6, 3.3],
[11.8, 7.9, 2.8],
[6.6, 11.2, 2.2],
[-8.8, 11.2, 2.8],
[-12.1, 7.2, 2.3]
];
mountainPositions.forEach((position, index) => {
const [x, z, height] = position;
makeBox(
world,
3.2 + index % 2,
height,
2.8,
x,
height / 2 - 0.1,
z,
mountainColors[index % mountainColors.length]
);
makeBox(
world,
2.1,
1.5,
2.0,
x + 0.35,
height + 0.45,
z - 0.2,
"#66716a"
);
});
// Small cubic clouds.
const cloudMaterial = new THREE.MeshBasicMaterial({
color: 0xd9eeee,
transparent: true,
opacity: 0.55
});
[
[-9, 7.2, -9],
[5, 8.5, -11],
[11, 6.8, 3]
].forEach(([x, y, z], index) => {
const group = new THREE.Group();
group.position.set(x, y, z);
group.userData.cloudOffset = index;
world.add(group);
const p1 = new THREE.Mesh(new THREE.BoxGeometry(1.7, 0.45, 0.65), cloudMaterial);
const p2 = new THREE.Mesh(new THREE.BoxGeometry(0.9, 0.85, 0.65), cloudMaterial);
p2.position.set(-0.25, 0.18, 0);
const p3 = new THREE.Mesh(new THREE.BoxGeometry(0.65, 0.55, 0.65), cloudMaterial);
p3.position.set(0.65, -0.04, 0);
group.add(p1, p2, p3);
});
}
function buildRoads() {
links.forEach(([fromId, toId], linkIndex) => {
const from = villageById.get(fromId);
const to = villageById.get(toId);
const dx = to.x - from.x;
const dz = to.z - from.z;
const length = Math.hypot(dx, dz);
const angle = -Math.atan2(dz, dx);
const midpointX = (from.x + to.x) / 2;
const midpointZ = (from.z + to.z) / 2;
makeBox(
roads,
length,
0.09,
0.48,
midpointX,
0.055,
midpointZ,
"#c3aa7b",
{ rotationY: angle, castShadow: false }
);
const dashCount = Math.max(2, Math.floor(length / 1.6));
for (let i = 0; i < dashCount; i++) {
const t = (i + 0.5) / dashCount;
makeBox(
roads,
0.38,
0.025,
0.075,
from.x + dx * t,
0.115,
from.z + dz * t,
"#efe1b7",
{ rotationY: angle, castShadow: false }
);
}
});
}
function buildVillage(village, villageIndex) {
const group = new THREE.Group();
group.position.set(village.x, 0, village.z);
villageGroup.add(group);
makeBox(group, 2.9, 0.14, 2.7, 0, 0.06, 0, "#8c9874");
const marker = makeBox(
group,
0.48,
2.15,
0.48,
0,
1.25,
-0.35,
"#dce7df",
{ emissive: "#315d63", emissiveIntensity: 0.18 }
);
makeBox(
group,
0.8,
0.23,
0.8,
0,
2.42,
-0.35,
"#74d8ce",
{ emissive: "#2a938a", emissiveIntensity: 0.35 }
);
marker.userData = { type: "village", id: village.id };
pickables.push(marker);
const offsets = [
[-1.25, -0.78],
[1.16, -0.7],
[1.3, 0.8],
[-1.05, 1.05],
[-0.25, 1.55]
];
const wallColors = ["#d7c29e", "#c7d3c0", "#d8b39d", "#c5bca4", "#d5d1b6"];
const roofColors = ["#784f45", "#5d716c", "#8a624e", "#526b70", "#8b6048"];
offsets.forEach(([offsetX, offsetZ], buildingIndex) => {
const width = 0.68 + random(villageIndex * 19 + buildingIndex) * 0.22;
const depth = 0.7 + random(villageIndex * 29 + buildingIndex * 3) * 0.2;
const height = 0.65 + random(villageIndex * 7 + buildingIndex) * 0.4;
const building = new THREE.Group();
building.position.set(offsetX, 0.13, offsetZ);
building.rotation.y = (random(villageIndex * 11 + buildingIndex) - 0.5) * 0.5;
group.add(building);
makeBox(
building,
width,
height,
depth,
0,
height / 2,
0,
wallColors[(villageIndex + buildingIndex) % wallColors.length]
);
makeBox(
building,
width + 0.16,
0.18,
depth + 0.16,
0,
height + 0.08,
0,
roofColors[(villageIndex + buildingIndex) % roofColors.length]
);
makeBox(
building,
0.14,
0.26,
0.14,
width * 0.25,
height + 0.26,
-depth * 0.18,
"#735c52"
);
const windowMaterial = new THREE.MeshBasicMaterial({ color: 0xffd78d });
const windowGeometry = new THREE.BoxGeometry(0.15, 0.16, 0.035);
[-0.22, 0.22].forEach((windowX) => {
const windowMesh = new THREE.Mesh(windowGeometry, windowMaterial);
windowMesh.position.set(windowX, height * 0.55, -depth / 2 - 0.022);
building.add(windowMesh);
});
});
const treeOffsets = [
[-2.1, 0.3],
[2.0, 0.5],
[0.4, -2.0],
[-0.8, 2.1]
];
treeOffsets.forEach(([treeX, treeZ], treeIndex) => {
const tree = new THREE.Group();
tree.position.set(treeX, 0.08, treeZ);
group.add(tree);
const trunkHeight = 0.5 + random(villageIndex * 37 + treeIndex) * 0.3;
makeBox(tree, 0.17, trunkHeight, 0.17, 0, trunkHeight / 2, 0, "#6b523d");
const canopyColor = treeIndex % 2 ? "#3f6954" : "#4f7658";
makeBox(tree, 0.75, 0.72, 0.75, 0, trunkHeight + 0.25, 0, canopyColor);
makeBox(tree, 0.54, 0.56, 0.54, 0.06, trunkHeight + 0.73, 0, "#5e8260");
});
const label = document.createElement("div");
label.className = "scene-label node-label";
label.innerHTML = `${village.name}<small>0 claims received</small>`;
viewport.appendChild(label);
const labelPosition = new THREE.Vector3(village.x, 3.15, village.z);
labelItems.push({
element: label,
position: () => labelPosition,
kind: "node"
});
nodeObjects.set(village.id, {
village,
group,
marker,
label,
received: new Map()
});
}
function buildPackets() {
messages.forEach((message, messageIndex) => {
const color = STATUS[message.status].color;
const group = new THREE.Group();
packetGroup.add(group);
const packet = makeBox(
group,
0.34,
0.34,
0.34,
0,
0,
0,
color,
{
emissive: color,
emissiveIntensity: 0.55,
metalness: 0.12,
roughness: 0.42
}
);
packet.userData = { type: "message", id: message.id };
pickables.push(packet);
const outline = new THREE.LineSegments(
new THREE.EdgesGeometry(new THREE.BoxGeometry(0.46, 0.46, 0.46)),
new THREE.LineBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.55
})
);
group.add(outline);
const notice = makeBox(
group,
0.15,
0.15,
0.15,
0.45,
0.4,
0,
"#ff716d",
{
emissive: "#ff716d",
emissiveIntensity: 0.75,
castShadow: false
}
);
notice.visible = message.status === "corrected";
const sourceLabel = document.createElement("div");
sourceLabel.className = "scene-label source-label";
sourceLabel.style.setProperty("--status-color", color);
sourceLabel.innerHTML = `
<span class="source-kicker">Source · ${message.id}</span>
<strong>${message.source}</strong>
${
message.status === "corrected"
? '<span class="correction-mini">Correction attached</span>'
: ""
}
`;
viewport.appendChild(sourceLabel);
labelItems.push({
element: sourceLabel,
position: () => group.position,
kind: "source"
});
messageObjects.set(message.id, {
packet,
group,
outline,
notice,
sourceLabel
});
resetMessage(message, messageIndex);
});
}
function resetMessage(message, messageIndex) {
const originId = message.path[0];
const originNode = nodeObjects.get(originId);
if (originNode) {
originNode.received.set(message.id, {
firstSeen: timeStamp(),
hits: 1
});
}
message.uniqueRecipients = new Set([originId]);
message.exposures = 1;
message.progress = 0;
message.lastArrival = 0;
message.delay = messageIndex * 0.72;
message.wait = 0;
message.needsReset = false;
message.cycle = 0;
message.events = [
{
time: timeStamp(),
text: `Posted by ${message.source} in ${villageById.get(originId).name}.`
}
];
}
function timeStamp() {
return new Date().toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false
});
}
function logGlobal(text) {
state.globalEvents.unshift({ time: timeStamp(), text });
state.globalEvents = state.globalEvents.slice(0, 12);
$("#liveTicker").textContent = `${timeStamp()} / ${text}`;
}
function arriveMessage(message, pathIndex, repeat = false) {
const nodeId = message.path[pathIndex];
const node = nodeObjects.get(nodeId);
const isNewRecipient = !message.uniqueRecipients.has(nodeId);
if (pathIndex === 0 && !repeat) return;
if (isNewRecipient) {
message.uniqueRecipients.add(nodeId);
message.exposures += 1;
} else {
message.exposures += 1;
}
const existingReceipt = node.received.get(message.id);
if (existingReceipt) {
existingReceipt.hits += 1;
} else {
node.received.set(message.id, {
firstSeen: timeStamp(),
hits: 1
});
}
const eventText = isNewRecipient
? `First reached ${node.village.name}.`
: `Repeated at ${node.village.name}.`;
message.events.push({ time: timeStamp(), text: eventText });
message.events = message.events.slice(-12);
logGlobal(`${message.id}: ${eventText}`);
renderFeed();
updateStats();
if (
(state.selection.type === "message" && state.selection.id === message.id) ||
(state.selection.type === "village" && state.selection.id === nodeId)
) {
renderInspector();
}
}
function updateMessages(delta, elapsed) {
messages.forEach((message) => {
const object = messageObjects.get(message.id);
if (message.delay > 0) {
message.delay -= delta;
return;
}
if (message.wait > 0) {
message.wait -= delta;
if (message.wait <= 0 && message.needsReset) {
message.cycle += 1;
message.progress = 0;
message.lastArrival = 0;
message.needsReset = false;
arriveMessage(message, 0, true);
}
return;
}
message.progress += delta * 0.245 * state.speed;
const arrivalIndex = Math.floor(message.progress + 0.00001);
while (
message.lastArrival < arrivalIndex &&
message.lastArrival + 1 < message.path.length
) {
message.lastArrival += 1;
arriveMessage(message, message.lastArrival, false);
}
const pathLength = message.path.length;
if (message.progress >= pathLength - 1) {
message.progress = pathLength - 1;
message.wait = 1.5;
message.needsReset = true;
}
const segment = Math.min(
Math.floor(message.progress),
pathLength - 2
);
const localT = Math.min(1, Math.max(0, message.progress - segment));
const from = villageById.get(message.path[segment]);
const to = villageById.get(message.path[segment + 1]);
const x = THREE.MathUtils.lerp(from.x, to.x, localT);
const z = THREE.MathUtils.lerp(from.z, to.z, localT);
const arc = Math.sin(localT * Math.PI);
object.group.position.set(
x,
1.08 + arc * 0.82 + Math.sin(elapsed * 3 + message.path.length) * 0.04,
z
);
object.group.rotation.y += delta * 0.75;
if (message.status === "corrected") {
object.notice.position.set(
Math.sin(elapsed * 3.1) * 0.44,
0.4 + Math.sin(elapsed * 4) * 0.12,
Math.cos(elapsed * 3.1) * 0.44
);
object.notice.rotation.y += delta * 2;
}
});
}
function clearGroup(group) {
while (group.children.length) {
const child = group.children.pop();
child.geometry?.dispose();
if (Array.isArray(child.material)) {
child.material.forEach((material) => material.dispose());
} else {
child.material?.dispose();
}
}
}
function updateRouteHighlight() {
clearGroup(routeHighlight);
if (!state.showRoute || state.selection.type !== "message") return;
const message = messages.find((item) => item.id === state.selection.id);
if (!message) return;
const color = STATUS[message.status].color;
for (let i = 0; i < message.path.length - 1; i++) {
const from = villageById.get(message.path[i]);
const to = villageById.get(message.path[i + 1]);
const dx = to.x - from.x;
const dz = to.z - from.z;
const length = Math.hypot(dx, dz);
makeBox(
routeHighlight,
length,
0.055,
0.22,
(from.x + to.x) / 2,
0.16,
(from.z + to.z) / 2,
color,
{
rotationY: -Math.atan2(dz, dx),
emissive: color,
emissiveIntensity: 0.65,
transparent: true,
opacity: 0.82,
castShadow: false
}
);
}
}
function updatePacketSelection() {
messages.forEach((message) => {
const object = messageObjects.get(message.id);
const selected =
state.selection.type === "message" &&
state.selection.id === message.id;
object.group.scale.setScalar(selected ? 1.32 : 1);
object.outline.material.opacity = selected ? 0.95 : 0.38;
object.packet.material.emissiveIntensity = selected ? 0.95 : 0.55;
});
}
function setSelection(type, id) {
state.selection = { type, id };
updateRouteHighlight();
updatePacketSelection();
renderFeed();
renderInspector();
}
function statusBadge(status) {
const meta = STATUS[status];
return `<span class="status-badge ${status}">${meta.label}</span>`;
}
function renderFeed() {
const list = $("#feedList");
const filtered = messages.filter((message) => {
if (state.filter === "all") return true;
return STATUS[message.status].filter === state.filter;
});
list.innerHTML = filtered
.map((message) => {
const selected =
state.selection.type === "message" &&
state.selection.id === message.id;
return `
<button
class="message-card ${selected ? "selected" : ""}"
data-message="${message.id}"
type="button"
aria-pressed="${selected}"
>
<div class="card-top">
${statusBadge(message.status)}
<span class="card-id">${message.id}</span>
</div>
<h3>${message.claim}</h3>
<div class="card-source">
<strong>Source:</strong> ${message.source}
</div>
<div class="card-metrics">
<span>${message.uniqueRecipients.size} unique recipients</span>
<span>${message.exposures} sightings</span>
<span>${message.exposures - message.uniqueRecipients.size} repeats</span>
</div>
</button>
`;
})
.join("");
list.querySelectorAll("[data-message]").forEach((button) => {
button.addEventListener("click", () => {
setSelection("message", button.dataset.message);
});
});
}
function renderMessageInspector(message) {
const repeatSightings = message.exposures - message.uniqueRecipients.size;
const evidenceHeading =
message.status === "unverified"
? "Records & context"
: "Evidence records";
const events = message.events
.slice()
.reverse()
.slice(0, 6)
.map(
(event) => `
<div class="event-row">
<time>${event.time}</time>
<span>${event.text}</span>
</div>
`
)
.join("");
return `
<div class="inspector-inner">
<div class="claim-id">
<p class="eyebrow">Claim dossier</p>
${statusBadge(message.status)}
</div>
<blockquote class="claim-quote">“${message.claim}”</blockquote>
<div class="source-box">
<div class="label">Source label</div>
<strong>${message.source}</strong>
<small>${message.sourceKind} · ${message.id}</small>
</div>
<div class="section-title">
<h3>Dissemination</h3>
<span>Attention, not accuracy</span>
</div>
<div class="metric-grid">
<div class="metric">
<strong>${message.uniqueRecipients.size}</strong>
<span>Unique village recipients</span>
</div>
<div class="metric">
<strong>${message.exposures}</strong>
<span>Total packet sightings</span>
</div>
<div class="metric">
<strong>${repeatSightings}</strong>
<span>Repeated sightings</span>
</div>
</div>
<div class="section-title">
<h3>${evidenceHeading}</h3>
<span>${message.evidence.length} traceable items</span>
</div>
<div class="evidence-list">
${message.evidence
.map(
(evidence) => `
<div class="evidence-item">
<div class="evidence-icon">◆</div>
<div>
<strong>${evidence.title}</strong>
<p>${evidence.detail}</p>
</div>
</div>
`
)
.join("")}
</div>
<div class="section-title">
<h3>Verification</h3>
<span>${STATUS[message.status].label}</span>
</div>
<div class="verification-box ${message.status}">
<p>${message.verification}</p>
</div>
${
message.correction
? `
<div class="correction-notice">
<h4>${message.correction.title}</h4>
<p>${message.correction.body}</p>
</div>
`
: ""
}
<div class="guardrail">
Dissemination metrics record where a packet traveled and how often it was seen.
They do not vote on whether the claim is accurate.
</div>
<div class="section-title">
<h3>Dissemination log</h3>
<span>${message.cycle} recirculation cycles</span>
</div>
<div class="event-log">${events}</div>
<div class="inspector-actions">
<button class="small-button" id="focusSelection" type="button">
Focus in network
</button>
</div>
</div>
`;
}
function renderVillageInspector(node) {
const receipts = Array.from(node.received.entries()).reverse();
const receiptMarkup = receipts.length
? receipts
.map(([messageId, receipt]) => {
const message = messages.find((item) => item.id === messageId);
return `
<div class="evidence-item">
<div class="evidence-icon">${message.id.slice(0, 2)}</div>
<div>
<strong>${message.claim}</strong>
<p>
${STATUS[message.status].label} ·
first seen ${receipt.firstSeen} ·
${receipt.hits} sighting${receipt.hits === 1 ? "" : "s"}
</p>
</div>
</div>
`;
})
.join("")
: `<p style="color:var(--muted);font-size:10px;line-height:1.5">
No claim packets have arrived here yet.
</p>`;
const corrections = receipts.filter(([messageId]) => {
const message = messages.find((item) => item.id === messageId);
return message.status === "corrected";
});
return `
<div class="inspector-inner">
<div class="claim-id">
<p class="eyebrow">Village receipt log</p>
<span class="status-badge verified">Local node</span>
</div>
<blockquote class="claim-quote">${node.village.name}</blockquote>
<div class="source-box">
<div class="label">Network location</div>
<strong>${node.village.region}</strong>
<small>${receipts.length} distinct claim packet${receipts.length === 1 ? "" : "s"} received</small>
</div>
<div class="section-title">
<h3>Received claims</h3>
<span>Receipt is not endorsement</span>
</div>
<div class="evidence-list">${receiptMarkup}</div>
${
corrections.length
? `
<div class="correction-notice">
<h4>Correction received here</h4>
<p>
${corrections
.map(([messageId]) => {
const message = messages.find((item) => item.id === messageId);
return message.correction.body;
})
.join(" ")}
</p>
</div>
`
: ""
}
<div class="guardrail">
This village’s receipt count is a circulation record. A claim can be received often
and still be false, unverified, or corrected.
</div>
<div class="inspector-actions">
<button class="small-button" id="focusSelection" type="button">
Focus village
</button>
</div>
</div>
`;
}
function renderInspector() {
const inspector = $("#inspector");
if (state.selection.type === "message") {
const message = messages.find((item) => item.id === state.selection.id);
if (message) inspector.innerHTML = renderMessageInspector(message);
} else {
const node = nodeObjects.get(state.selection.id);
if (node) inspector.innerHTML = renderVillageInspector(node);
}
const focusButton = $("#focusSelection");
if (focusButton) focusButton.addEventListener("click", focusSelection);
}
function updateStats() {
const uniqueTouches = messages.reduce(
(total, message) => total + message.uniqueRecipients.size,
0
);
const sightings = messages.reduce(
(total, message) => total + message.exposures,
0
);
const supported = messages.filter(
(message) => message.status === "verified"
).length;
$("#statVillages").textContent = villages.length;
$("#statSupported").textContent = `${supported}/${messages.length}`;
$("#statTouches").textContent = uniqueTouches;
$("#statSightings").textContent = sightings;
}
function focusSelection() {
if (state.selection.type === "message") {
const message = messages.find((item) => item.id === state.selection.id);
const object = messageObjects.get(message.id);
cameraTarget.copy(object.group.position);
cameraTarget.y = 0;
cameraRadius = 18;
} else {
const node = nodeObjects.get(state.selection.id);
cameraTarget.set(node.village.x, 0, node.village.z);
cameraRadius = 18;
}
updateCamera();
}
function resetCamera() {
cameraTarget.set(0, 0, 0);
cameraTheta = 0.72;
cameraPhi = 0.76;
cameraRadius = 25;
updateCamera();
}
function updateCamera() {
const sinPhi = Math.sin(cameraPhi);
camera.position.set(
cameraTarget.x + cameraRadius * sinPhi * Math.sin(cameraTheta),
cameraTarget.y + cameraRadius * Math.cos(cameraPhi),
cameraTarget.z + cameraRadius * sinPhi * Math.cos(cameraTheta)
);
camera.lookAt(cameraTarget);
const aspect = viewport.clientWidth / Math.max(1, viewport.clientHeight);
const responsiveZoom = Math.min(1, aspect / 1.12);
camera.zoom = (28 / cameraRadius) * responsiveZoom;
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
function resize() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
const aspect = width / Math.max(1, height);
renderer.setSize(width, height);
camera.left = -10.5 * aspect;
camera.right = 10.5 * aspect;
camera.top = 10.5;
camera.bottom = -10.5;
updateCamera();
}
function updateLabels() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
labelItems.forEach((item) => {
if (!state.showLabels) {
item.element.hidden = true;
return;
}
const projected = item.position().clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.15 &&
projected.x < 1.15 &&
projected.y > -1.15 &&
projected.y < 1.15;
item.element.hidden = !visible;
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
item.element.style.left = `${x}px`;
item.element.style.top = `${y}px`;
});
nodeObjects.forEach((node) => {
const count = node.received.size;
node.label.querySelector("small").textContent =
`${count} claim${count === 1 ? "" : "s"} received`;
});
}
function restartSimulation() {
nodeObjects.forEach((node) => node.received.clear());
messages.forEach((message, index) => resetMessage(message, index));
state.globalEvents = [];
logGlobal("Simulation restarted; circulation counters reset.");
renderFeed();
renderInspector();
updateStats();
updatePacketSelection();
}
function togglePlayback() {
state.paused = !state.paused;
$("#playButton").textContent = state.paused ? "Resume" : "Pause";
}
// Custom camera controls, implemented directly without addons.
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let drag = null;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.button !== 2) return;
renderer.domElement.setPointerCapture(event.pointerId);
drag = {
startX: event.clientX,
startY: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
distance: 0,
mode: event.shiftKey || event.button === 2 ? "pan" : "orbit"
};
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!drag) return;
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.distance += Math.abs(dx) + Math.abs(dy);
if (drag.mode === "orbit") {
cameraTheta -= dx * 0.007;
cameraPhi = THREE.MathUtils.clamp(
cameraPhi - dy * 0.006,
0.42,
1.28
);
} else {
const scale = cameraRadius * 0.0013;
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3()
.crossVectors(forward, camera.up)
.normalize();
cameraTarget.addScaledVector(right, -dx * scale);
cameraTarget.addScaledVector(forward, -dy * scale);
cameraTarget.x = THREE.MathUtils.clamp(cameraTarget.x, -12, 12);
cameraTarget.z = THREE.MathUtils.clamp(cameraTarget.z, -12, 12);
}
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!drag) return;
if (drag.distance < 6) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(pickables, false)[0];
if (hit) {
const data = hit.object.userData;
setSelection(data.type, data.id);
}
}
drag = null;
});
renderer.domElement.addEventListener("pointercancel", () => {
drag = null;
});
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * Math.exp(event.deltaY * 0.001),
13,
46
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
document.querySelectorAll(".filter").forEach((button) => {
button.addEventListener("click", () => {
state.filter = button.dataset.filter;
document.querySelectorAll(".filter").forEach((filterButton) => {
filterButton.classList.toggle("active", filterButton === button);
});
renderFeed();
});
});
$("#playButton").addEventListener("click", togglePlayback);
$("#restartButton").addEventListener("click", restartSimulation);
$("#overviewButton").addEventListener("click", resetCamera);
$("#speedSelect").addEventListener("change", (event) => {
state.speed = Number(event.target.value);
});
$("#routeToggle").addEventListener("change", (event) => {
state.showRoute = event.target.checked;
updateRouteHighlight();
});
$("#labelToggle").addEventListener("change", (event) => {
state.showLabels = event.target.checked;
});
window.addEventListener("keydown", (event) => {
const tag = event.target.tagName;
if (tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA") return;
if (event.code === "Space") {
event.preventDefault();
togglePlayback();
}
if (event.key.toLowerCase() === "r") {
restartSimulation();
}
if (event.key === "ArrowLeft") cameraTheta -= 0.12;
if (event.key === "ArrowRight") cameraTheta += 0.12;
if (event.key === "ArrowUp") cameraPhi = Math.max(0.42, cameraPhi - 0.08);
if (event.key === "ArrowDown") cameraPhi = Math.min(1.28, cameraPhi + 0.08);
if (event.key === "+" || event.key === "=") cameraRadius = Math.max(13, cameraRadius - 2);
if (event.key === "-") cameraRadius = Math.min(46, cameraRadius + 2);
updateCamera();
});
window.addEventListener("resize", resize);
buildTerrain();
buildRoads();
villages.forEach((village, index) => buildVillage(village, index));
buildPackets();
updateCamera();
resize();
updateRouteHighlight();
updatePacketSelection();
renderFeed();
renderInspector();
updateStats();
logGlobal("Monitoring started. All claims, people, and records in this scene are fictional.");
if (state.paused) $("#playButton").textContent = "Resume";
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (!state.paused) {
updateMessages(delta, elapsed);
}
updateLabels();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```