Prompt specification
Build or customize the Three.js 3D scene "Oversight Detects an Incomplete Repair" 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: Oversight Detects an Incomplete Repair
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/oversight-detects-an-incomplete-repair-x3232
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring institutional roles, approval steps, and oversight. Create a toy public-works workflow where inspection can detect a missed requirement. Compare outcomes with and without independent verification under identical task instructions. Voxel style.
Working Three.js Starter (oversight-detects-an-incomplete-repair-x3232):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Civic Works Verification Lab</title>
<style>
:root {
--navy: #153243;
--navy-2: #0e2735;
--ink: #183444;
--muted: #627985;
--paper: #f7fafb;
--line: #d7e2e6;
--orange: #d97706;
--teal: #0f766e;
--green: #15803d;
--red: #c2413b;
--amber: #b45309;
--shadow: 0 14px 40px rgba(22, 50, 67, 0.12);
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: #e6eef1;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button,
input,
select {
font: inherit;
}
button {
border: 0;
}
.app-header {
height: 82px;
padding: 0 26px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 22px;
color: white;
background:
linear-gradient(110deg, rgba(255, 255, 255, 0.05), transparent 45%),
var(--navy-2);
border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
width: 43px;
height: 43px;
flex: 0 0 auto;
display: grid;
place-items: center;
color: #d9fff6;
background: #0f766e;
border: 1px solid rgba(255, 255, 255, 0.22);
box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.08);
font-size: 22px;
font-weight: 900;
}
.eyebrow {
margin: 0 0 4px;
color: #86d8cc;
font-size: 10px;
line-height: 1;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: clamp(17px, 2vw, 24px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.header-meta {
display: flex;
align-items: center;
gap: 10px;
flex: 0 0 auto;
}
.meta-pill {
padding: 8px 11px;
color: #c7d8df;
border: 1px solid rgba(255, 255, 255, 0.15);
background: rgba(255, 255, 255, 0.04);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.03em;
}
.meta-pill.live::before {
content: "";
display: inline-block;
width: 7px;
height: 7px;
margin-right: 7px;
background: #5eead4;
border-radius: 50%;
box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.12);
}
.workspace {
height: calc(100vh - 82px);
display: grid;
grid-template-columns: 320px minmax(0, 1fr);
}
.brief {
position: relative;
z-index: 4;
overflow-y: auto;
padding: 22px 20px 28px;
background: rgba(250, 252, 253, 0.98);
border-right: 1px solid var(--line);
box-shadow: 8px 0 30px rgba(28, 58, 73, 0.06);
}
.brief h2 {
margin: 7px 0 8px;
font-size: 22px;
line-height: 1.15;
letter-spacing: -0.04em;
}
.intro {
margin: 0 0 18px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.task-card {
padding: 14px;
background: #eef5f6;
border: 1px solid #d6e4e7;
border-left: 4px solid #0f766e;
border-radius: 4px;
}
.task-card .eyebrow {
color: var(--teal);
}
.task-card strong {
display: block;
margin: 7px 0 9px;
font-size: 13px;
line-height: 1.4;
}
.scope-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
}
.scope-cell {
padding: 8px 4px;
color: #385564;
background: white;
border: 1px solid #d7e4e7;
text-align: center;
font-size: 10px;
font-weight: 800;
}
.scope-cell::before {
content: "";
display: block;
width: 9px;
height: 9px;
margin: 0 auto 6px;
background: #2563eb;
border: 1px solid #1d4ed8;
box-shadow: inset 0 0 0 2px #93c5fd;
}
.control-card {
margin: 14px 0;
border: 1px solid var(--line);
border-radius: 5px;
overflow: hidden;
background: white;
}
.control-row {
display: grid;
grid-template-columns: 48px 1fr;
gap: 10px;
align-items: start;
padding: 11px 12px;
}
.control-row + .control-row {
border-top: 1px solid var(--line);
}
.lane-letter {
width: 34px;
height: 34px;
display: grid;
place-items: center;
color: white;
background: var(--orange);
font-size: 15px;
font-weight: 900;
}
.lane-letter.b {
background: var(--teal);
}
.control-row strong {
display: block;
margin-bottom: 3px;
font-size: 11px;
}
.control-row span {
display: block;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.run-panel {
margin-top: 17px;
padding-top: 16px;
border-top: 1px solid var(--line);
}
.button-row {
display: grid;
grid-template-columns: 1fr auto;
gap: 8px;
}
.primary,
.secondary {
min-height: 39px;
padding: 0 13px;
border-radius: 4px;
cursor: pointer;
font-size: 11px;
font-weight: 800;
transition:
transform 120ms ease,
background 120ms ease;
}
.primary {
color: white;
background: var(--navy);
}
.primary:hover {
background: #20475c;
transform: translateY(-1px);
}
.secondary {
color: var(--ink);
background: #e7eef1;
border: 1px solid #d2dfe4;
}
.secondary:hover {
background: #dce7eb;
}
.timeline-head {
margin: 14px 0 7px;
display: flex;
justify-content: space-between;
align-items: center;
color: var(--muted);
font-size: 10px;
font-weight: 700;
}
#timeValue {
color: var(--ink);
font-variant-numeric: tabular-nums;
}
#timeline {
width: 100%;
margin: 0;
accent-color: var(--teal);
cursor: pointer;
}
.speed-row {
margin: 9px 0 15px;
display: flex;
justify-content: space-between;
align-items: center;
color: var(--muted);
font-size: 10px;
}
#speed {
padding: 5px 7px;
color: var(--ink);
background: white;
border: 1px solid var(--line);
border-radius: 3px;
font-size: 10px;
}
.phase-title {
margin: 0 0 8px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.phase-list {
display: grid;
gap: 4px;
}
.phase-step {
position: relative;
min-height: 35px;
padding: 7px 8px 7px 34px;
color: #6c808a;
background: #f3f7f8;
border: 1px solid transparent;
border-radius: 4px;
font-size: 10px;
line-height: 1.25;
}
.phase-step::before {
content: attr(data-number);
position: absolute;
left: 9px;
top: 8px;
width: 17px;
height: 17px;
display: grid;
place-items: center;
color: #81939c;
background: #dfe8eb;
border-radius: 50%;
font-size: 9px;
font-weight: 900;
}
.phase-step strong {
display: block;
color: inherit;
font-size: 10px;
}
.phase-step small {
display: block;
margin-top: 2px;
color: #82939b;
font-size: 9px;
}
.phase-step.active {
color: #155e75;
background: #e8f5f7;
border-color: #b9dde2;
}
.phase-step.active::before {
color: white;
background: #0e7490;
}
.phase-step.done {
color: var(--green);
background: #edf7ef;
}
.phase-step.done::before {
color: white;
background: var(--green);
content: "✓";
}
.phase-step.warn {
color: var(--amber);
background: #fff5e9;
border-color: #f0d5b2;
}
.phase-step.warn::before {
color: white;
background: var(--amber);
}
.phase-step.fail {
color: var(--red);
background: #fff0ee;
border-color: #efc8c4;
}
.phase-step.fail::before {
color: white;
background: var(--red);
content: "!";
}
.method-note {
margin-top: 16px;
padding: 11px 12px;
color: #536c79;
background: #f2f6f7;
border: 1px dashed #c6d5da;
font-size: 10px;
line-height: 1.5;
}
.method-note strong {
color: var(--ink);
}
.stage {
min-width: 0;
min-height: 0;
display: grid;
grid-template-rows: minmax(0, 1fr) 186px;
}
#viewport {
position: relative;
min-height: 0;
overflow: hidden;
background: #dce9ee;
}
#viewport canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
z-index: 0;
touch-action: none;
cursor: grab;
}
#viewport canvas:active {
cursor: grabbing;
}
.scene-toolbar {
position: absolute;
z-index: 5;
top: 15px;
left: 16px;
right: 16px;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
pointer-events: none;
}
.view-switch {
display: flex;
padding: 3px;
background: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(50, 80, 94, 0.16);
border-radius: 5px;
box-shadow: 0 6px 18px rgba(29, 56, 69, 0.1);
pointer-events: auto;
}
.view-switch button {
padding: 8px 11px;
color: #56707d;
background: transparent;
border-radius: 3px;
cursor: pointer;
font-size: 10px;
font-weight: 800;
}
.view-switch button.active {
color: white;
background: var(--navy);
}
.scene-options {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 10px;
color: #496572;
background: rgba(255, 255, 255, 0.86);
border: 1px solid rgba(50, 80, 94, 0.14);
border-radius: 4px;
font-size: 10px;
pointer-events: auto;
}
.scene-options label {
display: flex;
align-items: center;
gap: 5px;
cursor: pointer;
}
.scene-options input {
accent-color: var(--teal);
}
.event-banner {
position: absolute;
z-index: 5;
top: 66px;
left: 50%;
max-width: min(620px, calc(100% - 40px));
padding: 10px 15px;
color: white;
background: rgba(18, 47, 62, 0.92);
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 4px;
box-shadow: 0 8px 24px rgba(22, 49, 63, 0.18);
opacity: 0;
transform: translate(-50%, -8px);
transition:
opacity 180ms ease,
transform 180ms ease;
text-align: center;
font-size: 11px;
line-height: 1.4;
pointer-events: none;
}
.event-banner.show {
opacity: 1;
transform: translate(-50%, 0);
}
.legend {
position: absolute;
z-index: 4;
left: 16px;
bottom: 14px;
display: flex;
flex-wrap: wrap;
gap: 6px;
max-width: calc(100% - 210px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 5px;
padding: 6px 8px;
color: #516d79;
background: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(50, 80, 94, 0.12);
border-radius: 3px;
font-size: 9px;
font-weight: 700;
}
.legend-dot {
width: 8px;
height: 8px;
border-radius: 2px;
}
.camera-hint {
position: absolute;
z-index: 4;
right: 16px;
bottom: 14px;
padding: 7px 9px;
color: #5d7480;
background: rgba(255, 255, 255, 0.82);
border: 1px solid rgba(50, 80, 94, 0.12);
border-radius: 3px;
font-size: 9px;
pointer-events: none;
}
#annotations {
position: absolute;
inset: 0;
z-index: 3;
overflow: hidden;
pointer-events: none;
}
.annotation {
position: absolute;
left: 0;
top: 0;
min-width: 76px;
padding: 5px 8px;
color: #274857;
background: rgba(255, 255, 255, 0.91);
border: 1px solid rgba(50, 80, 94, 0.16);
border-bottom: 2px solid #7b919c;
border-radius: 3px;
box-shadow: 0 5px 12px rgba(33, 60, 73, 0.1);
text-align: center;
white-space: nowrap;
will-change: transform;
}
.annotation.lane-title {
min-width: 180px;
padding: 7px 10px;
color: white;
background: rgba(18, 47, 62, 0.9);
border-color: rgba(255, 255, 255, 0.16);
border-bottom-color: #7dd3c7;
}
.annotation.lane-title.a {
border-bottom-color: #fbbf24;
}
.annotation.orange {
border-bottom-color: #f59e0b;
}
.annotation.blue {
border-bottom-color: #3b82f6;
}
.annotation.purple {
border-bottom-color: #8b5cf6;
}
.annotation.red {
border-bottom-color: #dc5148;
}
.annotation.green {
border-bottom-color: #22a35a;
}
.annotation .label-title {
display: block;
font-size: 8px;
font-weight: 900;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.annotation .label-sub {
display: block;
margin-top: 2px;
color: #6b818b;
font-size: 8px;
font-weight: 600;
}
.annotation.lane-title .label-sub {
color: #c8dbe2;
}
.outcomes {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
padding: 13px 15px 15px;
min-width: 0;
background: #edf3f5;
border-top: 1px solid var(--line);
}
.outcome-card {
position: relative;
min-width: 0;
padding: 12px 14px 11px;
background: white;
border: 1px solid var(--line);
border-top: 4px solid #8a9ca5;
border-radius: 5px;
box-shadow: 0 5px 16px rgba(25, 55, 68, 0.05);
transition:
border-color 180ms ease,
background 180ms ease;
}
.outcome-card.a {
border-top-color: var(--orange);
}
.outcome-card.b {
border-top-color: var(--teal);
}
.outcome-card.danger {
border-top-color: var(--red);
background: #fffafa;
}
.outcome-card.warning {
border-top-color: var(--amber);
background: #fffdf8;
}
.outcome-card.success {
border-top-color: var(--green);
background: #fbfffb;
}
.outcome-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
}
.outcome-kicker {
margin: 0 0 3px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.outcome-title {
margin: 0;
font-size: 14px;
letter-spacing: -0.025em;
}
.status-badge {
flex: 0 0 auto;
padding: 5px 7px;
color: #667d87;
background: #edf2f4;
border-radius: 3px;
font-size: 8px;
font-weight: 900;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.danger .status-badge {
color: #a3312c;
background: #fee7e5;
}
.warning .status-badge {
color: #955516;
background: #fff0d5;
}
.success .status-badge {
color: #166534;
background: #e3f5e8;
}
.outcome-detail {
min-height: 28px;
margin: 6px 0 8px;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
.decision-path {
display: flex;
align-items: center;
gap: 5px;
margin-bottom: 9px;
}
.decision-path span {
padding: 4px 6px;
color: #809199;
background: #f1f5f6;
border: 1px solid #e1e9eb;
border-radius: 3px;
font-size: 8px;
font-weight: 800;
}
.decision-path span.active {
color: #155e75;
background: #e9f5f7;
border-color: #b8dce2;
}
.decision-path span.done {
color: #166534;
background: #eaf7ed;
border-color: #c9e7d1;
}
.decision-path span.fail {
color: #a3312c;
background: #fee9e7;
border-color: #efc5c1;
}
.decision-path i {
color: #a4b2b8;
font-size: 9px;
font-style: normal;
}
.metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
}
.metric {
padding: 6px 7px;
background: #f4f7f8;
border-radius: 3px;
}
.metric span {
display: block;
color: #7a8d95;
font-size: 7px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.metric strong {
display: block;
margin-top: 3px;
color: var(--ink);
font-size: 11px;
}
@media (max-width: 980px) {
.workspace {
grid-template-columns: 285px minmax(0, 1fr);
}
.brief {
padding-inline: 15px;
}
.header-meta .meta-pill:first-child {
display: none;
}
.outcomes {
grid-template-columns: 1fr;
overflow-y: auto;
}
.stage {
grid-template-rows: minmax(0, 1fr) 290px;
}
}
@media (max-width: 720px) {
body {
overflow: auto;
}
.app-header {
height: auto;
min-height: 76px;
padding: 13px 15px;
}
.brand-mark {
width: 37px;
height: 37px;
}
.header-meta {
display: none;
}
.workspace {
height: auto;
display: flex;
flex-direction: column;
}
.stage {
order: 1;
height: 790px;
grid-template-rows: 570px 220px;
}
.brief {
order: 2;
overflow: visible;
border-right: 0;
border-top: 1px solid var(--line);
}
.scene-options {
display: none;
}
.camera-hint {
display: none;
}
.legend {
max-width: calc(100% - 28px);
}
.event-banner {
top: 61px;
width: calc(100% - 32px);
}
.annotation {
transform-origin: center bottom;
scale: 0.85;
}
}
</style>
</head>
<body>
<header class="app-header">
<div class="brand">
<div class="brand-mark" aria-hidden="true">▦</div>
<div>
<p class="eyebrow">Civic Works Verification Lab</p>
<h1>Independent verification changes the outcome</h1>
</div>
</div>
<div class="header-meta">
<div class="meta-pill">Institutional workflow model</div>
<div class="meta-pill live">Deterministic paired comparison</div>
</div>
</header>
<main class="workspace">
<aside class="brief">
<p class="eyebrow">Paired scenario</p>
<h2>Same work order. Different control.</h2>
<p class="intro">
Both field crews receive identical instructions and perform the same work.
The only difference is whether an independent inspector verifies the work
before oversight releases the project.
</p>
<section class="task-card">
<p class="eyebrow">Identical task instructions</p>
<strong>Install four cobalt tactile panels along curb section C, at the
four marked locations.</strong>
<div class="scope-grid" aria-label="Four required panel locations">
<div class="scope-cell">C-2</div>
<div class="scope-cell">C-3</div>
<div class="scope-cell">C-4</div>
<div class="scope-cell">C-5</div>
</div>
</section>
<section class="control-card" aria-label="Control differences">
<div class="control-row">
<div class="lane-letter">A</div>
<div>
<strong>Without independent verification</strong>
<span>Crew record → engineer approval → oversight release</span>
</div>
</div>
<div class="control-row">
<div class="lane-letter b">B</div>
<div>
<strong>With independent verification</strong>
<span>Crew record → engineer approval → inspection → oversight release</span>
</div>
</div>
</section>
<section class="run-panel">
<div class="button-row">
<button class="primary" id="playButton">Run comparison</button>
<button class="secondary" id="resetButton">Reset</button>
</div>
<div class="timeline-head">
<span>Simulation timeline</span>
<span id="timeValue">0.0 / 16.0 s</span>
</div>
<input
id="timeline"
type="range"
min="0"
max="16"
step="0.01"
value="0"
aria-label="Simulation timeline"
/>
<div class="speed-row">
<span>Drag to inspect any decision point</span>
<select id="speed" aria-label="Playback speed">
<option value="0.5">0.5×</option>
<option value="1" selected>1×</option>
<option value="1.5">1.5×</option>
<option value="2">2×</option>
</select>
</div>
<p class="phase-title">Approval sequence</p>
<div class="phase-list">
<div class="phase-step active" id="phaseTask" data-number="1">
<strong>Task issued</strong>
<small>Identical scope reaches both crews</small>
</div>
<div class="phase-step" id="phaseCrew" data-number="2">
<strong>Field execution</strong>
<small>Three of four panels installed</small>
</div>
<div class="phase-step" id="phaseEngineer" data-number="3">
<strong>Project engineer review</strong>
<small>Approval based on the crew record</small>
</div>
<div class="phase-step" id="phaseInspection" data-number="4">
<strong>Independent inspection · lane B</strong>
<small>Lane A omits this control</small>
</div>
<div class="phase-step" id="phaseOversight" data-number="5">
<strong>Oversight release</strong>
<small>Final institutional authorization</small>
</div>
</div>
<div class="method-note">
<strong>Deterministic test:</strong> both crews miss C-5 in the same
way. Lane A cannot detect that omission through independent review.
Lane B detects it, pauses release, and permits correction.
</div>
</section>
</aside>
<section class="stage">
<div id="viewport">
<div id="annotations"></div>
<div class="scene-toolbar">
<div class="view-switch" aria-label="Camera focus">
<button data-focus="overview" class="active">Overview</button>
<button data-focus="a">Lane A</button>
<button data-focus="b">Lane B</button>
</div>
<div class="scene-options">
<label>
<input id="showLabels" type="checkbox" checked />
Role labels
</label>
</div>
</div>
<div class="event-banner" id="eventBanner" aria-live="polite"></div>
<div class="legend" aria-label="Role color legend">
<div class="legend-item">
<span class="legend-dot" style="background:#f59e0b"></span>
Field crew
</div>
<div class="legend-item">
<span class="legend-dot" style="background:#3b82f6"></span>
Project engineer
</div>
<div class="legend-item">
<span class="legend-dot" style="background:#8b5cf6"></span>
Independent inspector
</div>
<div class="legend-item">
<span class="legend-dot" style="background:#e11d48"></span>
Oversight
</div>
</div>
<div class="camera-hint">
Drag to orbit · wheel to zoom · arrow keys when canvas is focused
</div>
</div>
<div class="outcomes">
<article class="outcome-card a" id="outcomeA">
<div class="outcome-head">
<div>
<p class="outcome-kicker">Lane A · No independent verification</p>
<h3 class="outcome-title" id="aTitle">Awaiting execution</h3>
</div>
<div class="status-badge" id="aStatus">Pending</div>
</div>
<p class="outcome-detail" id="aDetail">
The work order and field execution are identical to lane B.
</p>
<div class="decision-path" aria-label="Lane A decision path">
<span id="aPathWork">Work</span>
<i>→</i>
<span id="aPathEngineer">Engineer</span>
<i>→</i>
<span id="aPathRelease">Oversight</span>
</div>
<div class="metrics">
<div class="metric">
<span>Panels at release</span>
<strong id="aPanels">—</strong>
</div>
<div class="metric">
<span>Released</span>
<strong id="aReleased">No</strong>
</div>
<div class="metric">
<span>Defect caught</span>
<strong id="aCaught">—</strong>
</div>
</div>
</article>
<article class="outcome-card b" id="outcomeB">
<div class="outcome-head">
<div>
<p class="outcome-kicker">Lane B · Independent verification enabled</p>
<h3 class="outcome-title" id="bTitle">Awaiting execution</h3>
</div>
<div class="status-badge" id="bStatus">Pending</div>
</div>
<p class="outcome-detail" id="bDetail">
The same work order receives an additional independent inspection gate.
</p>
<div class="decision-path" aria-label="Lane B decision path">
<span id="bPathWork">Work</span>
<i>→</i>
<span id="bPathEngineer">Engineer</span>
<i>→</i>
<span id="bPathInspect">Inspection</span>
<i>→</i>
<span id="bPathRelease">Oversight</span>
</div>
<div class="metrics">
<div class="metric">
<span>Panels at release</span>
<strong id="bPanels">—</strong>
</div>
<div class="metric">
<span>Released</span>
<strong id="bReleased">No</strong>
</div>
<div class="metric">
<span>Defect caught</span>
<strong id="bCaught">—</strong>
</div>
</div>
</article>
</div>
</section>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.getElementById("viewport");
const annotationLayer = document.getElementById("annotations");
const scene = new THREE.Scene();
scene.background = new THREE.Color("#dce9ee");
scene.fog = new THREE.Fog("#dce9ee", 18, 35);
const camera = new THREE.PerspectiveCamera(
37,
viewport.clientWidth / viewport.clientHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(viewport.clientWidth, viewport.clientHeight, false);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
viewport.appendChild(renderer.domElement);
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel public-works comparison. Drag to orbit and use arrow keys to rotate."
);
const hemisphere = new THREE.HemisphereLight(
"#e9f7ff",
"#9ba99f",
2.2
);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff7df", 3.4);
sun.position.set(-7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 11;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b9ddff", 1.1);
fill.position.set(8, 7, -5);
scene.add(fill);
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function getMaterial(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0.02,
flatShading: true
})
);
}
return materialCache.get(color);
}
function block(
parent,
x,
y,
z,
width,
height,
depth,
color,
options = {}
) {
const mesh = new THREE.Mesh(
cubeGeometry,
options.material || getMaterial(color)
);
mesh.position.set(x, y, z);
mesh.scale.set(width, height, depth);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
return mesh;
}
function makeTextSprite(lines, background, foreground, width = 2.5) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = lines.length > 1 ? 256 : 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = foreground;
ctx.fillRect(0, 0, canvas.width, 10);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
if (lines.length === 1) {
ctx.font = "800 51px ui-sans-serif, system-ui, sans-serif";
ctx.fillText(lines[0], canvas.width / 2, canvas.height / 2 + 3, 720);
} else {
ctx.font = "800 43px ui-sans-serif, system-ui, sans-serif";
ctx.fillText(lines[0], canvas.width / 2, 64, 720);
ctx.font = "700 30px ui-sans-serif, system-ui, sans-serif";
for (let i = 1; i < lines.length; i++) {
ctx.fillText(lines[i], canvas.width / 2, 125 + (i - 1) * 49, 720);
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, width * (canvas.height / canvas.width), 1);
return sprite;
}
function createTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, -0.43, z);
tree.scale.setScalar(scale);
block(tree, 0, 0.42, 0, 0.2, 0.85, 0.2, "#80664a");
block(tree, 0, 1.0, 0, 1.0, 0.8, 0.9, "#4f8b69");
block(tree, -0.28, 1.34, 0.05, 0.75, 0.65, 0.75, "#65a879");
block(tree, 0.3, 1.42, -0.06, 0.72, 0.7, 0.7, "#76b486");
scene.add(tree);
return tree;
}
block(scene, 0, -0.57, 0, 40, 0.2, 30, "#c9dce2", {
cast: false
});
createTree(-7.2, -1.6, 1.1);
createTree(-7.1, 2.1, 0.8);
createTree(7.2, -1.4, 1.05);
createTree(7.0, 2.2, 0.82);
function createPerson(parent, roleColor, accentColor, role) {
const group = new THREE.Group();
const leftLeg = block(group, -0.09, 0.15, 0, 0.13, 0.3, 0.16, "#263b49");
const rightLeg = block(group, 0.09, 0.15, 0, 0.13, 0.3, 0.16, "#263b49");
block(group, 0, 0.44, 0, 0.36, 0.38, 0.23, roleColor);
block(group, 0, 0.47, 0.123, 0.22, 0.22, 0.025, accentColor);
block(group, -0.25, 0.43, 0, 0.11, 0.34, 0.13, roleColor);
block(group, 0.25, 0.43, 0, 0.11, 0.34, 0.13, roleColor);
block(group, 0, 0.73, 0, 0.29, 0.27, 0.27, "#d9a46f");
block(group, 0, 0.76, 0.142, 0.2, 0.055, 0.02, "#263b49");
block(group, 0, 0.9, 0, 0.35, 0.12, 0.32, accentColor);
block(group, 0, 0.96, 0, 0.26, 0.08, 0.26, accentColor);
block(group, -0.11, 0.25, 0, 0.14, 0.09, 0.18, "#213744");
block(group, 0.11, 0.25, 0, 0.14, 0.09, 0.18, "#213744");
if (role === "inspector") {
block(group, 0.29, 0.45, 0.13, 0.18, 0.25, 0.05, "#eef4f6");
block(group, 0.29, 0.45, 0.16, 0.12, 0.17, 0.02, "#8b5cf6");
} else if (role === "engineer") {
block(group, 0.28, 0.47, 0.14, 0.18, 0.24, 0.04, "#dce6ea");
} else if (role === "oversight") {
block(group, 0.28, 0.45, 0.14, 0.19, 0.16, 0.035, "#fff7d6");
}
group.userData.legs = [leftLeg, rightLeg];
parent.add(group);
return { group, role };
}
function createStation(parent, x, accentColor) {
const desk = new THREE.Group();
desk.position.set(x, 0, -1.1);
block(desk, 0, 0.33, 0, 1.05, 0.12, 0.62, "#e5ecee");
block(desk, -0.43, 0.18, 0, 0.09, 0.36, 0.52, "#93a6ad");
block(desk, 0.43, 0.18, 0, 0.09, 0.36, 0.52, "#93a6ad");
block(desk, 0.12, 0.49, -0.03, 0.37, 0.25, 0.08, "#314b59");
block(desk, 0.12, 0.49, 0.02, 0.3, 0.18, 0.015, "#9dd9d1");
parent.add(desk);
const lightMaterial = new THREE.MeshStandardMaterial({
color: "#91a2aa",
emissive: "#91a2aa",
emissiveIntensity: 0.12,
roughness: 0.75
});
block(parent, x - 0.43, 0.91, -1.1, 0.17, 0.17, 0.17, "#91a2aa", {
material: lightMaterial
});
block(parent, x - 0.43, 0.73, -1.1, 0.07, 0.26, 0.07, "#84979f");
block(parent, x + 0.08, 0.72, -0.05, 0.16, 0.07, 0.28, accentColor);
return { lightMaterial };
}
function createTactilePanel(parent, x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
block(group, 0, 0.2, 0, 0.66, 0.12, 0.58, "#2563eb");
for (let ix = -1; ix <= 1; ix++) {
for (let iz = -1; iz <= 1; iz++) {
block(
group,
ix * 0.16,
0.3,
iz * 0.15,
0.065,
0.075,
0.065,
"#facc15"
);
}
}
parent.add(group);
return group;
}
function createSlotOutline(parent, x, z) {
const y = 0.145;
const w = 0.78;
const d = 0.69;
const t = 0.035;
block(parent, x, y, z - d / 2, w, 0.025, t, "#83979f");
block(parent, x, y, z + d / 2, w, 0.025, t, "#83979f");
block(parent, x - w / 2, y, z, t, 0.025, d, "#83979f");
block(parent, x + w / 2, y, z, t, 0.025, d, "#83979f");
}
function createInspectionMarker(parent, x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
const redMaterial = new THREE.MeshStandardMaterial({
color: "#ef4444",
emissive: "#ef4444",
emissiveIntensity: 0.25,
roughness: 0.7
});
block(group, 0, 0.92, 0, 0.11, 0.55, 0.11, "#ef4444", {
material: redMaterial
});
block(group, 0, 0.57, 0, 0.13, 0.13, 0.13, "#ef4444", {
material: redMaterial
});
const outline = new THREE.Group();
block(outline, 0, 0.17, -0.4, 0.9, 0.035, 0.055, "#ef4444");
block(outline, 0, 0.17, 0.4, 0.9, 0.035, 0.055, "#ef4444");
block(outline, -0.42, 0.17, 0, 0.055, 0.035, 0.82, "#ef4444");
block(outline, 0.42, 0.17, 0, 0.055, 0.035, 0.82, "#ef4444");
group.add(outline);
const check = new THREE.Group();
block(check, -0.15, 0.88, 0, 0.12, 0.12, 0.12, "#22c55e", {
rotation: undefined
});
check.visible = false;
group.add(check);
parent.add(group);
return { group, redMaterial, check };
}
function createLane(xPosition, verified) {
const lane = {
x: xPosition,
verified,
annotations: []
};
lane.group = new THREE.Group();
lane.group.position.x = xPosition;
scene.add(lane.group);
const accent = verified ? "#0f766e" : "#d97706";
block(lane.group, 0, -0.25, 0, 6.4, 0.5, 5.2, "#9babb1");
block(lane.group, 0, 0.015, 0, 6.12, 0.06, 4.92, "#d8d5ca");
block(lane.group, 0, 0.03, 2.48, 6.25, 0.11, 0.12, accent);
block(lane.group, 0, 0.055, -0.12, 5.95, 0.11, 0.22, "#f5f1e8");
// Identical civic-office backdrop in both lanes.
block(lane.group, 0, 0.65, -2.14, 5.8, 1.3, 0.32, "#e9e2d3");
block(lane.group, 0, 1.34, -2.14, 5.95, 0.12, 0.4, "#c9d6d9");
[-2.25, -0.75, 0.75, 2.25].forEach((windowX, index) => {
block(
lane.group,
windowX,
0.82,
-1.965,
0.88,
0.48,
0.025,
index === 1 ? "#9ed6d2" : "#83b9c8"
);
block(lane.group, windowX, 0.82, -1.94, 0.045, 0.5, 0.03, "#e9e2d3");
});
block(lane.group, -2.8, 0.29, 1.65, 0.6, 0.58, 0.6, "#d7bd71");
block(lane.group, -2.8, 0.61, 1.65, 0.7, 0.08, 0.7, "#e7cf83");
block(lane.group, -2.8, 0.72, 1.65, 0.46, 0.14, 0.45, "#a98b49");
const taskSign = makeTextSprite(
[
"TASK C-14 · IDENTICAL WORK ORDER",
"INSTALL 4 COBALT TACTILE PANELS",
"LOCATIONS: C-2 · C-3 · C-4 · C-5"
],
"#f8fbfc",
"#173849",
2.95
);
taskSign.position.set(0, 1.84, -1.87);
lane.group.add(taskSign);
lane.stations = {
engineer: createStation(lane.group, -2.08, "#3b82f6"),
inspector: createStation(lane.group, 0, "#8b5cf6"),
oversight: createStation(lane.group, 2.08, "#e11d48")
};
lane.crew = createPerson(lane.group, "#f59e0b", "#fde047", "crew");
lane.crew.group.position.set(-2.5, 0.12, 1.55);
lane.engineer = createPerson(lane.group, "#3b82f6", "#dbeafe", "engineer");
lane.engineer.group.position.set(-2.08, 0.12, -0.57);
lane.oversight = createPerson(lane.group, "#e11d48", "#fecdd3", "oversight");
lane.oversight.group.position.set(2.08, 0.12, -0.57);
if (verified) {
lane.inspector = createPerson(lane.group, "#8b5cf6", "#ede9fe", "inspector");
lane.inspector.group.position.set(0, 0.12, -0.57);
}
lane.slotXs = [-1.65, -0.55, 0.55, 1.65];
lane.panels = [];
lane.slotXs.forEach((slotX, index) => {
createSlotOutline(lane.group, slotX, 0.45);
const panel = createTactilePanel(lane.group, slotX, 0.45);
panel.visible = false;
lane.panels.push(panel);
const slotLabel = makeTextSprite(
[`C-${index + 2}`],
"#f7fafb",
"#31505e",
0.46
);
slotLabel.position.set(slotX, 0.34, 0.89);
lane.group.add(slotLabel);
});
lane.inspectionMarker = createInspectionMarker(
lane.group,
lane.slotXs[3],
0.45
);
lane.inspectionMarker.group.visible = false;
return lane;
}
const laneA = createLane(-3.45, false);
const laneB = createLane(3.45, true);
function createAnnotation(lane, title, subtitle, anchor, tone, isRole = true) {
const element = document.createElement("div");
element.className = `annotation ${tone}`;
element.innerHTML = `
<span class="label-title"></span>
<span class="label-sub"></span>
`;
const titleElement = element.querySelector(".label-title");
const subtitleElement = element.querySelector(".label-sub");
titleElement.textContent = title;
subtitleElement.textContent = subtitle;
annotationLayer.appendChild(element);
const annotation = {
element,
titleElement,
subtitleElement,
anchor,
isRole,
lane,
visible: true
};
lane.annotations.push(annotation);
return annotation;
}
function makeAnchor(parent, x = 0, y = 0, z = 0) {
const anchor = new THREE.Object3D();
anchor.position.set(x, y, z);
parent.add(anchor);
return anchor;
}
function prepareLaneAnnotations(lane) {
const laneTitleAnchor = makeAnchor(lane.group, 0, 2.75, -1.85);
lane.titleAnnotation = createAnnotation(
lane,
lane.verified
? "B · INDEPENDENT VERIFICATION"
: "A · NO INDEPENDENT VERIFICATION",
"Same task instructions",
laneTitleAnchor,
lane.verified ? "green" : "orange",
false
);
const crewAnchor = makeAnchor(lane.crew.group, 0, 1.1, 0);
lane.crewAnnotation = createAnnotation(
lane,
"Field crew",
"Executing work order",
crewAnchor,
"orange"
);
const engineerAnchor = makeAnchor(lane.engineer.group, 0, 1.1, 0);
lane.engineerAnnotation = createAnnotation(
lane,
"Project engineer",
"Record review",
engineerAnchor,
"blue"
);
const oversightAnchor = makeAnchor(lane.oversight.group, 0, 1.1, 0);
lane.oversightAnnotation = createAnnotation(
lane,
"Oversight board",
"Release authority",
oversightAnchor,
"red"
);
if (lane.verified) {
const inspectorAnchor = makeAnchor(lane.inspector.group, 0, 1.1, 0);
lane.inspectorAnnotation = createAnnotation(
lane,
"Independent inspector",
"Verification pending",
inspectorAnchor,
"purple"
);
} else {
const absentAnchor = makeAnchor(lane.group, 0, 1.15, -0.55);
lane.absentInspectorAnnotation = createAnnotation(
lane,
"Independent check omitted",
"No verification role assigned",
absentAnchor,
"red"
);
}
}
prepareLaneAnnotations(laneA);
prepareLaneAnnotations(laneB);
const projected = new THREE.Vector3();
function updateAnnotations() {
scene.updateMatrixWorld(true);
const width = viewport.clientWidth;
const height = viewport.clientHeight;
const labelsVisible = document.getElementById("showLabels").checked;
for (const lane of [laneA, laneB]) {
for (const annotation of lane.annotations) {
if (!annotation.visible || (annotation.isRole && !labelsVisible)) {
annotation.element.style.display = "none";
continue;
}
annotation.anchor.getWorldPosition(projected);
projected.project(camera);
if (projected.z < -1 || projected.z > 1) {
annotation.element.style.display = "none";
continue;
}
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
annotation.element.style.display = "block";
annotation.element.style.transform =
`translate3d(${x}px, ${y}px, 0) translate(-50%, -100%)`;
}
}
}
function setAnnotationTone(annotation, tone) {
const base = annotation.element.classList.contains("lane-title")
? "lane-title"
: "";
annotation.element.className = `annotation ${base} ${tone}`.trim();
}
// Custom camera controls: no Three.js addons are used.
const cameraState = {
radius: 15.8,
targetRadius: 15.8,
theta: 0.58,
targetTheta: 0.58,
phi: 0.82,
targetPhi: 0.82,
target: new THREE.Vector3(0, 0.45, 0),
targetTarget: new THREE.Vector3(0, 0.45, 0)
};
function clamp(value, min, max) {
return Math.min(max, Math.max(min, value));
}
function updateCamera(delta) {
const smoothing = 1 - Math.exp(-delta * 8);
cameraState.radius +=
(cameraState.targetRadius - cameraState.radius) * smoothing;
cameraState.theta +=
(cameraState.targetTheta - cameraState.theta) * smoothing;
cameraState.phi +=
(cameraState.targetPhi - cameraState.phi) * smoothing;
cameraState.target.lerp(cameraState.targetTarget, smoothing);
const spherical = new THREE.Spherical(
cameraState.radius,
cameraState.phi,
cameraState.theta
);
camera.position.setFromSpherical(spherical).add(cameraState.target);
camera.lookAt(cameraState.target);
}
function setFocus(focus) {
document.querySelectorAll("[data-focus]").forEach((button) => {
button.classList.toggle("active", button.dataset.focus === focus);
});
if (focus === "a") {
cameraState.targetTarget.set(laneA.x, 0.48, 0);
cameraState.targetRadius = 9.2;
cameraState.targetTheta = 0.43;
cameraState.targetPhi = 0.76;
} else if (focus === "b") {
cameraState.targetTarget.set(laneB.x, 0.48, 0);
cameraState.targetRadius = 9.2;
cameraState.targetTheta = 0.43;
cameraState.targetPhi = 0.76;
} else {
cameraState.targetTarget.set(0, 0.45, 0);
cameraState.targetRadius = 15.8;
cameraState.targetTheta = 0.58;
cameraState.targetPhi = 0.82;
}
}
document.querySelectorAll("[data-focus]").forEach((button) => {
button.addEventListener("click", () => setFocus(button.dataset.focus));
});
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.targetTheta -= deltaX * 0.006;
cameraState.targetPhi = clamp(
cameraState.targetPhi + deltaY * 0.0045,
0.38,
1.2
);
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.targetRadius = clamp(
cameraState.targetRadius + event.deltaY * 0.009,
7.4,
23
);
},
{ passive: false }
);
renderer.domElement.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
cameraState.targetTheta += 0.09;
break;
case "ArrowRight":
cameraState.targetTheta -= 0.09;
break;
case "ArrowUp":
cameraState.targetPhi = clamp(cameraState.targetPhi - 0.07, 0.38, 1.2);
break;
case "ArrowDown":
cameraState.targetPhi = clamp(cameraState.targetPhi + 0.07, 0.38, 1.2);
break;
case "+":
case "=":
cameraState.targetRadius = clamp(cameraState.targetRadius - 0.7, 7.4, 23);
break;
case "-":
cameraState.targetRadius = clamp(cameraState.targetRadius + 0.7, 7.4, 23);
break;
case "0":
setFocus("overview");
break;
case "1":
setFocus("a");
break;
case "2":
setFocus("b");
break;
default:
handled = false;
}
if (handled) event.preventDefault();
});
const DURATION = 16;
const TIMING = {
issueEnd: 1.2,
crewEnd: 4.8,
engineerEnd: 6.4,
divergence: 6.8,
laneARelease: 7.5,
detection: 8.7,
correction: 10.8,
reverified: 12.4,
laneBRelease: 13.5
};
const CREW_INITIAL_PATH = [
[0.0, -2.5, 1.55],
[1.05, -2.5, 0.93],
[1.55, -1.65, 0.45],
[1.95, -1.65, 0.45],
[2.18, -0.55, 0.45],
[2.65, -0.55, 0.45],
[2.98, 0.55, 0.45],
[3.55, 0.55, 0.45],
[3.92, 1.65, 0.45],
[4.6, -2.5, 1.55]
];
const CREW_CORRECTION_PATH = [
...CREW_INITIAL_PATH,
[9.5, -2.5, 1.55],
[10.25, 1.65, 0.45],
[10.8, 1.65, 0.45],
[11.45, -2.5, 1.55]
];
const ENGINEER_PATH = [
[0, -2.08, -0.57],
[4.85, -2.08, -0.57],
[5.25, -0.8, 0.05],
[5.78, -0.8, 0.05],
[6.45, -2.08, -0.57]
];
const INSPECTOR_PATH = [
[0, 0, -0.57],
[6.9, 0, -0.57],
[7.42, -1.65, 0.45],
[7.95, -0.55, 0.45],
[8.42, 0.55, 0.45],
[8.9, 1.65, 0.45],
[10.65, 1.65, 0.45],
[11.55, 1.65, 0.45],
[12.35, 0, -0.57]
];
function samplePath(path, time) {
if (time <= path[0][0]) {
return {
x: path[0][1],
z: path[0][2],
moving: false,
dx: 0,
dz: 0
};
}
for (let i = 0; i < path.length - 1; i++) {
const a = path[i];
const b = path[i + 1];
if (time >= a[0] && time <= b[0]) {
const span = Math.max(0.0001, b[0] - a[0]);
const raw = (time - a[0]) / span;
const eased = raw * raw * (3 - 2 * raw);
const dx = b[1] - a[1];
const dz = b[2] - a[2];
const distance = Math.hypot(dx, dz);
return {
x: THREE.MathUtils.lerp(a[1], b[1], eased),
z: THREE.MathUtils.lerp(a[2], b[2], eased),
moving: distance > 0.04 && raw > 0.02 && raw < 0.98,
dx,
dz
};
}
}
const last = path[path.length - 1];
return {
x: last[1],
z: last[2],
moving: false,
dx: 0,
dz: 0
};
}
function applyPath(person, path, time) {
const sample = samplePath(path, time);
person.group.position.x = sample.x;
person.group.position.z = sample.z;
if (sample.moving) {
person.group.rotation.y = Math.atan2(sample.dx, sample.dz);
} else {
person.group.rotation.y = 0;
}
const legs = person.group.userData.legs;
const swing = sample.moving ? Math.sin(time * 13) * 0.32 : 0;
legs[0].rotation.x = swing;
legs[1].rotation.x = -swing;
}
function smoothStep(value) {
const x = clamp(value, 0, 1);
return x * x * (3 - 2 * x);
}
function setLight(station, color, intensity = 0.2) {
station.lightMaterial.color.set(color);
station.lightMaterial.emissive.set(color);
station.lightMaterial.emissiveIntensity = intensity;
}
function setPhase(element, state) {
element.classList.remove("active", "done", "warn", "fail");
if (state === "active") element.classList.add("active");
if (state === "done") element.classList.add("done");
if (state === "warn") element.classList.add("warn");
if (state === "fail") element.classList.add("fail");
}
function setPathStep(element, state) {
element.classList.remove("active", "done", "fail");
if (state) element.classList.add(state);
}
function setOutcomeTone(card, tone) {
card.classList.remove("danger", "warning", "success");
if (tone) card.classList.add(tone);
}
const phaseTask = document.getElementById("phaseTask");
const phaseCrew = document.getElementById("phaseCrew");
const phaseEngineer = document.getElementById("phaseEngineer");
const phaseInspection = document.getElementById("phaseInspection");
const phaseOversight = document.getElementById("phaseOversight");
const outcomeA = document.getElementById("outcomeA");
const outcomeB = document.getElementById("outcomeB");
const aTitle = document.getElementById("aTitle");
const aStatus = document.getElementById("aStatus");
const aDetail = document.getElementById("aDetail");
const aPanels = document.getElementById("aPanels");
const aReleased = document.getElementById("aReleased");
const aCaught = document.getElementById("aCaught");
const bTitle = document.getElementById("bTitle");
const bStatus = document.getElementById("bStatus");
const bDetail = document.getElementById("bDetail");
const bPanels = document.getElementById("bPanels");
const bReleased = document.getElementById("bReleased");
const bCaught = document.getElementById("bCaught");
const aPathWork = document.getElementById("aPathWork");
const aPathEngineer = document.getElementById("aPathEngineer");
const aPathRelease = document.getElementById("aPathRelease");
const bPathWork = document.getElementById("bPathWork");
const bPathEngineer = document.getElementById("bPathEngineer");
const bPathInspect = document.getElementById("bPathInspect");
const bPathRelease = document.getElementById("bPathRelease");
const eventBanner = document.getElementById("eventBanner");
const events = [
{
at: 0,
until: 1.2,
text: "Both lanes receive the same work order: install four cobalt tactile panels at C-2 through C-5."
},
{
at: 1.2,
until: 4.8,
text: "The field crews execute identically. Both omit panel C-5, leaving one required location empty."
},
{
at: 4.8,
until: 6.8,
text: "The project engineer approves the crew record in both lanes. The record still contains the omission."
},
{
at: 6.8,
until: 7.5,
text: "Control paths diverge: lane A skips independent inspection; lane B sends the work to an inspector."
},
{
at: 7.5,
until: 8.7,
text: "Lane A is released by oversight from the incomplete record. Its missed panel remains in the field."
},
{
at: 8.7,
until: 10.8,
text: "The independent inspector detects the missing C-5 requirement. Lane B release is paused."
},
{
at: 10.8,
until: 12.4,
text: "The field crew corrects C-5. The inspector now re-verifies the completed installation."
},
{
at: 12.4,
until: 13.5,
text: "Independent verification passes. All four required panels are now present."
},
{
at: 13.5,
until: 16.1,
text: "Lane B is released after correction. Lane A was released earlier with the same defect uncorrected."
}
];
function updateEvent(time) {
const event = events.find(
(item) => time >= item.at && time < item.until
);
if (event) {
eventBanner.textContent = event.text;
eventBanner.classList.add("show");
} else {
eventBanner.classList.remove("show");
}
}
function updateLaneState(lane, time) {
const revealTimes = [1.55, 2.65, 3.55];
lane.panels.forEach((panel, index) => {
const revealTime =
index === 3
? lane.verified
? TIMING.correction
: Infinity
: revealTimes[index];
const progress = smoothStep((time - revealTime) / 0.3);
panel.visible = progress > 0.001;
panel.scale.setScalar(Math.max(0.001, progress));
});
applyPath(
lane.crew,
lane.verified ? CREW_CORRECTION_PATH : CREW_INITIAL_PATH,
time
);
applyPath(lane.engineer, ENGINEER_PATH, time);
if (lane.inspector) {
applyPath(lane.inspector, INSPECTOR_PATH, time);
}
const engineerActive =
time >= TIMING.crewEnd && time < TIMING.engineerEnd;
setLight(
lane.stations.engineer,
engineerActive
? "#f59e0b"
: time >= TIMING.engineerEnd
? "#22c55e"
: "#91a2aa",
engineerActive ? 0.45 : 0.2
);
if (!lane.verified) {
const oversightActive =
time >= TIMING.divergence && time < TIMING.laneARelease;
setLight(
lane.stations.oversight,
oversightActive
? "#f59e0b"
: time >= TIMING.laneARelease
? "#ef4444"
: "#91a2aa",
oversightActive ? 0.45 : 0.22
);
setLight(lane.stations.inspector, "#64748b", 0.05);
} else {
const inspectorActive =
time >= TIMING.divergence &&
time < TIMING.reverified &&
!(time >= TIMING.detection && time < TIMING.correction);
const inspectorFailed =
time >= TIMING.detection && time < TIMING.correction;
setLight(
lane.stations.inspector,
inspectorFailed
? "#ef4444"
: inspectorActive
? "#f59e0b"
: time >= TIMING.reverified
? "#22c55e"
: "#91a2aa",
inspectorFailed ? 0.5 : inspectorActive ? 0.45 : 0.2
);
const oversightActive =
time >= TIMING.reverified && time < TIMING.laneBRelease;
setLight(
lane.stations.oversight,
oversightActive
? "#f59e0b"
: time >= TIMING.laneBRelease
? "#22c55e"
: "#91a2aa",
oversightActive ? 0.45 : 0.2
);
const marker = lane.inspectionMarker;
const markerVisible =
time >= TIMING.detection && time < TIMING.correction;
marker.group.visible = markerVisible;
if (markerVisible) {
const pulse = 1 + Math.sin(time * 9) * 0.08;
marker.group.scale.set(pulse, pulse, pulse);
}
}
}
function updateInterface(time) {
setPhase(
phaseTask,
time >= TIMING.issueEnd ? "done" : "active"
);
setPhase(
phaseCrew,
time >= TIMING.crewEnd
? "done"
: time >= TIMING.issueEnd
? "active"
: "pending"
);
setPhase(
phaseEngineer,
time >= TIMING.engineerEnd
? "done"
: time >= TIMING.crewEnd
? "active"
: "pending"
);
if (time < TIMING.divergence) {
setPhase(phaseInspection, "pending");
} else if (time < TIMING.detection) {
setPhase(phaseInspection, "active");
} else if (time < TIMING.correction) {
setPhase(phaseInspection, "fail");
} else if (time < TIMING.reverified) {
setPhase(phaseInspection, "warn");
} else {
setPhase(phaseInspection, "done");
}
if (time < TIMING.divergence) {
setPhase(phaseOversight, "pending");
} else if (time < TIMING.laneBRelease) {
setPhase(phaseOversight, "warn");
} else {
setPhase(phaseOversight, "done");
}
// Lane A interface.
setPathStep(
aPathWork,
time >= TIMING.crewEnd
? "done"
: time >= TIMING.issueEnd
? "active"
: ""
);
setPathStep(
aPathEngineer,
time >= TIMING.engineerEnd
? "done"
: time >= TIMING.crewEnd
? "active"
: ""
);
setPathStep(
aPathRelease,
time >= TIMING.laneARelease
? "fail"
: time >= TIMING.divergence
? "active"
: ""
);
if (time < TIMING.issueEnd) {
aTitle.textContent = "Awaiting execution";
aStatus.textContent = "Pending";
aDetail.textContent =
"The work order and field execution are identical to lane B.";
aPanels.textContent = "—";
aReleased.textContent = "No";
aCaught.textContent = "—";
setOutcomeTone(outcomeA, "");
} else if (time < TIMING.crewEnd) {
aTitle.textContent = "Field crew working";
aStatus.textContent = "In progress";
aDetail.textContent =
"Both crews are placing panels at the same marked locations.";
aPanels.textContent = `${laneA.panels.filter((p) => p.visible).length}/4`;
aReleased.textContent = "No";
aCaught.textContent = "—";
setOutcomeTone(outcomeA, "");
} else if (time < TIMING.engineerEnd) {
aTitle.textContent = "Engineer review in progress";
aStatus.textContent = "Review";
aDetail.textContent =
"The project engineer is reviewing the submitted crew record.";
aPanels.textContent = "3/4";
aReleased.textContent = "No";
aCaught.textContent = "—";
setOutcomeTone(outcomeA, "");
} else if (time < TIMING.laneARelease) {
aTitle.textContent = "Awaiting oversight release";
aStatus.textContent = "Pending";
aDetail.textContent =
"No independent inspector will examine the physical installation.";
aPanels.textContent = "3/4";
aReleased.textContent = "No";
aCaught.textContent = "No";
setOutcomeTone(outcomeA, "");
} else {
aTitle.textContent = "Released with missed requirement";
aStatus.textContent = "Defect escaped";
aDetail.textContent =
"Oversight relies on the approved record. C-5 remains absent at release.";
aPanels.textContent = "3/4";
aReleased.textContent = "Yes";
aCaught.textContent = "No";
setOutcomeTone(outcomeA, "danger");
}
// Lane B interface.
setPathStep(
bPathWork,
time >= TIMING.crewEnd
? "done"
: time >= TIMING.issueEnd
? "active"
: ""
);
setPathStep(
bPathEngineer,
time >= TIMING.engineerEnd
? "done"
: time >= TIMING.crewEnd
? "active"
: ""
);
if (time < TIMING.divergence) {
setPathStep(bPathInspect, "");
} else if (time < TIMING.detection) {
setPathStep(bPathInspect, "active");
} else if (time < TIMING.correction) {
setPathStep(bPathInspect, "fail");
} else if (time < TIMING.reverified) {
setPathStep(bPathInspect, "active");
} else {
setPathStep(bPathInspect, "done");
}
setPathStep(
bPathRelease,
time >= TIMING.laneBRelease
? "done"
: time >= TIMING.reverified
? "active"
: ""
);
if (time < TIMING.issueEnd) {
bTitle.textContent = "Awaiting execution";
bStatus.textContent = "Pending";
bDetail.textContent =
"The same work order receives an additional independent inspection gate.";
bPanels.textContent = "—";
bReleased.textContent = "No";
bCaught.textContent = "—";
setOutcomeTone(outcomeB, "");
} else if (time < TIMING.crewEnd) {
bTitle.textContent = "Field crew working";
bStatus.textContent = "In progress";
bDetail.textContent =
"The crew actions are identical to lane A, including the missed C-5.";
bPanels.textContent = `${laneB.panels.filter((p) => p.visible).length}/4`;
bReleased.textContent = "No";
bCaught.textContent = "—";
setOutcomeTone(outcomeB, "");
} else if (time < TIMING.divergence) {
bTitle.textContent = "Standard approval path";
bStatus.textContent = "Review";
bDetail.textContent =
"The engineer approves the same incomplete record used in lane A.";
bPanels.textContent = "3/4";
bReleased.textContent = "No";
bCaught.textContent = "—";
setOutcomeTone(outcomeB, "");
} else if (time < TIMING.detection) {
bTitle.textContent = "Independent inspection underway";
bStatus.textContent = "Inspecting";
bDetail.textContent =
"The inspector is checking the physical work rather than relying only on records.";
bPanels.textContent = "3/4";
bReleased.textContent = "No";
bCaught.textContent = "—";
setOutcomeTone(outcomeB, "");
} else if (time < TIMING.correction) {
bTitle.textContent = "Deficiency detected";
bStatus.textContent = "Release paused";
bDetail.textContent =
"The inspector detects that required panel C-5 is missing. Oversight release is withheld.";
bPanels.textContent = "3/4";
bReleased.textContent = "No";
bCaught.textContent = "Yes";
setOutcomeTone(outcomeB, "danger");
} else if (time < TIMING.reverified) {
bTitle.textContent = "Corrective work complete";
bStatus.textContent = "Re-verifying";
bDetail.textContent =
"The crew installs C-5. The inspector is independently re-checking the completed work.";
bPanels.textContent = "4/4";
bReleased.textContent = "No";
bCaught.textContent = "Yes";
setOutcomeTone(outcomeB, "warning");
} else if (time < TIMING.laneBRelease) {
bTitle.textContent = "Verified and ready for release";
bStatus.textContent = "Approved";
bDetail.textContent =
"Independent verification confirms that all four required panels are present.";
bPanels.textContent = "4/4";
bReleased.textContent = "No";
bCaught.textContent = "Yes";
setOutcomeTone(outcomeB, "warning");
} else {
bTitle.textContent = "Released after verified correction";
bStatus.textContent = "Verified release";
bDetail.textContent =
"The omission was detected, corrected, and re-verified before oversight released the work.";
bPanels.textContent = "4/4";
bReleased.textContent = "Yes";
bCaught.textContent = "Yes";
setOutcomeTone(outcomeB, "success");
}
// Role annotation states.
laneA.crewAnnotation.subtitleElement.textContent =
time >= TIMING.crewEnd ? "C-5 omitted" : "Executing work order";
laneB.crewAnnotation.subtitleElement.textContent =
time >= TIMING.correction
? "C-5 corrected"
: time >= TIMING.crewEnd
? "C-5 omitted"
: "Executing work order";
laneA.engineerAnnotation.subtitleElement.textContent =
time >= TIMING.engineerEnd ? "Record approved" : "Record review";
laneB.engineerAnnotation.subtitleElement.textContent =
time >= TIMING.engineerEnd ? "Record approved" : "Record review";
laneA.oversightAnnotation.subtitleElement.textContent =
time >= TIMING.laneARelease
? "Released incomplete record"
: time >= TIMING.divergence
? "Release review"
: "Release authority";
laneB.oversightAnnotation.subtitleElement.textContent =
time >= TIMING.laneBRelease
? "Release authorized"
: time >= TIMING.reverified
? "Release review"
: "Release withheld";
if (laneB.inspectorAnnotation) {
laneB.inspectorAnnotation.subtitleElement.textContent =
time >= TIMING.reverified
? "Verification passed"
: time >= TIMING.detection && time < TIMING.correction
? "Deficiency found"
: time >= TIMING.divergence
? "Inspecting work"
: "Verification pending";
setAnnotationTone(
laneB.inspectorAnnotation,
time >= TIMING.detection && time < TIMING.correction
? "red"
: time >= TIMING.reverified
? "green"
: "purple"
);
}
laneA.titleAnnotation.subtitleElement.textContent =
time >= TIMING.laneARelease
? "Released with one missed panel"
: "Same task instructions";
laneB.titleAnnotation.subtitleElement.textContent =
time >= TIMING.laneBRelease
? "Verified release · four of four panels"
: time >= TIMING.detection && time < TIMING.correction
? "Deficiency detected"
: "Same task instructions";
updateEvent(time);
}
let simulationTime = 0;
let playing = false;
let playbackSpeed = 1;
const playButton = document.getElementById("playButton");
const resetButton = document.getElementById("resetButton");
const timeline = document.getElementById("timeline");
const timeValue = document.getElementById("timeValue");
const speedSelect = document.getElementById("speed");
function syncPlayButton() {
if (simulationTime >= DURATION) {
playButton.textContent = "Replay comparison";
} else if (playing) {
playButton.textContent = "Pause";
} else {
playButton.textContent =
simulationTime === 0 ? "Run comparison" : "Resume";
}
}
function resetSimulation() {
simulationTime = 0;
playing = false;
timeline.value = "0";
timeValue.textContent = "0.0 / 16.0 s";
syncPlayButton();
updateSimulation();
}
playButton.addEventListener("click", () => {
if (simulationTime >= DURATION) {
simulationTime = 0;
playing = true;
} else {
playing = !playing;
}
syncPlayButton();
});
resetButton.addEventListener("click", resetSimulation);
timeline.addEventListener("input", () => {
playing = false;
simulationTime = Number(timeline.value);
syncPlayButton();
updateSimulation();
});
speedSelect.addEventListener("change", () => {
playbackSpeed = Number(speedSelect.value);
});
function updateSimulation() {
updateLaneState(laneA, simulationTime);
updateLaneState(laneB, simulationTime);
updateInterface(simulationTime);
timeline.value = simulationTime.toString();
timeValue.textContent = `${simulationTime.toFixed(1)} / ${DURATION.toFixed(1)} s`;
}
const resizeObserver = new ResizeObserver(() => {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(1, height);
camera.updateProjectionMatrix();
});
resizeObserver.observe(viewport);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (playing) {
simulationTime += delta * playbackSpeed;
if (simulationTime >= DURATION) {
simulationTime = DURATION;
playing = false;
syncPlayButton();
}
}
updateSimulation();
updateCamera(delta);
updateAnnotations();
renderer.render(scene, camera);
}
resetSimulation();
animate();
</script>
</body>
</html>
```