Prompt specification
Build or customize the Three.js 3D scene "Community Consultation Route Planning" 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: Community Consultation Route Planning
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/community-consultation-route-planning-x3259
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing representation and bias in community sampling. Build a small district with homes, workplaces, and varying attendance windows. Let users place consultation points and inspect which groups remain unrepresented under stated assumptions. Voxel style.
Working Three.js Starter (community-consultation-route-planning-x3259):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Civic Atlas — Representation & Bias in Community Sampling</title>
<style>
:root {
color-scheme: dark;
--bg: #09111e;
--panel: rgba(14, 24, 39, 0.9);
--panel-strong: rgba(18, 30, 48, 0.96);
--border: rgba(164, 190, 218, 0.16);
--text: #eef5fc;
--muted: #91a4b9;
--soft: #b8c6d5;
--accent: #73e2bd;
--warning: #ffb86b;
--danger: #ff7c82;
--blue: #75b9ff;
--radius: 17px;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button,
select,
input {
font: inherit;
}
button,
select,
label,
input[type="checkbox"] {
-webkit-tap-highlight-color: transparent;
}
button {
color: inherit;
}
#stage {
position: fixed;
inset: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 42%, #172a42 0%, #0a1423 48%, #07101b 100%);
}
#stage canvas {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
#labelLayer {
position: absolute;
inset: 0;
z-index: 2;
pointer-events: none;
overflow: hidden;
}
.vignette {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
background:
linear-gradient(90deg, rgba(5, 11, 20, 0.34), transparent 25%, transparent 75%, rgba(5, 11, 20, 0.34)),
linear-gradient(0deg, rgba(5, 11, 20, 0.28), transparent 22%);
}
.topbar {
position: fixed;
z-index: 20;
top: 14px;
left: 16px;
right: 16px;
min-height: 60px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 10px 13px 10px 15px;
border: 1px solid var(--border);
border-radius: 16px;
background: rgba(10, 19, 32, 0.86);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(16px);
}
.brand {
display: flex;
align-items: center;
min-width: 0;
gap: 12px;
}
.brand-mark {
width: 38px;
height: 38px;
position: relative;
flex: 0 0 auto;
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
width: 19px;
height: 19px;
border: 1px solid rgba(115, 226, 189, 0.7);
background: rgba(115, 226, 189, 0.13);
transform: rotate(30deg) skew(-5deg);
}
.brand-mark::before {
left: 3px;
top: 8px;
}
.brand-mark::after {
right: 2px;
top: 2px;
border-color: rgba(117, 185, 255, 0.75);
background: rgba(117, 185, 255, 0.13);
}
.eyebrow {
margin: 0 0 3px;
color: var(--accent);
font-size: 10px;
line-height: 1;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
h1 {
margin: 0;
overflow: hidden;
color: #f5f9fd;
font-size: 17px;
line-height: 1.15;
letter-spacing: -0.015em;
text-overflow: ellipsis;
white-space: nowrap;
}
.top-actions {
display: flex;
align-items: center;
gap: 8px;
}
.live-chip {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 10px;
color: #b9c9d8;
border: 1px solid var(--border);
border-radius: 10px;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
.live-chip::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 12px var(--accent);
}
.icon-button,
.ghost-button,
.primary-button {
border: 1px solid var(--border);
border-radius: 10px;
background: rgba(255, 255, 255, 0.035);
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.icon-button:hover,
.ghost-button:hover {
border-color: rgba(164, 190, 218, 0.36);
background: rgba(255, 255, 255, 0.075);
}
.icon-button:active,
.ghost-button:active,
.primary-button:active {
transform: translateY(1px);
}
.icon-button {
width: 36px;
height: 36px;
color: #c7d4e1;
font-size: 17px;
}
.ghost-button {
padding: 9px 11px;
color: #c5d2df;
font-size: 12px;
font-weight: 700;
}
.primary-button {
padding: 11px 13px;
color: #092019;
border-color: rgba(115, 226, 189, 0.85);
background: var(--accent);
font-size: 12px;
font-weight: 850;
}
.primary-button:hover {
background: #8aefcd;
}
.primary-button.active {
color: #effbf7;
border-color: rgba(115, 226, 189, 0.65);
background: rgba(115, 226, 189, 0.15);
box-shadow: inset 0 0 0 1px rgba(115, 226, 189, 0.08);
}
.panel {
position: fixed;
z-index: 12;
top: 88px;
bottom: 16px;
width: 318px;
overflow: auto;
padding: 18px;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--panel);
box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(18px);
scrollbar-width: thin;
scrollbar-color: #34465b transparent;
}
.left-panel {
left: 16px;
}
.right-panel {
right: 16px;
width: 348px;
}
.panel::-webkit-scrollbar {
width: 6px;
}
.panel::-webkit-scrollbar-thumb {
border-radius: 6px;
background: #34465b;
}
.panel h2 {
margin: 0 0 7px;
font-size: 18px;
line-height: 1.2;
letter-spacing: -0.025em;
}
.panel h3 {
margin: 0;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.panel-intro {
margin: 0 0 17px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.section {
margin-top: 16px;
padding-top: 16px;
border-top: 1px solid var(--border);
}
.section:first-of-type {
margin-top: 0;
padding-top: 0;
border-top: 0;
}
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 11px;
}
.section-count {
color: var(--muted);
font-size: 11px;
}
.form-row {
display: grid;
grid-template-columns: 1fr auto;
gap: 8px;
}
.field {
display: flex;
flex-direction: column;
gap: 6px;
}
.field label,
.field-label {
color: #aab9c9;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
select {
width: 100%;
min-height: 39px;
padding: 0 31px 0 11px;
color: #e8f0f8;
border: 1px solid var(--border);
border-radius: 10px;
background:
linear-gradient(45deg, transparent 50%, #8295aa 50%) calc(100% - 15px) 16px / 5px 5px no-repeat,
linear-gradient(135deg, #8295aa 50%, transparent 50%) calc(100% - 11px) 16px / 5px 5px no-repeat,
#152337;
appearance: none;
font-size: 12px;
outline: none;
}
select:focus {
border-color: rgba(115, 226, 189, 0.65);
}
.check-row {
display: flex;
align-items: center;
gap: 9px;
min-height: 39px;
padding: 8px 10px;
border: 1px solid var(--border);
border-radius: 10px;
background: rgba(255, 255, 255, 0.025);
color: #bdcad7;
font-size: 11px;
cursor: pointer;
}
.check-row input {
width: 15px;
height: 15px;
margin: 0;
accent-color: var(--accent);
}
.full-button {
width: 100%;
margin-top: 9px;
}
.hint {
margin: 9px 0 0;
color: #8397ab;
font-size: 10px;
line-height: 1.45;
}
.point-list {
display: grid;
gap: 8px;
}
.point-item {
display: grid;
grid-template-columns: 31px 1fr 28px;
align-items: center;
gap: 9px;
min-height: 55px;
padding: 8px;
border: 1px solid var(--border);
border-radius: 12px;
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
transition: 150ms ease;
}
.point-item:hover {
border-color: rgba(164, 190, 218, 0.35);
background: rgba(255, 255, 255, 0.045);
}
.point-item.selected {
border-color: rgba(115, 226, 189, 0.5);
background: rgba(115, 226, 189, 0.065);
}
.point-number {
display: grid;
place-items: center;
width: 29px;
height: 29px;
border-radius: 8px;
background: #203249;
color: #dfeaf5;
font-size: 10px;
font-weight: 850;
}
.point-main {
min-width: 0;
}
.point-title {
overflow: hidden;
color: #e4edf6;
font-size: 11px;
font-weight: 760;
text-overflow: ellipsis;
white-space: nowrap;
}
.point-meta {
margin-top: 4px;
overflow: hidden;
color: #8498ad;
font-size: 9px;
text-overflow: ellipsis;
white-space: nowrap;
}
.remove-button {
width: 27px;
height: 27px;
padding: 0;
color: #93a5b8;
border: 1px solid transparent;
border-radius: 8px;
background: transparent;
cursor: pointer;
}
.remove-button:hover {
color: #ff9297;
border-color: rgba(255, 124, 130, 0.25);
background: rgba(255, 124, 130, 0.08);
}
.range-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.range-value {
color: var(--accent);
font-size: 12px;
font-weight: 850;
}
input[type="range"] {
width: 100%;
height: 4px;
border-radius: 4px;
background: #27394d;
accent-color: var(--accent);
cursor: pointer;
}
.scale-row {
display: flex;
justify-content: space-between;
margin-top: 6px;
color: #6f8297;
font-size: 9px;
}
.inspector {
margin-top: 10px;
padding: 12px;
border: 1px solid rgba(164, 190, 218, 0.14);
border-radius: 13px;
background: rgba(255, 255, 255, 0.025);
}
.inspector-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 10px;
}
.inspector-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 9px;
}
.mini-stat {
padding: 9px;
border-radius: 9px;
background: rgba(5, 12, 22, 0.36);
}
.mini-stat strong {
display: block;
color: #e9f2fb;
font-size: 12px;
}
.mini-stat span {
display: block;
margin-top: 3px;
color: #7f93a9;
font-size: 9px;
}
.reach-list {
display: grid;
gap: 5px;
margin-top: 10px;
}
.reach-row {
display: grid;
grid-template-columns: 8px 1fr auto;
align-items: center;
gap: 8px;
padding: 5px 0;
border-bottom: 1px solid rgba(164, 190, 218, 0.08);
color: #a9b8c8;
font-size: 10px;
}
.reach-row:last-child {
border-bottom: 0;
}
.reach-dot {
width: 7px;
height: 7px;
border-radius: 2px;
}
.reach-row strong {
color: #dce7f2;
font-size: 10px;
}
.audit-summary {
display: grid;
grid-template-columns: 88px 1fr;
gap: 15px;
align-items: center;
padding: 14px;
border: 1px solid var(--border);
border-radius: 15px;
background:
linear-gradient(135deg, rgba(115, 226, 189, 0.07), rgba(117, 185, 255, 0.025));
}
.score-ring {
--pct: 0;
display: grid;
place-items: center;
width: 82px;
height: 82px;
border-radius: 50%;
background: conic-gradient(var(--accent) calc(var(--pct) * 1%), #26384d 0);
box-shadow: 0 0 28px rgba(115, 226, 189, 0.08);
}
.score-ring > div {
display: grid;
place-items: center;
width: 67px;
height: 67px;
border-radius: 50%;
background: #101d2e;
}
.score-ring strong {
font-size: 20px;
line-height: 1;
}
.score-ring span {
margin-top: 3px;
color: #8fa2b6;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.summary-copy strong {
display: block;
margin-bottom: 5px;
font-size: 13px;
}
.summary-copy p {
margin: 0;
color: #8fa2b6;
font-size: 10px;
line-height: 1.45;
}
.reach-bar {
height: 5px;
margin-top: 10px;
overflow: hidden;
border-radius: 5px;
background: #27384b;
}
.reach-bar > span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--accent), var(--blue));
transition: width 300ms ease;
}
.audit-note {
margin-top: 10px;
padding: 10px 11px;
border-left: 2px solid var(--warning);
border-radius: 0 9px 9px 0;
background: rgba(255, 184, 107, 0.06);
color: #c2b5a9;
font-size: 10px;
line-height: 1.5;
}
.audit-note.good {
border-left-color: var(--accent);
background: rgba(115, 226, 189, 0.055);
color: #a9c3bc;
}
.group-list {
display: grid;
gap: 8px;
}
.group-card {
position: relative;
width: 100%;
overflow: hidden;
padding: 11px 11px 10px 14px;
color: inherit;
border: 1px solid var(--border);
border-radius: 12px;
background: rgba(255, 255, 255, 0.025);
text-align: left;
cursor: pointer;
transition: 150ms ease;
}
.group-card::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 4px;
background: var(--group-color);
}
.group-card:hover {
border-color: rgba(164, 190, 218, 0.35);
background: rgba(255, 255, 255, 0.045);
}
.group-card.selected {
border-color: color-mix(in srgb, var(--group-color) 65%, transparent);
background: color-mix(in srgb, var(--group-color) 8%, transparent);
box-shadow: 0 0 0 1px color-mix(in srgb, var(--group-color) 12%, transparent);
}
.group-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.group-name {
color: #e8eff7;
font-size: 11px;
font-weight: 800;
}
.status-pill {
padding: 4px 7px;
border-radius: 999px;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.06em;
text-transform: uppercase;
white-space: nowrap;
}
.status-pill.good {
color: #a8ebd6;
background: rgba(115, 226, 189, 0.12);
}
.status-pill.warn {
color: #ffd0a0;
background: rgba(255, 184, 107, 0.13);
}
.status-pill.bad {
color: #ffb2b6;
background: rgba(255, 124, 130, 0.13);
}
.group-meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 7px;
color: #8498ad;
font-size: 9px;
}
.group-progress {
height: 4px;
margin-top: 9px;
overflow: hidden;
border-radius: 4px;
background: #27384b;
}
.group-progress span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--group-color);
transition: width 350ms ease;
}
.group-detail {
margin-top: 10px;
padding: 12px;
border: 1px solid var(--border);
border-radius: 13px;
background: rgba(255, 255, 255, 0.025);
}
.group-detail h3 {
color: var(--soft);
}
.detail-copy {
margin: 8px 0 0;
color: #8ea1b5;
font-size: 10px;
line-height: 1.5;
}
.chip-row {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin-top: 9px;
}
.chip {
padding: 5px 7px;
color: #aebdcc;
border: 1px solid var(--border);
border-radius: 7px;
background: rgba(255, 255, 255, 0.025);
font-size: 8px;
font-weight: 750;
}
details {
border: 1px solid var(--border);
border-radius: 12px;
background: rgba(255, 255, 255, 0.018);
}
summary {
padding: 11px 12px;
color: #b8c7d6;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
cursor: pointer;
}
.assumptions {
padding: 0 12px 12px;
color: #8799ad;
font-size: 10px;
line-height: 1.55;
}
.assumptions ul {
margin: 0;
padding-left: 17px;
}
.assumptions li + li {
margin-top: 6px;
}
.point-label {
position: absolute;
display: grid;
place-items: center;
min-width: 25px;
height: 25px;
padding: 0 6px;
color: #07131f;
border: 2px solid rgba(255, 255, 255, 0.75);
border-radius: 8px;
background: #73e2bd;
box-shadow: 0 5px 14px rgba(0, 0, 0, 0.35);
font-size: 9px;
font-weight: 900;
pointer-events: auto;
cursor: pointer;
transform: translate(-50%, -100%);
}
.point-label:hover {
filter: brightness(1.12);
}
.zone-label {
position: absolute;
color: rgba(204, 221, 237, 0.54);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
transform: translate(-50%, -50%);
white-space: nowrap;
}
#toast {
position: fixed;
z-index: 50;
left: 50%;
bottom: 25px;
max-width: min(440px, calc(100vw - 32px));
padding: 11px 15px;
color: #eaf2f9;
border: 1px solid rgba(164, 190, 218, 0.24);
border-radius: 11px;
background: rgba(12, 23, 38, 0.96);
box-shadow: 0 15px 45px rgba(0, 0, 0, 0.35);
font-size: 11px;
line-height: 1.4;
opacity: 0;
pointer-events: none;
transform: translate(-50%, 12px);
transition: 180ms ease;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
.bottom-hint {
position: fixed;
z-index: 8;
left: 50%;
bottom: 17px;
display: flex;
align-items: center;
gap: 9px;
padding: 8px 11px;
color: rgba(178, 196, 214, 0.72);
border: 1px solid rgba(164, 190, 218, 0.12);
border-radius: 999px;
background: rgba(8, 16, 27, 0.72);
font-size: 9px;
pointer-events: none;
transform: translateX(-50%);
backdrop-filter: blur(10px);
}
kbd {
padding: 2px 5px;
color: #d8e5f0;
border: 1px solid rgba(164, 190, 218, 0.2);
border-radius: 5px;
background: rgba(255, 255, 255, 0.04);
font-family: inherit;
font-size: 8px;
font-weight: 800;
}
@media (max-width: 1040px) {
.panel {
width: 285px;
padding: 15px;
}
.right-panel {
width: 302px;
}
.live-chip {
display: none;
}
}
@media (max-width: 760px) {
body {
overflow: auto;
}
#stage {
position: relative;
inset: auto;
height: 58vh;
min-height: 430px;
}
.vignette {
display: none;
}
.topbar {
position: sticky;
top: 8px;
left: 8px;
right: 8px;
}
.brand-mark {
display: none;
}
h1 {
font-size: 14px;
}
.top-actions .ghost-button {
display: none;
}
.panel {
position: relative;
inset: auto;
width: auto;
margin: 10px;
max-height: none;
overflow: visible;
}
.bottom-hint {
display: none;
}
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive voxel district">
<div id="labelLayer"></div>
</div>
<div class="vignette"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<p class="eyebrow">Civic Atlas</p>
<h1>Representation & bias in community sampling</h1>
</div>
</div>
<div class="top-actions">
<span class="live-chip">Live spatial model</span>
<button class="ghost-button" id="resetView" title="Reset the camera">Reset view</button>
<button class="ghost-button" id="clearPlan">Clear plan</button>
<button class="icon-button" id="topView" title="Top-down view" aria-label="Top-down view">⌖</button>
</div>
</header>
<aside class="panel left-panel" aria-label="Consultation plan controls">
<p class="eyebrow">Plan builder</p>
<h2>Place consultation points</h2>
<p class="panel-intro">
Add a session, then place it on an open plot or street. Coverage updates
immediately against each community's attendance window.
</p>
<section class="section">
<div class="section-head">
<h3>New point</h3>
<span class="section-count">Click the map to place</span>
</div>
<div class="form-row">
<div class="field">
<label for="placeSession">Attendance window</label>
<select id="placeSession">
<option value="morning">Weekday · 09:00–12:00</option>
<option value="afternoon">Weekday · 12:00–16:00</option>
<option value="evening">Weekday · 16:00–20:00</option>
<option value="weekend">Weekend · 10:00–14:00</option>
</select>
</div>
<label class="check-row" for="placeStepFree">
<input id="placeStepFree" type="checkbox" checked />
Step-free
</label>
</div>
<button class="primary-button full-button" id="addPointButton">
+ Activate point placement
</button>
<p class="hint" id="placementHint">
Press A to toggle placement. Existing points can be selected on the map.
</p>
</section>
<section class="section">
<div class="section-head">
<h3>Consultation points</h3>
<span class="section-count" id="pointCount">0 points</span>
</div>
<div class="point-list" id="pointList"></div>
<div class="inspector" id="pointInspector" hidden>
<div class="inspector-title">
<h3>Point settings</h3>
<span class="section-count" id="selectedPointLabel"></span>
</div>
<div class="form-row">
<div class="field">
<label for="editSession">Attendance window</label>
<select id="editSession">
<option value="morning">Weekday · 09:00–12:00</option>
<option value="afternoon">Weekday · 12:00–16:00</option>
<option value="evening">Weekday · 16:00–20:00</option>
<option value="weekend">Weekend · 10:00–14:00</option>
</select>
</div>
<label class="check-row" for="editStepFree">
<input id="editStepFree" type="checkbox" />
Step-free
</label>
</div>
<div class="reach-list" id="pointReachList"></div>
</div>
</section>
<section class="section">
<div class="section-head">
<h3>Travel assumption</h3>
<span class="range-value" id="distanceValue">11 m</span>
</div>
<input
id="distanceSlider"
type="range"
min="6"
max="18"
step="1"
value="11"
aria-label="Maximum travel distance"
/>
<div class="scale-row">
<span>6 m</span>
<span>Straight-line distance</span>
<span>18 m</span>
</div>
<p class="hint">
Residents may travel from either their home or workplace. Travel is
modelled as a direct distance rather than a street-network route.
</p>
</section>
</aside>
<aside class="panel right-panel" aria-label="Coverage and bias assessment">
<p class="eyebrow">Bias lens</p>
<h2>Coverage audit</h2>
<p class="panel-intro">
A low coverage score flags a representation risk. It does not diagnose
why an individual would or would not participate.
</p>
<div class="audit-summary">
<div class="score-ring" id="scoreRing">
<div>
<strong id="groupScore">0/6</strong>
<span>groups met</span>
</div>
</div>
<div class="summary-copy">
<strong id="auditHeadline">Assessing the plan…</strong>
<p id="auditDescription"></p>
<div class="reach-bar"><span id="reachBar"></span></div>
<p id="reachText" style="margin-top: 6px"></p>
</div>
</div>
<div class="audit-note" id="auditNote" aria-live="polite"></div>
<section class="section">
<div class="section-head">
<h3>Community groups</h3>
<span class="section-count">Select to inspect</span>
</div>
<div class="group-list" id="groupList"></div>
<div id="groupInspector"></div>
</section>
<section class="section">
<details>
<summary>Stated assumptions</summary>
<div class="assumptions">
<ul>
<li>
A community group is considered represented when at least
<strong>70%</strong> of its modelled residents can reach an
eligible consultation point.
</li>
<li>A point is eligible only when its attendance window overlaps
the group's available window.</li>
<li>Groups marked “step-free required” can use only step-free points.</li>
<li>Distance is the minimum direct distance from a point to a
resident's home or workplace.</li>
<li>The model does not test capacity, public transport, childcare,
language, disability, digital access, or willingness to attend.</li>
<li>Coverage is therefore a screening signal for sampling bias, not
a fairness verdict.</li>
</ul>
</div>
</details>
</section>
</aside>
<div class="bottom-hint">
<span><kbd>Drag</kbd> orbit</span>
<span><kbd>Shift + drag</kbd> pan</span>
<span><kbd>Scroll</kbd> zoom</span>
<span><kbd>Esc</kbd> cancel placement</span>
</div>
<div id="toast" role="status" aria-live="polite"></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// DOM and model definitions
// -------------------------------------------------------------------------
const stage = document.getElementById("stage");
const labelLayer = document.getElementById("labelLayer");
const toast = document.getElementById("toast");
const placeSession = document.getElementById("placeSession");
const placeStepFree = document.getElementById("placeStepFree");
const addPointButton = document.getElementById("addPointButton");
const placementHint = document.getElementById("placementHint");
const pointList = document.getElementById("pointList");
const pointCount = document.getElementById("pointCount");
const pointInspector = document.getElementById("pointInspector");
const selectedPointLabel = document.getElementById("selectedPointLabel");
const editSession = document.getElementById("editSession");
const editStepFree = document.getElementById("editStepFree");
const pointReachList = document.getElementById("pointReachList");
const distanceSlider = document.getElementById("distanceSlider");
const distanceValue = document.getElementById("distanceValue");
const scoreRing = document.getElementById("scoreRing");
const groupScore = document.getElementById("groupScore");
const auditHeadline = document.getElementById("auditHeadline");
const auditDescription = document.getElementById("auditDescription");
const reachBar = document.getElementById("reachBar");
const reachText = document.getElementById("reachText");
const auditNote = document.getElementById("auditNote");
const groupList = document.getElementById("groupList");
const groupInspector = document.getElementById("groupInspector");
const sessions = {
morning: {
label: "Weekday mornings",
short: "09:00–12:00",
color: 0x73e2bd,
hex: "#73e2bd"
},
afternoon: {
label: "Weekday afternoons",
short: "12:00–16:00",
color: 0x75b9ff,
hex: "#75b9ff"
},
evening: {
label: "Weekday evenings",
short: "16:00–20:00",
color: 0xc69aff,
hex: "#c69aff"
},
weekend: {
label: "Weekend daytime",
short: "10:00–14:00",
color: 0xffc56f,
hex: "#ffc56f"
}
};
const groups = [
{
id: "families",
name: "Families & caregivers",
color: 0xff8b78,
hex: "#ff8b78",
sample: 32,
home: { x: -8, z: 10.5 },
work: { x: 8, z: -3.5 },
windows: ["morning", "afternoon"],
stepFree: true,
context: "Availability varies around school runs, childcare, and daytime care.",
places: "West homes → central offices"
},
{
id: "seniors",
name: "Older residents",
color: 0x72c7ef,
hex: "#72c7ef",
sample: 18,
home: { x: -16, z: -10.5 },
work: { x: -6, z: -10.5 },
windows: ["morning"],
stepFree: true,
context: "The model assumes a narrower weekday-morning availability window.",
places: "West cottages → community hub"
},
{
id: "students",
name: "Students & young adults",
color: 0xffcf67,
hex: "#ffcf67",
sample: 26,
home: { x: 16, z: 10.5 },
work: { x: 16, z: -10.5 },
windows: ["evening", "weekend"],
stepFree: false,
context: "Availability is concentrated after work or class and on weekends.",
places: "East residences → campus"
},
{
id: "shift",
name: "Shift workers",
color: 0xbf9bff,
hex: "#bf9bff",
sample: 24,
home: { x: 0, z: 10.5 },
work: { x: 16, z: 3.5 },
windows: ["evening", "weekend"],
stepFree: false,
context: "Rota patterns make weekday mornings and afternoons difficult to attend.",
places: "Central housing → east depot"
},
{
id: "carers",
name: "People providing care",
color: 0x6ee0bc,
hex: "#6ee0bc",
sample: 20,
home: { x: -16, z: 3.5 },
work: { x: -16, z: -3.5 },
windows: ["morning", "evening"],
stepFree: true,
context: "The model assumes limited middle-of-day availability around care duties.",
places: "West homes → care centre"
},
{
id: "newcomers",
name: "Recent arrivals",
color: 0x75b9ff,
hex: "#75b9ff",
sample: 24,
home: { x: 22, z: 3.5 },
work: { x: 10, z: 3.5 },
windows: ["afternoon", "weekend"],
stepFree: false,
context: "The model assumes variable familiarity with weekday morning sessions.",
places: "East apartments → arrival hub"
}
];
const REPRESENTATION_THRESHOLD = 0.7;
let travelRadius = Number(distanceSlider.value);
let points = [];
let nextPointNumber = 1;
let selectedPointId = null;
let selectedGroupId = null;
let placementMode = false;
let assessment = null;
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x09111e);
scene.fog = new THREE.Fog(0x09111e, 58, 112);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
stage.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-35, 35, 24, -24, 0.1, 180);
const cameraState = {
target: new THREE.Vector3(0, 0, 0),
radius: 58,
theta: 0.72,
phi: 0.83,
zoom: 1
};
const hemisphere = new THREE.HemisphereLight(0xbcd8ff, 0x172236, 2.2);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d0, 3.1);
sun.position.set(-24, 38, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -38;
sun.shadow.camera.right = 38;
sun.shadow.camera.top = 32;
sun.shadow.camera.bottom = -32;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 95;
sun.shadow.bias = -0.0003;
scene.add(sun);
const fillLight = new THREE.DirectionalLight(0x7fa8ff, 0.75);
fillLight.position.set(26, 18, -25);
scene.add(fillLight);
const material = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0.02,
...extra
});
const materials = {
ground: material(0x18283a),
edge: material(0x24374b),
sidewalk: material(0x405168),
road: material(0x152131),
lane: material(0x8d947b, { emissive: 0x272b1d, emissiveIntensity: 0.2 }),
plaza: material(0x30475b),
home: material(0x8593a2),
work: material(0x52677c),
roof: material(0x35485e),
window: material(0xffd38a, { emissive: 0xffb347, emissiveIntensity: 0.38 }),
trunk: material(0x655242),
leaves: material(0x477b68),
leavesLight: material(0x5b9276),
lamp: material(0xffe2a4, { emissive: 0xffbd54, emissiveIntensity: 1.2 })
};
function addBox(w, h, d, mat, x, y, z, parent = scene, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Ground slab and a subtle raised perimeter.
addBox(55, 1.15, 41, materials.edge, 0, -0.75, 0, scene, false);
addBox(53.4, 0.5, 39.4, materials.ground, 0, -0.23, 0, scene, false);
const roadXs = [-20, -12, -4, 4, 12, 20];
const roadZs = [-14, -7, 0, 7, 14];
for (const x of roadXs) {
addBox(3.25, 0.09, 39.5, materials.sidewalk, x, 0.045, 0, scene, false);
addBox(2.55, 0.11, 39.6, materials.road, x, 0.075, 0, scene, false);
}
for (const z of roadZs) {
addBox(53.5, 0.09, 3.25, materials.sidewalk, 0, 0.05, z, scene, false);
addBox(53.6, 0.11, 2.55, materials.road, 0, 0.08, z, scene, false);
}
const laneGeometry = new THREE.BoxGeometry(0.11, 0.025, 0.82);
const laneMesh = new THREE.InstancedMesh(laneGeometry, materials.lane, 208);
const dummy = new THREE.Object3D();
let laneIndex = 0;
for (const x of roadXs) {
for (let z = -18; z <= 18; z += 2.1) {
dummy.position.set(x, 0.145, z);
dummy.rotation.set(0, 0, 0);
dummy.updateMatrix();
laneMesh.setMatrixAt(laneIndex++, dummy.matrix);
}
}
for (const z of roadZs) {
for (let x = -25; x <= 25; x += 2.1) {
dummy.position.set(x, 0.15, z);
dummy.rotation.set(0, Math.PI / 2, 0);
dummy.updateMatrix();
laneMesh.setMatrixAt(laneIndex++, dummy.matrix);
}
}
laneMesh.count = laneIndex;
laneMesh.receiveShadow = true;
scene.add(laneMesh);
// Small civic plazas.
for (const plaza of [
{ x: -8, z: 3.5 },
{ x: 8, z: 3.5 },
{ x: 0, z: -3.5 },
{ x: 16, z: -3.5 }
]) {
addBox(4.2, 0.08, 4.2, materials.plaza, plaza.x, 0.13, plaza.z, scene, false);
addBox(2.8, 0.1, 0.08, materials.lane, plaza.x, 0.19, plaza.z - 1.3, scene, false);
addBox(0.08, 0.1, 2.8, materials.lane, plaza.x - 1.3, 0.19, plaza.z, scene, false);
}
const buildingFootprints = [];
function createHome(x, z, accentHex, seed) {
const height = 1.25 + (seed % 3) * 0.22;
const width = 2.15 + (seed % 2) * 0.25;
const depth = 1.95 + (seed % 2) * 0.2;
buildingFootprints.push({ x, z, w: width + 0.3, d: depth + 0.3 });
addBox(width, height, depth, materials.home, x, height / 2 + 0.16, z);
addBox(
width * 0.78,
0.28,
depth * 0.78,
materials.roof,
x,
height + 0.3,
z
);
addBox(
width * 0.42,
0.24,
depth * 0.42,
materials.roof,
x + width * 0.12,
height + 0.56,
z
);
const accentMat = material(accentHex, { emissive: accentHex, emissiveIntensity: 0.07 });
addBox(width * 0.82, 0.22, 0.08, accentMat, x, 0.42, z + depth / 2 + 0.045);
addBox(
0.32,
0.35,
0.07,
materials.window,
x - width * 0.23,
height * 0.58,
z + depth / 2 + 0.045
);
addBox(
0.32,
0.35,
0.07,
materials.window,
x + width * 0.23,
height * 0.58,
z + depth / 2 + 0.045
);
}
function createWorkplace(x, z, accentHex, kind = "work") {
const width = kind === "apartment" ? 2.65 : 5.2;
const depth = kind === "apartment" ? 3.65 : 3.45;
const height = kind === "apartment" ? 5.5 : kind === "depot" ? 3.5 : 4.6;
buildingFootprints.push({ x, z, w: width + 0.35, d: depth + 0.35 });
addBox(width, height, depth, materials.work, x, height / 2 + 0.16, z);
addBox(
width * 0.78,
0.42,
depth * 0.75,
materials.roof,
x,
height + 0.37,
z
);
addBox(
width * 0.32,
0.72,
depth * 0.35,
materials.roof,
x + width * 0.12,
height + 0.94,
z
);
const accentMat = material(accentHex, { emissive: accentHex, emissiveIntensity: 0.12 });
addBox(width * 0.9, 0.35, 0.1, accentMat, x, height * 0.72, z + depth / 2 + 0.06);
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 3; col++) {
addBox(
0.38,
0.31,
0.07,
materials.window,
x + (col - 1) * width * 0.22,
0.85 + row * 0.92,
z + depth / 2 + 0.06
);
}
}
}
const homeOffsets = [
[-1.55, -1.55],
[1.55, -1.55],
[-1.55, 1.55],
[1.55, 1.55]
];
let buildingSeed = 0;
for (const group of groups) {
if (group.id === "newcomers") {
createWorkplace(group.home.x, group.home.z, group.hex, "apartment");
} else {
for (const [dx, dz] of homeOffsets) {
createHome(
group.home.x + dx,
group.home.z + dz,
group.hex,
buildingSeed++
);
}
}
const workplaceKind =
group.id === "shift" ? "depot" : group.id === "students" ? "campus" : "work";
createWorkplace(group.work.x, group.work.z, group.hex, workplaceKind);
}
function createTree(x, z, scale = 1) {
addBox(0.35 * scale, 1.35 * scale, 0.35 * scale, materials.trunk, x, 0.72 * scale, z);
addBox(
1.15 * scale,
0.8 * scale,
1.15 * scale,
materials.leaves,
x,
1.45 * scale,
z
);
addBox(
0.72 * scale,
0.62 * scale,
0.72 * scale,
materials.leavesLight,
x + 0.17 * scale,
2.0 * scale,
z - 0.12 * scale
);
}
const treePositions = [
[-21, 10.5], [-21, 6], [-21, -6], [-21, -11],
[-8, -16], [-4, -16], [1, -16], [5, -16],
[21, -16], [21, -11], [21, 10.5], [21, 6],
[-3, -3.5], [3, -3.5], [-16, 17], [0, 17],
[8, -16], [-16, -16]
];
treePositions.forEach(([x, z], index) => {
createTree(x, z, 0.78 + (index % 3) * 0.12);
});
function createLamp(x, z) {
addBox(0.16, 2.25, 0.16, materials.roof, x, 1.2, z);
addBox(0.48, 0.2, 0.48, materials.lamp, x, 2.36, z);
}
[
[-18.2, 4], [-6.2, 4], [6.2, 4], [18.2, 4],
[-16, -12.2], [-6, -12.2], [6, -12.2], [16, -12.2],
[-16, 12.2], [6, 12.2], [18, 12.2]
].forEach(([x, z]) => createLamp(x, z));
// -------------------------------------------------------------------------
// Modelled residents
// -------------------------------------------------------------------------
let randomSeed = 173;
function random() {
randomSeed |= 0;
randomSeed = (randomSeed + 0x6d2b79f5) | 0;
let t = Math.imul(randomSeed ^ (randomSeed >>> 15), 1 | randomSeed);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
}
function jitter(center, radius = 1.05) {
return {
x: center.x + (random() - 0.5) * radius * 2,
z: center.z + (random() - 0.5) * radius * 2
};
}
const residents = [];
for (const group of groups) {
for (let i = 0; i < group.sample; i++) {
const home = jitter(group.home, 0.9);
const work = jitter(group.work, 0.8);
residents.push({
groupId: group.id,
home,
work,
display: i % 3 === 0 ? work : home,
covered: false
});
}
}
const residentCount = residents.length;
const bodyGeometry = new THREE.BoxGeometry(0.25, 0.38, 0.25);
const headGeometry = new THREE.BoxGeometry(0.22, 0.22, 0.22);
const bodyMesh = new THREE.InstancedMesh(bodyGeometry, material(0xffffff), residentCount);
const headMesh = new THREE.InstancedMesh(headGeometry, material(0xffffff), residentCount);
residents.forEach((resident, index) => {
dummy.position.set(resident.display.x, 0.37, resident.display.z);
dummy.rotation.set(0, 0, 0);
dummy.updateMatrix();
bodyMesh.setMatrixAt(index, dummy.matrix);
dummy.position.set(resident.display.x, 0.67, resident.display.z);
dummy.updateMatrix();
headMesh.setMatrixAt(index, dummy.matrix);
});
bodyMesh.castShadow = true;
headMesh.castShadow = true;
scene.add(bodyMesh, headMesh);
// -------------------------------------------------------------------------
// Zone labels and ground picking plane
// -------------------------------------------------------------------------
const zoneLabels = [];
function createZoneLabel(text, x, y, z) {
const element = document.createElement("div");
element.className = "zone-label";
element.textContent = text;
labelLayer.appendChild(element);
zoneLabels.push({
element,
position: new THREE.Vector3(x, y, z)
});
}
createZoneLabel("West homes", -16, 3.1, 10.5);
createZoneLabel("Care quarter", -16, 6.5, -3.5);
createZoneLabel("East campus", 16, 7.2, -10.5);
createZoneLabel("Shift depot", 16, 5.2, 3.5);
createZoneLabel("East apartments", 22, 7, 3.5);
createZoneLabel("Central offices", 8, 6.1, -3.5);
const groundPick = new THREE.Mesh(
new THREE.PlaneGeometry(53, 39),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
side: THREE.DoubleSide
})
);
groundPick.rotation.x = -Math.PI / 2;
groundPick.position.y = 0.18;
scene.add(groundPick);
// -------------------------------------------------------------------------
// Consultation points
// -------------------------------------------------------------------------
const pointBaseGeometry = new THREE.BoxGeometry(1.25, 0.18, 1.25);
const pointPillarGeometry = new THREE.BoxGeometry(0.32, 1.15, 0.32);
const pointTopGeometry = new THREE.BoxGeometry(0.78, 0.78, 0.78);
const pointAccessGeometry = new THREE.BoxGeometry(0.24, 0.24, 0.24);
const pointHitGeometry = new THREE.BoxGeometry(2, 3, 2);
const pointHitMaterial = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
colorWrite: false
});
const pointBaseMaterial = material(0x1c2c3e);
const accessMaterial = material(0x73e2bd, {
emissive: 0x73e2bd,
emissiveIntensity: 0.5
});
const noAccessMaterial = material(0xffb86b, {
emissive: 0xffb86b,
emissiveIntensity: 0.45
});
const pointHitMeshes = [];
function createPoint(x, z, session, stepFree) {
const point = {
id: nextPointNumber,
number: nextPointNumber,
x,
z,
session,
stepFree,
stats: {},
tiles: new Map()
};
nextPointNumber++;
const marker = new THREE.Group();
marker.position.set(x, 0.18, z);
addBox(1.25, 0.18, 1.25, pointBaseMaterial, 0, 0.09, 0, marker);
addBox(0.32, 1.15, 0.32, material(sessions[session].color), 0, 0.75, 0, marker);
const top = addBox(
0.78,
0.78,
0.78,
material(sessions[session].color, {
emissive: sessions[session].color,
emissiveIntensity: 0.22
}),
0,
1.62,
0,
marker
);
const access = addBox(
0.24,
0.24,
0.24,
stepFree ? accessMaterial : noAccessMaterial,
0.53,
1.65,
0,
marker
);
const hit = new THREE.Mesh(pointHitGeometry, pointHitMaterial);
hit.position.set(0, 1.1, 0);
hit.userData.pointId = point.id;
marker.add(hit);
pointHitMeshes.push(hit);
point.marker = marker;
point.top = top;
point.access = access;
scene.add(marker);
for (const group of groups) {
const tile = new THREE.Mesh(
new THREE.CircleGeometry(1, 48),
new THREE.MeshBasicMaterial({
color: group.color,
transparent: true,
opacity: 0.07,
depthWrite: false,
side: THREE.DoubleSide
})
);
tile.rotation.x = -Math.PI / 2;
tile.position.set(x, 0.205, z);
tile.scale.set(travelRadius, travelRadius, 1);
tile.visible = false;
scene.add(tile);
point.tiles.set(group.id, tile);
}
const label = document.createElement("button");
label.type = "button";
label.className = "point-label";
label.textContent = String(point.number).padStart(2, "0");
label.title = `${sessions[session].label} · ${stepFree ? "step-free" : "not step-free"}`;
label.addEventListener("click", event => {
event.stopPropagation();
selectPoint(point.id);
});
labelLayer.appendChild(label);
point.label = label;
points.push(point);
return point;
}
function removePoint(point) {
const index = points.indexOf(point);
if (index === -1) return;
scene.remove(point.marker);
point.label.remove();
for (const tile of point.tiles.values()) {
scene.remove(tile);
tile.geometry.dispose();
tile.material.dispose();
}
const hitIndex = pointHitMeshes.indexOf(point.marker.children[3]);
if (hitIndex !== -1) pointHitMeshes.splice(hitIndex, 1);
points.splice(index, 1);
if (selectedPointId === point.id) selectedPointId = null;
}
function selectPoint(id) {
selectedPointId = id;
selectedGroupId = null;
renderAll();
}
function togglePlacement() {
placementMode = !placementMode;
addPointButton.classList.toggle("active", placementMode);
addPointButton.textContent = placementMode
? "● Placement active — click the map"
: "+ Activate point placement";
placementHint.textContent = placementMode
? "Click an open plot or street. Press Esc to cancel."
: "Press A to toggle placement. Existing points can be selected on the map.";
renderer.domElement.style.cursor = placementMode ? "crosshair" : "grab";
}
function pointIsInsideBuilding(x, z) {
return buildingFootprints.some(
footprint =>
Math.abs(x - footprint.x) < footprint.w / 2 + 0.65 &&
Math.abs(z - footprint.z) < footprint.d / 2 + 0.65
);
}
function placePointAt(x, z) {
x = Math.round(x * 2) / 2;
z = Math.round(z * 2) / 2;
if (Math.abs(x) > 25 || Math.abs(z) > 17.5) {
showToast("Place the point inside the district boundary.");
return;
}
if (pointIsInsideBuilding(x, z)) {
showToast("That plot contains a building. Try a nearby street or open square.");
return;
}
if (points.some(point => Math.hypot(point.x - x, point.z - z) < 2.2)) {
showToast("A consultation point is already nearby.");
return;
}
const point = createPoint(
x,
z,
placeSession.value,
placeStepFree.checked
);
selectedPointId = point.id;
selectedGroupId = null;
assess();
renderAll();
showToast(`Point ${String(point.number).padStart(2, "0")} placed. Coverage updated.`);
}
// -------------------------------------------------------------------------
// Coverage model
// -------------------------------------------------------------------------
function pointEligible(group, point) {
const windowMatches = group.windows.includes(point.session);
const accessMatches = !group.stepFree || point.stepFree;
return windowMatches && accessMatches;
}
function distanceToResident(point, resident) {
const homeDistance = Math.hypot(point.x - resident.home.x, point.z - resident.home.z);
const workDistance = Math.hypot(point.x - resident.work.x, point.z - resident.work.z);
return Math.min(homeDistance, workDistance);
}
function assess() {
for (const point of points) point.stats = {};
const results = {};
for (const group of groups) {
const groupResidents = residents.filter(resident => resident.groupId === group.id);
let coveredCount = 0;
const compatibleWindowPoints = points.filter(point =>
group.windows.includes(point.session)
);
const eligiblePoints = points.filter(point => pointEligible(group, point));
for (const resident of groupResidents) {
resident.covered = false;
let closestPoint = null;
let closestDistance = Infinity;
for (const point of eligiblePoints) {
const distance = distanceToResident(point, resident);
if (distance < closestDistance) {
closestDistance = distance;
closestPoint = point;
}
}
if (closestPoint && closestDistance <= travelRadius) {
resident.covered = true;
coveredCount++;
closestPoint.stats[group.id] = (closestPoint.stats[group.id] || 0) + 1;
}
}
const coverage = coveredCount / groupResidents.length;
const represented = coverage >= REPRESENTATION_THRESHOLD;
let reason;
if (!points.length) {
reason = "No consultation points have been placed.";
} else if (!compatibleWindowPoints.length) {
reason = `No consultation window overlaps ${group.windows
.map(key => sessions[key].label.toLowerCase())
.join(" or ")}.`;
} else if (!eligiblePoints.length) {
reason = "Compatible sessions exist, but none are step-free.";
} else if (coveredCount === 0) {
reason = `Every eligible point is more than ${travelRadius} m from this group's homes or workplaces.`;
} else if (!represented) {
reason = `${groupResidents.length - coveredCount} residents cannot reach an eligible point within ${travelRadius} m.`;
} else {
reason = `${coveredCount} of ${groupResidents.length} residents can reach an eligible point.`;
}
results[group.id] = {
group,
residents: groupResidents,
coveredCount,
coverage,
represented,
reason,
eligiblePoints,
compatibleWindowPoints
};
}
assessment = results;
updateResidentColors();
updateReachTiles();
}
function updateResidentColors() {
const focusColor = new THREE.Color(0x27384c);
residents.forEach((resident, index) => {
const group = groups.find(group => group.id === resident.groupId);
const base = new THREE.Color(group.color);
let color;
if (selectedGroupId && selectedGroupId !== resident.groupId) {
color = focusColor.clone();
} else if (resident.covered) {
color = base;
} else {
color = base.clone().lerp(focusColor, 0.7);
}
bodyMesh.setColorAt(index, color);
headMesh.setColorAt(
index,
color.clone().lerp(new THREE.Color(0xffffff), selectedGroupId === resident.groupId ? 0.18 : 0.04)
);
});
if (bodyMesh.instanceColor) bodyMesh.instanceColor.needsUpdate = true;
if (headMesh.instanceColor) headMesh.instanceColor.needsUpdate = true;
}
function updateReachTiles() {
for (const point of points) {
for (const group of groups) {
const tile = point.tiles.get(group.id);
const count = point.stats[group.id] || 0;
const showForGroup = selectedGroupId === group.id && count > 0;
const showForPoint = !selectedGroupId && selectedPointId === point.id && count > 0;
tile.visible = showForGroup || showForPoint;
tile.scale.set(travelRadius, travelRadius, 1);
tile.material.opacity = showForGroup ? 0.075 : 0.045;
}
}
}
// -------------------------------------------------------------------------
// Interface rendering
// -------------------------------------------------------------------------
function formatWindows(group) {
return group.windows
.map(key => `${sessions[key].short}`)
.join(" · ");
}
function renderPointList() {
pointCount.textContent = `${points.length} ${points.length === 1 ? "point" : "points"}`;
if (!points.length) {
pointList.innerHTML = `
<div class="hint" style="padding: 13px; border: 1px dashed rgba(164,190,218,.16); border-radius: 11px;">
No points yet. Activate placement and choose a session.
</div>
`;
} else {
pointList.innerHTML = points
.map(point => {
const session = sessions[point.session];
return `
<div class="point-item ${selectedPointId === point.id ? "selected" : ""}" data-point-id="${point.id}">
<span class="point-number">${String(point.number).padStart(2, "0")}</span>
<div class="point-main">
<div class="point-title" style="color:${session.hex}">${session.label}</div>
<div class="point-meta">
${session.short} · ${point.stepFree ? "Step-free" : "Standard access"} · ${point.x}, ${point.z}
</div>
</div>
<button class="remove-button" data-remove-point="${point.id}" title="Remove point" aria-label="Remove point">×</button>
</div>
`;
})
.join("");
}
const selectedPoint = points.find(point => point.id === selectedPointId);
pointInspector.hidden = !selectedPoint;
if (selectedPoint) {
selectedPointLabel.textContent = `P${String(selectedPoint.number).padStart(2, "0")}`;
editSession.value = selectedPoint.session;
editStepFree.checked = selectedPoint.stepFree;
pointReachList.innerHTML = groups
.map(group => {
const eligible = pointEligible(group, selectedPoint);
const count = selectedPoint.stats[group.id] || 0;
return `
<div class="reach-row">
<span class="reach-dot" style="background:${group.hex}"></span>
<span>${group.name}</span>
<strong>${eligible ? `${count} reached` : "Not eligible"}</strong>
</div>
`;
})
.join("");
}
}
function renderSummary() {
if (!assessment) return;
const represented = groups.filter(group => assessment[group.id].represented);
const gaps = groups.filter(group => !assessment[group.id].represented);
const reached = residents.filter(resident => resident.covered).length;
const reachedPercent = Math.round((reached / residents.length) * 100);
const groupPercent = Math.round((represented.length / groups.length) * 100);
scoreRing.style.setProperty("--pct", groupPercent);
groupScore.textContent = `${represented.length}/${groups.length}`;
auditHeadline.textContent =
gaps.length === 0
? "No threshold gaps detected"
: `${gaps.length} ${gaps.length === 1 ? "group has" : "groups have"} a coverage gap`;
auditDescription.textContent =
gaps.length === 0
? "Every community clears the 70% representation threshold in this plan."
: "Potential sampling bias remains where access or timing excludes residents.";
reachBar.style.width = `${reachedPercent}%`;
reachText.textContent = `${reached} of ${residents.length} modelled residents can reach an eligible point (${reachedPercent}%).`;
if (gaps.length) {
auditNote.classList.remove("good");
auditNote.innerHTML = `<strong>Bias lens:</strong> ${gaps
.map(group => group.name)
.join(", ")} ${gaps.length === 1 ? "remains" : "remain"} below the representation threshold. Inspect the group card to see whether the gap is temporal, spatial, or accessibility-related.`;
} else {
auditNote.classList.add("good");
auditNote.innerHTML = `<strong>Bias lens:</strong> No modelled group falls below 70% coverage. Other participation barriers may still exist because they are outside this model.`;
}
}
function renderGroupList() {
groupList.innerHTML = groups
.map(group => {
const result = assessment[group.id];
const percentage = Math.round(result.coverage * 100);
const status = result.coveredCount === 0
? "Unrepresented"
: result.represented
? "Represented"
: "Coverage gap";
const statusClass = result.coveredCount === 0
? "bad"
: result.represented
? "good"
: "warn";
return `
<button class="group-card ${selectedGroupId === group.id ? "selected" : ""}" data-group-id="${group.id}" style="--group-color:${group.hex}">
<span class="group-top">
<span class="group-name">${group.name}</span>
<span class="status-pill ${statusClass}">${status}</span>
</span>
<span class="group-meta">
<span>${formatWindows(group)}</span>
<span>${result.coveredCount}/${result.residents.length} reached</span>
</span>
<span class="group-progress"><span style="width:${percentage}%"></span></span>
</button>
`;
})
.join("");
}
function renderGroupInspector() {
const group = groups.find(group => group.id === selectedGroupId);
if (!group || !assessment) {
groupInspector.innerHTML = "";
return;
}
const result = assessment[group.id];
const percentage = Math.round(result.coverage * 100);
groupInspector.innerHTML = `
<div class="group-detail">
<h3 style="color:${group.hex}">${group.name}</h3>
<p class="detail-copy">${group.context}</p>
<p class="detail-copy"><strong>${result.reason}</strong></p>
<div class="chip-row">
<span class="chip">${percentage}% coverage</span>
<span class="chip">${group.stepFree ? "Step-free required" : "Step-free optional"}</span>
<span class="chip">${result.eligiblePoints.length} eligible points</span>
</div>
<div class="inspector-grid">
<div class="mini-stat">
<strong>${group.places}</strong>
<span>Modelled home / workplace relationship</span>
</div>
<div class="mini-stat">
<strong>${group.windows.map(key => sessions[key].label).join(" + ")}</strong>
<span>Available attendance window</span>
</div>
</div>
<p class="hint">
The coloured reach circles show which points serve this group.
Select the card again to clear the focus.
</p>
</div>
`;
}
function renderAll() {
renderPointList();
if (assessment) {
renderSummary();
renderGroupList();
renderGroupInspector();
}
}
function showToast(message) {
toast.textContent = message;
toast.classList.add("show");
clearTimeout(showToast.timeout);
showToast.timeout = setTimeout(() => toast.classList.remove("show"), 2700);
}
// -------------------------------------------------------------------------
// Camera controls implemented directly with Three.js core
// -------------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let pointerDown = null;
function updateCamera() {
const { target, radius, theta, phi, zoom } = cameraState;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
camera.zoom = zoom;
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
function resetCamera() {
cameraState.target.set(0, 0, 0);
cameraState.theta = 0.72;
cameraState.phi = 0.83;
cameraState.zoom = 1;
updateCamera();
}
function topCamera() {
cameraState.target.set(0, 0, 0);
cameraState.theta = 0;
cameraState.phi = 0.055;
cameraState.zoom = 0.9;
updateCamera();
}
function panCamera(dx, dy) {
const right = new THREE.Vector3(1, 0, 0).applyQuaternion(camera.quaternion);
right.y = 0;
right.normalize();
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const amount = (cameraState.radius * 0.0015) / cameraState.zoom;
cameraState.target.addScaledVector(right, -dx * amount);
cameraState.target.addScaledVector(forward, -dy * amount);
cameraState.target.x = THREE.MathUtils.clamp(cameraState.target.x, -18, 18);
cameraState.target.z = THREE.MathUtils.clamp(cameraState.target.z, -14, 14);
}
function setPointerFromEvent(event) {
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;
}
function handleMapClick(event) {
if (event.button !== 0) return;
setPointerFromEvent(event);
raycaster.setFromCamera(pointer, camera);
const pointHits = raycaster.intersectObjects(pointHitMeshes, false);
if (pointHits.length) {
const id = pointHits[0].object.userData.pointId;
selectPoint(id);
return;
}
if (!placementMode) return;
const hits = raycaster.intersectObject(groundPick, false);
if (hits.length) {
placePointAt(hits[0].point.x, hits[0].point.z);
}
}
renderer.domElement.addEventListener("pointerdown", event => {
pointerDown = {
x: event.clientX,
y: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
moved: 0,
button: event.button,
shift: event.shiftKey
};
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = placementMode ? "crosshair" : "grabbing";
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointerDown) return;
const dx = event.clientX - pointerDown.lastX;
const dy = event.clientY - pointerDown.lastY;
pointerDown.moved += Math.hypot(dx, dy);
pointerDown.lastX = event.clientX;
pointerDown.lastY = event.clientY;
if (pointerDown.moved > 4) {
if (pointerDown.button === 2 || pointerDown.shift) {
panCamera(dx, dy);
} else {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.08,
1.22
);
}
updateCamera();
}
});
renderer.domElement.addEventListener("pointerup", event => {
if (!pointerDown) return;
const wasClick = pointerDown.moved < 5;
const button = pointerDown.button;
pointerDown = null;
renderer.domElement.style.cursor = placementMode ? "crosshair" : "grab";
if (wasClick) {
handleMapClick({
clientX: event.clientX,
clientY: event.clientY,
button
});
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = null;
renderer.domElement.style.cursor = placementMode ? "crosshair" : "grab";
});
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * Math.exp(-event.deltaY * 0.001),
0.65,
1.75
);
updateCamera();
},
{ passive: false }
);
// -------------------------------------------------------------------------
// UI events
// -------------------------------------------------------------------------
addPointButton.addEventListener("click", togglePlacement);
pointList.addEventListener("click", event => {
const removeButton = event.target.closest("[data-remove-point]");
if (removeButton) {
event.stopPropagation();
const point = points.find(point => point.id === Number(removeButton.dataset.removePoint));
if (point) {
removePoint(point);
assess();
renderAll();
showToast(`Point ${String(point.number).padStart(2, "0")} removed.`);
}
return;
}
const item = event.target.closest("[data-point-id]");
if (item) selectPoint(Number(item.dataset.pointId));
});
groupList.addEventListener("click", event => {
const card = event.target.closest("[data-group-id]");
if (!card) return;
const id = card.dataset.groupId;
selectedGroupId = selectedGroupId === id ? null : id;
selectedPointId = null;
updateResidentColors();
updateReachTiles();
renderAll();
});
editSession.addEventListener("change", () => {
const point = points.find(point => point.id === selectedPointId);
if (!point) return;
point.session = editSession.value;
const sessionColor = sessions[point.session].color;
point.top.material.color.setHex(sessionColor);
point.top.material.emissive.setHex(sessionColor);
point.marker.children[1].material.color.setHex(sessionColor);
point.label.style.background = sessions[point.session].hex;
point.label.title = `${sessions[point.session].label} · ${point.stepFree ? "step-free" : "not step-free"}`;
assess();
renderAll();
});
editStepFree.addEventListener("change", () => {
const point = points.find(point => point.id === selectedPointId);
if (!point) return;
point.stepFree = editStepFree.checked;
point.access.material = point.stepFree ? accessMaterial : noAccessMaterial;
point.label.title = `${sessions[point.session].label} · ${point.stepFree ? "step-free" : "not step-free"}`;
assess();
renderAll();
});
distanceSlider.addEventListener("input", () => {
travelRadius = Number(distanceSlider.value);
distanceValue.textContent = `${travelRadius} m`;
assess();
renderAll();
});
document.getElementById("resetView").addEventListener("click", resetCamera);
document.getElementById("topView").addEventListener("click", topCamera);
document.getElementById("clearPlan").addEventListener("click", () => {
for (const point of [...points]) removePoint(point);
nextPointNumber = 1;
selectedPointId = null;
selectedGroupId = null;
assess();
renderAll();
showToast("Plan cleared. Place a point to begin a new coverage scenario.");
});
window.addEventListener("keydown", event => {
const targetTag = document.activeElement?.tagName;
if (targetTag === "INPUT" || targetTag === "SELECT" || targetTag === "TEXTAREA") return;
if (event.key.toLowerCase() === "a") {
togglePlacement();
} else if (event.key === "Escape") {
if (placementMode) togglePlacement();
selectedPointId = null;
selectedGroupId = null;
updateResidentColors();
updateReachTiles();
renderAll();
} else if (event.key.toLowerCase() === "r") {
resetCamera();
}
});
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function resize() {
const width = Math.max(stage.clientWidth, 1);
const height = Math.max(stage.clientHeight, 1);
renderer.setSize(width, height, false);
const aspect = width / height;
const viewHeight = Math.max(44, 58 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
if ("ResizeObserver" in window) {
new ResizeObserver(resize).observe(stage);
}
const projected = new THREE.Vector3();
function projectLabel(element, worldPosition) {
projected.copy(worldPosition).project(camera);
const width = stage.clientWidth;
const height = stage.clientHeight;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const visible = projected.z > -1 && projected.z < 1 && x > -50 && x < width + 50 && y > -30 && y < height + 30;
element.style.display = visible ? "" : "none";
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function animate(time) {
requestAnimationFrame(animate);
for (const point of points) {
point.top.position.y = 1.62 + Math.sin(time * 0.0025 + point.id) * 0.06;
point.access.position.y = 1.65 + Math.sin(time * 0.0025 + point.id) * 0.06;
}
for (const point of points) {
projected.set(point.x, 2.55, point.z).project(camera);
const width = stage.clientWidth;
const height = stage.clientHeight;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
point.label.style.display =
projected.z > -1 && projected.z < 1 ? "" : "none";
point.label.style.left = `${x}px`;
point.label.style.top = `${y}px`;
}
for (const label of zoneLabels) {
projectLabel(label.element, label.position);
}
renderer.render(scene, camera);
}
// Start with a deliberately imperfect three-point example so the sampling
// bias is immediately visible. All points remain editable or removable.
createPoint(-8, 3.5, "morning", true);
createPoint(8, 3.5, "afternoon", true);
createPoint(13, 10.5, "evening", false);
assess();
renderAll();
resize();
updateCamera();
requestAnimationFrame(animate);
</script>
</body>
</html>
```