Prompt specification
Build or customize the Three.js 3D scene "Small-Group Disclosure Demonstrator" 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: Small-Group Disclosure Demonstrator
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/small-group-disclosure-demonstrator-x3248
Scene Description Prompt:
Use invented household records and voxel homes to show how tiny groups reveal individual attributes. Three.js from cdnjs, one HTML file.
Working Three.js Starter (small-group-disclosure-demonstrator-x3248):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Small Groups, Clear Signals</title>
<style>
:root {
--ink: #17362f;
--muted: #697b75;
--paper: #f4f3eb;
--panel: #fffdf7;
--line: #dce1d8;
--accent: #e86745;
--green: #2e7567;
--shadow: 0 12px 35px rgba(27, 55, 47, 0.09);
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button {
font: inherit;
}
button:focus-visible {
outline: 3px solid rgba(232, 103, 69, 0.4);
outline-offset: 2px;
}
.app {
display: grid;
grid-template-rows: 66px minmax(0, 1fr);
height: 100vh;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
border-bottom: 1px solid var(--line);
background: rgba(255, 253, 247, 0.94);
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.brand-mark {
display: grid;
grid-template-columns: repeat(2, 8px);
grid-template-rows: repeat(2, 8px);
gap: 3px;
flex: 0 0 auto;
}
.brand-mark i {
display: block;
background: var(--green);
border-radius: 1px;
}
.brand-mark i:nth-child(2) {
background: #e4b650;
}
.brand-mark i:nth-child(3) {
background: #e86745;
}
.brand-mark i:nth-child(4) {
background: #7ca99d;
}
.brand-title {
font-weight: 760;
font-size: 15px;
letter-spacing: -0.01em;
white-space: nowrap;
}
.brand-subtitle {
margin-top: 2px;
color: var(--muted);
font-size: 11px;
white-space: nowrap;
}
.synthetic-badge {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 7px 11px;
border: 1px solid #cbd9d1;
border-radius: 999px;
color: #46645b;
background: #f1f7f1;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
white-space: nowrap;
}
.synthetic-badge::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: #58a476;
box-shadow: 0 0 0 3px rgba(88, 164, 118, 0.13);
}
main {
display: grid;
grid-template-columns: minmax(0, 1fr) 455px;
min-height: 0;
}
.visual {
display: grid;
grid-template-rows: minmax(0, 1fr) 66px;
min-width: 0;
min-height: 0;
}
.viewport {
position: relative;
min-height: 0;
overflow: hidden;
isolation: isolate;
background: #e7ece5;
}
.viewport canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
z-index: 0;
}
.scene-heading {
position: absolute;
top: 24px;
left: 24px;
z-index: 2;
pointer-events: none;
max-width: min(430px, calc(100% - 150px));
}
.eyebrow {
margin-bottom: 8px;
color: #628077;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.scene-heading h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 3vw, 38px);
font-weight: 500;
letter-spacing: -0.035em;
}
.scene-heading p {
margin: 8px 0 0;
color: #60736d;
font-size: 12px;
line-height: 1.5;
}
.scene-tools {
position: absolute;
right: 18px;
top: 18px;
z-index: 3;
display: grid;
gap: 7px;
}
.tool-button {
width: 36px;
height: 36px;
display: grid;
place-items: center;
border: 1px solid rgba(23, 54, 47, 0.14);
border-radius: 10px;
color: var(--ink);
background: rgba(255, 253, 247, 0.9);
box-shadow: 0 5px 18px rgba(23, 54, 47, 0.08);
cursor: pointer;
transition: transform 150ms ease, background 150ms ease;
}
.tool-button:hover {
transform: translateY(-1px);
background: #fff;
}
.scene-legend {
position: absolute;
left: 18px;
bottom: 18px;
z-index: 2;
width: min(360px, calc(100% - 36px));
padding: 12px 14px;
border: 1px solid rgba(23, 54, 47, 0.11);
border-radius: 13px;
background: rgba(255, 253, 247, 0.88);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
pointer-events: none;
}
.legend-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.legend-title span:last-child {
color: var(--muted);
font-weight: 600;
letter-spacing: 0;
text-transform: none;
}
.field-legend {
display: flex;
flex-wrap: wrap;
gap: 7px 12px;
}
.legend-field {
display: inline-flex;
align-items: center;
gap: 6px;
color: #5d706a;
font-size: 10px;
font-weight: 650;
}
.legend-field i,
.attribute-chip i {
display: inline-block;
width: 7px;
height: 7px;
flex: 0 0 auto;
border-radius: 2px;
}
.scene-help {
position: absolute;
right: 18px;
bottom: 18px;
z-index: 2;
padding: 9px 11px;
border-radius: 10px;
color: #5f726c;
background: rgba(255, 253, 247, 0.82);
font-size: 10px;
pointer-events: none;
}
.hover-tooltip {
position: absolute;
z-index: 5;
min-width: 185px;
padding: 10px 12px;
border: 1px solid rgba(23, 54, 47, 0.14);
border-radius: 10px;
color: var(--ink);
background: rgba(255, 253, 247, 0.97);
box-shadow: var(--shadow);
font-size: 11px;
line-height: 1.45;
pointer-events: none;
}
.hover-tooltip strong {
display: block;
margin-bottom: 2px;
}
.loading {
position: absolute;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
color: var(--muted);
background: #e7ece5;
font-size: 13px;
}
.selection-bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 0 20px;
border-top: 1px solid var(--line);
background: var(--panel);
z-index: 4;
}
.selection-meta {
min-width: 0;
}
.selection-summary {
margin-bottom: 3px;
font-size: 12px;
font-weight: 800;
}
.selection-instruction {
color: var(--muted);
font-size: 10px;
}
.selected-chips {
display: flex;
align-items: center;
gap: 6px;
margin-top: 5px;
min-width: 0;
}
.selected-chip {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 3px 7px;
border: 1px solid var(--line);
border-radius: 999px;
background: #f7f7f1;
color: #4e655e;
font-size: 9px;
font-weight: 750;
white-space: nowrap;
}
.selected-chip button {
display: grid;
place-items: center;
width: 15px;
height: 15px;
padding: 0;
border: 0;
border-radius: 50%;
color: #657871;
background: transparent;
cursor: pointer;
}
.selected-chip button:hover {
color: var(--accent);
background: rgba(232, 103, 69, 0.1);
}
.selection-actions {
display: flex;
gap: 8px;
flex: 0 0 auto;
}
.action-button {
min-height: 34px;
padding: 0 13px;
border: 1px solid #d3dcd4;
border-radius: 9px;
color: var(--ink);
background: #f8f8f2;
font-size: 10px;
font-weight: 800;
cursor: pointer;
transition: transform 150ms ease, border-color 150ms ease;
}
.action-button:hover:not(:disabled) {
transform: translateY(-1px);
border-color: #9eb8ac;
}
.action-button.primary {
border-color: var(--ink);
color: #fff;
background: var(--ink);
}
.action-button:disabled {
opacity: 0.4;
cursor: default;
}
.insights {
overflow-y: auto;
min-height: 0;
padding: 28px 28px 40px;
border-left: 1px solid var(--line);
background: var(--panel);
scrollbar-width: thin;
scrollbar-color: #c7d0c8 transparent;
}
.panel-intro h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 36px;
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.04em;
}
.panel-intro h1 em {
color: var(--accent);
font-weight: 500;
}
.panel-intro > p {
margin: 13px 0 22px;
color: var(--muted);
font-size: 12px;
line-height: 1.65;
}
.exposure-card {
position: relative;
overflow: hidden;
padding: 20px;
border-radius: 18px;
color: #fff;
background:
radial-gradient(circle at 90% 5%, rgba(239, 186, 80, 0.24), transparent 33%),
linear-gradient(145deg, #173c33, #245b4f);
box-shadow: 0 14px 35px rgba(23, 56, 47, 0.16);
}
.exposure-card::after {
content: "";
position: absolute;
right: -32px;
bottom: -48px;
width: 140px;
height: 140px;
border: 22px solid rgba(255, 255, 255, 0.035);
border-radius: 24px;
transform: rotate(18deg);
pointer-events: none;
}
.metric-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
color: rgba(255, 255, 255, 0.7);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.risk-badge {
padding: 5px 7px;
border-radius: 999px;
color: #fff4d8;
background: rgba(255, 255, 255, 0.12);
font-size: 9px;
letter-spacing: 0.02em;
text-transform: none;
}
.metric-number {
display: flex;
align-items: baseline;
gap: 8px;
margin: 13px 0 5px;
font-family: Georgia, "Times New Roman", serif;
font-size: 49px;
line-height: 1;
letter-spacing: -0.04em;
}
.metric-number small {
color: rgba(255, 255, 255, 0.57);
font-family: Inter, ui-sans-serif, system-ui, sans-serif;
font-size: 10px;
letter-spacing: 0;
}
.metric-copy {
position: relative;
z-index: 1;
margin: 8px 0 15px;
color: rgba(255, 255, 255, 0.74);
font-size: 11px;
line-height: 1.55;
}
.meter {
height: 5px;
overflow: hidden;
border-radius: 999px;
background: rgba(255, 255, 255, 0.13);
}
.meter > span {
display: block;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #efaa58, #f4d18b);
transition: width 350ms ease;
}
.metric-grid {
position: relative;
z-index: 1;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin-top: 17px;
}
.metric-stat {
padding-top: 11px;
border-top: 1px solid rgba(255, 255, 255, 0.14);
}
.metric-stat strong {
display: block;
font-size: 18px;
line-height: 1;
}
.metric-stat span {
display: block;
margin-top: 4px;
color: rgba(255, 255, 255, 0.56);
font-size: 9px;
}
.section-heading {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 12px;
margin: 25px 0 12px;
}
.section-heading h2 {
margin: 0;
font-size: 13px;
letter-spacing: -0.01em;
}
.section-heading span {
color: var(--muted);
font-size: 9px;
}
.home-group {
overflow: hidden;
margin-bottom: 12px;
border: 1px solid var(--line);
border-radius: 14px;
background: #fffefa;
}
.home-group-header {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 14px;
border-bottom: 1px solid #edf0e9;
background: color-mix(in srgb, var(--home-color) 8%, white);
}
.home-swatch {
width: 22px;
height: 22px;
flex: 0 0 auto;
border-radius: 6px;
background: var(--home-color);
box-shadow: inset 0 0 0 1px rgba(23, 54, 47, 0.09);
}
.home-group-title {
min-width: 0;
flex: 1;
}
.home-group-title strong {
display: block;
font-size: 11px;
}
.home-group-title span {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.home-size {
padding: 4px 7px;
border: 1px solid rgba(23, 54, 47, 0.1);
border-radius: 999px;
color: #5d716a;
background: rgba(255, 255, 255, 0.55);
font-size: 9px;
font-weight: 750;
white-space: nowrap;
}
.person-row {
padding: 13px 14px;
border-bottom: 1px solid #f0f1ec;
}
.person-row:last-child {
border-bottom: 0;
}
.person-heading {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
}
.avatar {
display: grid;
place-items: center;
width: 29px;
height: 29px;
flex: 0 0 auto;
border-radius: 9px;
color: #fff;
background: var(--avatar-color);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.03em;
}
.person-name {
min-width: 0;
flex: 1;
}
.person-name strong {
display: block;
font-size: 11px;
}
.person-name span {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.mix-badge {
padding: 4px 6px;
border: 1px solid #cfe1d7;
border-radius: 999px;
color: #39705e;
background: #eff7f1;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.03em;
text-transform: uppercase;
white-space: nowrap;
}
.attribute-list {
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.attribute-chip {
display: inline-flex;
align-items: center;
gap: 5px;
min-height: 22px;
padding: 3px 7px;
border: 1px solid #e7e9e2;
border-radius: 6px;
color: #66766f;
background: #fafaf6;
font-size: 8.5px;
line-height: 1.2;
}
.attribute-chip b {
color: #3e554d;
font-weight: 800;
}
.empty-state {
padding: 35px 18px;
border: 1px dashed #cbd5cd;
border-radius: 14px;
color: var(--muted);
text-align: center;
background: #fafaf5;
font-size: 11px;
line-height: 1.6;
}
.empty-state strong {
display: block;
margin-bottom: 5px;
color: var(--ink);
font-size: 13px;
}
.method-note {
margin-top: 21px;
padding-top: 17px;
border-top: 1px solid var(--line);
color: #788780;
font-size: 9px;
line-height: 1.6;
}
.method-note strong {
color: #526860;
}
@media (max-width: 1120px) {
main {
grid-template-columns: minmax(0, 1fr) 400px;
}
.insights {
padding: 24px 22px 36px;
}
.scene-help {
display: none;
}
}
@media (max-width: 860px) {
body {
overflow: auto;
}
.app {
display: block;
height: auto;
}
.topbar {
height: 64px;
}
main {
display: block;
}
.visual {
height: 70vh;
min-height: 570px;
grid-template-rows: minmax(0, 1fr) auto;
}
.selection-bar {
min-height: 88px;
padding: 12px 14px;
align-items: flex-start;
}
.selection-actions {
flex-direction: column;
}
.action-button {
min-height: 30px;
}
.insights {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.scene-legend {
bottom: 14px;
}
}
@media (max-width: 540px) {
.brand-subtitle {
display: none;
}
.synthetic-badge {
padding: 6px 8px;
font-size: 9px;
}
.scene-heading {
top: 18px;
left: 16px;
}
.scene-heading p {
max-width: 260px;
}
.scene-tools {
top: 14px;
right: 12px;
}
.scene-legend {
left: 12px;
width: calc(100% - 24px);
}
.selection-instruction {
max-width: 210px;
}
.selected-chips {
flex-wrap: wrap;
}
.panel-intro h1 {
font-size: 33px;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div>
<div class="brand-title">Micro-Cohort Atlas</div>
<div class="brand-subtitle">Voxel households · individual attribute signals</div>
</div>
</div>
<div class="synthetic-badge">100% synthetic records</div>
</header>
<main>
<section class="visual" aria-label="Interactive voxel household map">
<div id="viewport" class="viewport">
<div class="scene-heading">
<div class="eyebrow">Neighborhood of nine</div>
<h2>Small groups.<br>Clear signals.</h2>
<p>
Select up to three homes. Colored stacks expose the fictional
attributes of every resident inside the cohort.
</p>
</div>
<div class="scene-tools" aria-label="Camera controls">
<button id="zoomIn" class="tool-button" aria-label="Zoom in">+</button>
<button id="zoomOut" class="tool-button" aria-label="Zoom out">−</button>
<button id="resetView" class="tool-button" aria-label="Reset camera" title="Reset view">
↺
</button>
</div>
<div class="scene-legend">
<div class="legend-title">
<span>Resident attribute stacks</span>
<span>Selected homes only</span>
</div>
<div id="fieldLegend" class="field-legend"></div>
</div>
<div class="scene-help">Drag to orbit · right-drag to pan · scroll to zoom</div>
<div id="hoverTooltip" class="hover-tooltip" hidden></div>
<div id="loading" class="loading">Building the synthetic neighborhood…</div>
</div>
<div class="selection-bar">
<div class="selection-meta">
<div id="selectionSummary" class="selection-summary"></div>
<div class="selection-instruction">
Click one home · Shift-click to compare up to three
</div>
<div id="selectedChips" class="selected-chips"></div>
</div>
<div class="selection-actions">
<button id="trioButton" class="action-button primary">Another revealing trio</button>
<button id="clearButton" class="action-button">Clear</button>
</div>
</div>
</section>
<aside class="insights" aria-label="Cohort insights">
<div class="panel-intro">
<div class="eyebrow">Micro-cohort explorer</div>
<h1>Small groups.<br><em>Clear signals.</em></h1>
<p>
A tiny cohort turns household summaries into person-level records.
Compare a few homes to see which attribute combinations stand out.
</p>
</div>
<section id="exposureCard" class="exposure-card" aria-live="polite"></section>
<div class="section-heading">
<h2>What the cohort reveals</h2>
<span>Exact synthetic fields</span>
</div>
<div id="profiles"></div>
<div class="method-note">
<strong>About this demonstration.</strong>
Every resident, household, address position, and attribute is invented
in this file. “Exposure” counts visible fields; it is not a probability
of identification or a privacy-risk estimate.
</div>
</aside>
</main>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const FIELD_META = {
age: {
label: "Age band",
short: "Age",
color: "#ee8064",
hex: 0xee8064
},
work: {
label: "Work pattern",
short: "Work",
color: "#6284e8",
hex: 0x6284e8
},
mobility: {
label: "Mobility",
short: "Mobility",
color: "#e8b84f",
hex: 0xe8b84f
},
pet: {
label: "Pet",
short: "Pet",
color: "#58a879",
hex: 0x58a879
},
diet: {
label: "Diet",
short: "Diet",
color: "#9a75d4",
hex: 0x9a75d4
},
rhythm: {
label: "Daily rhythm",
short: "Rhythm",
color: "#4fa9bb",
hex: 0x4fa9bb
}
};
const households = [
{
id: "H-01",
name: "Juniper House",
x: -10,
z: -9,
rotation: 0,
bedrooms: 2,
floors: 2,
color: "#d98567",
roof: "#3d514d",
residents: [
{
name: "Mara Vale",
age: "30–39",
work: "Hybrid",
mobility: "No aid",
pet: "Nori · dog",
diet: "Plant-forward",
rhythm: "Early riser"
},
{
name: "Ivo Vale",
age: "40–49",
work: "On-site",
mobility: "No aid",
pet: "None",
diet: "Omnivore",
rhythm: "Night owl"
}
]
},
{
id: "H-02",
name: "Cedar House",
x: 0,
z: -9,
rotation: 0,
bedrooms: 2,
floors: 2,
color: "#d3a657",
roof: "#6d5845",
residents: [
{
name: "Lea Moss",
age: "20–29",
work: "Remote",
mobility: "No aid",
pet: "Miso · cat",
diet: "Vegetarian",
rhythm: "Maker"
},
{
name: "Ben Moss",
age: "60–69",
work: "Retired",
mobility: "Limited steps",
pet: "None",
diet: "Omnivore",
rhythm: "Early riser"
}
]
},
{
id: "H-03",
name: "Harbor House",
x: 10,
z: -9,
rotation: 0,
bedrooms: 2,
floors: 2,
color: "#719d91",
roof: "#354f5c",
residents: [
{
name: "Nia Chen",
age: "30–39",
work: "On-site",
mobility: "No aid",
pet: "Pip · dog",
diet: "Pescatarian",
rhythm: "Cyclist"
},
{
name: "Theo Chen",
age: "10–19",
work: "Student",
mobility: "No aid",
pet: "Pip · dog",
diet: "Flexible",
rhythm: "Gamer"
}
]
},
{
id: "H-04",
name: "Larkspur House",
x: -10,
z: -1,
rotation: 0,
bedrooms: 3,
floors: 2,
color: "#a47b9c",
roof: "#4e465d",
residents: [
{
name: "Ada Rowan",
age: "50–59",
work: "Hybrid",
mobility: "No aid",
pet: "None",
diet: "Gluten-free",
rhythm: "Gardener"
},
{
name: "Rafi Rowan",
age: "50–59",
work: "On-site",
mobility: "No aid",
pet: "Clover · rabbit",
diet: "Omnivore",
rhythm: "Baker"
},
{
name: "Mina Rowan",
age: "20–29",
work: "Remote",
mobility: "No aid",
pet: "Miso · cat",
diet: "Vegan",
rhythm: "Night owl"
}
]
},
{
id: "H-05",
name: "Maple House",
x: 0,
z: -1,
rotation: 0,
bedrooms: 2,
floors: 2,
color: "#c96f62",
roof: "#65463f",
residents: [
{
name: "Sol Ali",
age: "30–39",
work: "Night shift",
mobility: "No aid",
pet: "None",
diet: "Halal",
rhythm: "Baker"
},
{
name: "Meri Ali",
age: "30–39",
work: "On-site",
mobility: "Step-free",
pet: "Miso · cat",
diet: "Omnivore",
rhythm: "Runner"
}
]
},
{
id: "H-06",
name: "Fern House",
x: 10,
z: -1,
rotation: 0,
bedrooms: 2,
floors: 2,
color: "#7c9f68",
roof: "#3d5948",
residents: [
{
name: "June Park",
age: "40–49",
work: "Remote",
mobility: "No aid",
pet: "Nori · dog",
diet: "Flexitarian",
rhythm: "Reader"
},
{
name: "Owen Park",
age: "40–49",
work: "On-site",
mobility: "No aid",
pet: "None",
diet: "Pescatarian",
rhythm: "Cyclist"
}
]
},
{
id: "H-07",
name: "Moss House",
x: -10,
z: 7,
rotation: Math.PI,
bedrooms: 2,
floors: 2,
color: "#8193a8",
roof: "#47526a",
residents: [
{
name: "Eli Ward",
age: "20–29",
work: "Hybrid",
mobility: "Step-free",
pet: "None",
diet: "Vegan",
rhythm: "Maker"
},
{
name: "Sam Ward",
age: "70–79",
work: "Retired",
mobility: "Limited steps",
pet: "Miso · cat",
diet: "Omnivore",
rhythm: "Gardener"
}
]
},
{
id: "H-08",
name: "Orchard House",
x: 0,
z: 7,
rotation: Math.PI,
bedrooms: 3,
floors: 3,
color: "#d19b72",
roof: "#5b5147",
residents: [
{
name: "Noor Diaz",
age: "30–39",
work: "On-site",
mobility: "No aid",
pet: "Pip · dog",
diet: "Plant-forward",
rhythm: "Cyclist"
},
{
name: "Ari Diaz",
age: "40–49",
work: "Night shift",
mobility: "No aid",
pet: "None",
diet: "Omnivore",
rhythm: "Baker"
},
{
name: "Luz Diaz",
age: "10–19",
work: "Student",
mobility: "No aid",
pet: "Miso · cat",
diet: "Flexible",
rhythm: "Gamer"
}
]
},
{
id: "H-09",
name: "Bright House",
x: 10,
z: 7,
rotation: Math.PI,
bedrooms: 2,
floors: 2,
color: "#b0a76b",
roof: "#4c5848",
residents: [
{
name: "Inez Costa",
age: "50–59",
work: "Remote",
mobility: "No aid",
pet: "Clover · rabbit",
diet: "Vegetarian",
rhythm: "Reader"
},
{
name: "Paulo Costa",
age: "50–59",
work: "On-site",
mobility: "No aid",
pet: "None",
diet: "Omnivore",
rhythm: "Baker"
},
{
name: "Kit Costa",
age: "20–29",
work: "Flexible",
mobility: "No aid",
pet: "Nori · dog",
diet: "Vegan",
rhythm: "Maker"
}
]
}
];
const curatedTrios = [
["H-04", "H-07", "H-09"],
["H-01", "H-03", "H-06"],
["H-02", "H-05", "H-08"]
];
const viewport = document.getElementById("viewport");
const loading = document.getElementById("loading");
const hoverTooltip = document.getElementById("hoverTooltip");
const exposureCard = document.getElementById("exposureCard");
const profiles = document.getElementById("profiles");
const selectionSummary = document.getElementById("selectionSummary");
const selectedChips = document.getElementById("selectedChips");
const clearButton = document.getElementById("clearButton");
const trioButton = document.getElementById("trioButton");
const recordById = new Map(households.map((record) => [record.id, record]));
const pickables = [];
const houseRoots = new Map();
const selectionFrames = new Map();
let selectedIds = [...curatedTrios[0]];
let trioIndex = 0;
let markerCubes = [];
let hoverId = null;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#e7ece5");
scene.fog = new THREE.Fog("#e7ece5", 31, 57);
const camera = new THREE.PerspectiveCamera(
42,
viewport.clientWidth / viewport.clientHeight,
0.1,
100
);
let renderer;
try {
renderer = new THREE.WebGLRenderer({ antialias: true });
} catch (error) {
loading.textContent = "This demonstration requires WebGL.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(viewport.clientWidth, viewport.clientHeight, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive neighborhood of fictional voxel homes. Click homes to reveal their residents."
);
viewport.prepend(renderer.domElement);
const hemiLight = new THREE.HemisphereLight(0xffffff, 0x7d958c, 2.15);
scene.add(hemiLight);
const sun = new THREE.DirectionalLight(0xfff4df, 3.1);
sun.position.set(-15, 25, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 60;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d9e8, 0.65);
fill.position.set(15, 12, -16);
scene.add(fill);
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xdce4d9,
roughness: 1
});
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(46, 42),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.08;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(44, 44, 0xaebfb2, 0xc3cec3);
grid.position.y = -0.055;
grid.material.transparent = true;
grid.material.opacity = 0.2;
grid.material.depthWrite = false;
scene.add(grid);
const sidewalkMaterial = new THREE.MeshStandardMaterial({
color: 0xcfd7cf,
roughness: 1
});
const roadMaterial = new THREE.MeshStandardMaterial({
color: 0x77817e,
roughness: 0.95
});
const markingMaterial = new THREE.MeshStandardMaterial({
color: 0xe7e4cf,
roughness: 0.9
});
const curbMaterial = new THREE.MeshStandardMaterial({
color: 0xbdc8bf,
roughness: 1
});
function addRoadBox(size, position, material) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// Sidewalks and roads.
for (const z of [-5, 3]) {
addRoadBox([38, 0.08, 3.4], [0, 0.01, z], sidewalkMaterial);
addRoadBox([38, 0.12, 2.35], [0, 0.075, z], roadMaterial);
}
for (const x of [-5, 5]) {
addRoadBox([3.4, 0.08, 30], [x, 0.01, -1], sidewalkMaterial);
addRoadBox([2.35, 0.12, 30], [x, 0.075, -1], roadMaterial);
}
for (const z of [-5, 3]) {
for (let x = -17; x <= 17; x += 2.2) {
if (Math.abs(Math.abs(x) - 5) > 1.5) {
addRoadBox([0.95, 0.025, 0.075], [x, 0.15, z], markingMaterial);
}
}
}
for (const x of [-5, 5]) {
for (let z = -14; z <= 12; z += 2.2) {
if (z > -6.4 && z < -3.6) continue;
if (z > 1.6 && z < 4.4) continue;
addRoadBox([0.075, 0.025, 0.95], [x, 0.15, z], markingMaterial);
}
}
// Low curbs around intersections.
for (const z of [-5, 3]) {
for (const x of [-5, 5]) {
addRoadBox([3.8, 0.15, 0.16], [x, 0.11, z - 1.78], curbMaterial);
addRoadBox([3.8, 0.15, 0.16], [x, 0.11, z + 1.78], curbMaterial);
}
}
const lotMaterial = new THREE.MeshStandardMaterial({
color: 0xd2dbce,
roughness: 1
});
const glassMaterial = new THREE.MeshStandardMaterial({
color: 0x315d66,
roughness: 0.25,
metalness: 0.12
});
const doorMaterial = new THREE.MeshStandardMaterial({
color: 0x405a52,
roughness: 0.65
});
const planterMaterial = new THREE.MeshStandardMaterial({
color: 0x789064,
roughness: 0.85
});
const solarMaterial = new THREE.MeshStandardMaterial({
color: 0x294c69,
roughness: 0.35,
metalness: 0.3
});
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0xffbd54,
emissive: 0xd98620,
emissiveIntensity: 0.48,
roughness: 0.55,
transparent: true,
opacity: 0.92
});
const markerBaseMaterial = new THREE.MeshStandardMaterial({
color: 0xf9f7ea,
roughness: 0.75
});
const markerPoleMaterial = new THREE.MeshStandardMaterial({
color: 0x34584e,
roughness: 0.7
});
const fieldMaterials = {};
for (const [key, meta] of Object.entries(FIELD_META)) {
fieldMaterials[key] = new THREE.MeshStandardMaterial({
color: meta.hex,
emissive: meta.hex,
emissiveIntensity: 0.1,
roughness: 0.5
});
}
function houseWidth(record) {
return 2.65 + record.bedrooms * 0.24;
}
function makeBox(
parent,
size,
position,
material,
{ id = null, rotation = 0, castShadow = true } = {}
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.y = rotation;
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
if (id) {
mesh.userData.householdId = id;
pickables.push(mesh);
}
parent.add(mesh);
return mesh;
}
function makeSelectionFrame(root) {
const frame = new THREE.Group();
const y = 0.27;
const half = 2.62;
makeBox(frame, [5.35, 0.09, 0.12], [0, y, -half], frameMaterial);
makeBox(frame, [5.35, 0.09, 0.12], [0, y, half], frameMaterial);
makeBox(frame, [0.12, 0.09, 5.35], [-half, y, 0], frameMaterial);
makeBox(frame, [0.12, 0.09, 5.35], [half, y, 0], frameMaterial);
frame.visible = false;
root.add(frame);
return frame;
}
function buildHouse(record) {
const root = new THREE.Group();
root.position.set(record.x, 0, record.z);
root.rotation.y = record.rotation;
scene.add(root);
const width = houseWidth(record);
const depth = 2.65;
const floorHeight = 1.06;
const bodyMaterial = new THREE.MeshStandardMaterial({
color: record.color,
roughness: 0.82
});
const roofMaterial = new THREE.MeshStandardMaterial({
color: record.roof,
roughness: 0.8
});
const trimMaterial = new THREE.MeshStandardMaterial({
color: 0xece5d4,
roughness: 0.88
});
makeBox(root, [5, 0.16, 5], [0, 0.08, 0], lotMaterial, {
id: record.id,
castShadow: false
});
for (let floor = 0; floor < record.floors; floor++) {
const floorWidth = width - floor * 0.12;
const floorDepth = depth - floor * 0.1;
const centerY = 0.18 + floorHeight * (floor + 0.5);
makeBox(
root,
[floorWidth, floorHeight, floorDepth],
[0, centerY, 0],
bodyMaterial,
{ id: record.id }
);
makeBox(
root,
[floorWidth + 0.04, 0.12, floorDepth + 0.04],
[0, 0.18 + floorHeight * (floor + 1), 0],
trimMaterial,
{ id: record.id }
);
const frontZ = floorDepth / 2 + 0.035;
makeBox(
root,
[0.48, 0.46, 0.07],
[-0.65, centerY + 0.03, frontZ],
glassMaterial,
{ id: record.id }
);
makeBox(
root,
[0.48, 0.46, 0.07],
[0.65, centerY + 0.03, frontZ],
glassMaterial,
{ id: record.id }
);
makeBox(
root,
[0.07, 0.44, 0.48],
[floorWidth / 2 + 0.035, centerY + 0.03, 0.25],
glassMaterial,
{ id: record.id }
);
}
const roofY = 0.18 + record.floors * floorHeight;
makeBox(
root,
[width + 0.28, 0.22, depth + 0.28],
[0, roofY + 0.11, 0],
roofMaterial,
{ id: record.id }
);
makeBox(
root,
[width * 0.72, 0.3, depth * 0.72],
[0, roofY + 0.37, 0],
roofMaterial,
{ id: record.id }
);
makeBox(
root,
[width * 0.4, 0.25, depth * 0.4],
[0, roofY + 0.645, 0],
roofMaterial,
{ id: record.id }
);
// Front door.
makeBox(
root,
[0.52, 0.82, 0.09],
[0, 0.59, depth / 2 + 0.055],
doorMaterial,
{ id: record.id }
);
const hasLimitedSteps = record.residents.some(
(resident) => resident.mobility === "Limited steps"
);
const isStepFree = record.residents.some(
(resident) => resident.mobility === "Step-free"
);
if (hasLimitedSteps) {
for (let step = 0; step < 3; step++) {
makeBox(
root,
[0.72, 0.12, 0.28],
[0, 0.2 + step * 0.1, depth / 2 + 0.28 + step * 0.2],
trimMaterial,
{ id: record.id }
);
}
} else if (isStepFree) {
makeBox(
root,
[0.95, 0.07, 1.25],
[0, 0.16, depth / 2 + 0.65],
trimMaterial,
{ id: record.id }
);
}
const hasGardener = record.residents.some(
(resident) => resident.rhythm === "Gardener"
);
if (hasGardener) {
makeBox(
root,
[0.85, 0.28, 0.45],
[-width / 2 - 0.45, 0.31, 0.45],
planterMaterial,
{ id: record.id }
);
}
const hasRemoteWork = record.residents.some(
(resident) => resident.work === "Remote" || resident.work === "Hybrid"
);
if (hasRemoteWork) {
const panel = makeBox(
root,
[1.18, 0.08, 0.82],
[-0.35, roofY + 0.83, 0],
solarMaterial,
{ id: record.id }
);
panel.rotation.x = -0.18;
}
const hasPet = record.residents.some((resident) => resident.pet !== "None");
if (hasPet) {
makeBox(
root,
[0.18, 0.55, 0.18],
[width / 2 + 0.48, 0.45, -0.6],
markerPoleMaterial,
{ id: record.id }
);
makeBox(
root,
[0.34, 0.3, 0.34],
[width / 2 + 0.48, 0.83, -0.6],
planterMaterial,
{ id: record.id }
);
}
const frame = makeSelectionFrame(root);
houseRoots.set(record.id, root);
selectionFrames.set(record.id, frame);
}
households.forEach(buildHouse);
// Voxel trees around the perimeter and a few neighborhood corners.
const trunkMaterial = new THREE.MeshStandardMaterial({
color: 0x80624c,
roughness: 1
});
const leafMaterials = [
new THREE.MeshStandardMaterial({ color: 0x6f9674, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x83a87c, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x5f8769, roughness: 1 })
];
function addTree(x, z, scale = 1, variant = 0) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
makeBox(tree, [0.34, 1.2, 0.34], [0, 0.6, 0], trunkMaterial);
makeBox(tree, [1.25, 0.8, 1.25], [0, 1.45, 0], leafMaterials[variant]);
makeBox(tree, [0.86, 0.7, 0.86], [0, 2.05, 0], leafMaterials[variant]);
makeBox(tree, [0.44, 0.5, 0.44], [0, 2.58, 0], leafMaterials[variant]);
scene.add(tree);
}
[
[-16, -12, 1.05, 0],
[-16, -5, 0.9, 1],
[-16, 2, 1.1, 2],
[-16, 10, 0.95, 0],
[16, -12, 1.1, 1],
[16, -5, 0.92, 2],
[16, 2, 1.02, 0],
[16, 10, 1.12, 1],
[-12.5, -13, 0.8, 2],
[-7.2, -13, 0.72, 0],
[-2.8, -13, 0.85, 1],
[2.8, -13, 0.76, 2],
[7.5, -13, 0.88, 0],
[-12.8, 13, 0.78, 1],
[-2.5, 13, 0.85, 2],
[2.8, 13, 0.74, 0],
[8.2, 13, 0.9, 1]
].forEach((entry) => addTree(...entry));
const markerLayer = new THREE.Group();
scene.add(markerLayer);
function clearMarkers() {
markerLayer.traverse((object) => {
if (object.isMesh) object.geometry.dispose();
});
markerLayer.clear();
markerCubes = [];
}
function rebuildMarkers() {
clearMarkers();
for (const id of selectedIds) {
const record = recordById.get(id);
const group = new THREE.Group();
group.position.set(record.x, 0, record.z);
group.rotation.y = record.rotation;
markerLayer.add(group);
const stackX = houseWidth(record) + 0.85;
record.residents.forEach((resident, residentIndex) => {
const stackZ = -0.95 + residentIndex * 0.5;
makeBox(
group,
[0.48, 0.08, 0.48],
[stackX, 0.27, stackZ],
markerBaseMaterial
);
makeBox(
group,
[0.035, 1.68, 0.035],
[stackX, 1.13, stackZ],
markerPoleMaterial
);
makeBox(
group,
[0.9, 0.035, 0.035],
[stackX - 0.46, 0.31, stackZ],
markerPoleMaterial
);
Object.keys(FIELD_META).forEach((field, fieldIndex) => {
const baseY = 0.51 + fieldIndex * 0.29;
const cube = makeBox(
group,
[0.25, 0.25, 0.25],
[stackX, baseY, stackZ],
fieldMaterials[field]
);
markerCubes.push({
mesh: cube,
baseY,
phase: residentIndex * 0.9 + fieldIndex * 0.45
});
});
});
}
}
// Custom camera controls: no addon imports.
const cameraState = {
theta: 0.65,
phi: 1.04,
radius: 35,
target: new THREE.Vector3(0, 0.4, 0),
desiredTheta: 0.65,
desiredPhi: 1.04,
desiredRadius: 35,
desiredTarget: new THREE.Vector3(0, 0.4, 0)
};
function updateCamera(delta) {
const damping = 1 - Math.pow(0.0008, delta);
cameraState.theta +=
(cameraState.desiredTheta - cameraState.theta) * damping;
cameraState.phi +=
(cameraState.desiredPhi - cameraState.phi) * damping;
cameraState.radius +=
(cameraState.desiredRadius - cameraState.radius) * damping;
cameraState.target.lerp(cameraState.desiredTarget, damping);
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y +
cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.desiredTheta = 0.65;
cameraState.desiredPhi = 1.04;
cameraState.desiredRadius = 35;
cameraState.desiredTarget.set(0, 0.4, 0);
}
function zoomBy(amount) {
cameraState.desiredRadius = THREE.MathUtils.clamp(
cameraState.desiredRadius + amount,
16,
52
);
}
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function householdAtEvent(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;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickables, false);
return hits.length ? hits[0].object.userData.householdId : null;
}
const pointerState = {
down: false,
dragging: false,
button: 0,
additive: false,
startX: 0,
startY: 0,
lastX: 0,
lastY: 0
};
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.button !== 2) return;
event.preventDefault();
pointerState.down = true;
pointerState.dragging = false;
pointerState.button = event.button;
pointerState.additive = event.shiftKey;
pointerState.startX = event.clientX;
pointerState.startY = event.clientY;
pointerState.lastX = event.clientX;
pointerState.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
hoverTooltip.hidden = true;
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (pointerState.down) {
const dx = event.clientX - pointerState.lastX;
const dy = event.clientY - pointerState.lastY;
const totalDistance = Math.hypot(
event.clientX - pointerState.startX,
event.clientY - pointerState.startY
);
if (totalDistance > 4) pointerState.dragging = true;
if (pointerState.dragging) {
if (pointerState.button === 2 || event.altKey) {
const forward = new THREE.Vector3()
.subVectors(cameraState.desiredTarget, camera.position)
.normalize();
const right = new THREE.Vector3()
.crossVectors(forward, camera.up)
.normalize();
const up = new THREE.Vector3()
.crossVectors(right, forward)
.normalize();
const scale = cameraState.desiredRadius * 0.0014;
cameraState.desiredTarget.addScaledVector(right, -dx * scale);
cameraState.desiredTarget.addScaledVector(up, dy * scale);
cameraState.desiredTarget.x = THREE.MathUtils.clamp(
cameraState.desiredTarget.x,
-14,
14
);
cameraState.desiredTarget.z = THREE.MathUtils.clamp(
cameraState.desiredTarget.z,
-14,
14
);
} else {
cameraState.desiredTheta -= dx * 0.006;
cameraState.desiredPhi = THREE.MathUtils.clamp(
cameraState.desiredPhi - dy * 0.005,
0.48,
1.4
);
}
}
pointerState.lastX = event.clientX;
pointerState.lastY = event.clientY;
return;
}
const id = householdAtEvent(event);
hoverId = id;
renderer.domElement.style.cursor = id ? "pointer" : "grab";
if (!id) {
hoverTooltip.hidden = true;
return;
}
const record = recordById.get(id);
const rect = viewport.getBoundingClientRect();
hoverTooltip.innerHTML = `
<strong>${record.id} · ${record.name}</strong>
${record.residents.length} residents · ${record.bedrooms} bedrooms
`;
hoverTooltip.style.left = `${
Math.min(event.clientX - rect.left + 14, rect.width - 235)
}px`;
hoverTooltip.style.top = `${
Math.min(event.clientY - rect.top + 14, rect.height - 75)
}px`;
hoverTooltip.hidden = false;
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!pointerState.down) return;
const wasClick = !pointerState.dragging;
const additive = pointerState.additive;
const button = pointerState.button;
pointerState.down = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
if (wasClick && button === 0) {
const id = householdAtEvent(event);
selectHouse(id, additive);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerState.down = false;
pointerState.dragging = false;
});
renderer.domElement.addEventListener("pointerleave", () => {
if (!pointerState.down) {
hoverTooltip.hidden = true;
hoverId = null;
}
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoomBy(event.deltaY * 0.018);
},
{ passive: false }
);
document.getElementById("zoomIn").addEventListener("click", () => zoomBy(-4));
document.getElementById("zoomOut").addEventListener("click", () => zoomBy(4));
document.getElementById("resetView").addEventListener("click", resetCamera);
function initials(name) {
return name
.split(" ")
.map((part) => part[0])
.join("")
.slice(0, 2)
.toUpperCase();
}
function signature(person) {
return Object.keys(FIELD_META)
.map((field) => person[field])
.join("|");
}
function attributeChips(person) {
return Object.entries(FIELD_META)
.map(
([key, meta]) => `
<span class="attribute-chip">
<i style="background:${meta.color}"></i>
<b>${meta.short}</b>
${person[key]}
</span>
`
)
.join("");
}
function selectedRecords() {
return selectedIds
.map((id) => recordById.get(id))
.filter(Boolean);
}
function renderExposure() {
const records = selectedRecords();
const rows = records.flatMap((record) =>
record.residents.map((person) => ({ record, person }))
);
const fieldCount = Object.keys(FIELD_META).length;
const exposure = rows.length * fieldCount;
const maxExposure = 54;
const signatureCounts = new Map();
for (const row of rows) {
const value = signature(row.person);
signatureCounts.set(value, (signatureCounts.get(value) || 0) + 1);
}
const unmatchedMixes = rows.filter((row) => {
return signatureCounts.get(signature(row.person)) === 1;
}).length;
const valueCounts = {};
let rareValues = 0;
for (const field of Object.keys(FIELD_META)) {
const counts = new Map();
for (const row of rows) {
const value = row.person[field];
counts.set(value, (counts.get(value) || 0) + 1);
}
for (const row of rows) {
if (counts.get(row.person[field]) === 1) rareValues++;
}
valueCounts[field] = counts;
}
let label = "No cohort";
let narrative = "Select a home to reveal the synthetic records of its residents.";
if (records.length === 1) {
label = "Focused reveal";
narrative =
`One home exposes ${exposure} exact attribute fields. ` +
"The person-level view is already complete.";
} else if (records.length === 2) {
label = "Comparative reveal";
narrative =
`Two homes expose ${exposure} fields and make repeated values easy to ` +
"contrast with unmatched personal combinations.";
} else if (records.length === 3) {
label = "High-detail reveal";
narrative =
`The three-home cohort exposes ${exposure} fields. ` +
`${unmatchedMixes} resident combinations are not repeated inside it.`;
}
const percentage = Math.min(100, (exposure / maxExposure) * 100);
exposureCard.innerHTML = `
<div class="metric-top">
<span>Visible attribute fields</span>
<span class="risk-badge">${label}</span>
</div>
<div class="metric-number">
${exposure}
<small>of ${maxExposure} in a max cohort</small>
</div>
<div class="meter"><span style="width:${percentage}%"></span></div>
<p class="metric-copy">${narrative}</p>
<div class="metric-grid">
<div class="metric-stat">
<strong>${records.length}</strong>
<span>homes</span>
</div>
<div class="metric-stat">
<strong>${rows.length}</strong>
<span>residents</span>
</div>
<div class="metric-stat">
<strong>${unmatchedMixes}</strong>
<span>unmatched mixes</span>
</div>
</div>
`;
}
function renderProfiles() {
const records = selectedRecords();
if (!records.length) {
profiles.innerHTML = `
<div class="empty-state">
<strong>Choose a voxel home</strong>
Click a building to expose its fictional resident records.
Shift-click to compare a tiny cohort.
</div>
`;
return;
}
const rows = records.flatMap((record) =>
record.residents.map((person) => ({ record, person }))
);
const signatureCounts = new Map();
for (const row of rows) {
const value = signature(row.person);
signatureCounts.set(value, (signatureCounts.get(value) || 0) + 1);
}
profiles.innerHTML = records
.map(
(record) => `
<article class="home-group" style="--home-color:${record.color}">
<header class="home-group-header">
<div class="home-swatch" aria-hidden="true"></div>
<div class="home-group-title">
<strong>${record.id} · ${record.name}</strong>
<span>${record.bedrooms} bedrooms · ${record.floors} floors · synthetic record</span>
</div>
<span class="home-size">${record.residents.length} people</span>
</header>
${record.residents
.map((person) => {
const isUnique =
signatureCounts.get(signature(person)) === 1;
return `
<div class="person-row">
<div class="person-heading">
<div
class="avatar"
style="--avatar-color:${FIELD_META.age.color}"
aria-hidden="true"
>
${initials(person.name)}
</div>
<div class="person-name">
<strong>${person.name}</strong>
<span>${person.age} · ${person.rhythm}</span>
</div>
${
isUnique
? `<span class="mix-badge">Unmatched mix</span>`
: `<span class="mix-badge" style="color:#7a837e;background:#f2f3ef;border-color:#e2e5df">Repeated mix</span>`
}
</div>
<div class="attribute-list">
${attributeChips(person)}
</div>
</div>
`;
})
.join("")}
</article>
`
)
.join("");
}
function renderChips() {
const records = selectedRecords();
selectionSummary.textContent =
`${records.length} home${records.length === 1 ? "" : "s"} selected` +
` · ${records.reduce((sum, record) => sum + record.residents.length, 0)} residents`;
clearButton.disabled = records.length === 0;
if (!records.length) {
selectedChips.innerHTML = "";
return;
}
selectedChips.innerHTML = records
.map(
(record) => `
<span class="selected-chip">
${record.id}
<button
type="button"
data-remove="${record.id}"
aria-label="Remove ${record.name}"
>×</button>
</span>
`
)
.join("");
selectedChips.querySelectorAll("[data-remove]").forEach((button) => {
button.addEventListener("click", () => {
selectedIds = selectedIds.filter((id) => id !== button.dataset.remove);
updateSelection();
});
});
}
function updateSelection() {
for (const [id, frame] of selectionFrames) {
frame.visible = selectedIds.includes(id);
}
rebuildMarkers();
renderExposure();
renderProfiles();
renderChips();
}
function selectHouse(id, additive = false) {
if (!id) {
selectedIds = [];
updateSelection();
return;
}
if (!additive) {
selectedIds = [id];
updateSelection();
return;
}
if (selectedIds.includes(id)) {
selectedIds = selectedIds.filter((selectedId) => selectedId !== id);
updateSelection();
return;
}
if (selectedIds.length >= 3) {
selectionSummary.textContent = "Tiny cohort limit: 3 homes";
window.setTimeout(renderChips, 1200);
return;
}
selectedIds.push(id);
updateSelection();
}
clearButton.addEventListener("click", () => {
selectedIds = [];
updateSelection();
});
trioButton.addEventListener("click", () => {
trioIndex = (trioIndex + 1) % curatedTrios.length;
selectedIds = [...curatedTrios[trioIndex]];
updateSelection();
});
document.addEventListener("keydown", (event) => {
if (event.key === "Escape") {
selectedIds = [];
updateSelection();
}
});
document.getElementById("fieldLegend").innerHTML =
Object.values(FIELD_META)
.map(
(meta) => `
<span class="legend-field" title="${meta.label}">
<i style="background:${meta.color}"></i>
${meta.short}
</span>
`
)
.join("");
const resizeObserver = new ResizeObserver(() => {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
if (!width || !height) return;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
});
resizeObserver.observe(viewport);
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
updateCamera(delta);
for (const item of markerCubes) {
item.mesh.position.y =
item.baseY + Math.sin(elapsed * 1.8 + item.phase) * 0.025;
}
frameMaterial.emissiveIntensity =
0.42 + Math.sin(elapsed * 2.1) * 0.1;
renderer.render(scene, camera);
}
updateSelection();
updateCamera(1);
animate();
loading.remove();
</script>
</body>
</html>
```