Prompt specification
Build or customize the Three.js 3D scene "Seed-lineage tracing game" 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: Seed-lineage tracing game
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/seed-lineage-tracing-game-x1104
Scene Description Prompt:
Trace fictional seed batches through a voxel garden's generations and exchanges, separating pedigree from visible inherited traits. Build one HTML with Three.js from cdnjs.
Working Three.js Starter (seed-lineage-tracing-game-x1104):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Linea — Voxel Seed Observatory</title>
<style>
:root {
--bg: #101713;
--bg-deep: #0b100d;
--panel: #151d18;
--panel-2: #1a241e;
--panel-3: #202c25;
--line: #2c3931;
--line-soft: #243029;
--text: #e8eee7;
--muted: #8e9c91;
--faint: #647168;
--green: #94b58d;
--green-bright: #b9d5a8;
--amber: #efb865;
--amber-soft: #d89b4d;
--blue: #86aeb5;
--violet: #ad91cf;
--radius: 12px;
--mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
--sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
background: var(--bg-deep);
color: var(--text);
font-family: var(--sans);
}
body {
overflow: hidden;
}
button, input {
font: inherit;
}
button {
color: inherit;
}
button:focus-visible,
input:focus-visible {
outline: 2px solid var(--amber);
outline-offset: 2px;
}
.app {
display: grid;
grid-template-columns: 282px minmax(480px, 1fr) 350px;
grid-template-rows: 68px minmax(0, 1fr);
width: 100vw;
height: 100vh;
background: var(--bg);
}
.topbar {
grid-column: 1 / -1;
display: grid;
grid-template-columns: 282px 1fr 350px;
align-items: center;
min-width: 0;
border-bottom: 1px solid var(--line);
background: #111814;
z-index: 20;
}
.brand {
height: 100%;
display: flex;
align-items: center;
gap: 12px;
padding: 0 20px;
border-right: 1px solid var(--line);
}
.brand-mark {
width: 30px;
height: 30px;
display: grid;
grid-template-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(3, 1fr);
gap: 2px;
transform: rotate(-2deg);
}
.brand-mark i {
display: block;
border-radius: 2px;
background: #314438;
}
.brand-mark i:nth-child(2),
.brand-mark i:nth-child(4),
.brand-mark i:nth-child(9) {
background: var(--amber);
}
.brand-mark i:nth-child(6),
.brand-mark i:nth-child(8) {
background: #739277;
}
.brand-name {
font-size: 17px;
font-weight: 760;
letter-spacing: .22em;
line-height: 1;
}
.brand-sub {
margin-top: 5px;
color: var(--faint);
font-family: var(--mono);
font-size: 9px;
letter-spacing: .11em;
text-transform: uppercase;
}
.cycle-strip {
min-width: 0;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
}
.cycle-title {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.cycle-kicker {
color: var(--faint);
font-family: var(--mono);
font-size: 9px;
letter-spacing: .12em;
text-transform: uppercase;
}
.cycle-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 13px;
font-weight: 560;
letter-spacing: .01em;
}
.live {
display: flex;
align-items: center;
gap: 8px;
flex: 0 0 auto;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
letter-spacing: .09em;
text-transform: uppercase;
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green-bright);
box-shadow: 0 0 0 4px rgba(185, 213, 168, .08);
}
.top-actions {
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
padding: 0 18px;
border-left: 1px solid var(--line);
}
.button {
border: 1px solid var(--line);
border-radius: 8px;
padding: 9px 12px;
background: var(--panel-2);
cursor: pointer;
font-size: 11px;
font-weight: 650;
transition: background .18s, border-color .18s, color .18s, transform .18s;
}
.button:hover {
background: var(--panel-3);
border-color: #405044;
transform: translateY(-1px);
}
.button.primary {
border-color: #6f5934;
background: #33291b;
color: #f2c780;
}
.sidebar {
min-width: 0;
min-height: 0;
background: var(--panel);
overflow: hidden;
}
.left-sidebar {
display: flex;
flex-direction: column;
border-right: 1px solid var(--line);
}
.right-sidebar {
overflow-y: auto;
border-left: 1px solid var(--line);
scrollbar-width: thin;
scrollbar-color: #35443a transparent;
}
.panel-head {
padding: 20px 18px 14px;
border-bottom: 1px solid var(--line-soft);
}
.eyebrow {
margin: 0 0 8px;
color: var(--faint);
font-family: var(--mono);
font-size: 9px;
font-weight: 700;
letter-spacing: .14em;
text-transform: uppercase;
}
.panel-title {
margin: 0;
font-size: 15px;
font-weight: 680;
letter-spacing: -.01em;
}
.panel-note {
margin: 8px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1px;
border-bottom: 1px solid var(--line-soft);
background: var(--line-soft);
}
.metric {
padding: 13px 10px;
background: var(--panel);
text-align: center;
}
.metric strong {
display: block;
margin-bottom: 4px;
font-family: var(--mono);
font-size: 17px;
font-weight: 500;
color: var(--text);
}
.metric span {
color: var(--faint);
font-size: 8px;
letter-spacing: .1em;
text-transform: uppercase;
}
.registry-tools {
padding: 14px 14px 10px;
}
.search-wrap {
position: relative;
}
.search-wrap svg {
position: absolute;
left: 10px;
top: 50%;
width: 14px;
height: 14px;
transform: translateY(-50%);
color: var(--faint);
pointer-events: none;
}
.search {
width: 100%;
height: 36px;
padding: 0 10px 0 32px;
border: 1px solid var(--line);
border-radius: 8px;
background: #111814;
color: var(--text);
font-size: 11px;
}
.search::placeholder {
color: #59665c;
}
.filter-row {
display: flex;
gap: 5px;
margin-top: 10px;
}
.filter-chip {
flex: 1;
min-width: 0;
height: 26px;
padding: 0 5px;
border: 1px solid var(--line);
border-radius: 6px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-family: var(--mono);
font-size: 9px;
transition: all .16s;
}
.filter-chip:hover {
color: var(--text);
border-color: #425147;
}
.filter-chip.active {
border-color: #765d35;
background: #2d261b;
color: var(--amber);
}
.batch-list {
flex: 1;
min-height: 0;
overflow-y: auto;
padding: 2px 8px 14px;
scrollbar-width: thin;
scrollbar-color: #35443a transparent;
}
.batch-row {
position: relative;
display: grid;
grid-template-columns: 50px minmax(0, 1fr) 52px 12px;
align-items: center;
gap: 8px;
min-height: 55px;
padding: 8px 9px;
border: 1px solid transparent;
border-radius: 8px;
cursor: pointer;
transition: background .15s, border-color .15s;
}
.batch-row:hover {
background: #19231d;
}
.batch-row.selected {
border-color: #5e4b2e;
background: #262219;
}
.batch-row.selected::before {
content: "";
position: absolute;
left: -9px;
top: 13px;
bottom: 13px;
width: 2px;
border-radius: 2px;
background: var(--amber);
}
.batch-code {
color: var(--muted);
font-family: var(--mono);
font-size: 10px;
}
.batch-name {
overflow: hidden;
color: var(--text);
font-size: 12px;
font-weight: 650;
text-overflow: ellipsis;
white-space: nowrap;
}
.batch-meta {
overflow: hidden;
margin-top: 4px;
color: var(--faint);
font-family: var(--mono);
font-size: 8px;
text-overflow: ellipsis;
white-space: nowrap;
}
.trait-dot {
width: 11px;
height: 11px;
justify-self: center;
border: 2px solid rgba(255,255,255,.18);
border-radius: 3px;
background: var(--dot, #888);
box-shadow: 0 0 0 1px rgba(0,0,0,.4);
}
.generation-tag {
position: absolute;
right: 9px;
top: 7px;
color: #58655b;
font-family: var(--mono);
font-size: 7px;
}
.list-empty {
padding: 30px 15px;
color: var(--faint);
font-size: 11px;
text-align: center;
}
.stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 25%, rgba(86, 115, 89, .16), transparent 43%),
#101713;
}
#viewport {
position: absolute;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#viewport canvas:active {
cursor: grabbing;
}
.stage-head {
position: absolute;
z-index: 5;
top: 18px;
left: 20px;
right: 20px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.stage-heading {
max-width: 380px;
padding: 12px 14px;
border: 1px solid rgba(62, 78, 67, .75);
border-radius: 10px;
background: rgba(15, 23, 18, .8);
backdrop-filter: blur(12px);
}
.stage-heading .eyebrow {
margin-bottom: 5px;
color: var(--amber-soft);
}
.stage-heading h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 21px;
font-weight: 400;
letter-spacing: -.02em;
}
.stage-heading p {
margin: 6px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.view-switch {
display: flex;
padding: 4px;
border: 1px solid rgba(62, 78, 67, .8);
border-radius: 10px;
background: rgba(15, 23, 18, .86);
backdrop-filter: blur(12px);
pointer-events: auto;
}
.view-button {
min-width: 96px;
height: 31px;
padding: 0 11px;
border: 0;
border-radius: 7px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 10px;
font-weight: 650;
transition: all .18s;
}
.view-button.active {
background: #2b372f;
color: var(--text);
box-shadow: inset 0 0 0 1px #3e4d43;
}
.layer-dock {
position: absolute;
z-index: 5;
left: 18px;
bottom: 91px;
display: flex;
flex-wrap: wrap;
gap: 6px;
max-width: 460px;
}
.layer-button {
display: flex;
align-items: center;
gap: 7px;
min-height: 30px;
padding: 0 10px;
border: 1px solid rgba(58, 74, 63, .85);
border-radius: 8px;
background: rgba(16, 24, 19, .86);
color: var(--muted);
cursor: pointer;
backdrop-filter: blur(10px);
font-size: 9px;
font-weight: 650;
}
.layer-button::before {
content: "";
width: 7px;
height: 7px;
border: 1px solid #5c6b60;
border-radius: 2px;
background: transparent;
}
.layer-button.active {
color: var(--text);
border-color: #536456;
}
.layer-button.active::before {
background: var(--green-bright);
border-color: var(--green-bright);
box-shadow: 0 0 0 3px rgba(185, 213, 168, .08);
}
.camera-tools {
position: absolute;
z-index: 5;
right: 18px;
bottom: 92px;
display: grid;
gap: 5px;
}
.camera-button {
width: 34px;
height: 34px;
display: grid;
place-items: center;
border: 1px solid rgba(58, 74, 63, .85);
border-radius: 8px;
background: rgba(16, 24, 19, .88);
color: var(--muted);
cursor: pointer;
font-size: 17px;
backdrop-filter: blur(10px);
}
.camera-button:hover {
color: var(--text);
border-color: #526257;
}
.camera-help {
position: absolute;
z-index: 4;
right: 18px;
bottom: 205px;
color: #657269;
font-family: var(--mono);
font-size: 8px;
line-height: 1.5;
text-align: right;
pointer-events: none;
}
.timeline {
position: absolute;
z-index: 6;
left: 18px;
right: 18px;
bottom: 16px;
min-height: 58px;
display: grid;
grid-template-columns: 130px 1fr 120px;
align-items: center;
gap: 18px;
padding: 9px 14px;
border: 1px solid rgba(59, 74, 64, .88);
border-radius: 11px;
background: rgba(15, 23, 18, .91);
backdrop-filter: blur(14px);
box-shadow: 0 12px 36px rgba(0,0,0,.22);
}
.timeline-title {
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
letter-spacing: .08em;
text-transform: uppercase;
}
.timeline-title strong {
display: block;
margin-top: 5px;
color: var(--text);
font-family: var(--sans);
font-size: 11px;
letter-spacing: 0;
text-transform: none;
}
.generation-rail {
display: grid;
grid-template-columns: repeat(5, 1fr);
align-items: center;
gap: 0;
}
.generation-step {
position: relative;
height: 34px;
border: 0;
background: transparent;
color: var(--faint);
cursor: pointer;
font-family: var(--mono);
font-size: 9px;
}
.generation-step::before {
content: "";
position: absolute;
top: 9px;
left: 0;
right: 0;
height: 1px;
background: #344138;
}
.generation-step:first-child::before {
left: 50%;
}
.generation-step:last-child::before {
right: 50%;
}
.generation-step span {
position: relative;
z-index: 1;
display: inline-grid;
place-items: center;
min-width: 30px;
height: 19px;
padding: 0 6px;
border: 1px solid #344138;
border-radius: 5px;
background: #151e18;
}
.generation-step:hover,
.generation-step.active {
color: var(--amber);
}
.generation-step.active span {
border-color: #8b6938;
background: #30271b;
color: #f0be72;
}
.timeline-note {
color: var(--faint);
font-family: var(--mono);
font-size: 8px;
line-height: 1.5;
text-align: right;
text-transform: uppercase;
}
.world-labels {
position: absolute;
z-index: 3;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.plant-label {
position: absolute;
display: flex;
align-items: center;
gap: 5px;
height: 22px;
padding: 0 7px;
transform: translate(-50%, -100%);
border: 1px solid rgba(77, 94, 81, .8);
border-radius: 6px;
background: rgba(16, 24, 19, .84);
color: #a9b6aa;
cursor: pointer;
pointer-events: auto;
backdrop-filter: blur(8px);
font-family: var(--mono);
font-size: 8px;
white-space: nowrap;
transition: border-color .15s, background .15s, color .15s;
}
.plant-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 9px;
background: #536257;
}
.plant-label .label-dot {
width: 7px;
height: 7px;
border-radius: 2px;
background: var(--dot);
}
.plant-label:hover,
.plant-label.selected {
z-index: 2;
border-color: #a37d43;
background: rgba(45, 37, 25, .93);
color: #f1c27c;
}
.garden-label,
.generation-label {
position: absolute;
transform: translate(-50%, -50%);
color: #8da18e;
font-family: var(--mono);
font-size: 9px;
font-weight: 700;
letter-spacing: .14em;
text-transform: uppercase;
white-space: nowrap;
text-shadow: 0 2px 7px #000;
}
.garden-label span {
display: block;
margin-top: 4px;
color: #536057;
font-size: 7px;
letter-spacing: .08em;
text-align: center;
}
.generation-label {
color: #9e7949;
font-size: 8px;
}
.inspector {
padding-bottom: 28px;
}
.passport {
padding: 20px 18px 17px;
border-bottom: 1px solid var(--line);
background:
linear-gradient(145deg, rgba(239, 184, 101, .055), transparent 48%),
var(--panel);
}
.passport-top {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
}
.batch-id {
color: var(--amber);
font-family: var(--mono);
font-size: 10px;
letter-spacing: .12em;
}
.batch-large-name {
margin: 7px 0 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 29px;
font-weight: 400;
letter-spacing: -.025em;
}
.passport-location {
display: inline-flex;
align-items: center;
gap: 6px;
margin-top: 10px;
padding: 5px 8px;
border: 1px solid #344239;
border-radius: 6px;
color: var(--muted);
font-size: 9px;
}
.passport-location::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--green-bright);
}
.trait-orb {
width: 43px;
height: 43px;
flex: 0 0 auto;
border: 4px solid #243028;
border-radius: 12px;
background: var(--orb, #777);
box-shadow: inset 0 0 0 1px rgba(255,255,255,.17), 0 7px 18px rgba(0,0,0,.2);
transform: rotate(4deg);
}
.passport-stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
margin-top: 17px;
}
.passport-stat {
padding: 9px 8px;
border: 1px solid var(--line-soft);
border-radius: 8px;
background: rgba(11, 16, 13, .22);
}
.passport-stat span {
display: block;
margin-bottom: 5px;
color: var(--faint);
font-family: var(--mono);
font-size: 7px;
letter-spacing: .08em;
text-transform: uppercase;
}
.passport-stat strong {
font-family: var(--mono);
font-size: 11px;
font-weight: 500;
}
.section {
padding: 18px;
border-bottom: 1px solid var(--line);
}
.section-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 14px;
}
.section-heading h2 {
margin: 0;
font-size: 12px;
font-weight: 720;
letter-spacing: .02em;
}
.section-heading p {
margin: 5px 0 0;
color: var(--faint);
font-size: 9px;
line-height: 1.45;
}
.section-number {
color: #5b695e;
font-family: var(--mono);
font-size: 9px;
}
.pedigree-card {
padding: 10px;
border: 1px solid var(--line-soft);
border-radius: 10px;
background: #111814;
}
.pedigree-card svg {
display: block;
width: 100%;
height: auto;
}
.pedigree-caption {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-top: 8px;
padding-top: 9px;
border-top: 1px solid var(--line-soft);
color: var(--faint);
font-family: var(--mono);
font-size: 8px;
}
.ancestor-chips {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin-top: 9px;
}
.ancestor-chip {
padding: 5px 7px;
border: 1px solid var(--line);
border-radius: 5px;
background: var(--panel-2);
color: var(--muted);
cursor: pointer;
font-family: var(--mono);
font-size: 8px;
}
.ancestor-chip:hover {
border-color: #80643b;
color: var(--amber);
}
.focus-button {
border: 0;
background: transparent;
color: var(--amber);
cursor: pointer;
font-size: 9px;
font-weight: 700;
}
.trait-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.trait-card {
min-width: 0;
padding: 10px;
border: 1px solid var(--line-soft);
border-radius: 9px;
background: #121a15;
}
.trait-card-top {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
}
.trait-swatch {
width: 24px;
height: 24px;
flex: 0 0 auto;
border-radius: 6px;
background: var(--swatch, #777);
box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.trait-swatch.leaf {
position: relative;
background: #526d4d;
}
.trait-swatch.leaf::before,
.trait-swatch.leaf::after {
content: "";
position: absolute;
top: 6px;
width: 9px;
height: 12px;
border-radius: 3px 1px 3px 1px;
background: #86a47e;
}
.trait-swatch.leaf::before { left: 3px; transform: rotate(-18deg); }
.trait-swatch.leaf::after { right: 3px; transform: scaleX(-1) rotate(-18deg); }
.trait-swatch.pattern {
background:
linear-gradient(90deg, transparent 25%, #f1e1b3 25% 50%, transparent 50% 75%, #f1e1b3 75%),
#9b7b54;
}
.trait-swatch.height {
position: relative;
background: #202b24;
}
.trait-swatch.height::before {
content: "";
position: absolute;
left: 10px;
bottom: 4px;
width: 4px;
height: 16px;
border-radius: 2px;
background: var(--amber);
}
.trait-label {
color: var(--faint);
font-family: var(--mono);
font-size: 7px;
letter-spacing: .07em;
text-transform: uppercase;
}
.trait-value {
overflow: hidden;
margin-top: 3px;
font-size: 10px;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
}
.trait-source {
grid-column: 1 / -1;
padding-top: 9px;
border-top: 1px solid var(--line-soft);
color: var(--muted);
font-size: 9px;
line-height: 1.55;
}
.trait-source strong {
color: #b6c2b7;
font-weight: 620;
}
.allele-row {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-top: 8px;
}
.allele {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 5px;
border: 1px solid #303c33;
border-radius: 4px;
color: #839087;
font-family: var(--mono);
font-size: 7px;
}
.allele i {
width: 7px;
height: 7px;
border-radius: 2px;
background: var(--allele-color);
}
.exchange-callout {
padding: 11px;
border: 1px solid #5e4b2e;
border-radius: 9px;
background: #251f16;
}
.exchange-callout .route {
display: flex;
align-items: center;
gap: 7px;
margin: 8px 0 6px;
color: #e1c18e;
font-size: 10px;
font-weight: 650;
}
.exchange-callout p {
margin: 0;
color: #9e8f75;
font-size: 9px;
line-height: 1.5;
}
.no-exchange {
padding: 11px;
border: 1px dashed #344138;
border-radius: 9px;
color: var(--faint);
font-size: 9px;
line-height: 1.5;
}
.ledger {
display: grid;
gap: 5px;
}
.event-row {
display: grid;
grid-template-columns: 31px 1fr auto;
align-items: center;
gap: 9px;
width: 100%;
min-height: 45px;
padding: 7px 8px;
border: 1px solid transparent;
border-radius: 7px;
background: #111814;
text-align: left;
cursor: pointer;
}
.event-row:hover,
.event-row.highlighted {
border-color: #4b402d;
background: #211d15;
}
.event-id {
color: var(--amber-soft);
font-family: var(--mono);
font-size: 8px;
}
.event-main {
min-width: 0;
font-size: 9px;
line-height: 1.4;
}
.event-main strong {
color: #c7d1c8;
font-weight: 650;
}
.event-main span {
display: block;
overflow: hidden;
color: var(--faint);
text-overflow: ellipsis;
white-space: nowrap;
}
.event-cycle {
color: #5f6c62;
font-family: var(--mono);
font-size: 7px;
}
.legend-note {
margin: 12px 0 0;
color: #59665c;
font-size: 8px;
line-height: 1.6;
}
@media (max-width: 1180px) {
.app {
grid-template-columns: 250px minmax(430px, 1fr) 320px;
}
.topbar {
grid-template-columns: 250px 1fr 320px;
}
.stage-heading {
max-width: 300px;
}
.stage-heading h1 {
font-size: 18px;
}
.view-button {
min-width: 78px;
}
.timeline {
grid-template-columns: 105px 1fr;
}
.timeline-note {
display: none;
}
}
@media (max-width: 900px) {
body {
overflow: auto;
}
.app {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 62px 70vh auto auto;
height: auto;
min-height: 100vh;
}
.topbar {
grid-template-columns: 1fr auto;
}
.brand {
border-right: 0;
}
.cycle-strip {
display: none;
}
.top-actions {
border-left: 1px solid var(--line);
}
.left-sidebar {
max-height: 520px;
border-top: 1px solid var(--line);
border-right: 0;
}
.right-sidebar {
border-top: 1px solid var(--line);
border-left: 0;
}
.stage {
min-height: 70vh;
}
.stage-head {
left: 12px;
right: 12px;
}
.stage-heading {
max-width: 220px;
}
.stage-heading p {
display: none;
}
.view-button {
min-width: 68px;
}
.timeline {
left: 10px;
right: 10px;
}
.layer-dock {
left: 10px;
}
}
</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><i></i><i></i><i></i><i></i><i></i>
</div>
<div>
<div class="brand-name">LINEA</div>
<div class="brand-sub">Voxel seed observatory</div>
</div>
</div>
<div class="cycle-strip">
<div class="cycle-title">
<span class="cycle-kicker">Archive / 07</span>
<span class="cycle-name">The Three Garden Exchange · Field generation record</span>
</div>
<div class="live"><span class="live-dot"></span>Archive synchronized</div>
</div>
<div class="top-actions">
<button class="button" id="reset-view">Reset view</button>
<button class="button primary" id="export-trace">Export trace</button>
</div>
</header>
<aside class="sidebar left-sidebar">
<div class="panel-head">
<p class="eyebrow">Batch archive</p>
<h2 class="panel-title">Living collection</h2>
<p class="panel-note">Select a batch to inspect its ancestry, visible traits, and transfer history.</p>
</div>
<div class="metrics">
<div class="metric"><strong>12</strong><span>Batches</span></div>
<div class="metric"><strong>03</strong><span>Gardens</span></div>
<div class="metric"><strong>05</strong><span>Exchanges</span></div>
</div>
<div class="registry-tools">
<div class="search-wrap">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="7"></circle>
<path d="m20 20-4-4"></path>
</svg>
<input class="search" id="batch-search" type="search" placeholder="Search batch or name…" aria-label="Search batches" />
</div>
<div class="filter-row" aria-label="Filter by generation">
<button class="filter-chip active" data-gen-filter="all">All</button>
<button class="filter-chip" data-gen-filter="0">G0</button>
<button class="filter-chip" data-gen-filter="1">G1</button>
<button class="filter-chip" data-gen-filter="2">G2</button>
<button class="filter-chip" data-gen-filter="3">G3</button>
</div>
</div>
<div class="batch-list" id="batch-list"></div>
</aside>
<main class="stage" id="stage">
<div id="viewport"></div>
<div class="world-labels" id="world-labels"></div>
<div class="stage-head">
<div class="stage-heading">
<p class="eyebrow">Interactive seed field</p>
<h1>Pedigree roots, visible leaves.</h1>
<p id="stage-description">Garden beds show current holding sites. Switch to pedigree lanes to rearrange generations by ancestry.</p>
</div>
<div class="view-switch" aria-label="Scene layout">
<button class="view-button active" data-mode="garden">Garden beds</button>
<button class="view-button" data-mode="lineage">Pedigree lanes</button>
</div>
</div>
<div class="layer-dock">
<button class="layer-button active" id="trait-coding" aria-pressed="true">Trait coding</button>
<button class="layer-button" id="pedigree-links" aria-pressed="false">Pedigree links</button>
<button class="layer-button" id="exchange-trails" aria-pressed="false">Exchange trails</button>
</div>
<div class="camera-help">Drag to orbit · Shift-drag to pan<br />Scroll to zoom · Select a voxel</div>
<div class="camera-tools">
<button class="camera-button" id="zoom-in" aria-label="Zoom in">+</button>
<button class="camera-button" id="zoom-out" aria-label="Zoom out">−</button>
<button class="camera-button" id="camera-reset" aria-label="Reset camera" title="Reset camera">⌂</button>
</div>
<div class="timeline">
<div class="timeline-title">Generation index<strong id="generation-caption">All generations</strong></div>
<div class="generation-rail">
<button class="generation-step active" data-gen-filter="all"><span>ALL</span></button>
<button class="generation-step" data-gen-filter="0"><span>G0</span></button>
<button class="generation-step" data-gen-filter="1"><span>G1</span></button>
<button class="generation-step" data-gen-filter="2"><span>G2</span></button>
<button class="generation-step" data-gen-filter="3"><span>G3</span></button>
</div>
<div class="timeline-note">Founder packets<br />through third generation</div>
</div>
</main>
<aside class="sidebar right-sidebar" id="inspector" aria-live="polite"></aside>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Fictional archive
// -------------------------------------------------------------------------
const gardens = {
lark: {
name: "Larkspur",
short: "LARK",
x: -4.9,
color: 0x3d5543,
border: 0x667a60
},
common: {
name: "Common Ground",
short: "COMMON",
x: 0,
color: 0x494a36,
border: 0x777151
},
moss: {
name: "Mossbank",
short: "MOSSBANK",
x: 4.9,
color: 0x354d45,
border: 0x5f7c70
}
};
const batches = [
{
id: "B01", name: "Cinder", gen: 0, parents: [],
garden: "lark", origin: "lark",
alleles: { bloom: ["C", "G"], leaf: ["Broad", "Spear"], pattern: ["Speck", "Plain"] },
height: 128,
note: "The first warm-colored packet recorded in the Larkspur ledger."
},
{
id: "B02", name: "Moss", gen: 0, parents: [],
garden: "common", origin: "common",
alleles: { bloom: ["G", "G"], leaf: ["Spear", "Split"], pattern: ["Plain", "Plain"] },
height: 142,
note: "A restrained amber founder held at Common Ground."
},
{
id: "B03", name: "Flint", gen: 0, parents: [],
garden: "moss", origin: "common",
alleles: { bloom: ["V", "V"], leaf: ["Split", "Broad"], pattern: ["Band", "Speck"] },
height: 156,
note: "A violet founder moved to Mossbank during the first exchange."
},
{
id: "B04", name: "Bell", gen: 1, parents: ["B01", "B02"],
garden: "lark", origin: "lark",
alleles: { bloom: ["C", "G"], leaf: ["Broad", "Spear"], pattern: ["Speck", "Plain"] },
height: 134,
note: "First cross between the Cinder and Moss founder lines."
},
{
id: "B05", name: "Char", gen: 1, parents: ["B01", "B03"],
garden: "common", origin: "lark",
alleles: { bloom: ["G", "V"], leaf: ["Spear", "Split"], pattern: ["Band", "Speck"] },
height: 143,
note: "A bronze-flowered cross later exchanged from Larkspur."
},
{
id: "B06", name: "Mica", gen: 1, parents: ["B02", "B03"],
garden: "moss", origin: "moss",
alleles: { bloom: ["G", "V"], leaf: ["Split", "Broad"], pattern: ["Band", "Plain"] },
height: 148,
note: "The first Mossbank-bred generation packet."
},
{
id: "B07", name: "Glow", gen: 2, parents: ["B04", "B05"],
garden: "lark", origin: "lark",
alleles: { bloom: ["C", "G"], leaf: ["Broad", "Spear"], pattern: ["Band", "Speck"] },
height: 139,
note: "A banded, apricot-flowered line rejoining two Larkspur crosses."
},
{
id: "B08", name: "Hush", gen: 2, parents: ["B04", "B06"],
garden: "lark", origin: "moss",
alleles: { bloom: ["C", "G"], leaf: ["Broad", "Broad"], pattern: ["Band", "Band"] },
height: 141,
note: "A broad-leaved line transferred north from Mossbank."
},
{
id: "B09", name: "Spore", gen: 2, parents: ["B05", "B06"],
garden: "moss", origin: "moss",
alleles: { bloom: ["G", "G"], leaf: ["Spear", "Split"], pattern: ["Band", "Band"] },
height: 146,
note: "The surviving amber-flowered line in the Mossbank collection."
},
{
id: "B10", name: "Lumen", gen: 3, parents: ["B07", "B09"],
garden: "lark", origin: "common",
alleles: { bloom: ["C", "G"], leaf: ["Broad", "Spear"], pattern: ["Band", "Band"] },
height: 143,
note: "Third-generation packet returned to Larkspur after circulation."
},
{
id: "B11", name: "Dusk", gen: 3, parents: ["B07", "B08"],
garden: "common", origin: "lark",
alleles: { bloom: ["C", "C"], leaf: ["Broad", "Broad"], pattern: ["Band", "Band"] },
height: 140,
note: "A coral-flowered sibling retained at Common Ground."
},
{
id: "B12", name: "Vale", gen: 3, parents: ["B08", "B09"],
garden: "moss", origin: "lark",
alleles: { bloom: ["C", "G"], leaf: ["Broad", "Spear"], pattern: ["Band", "Band"] },
height: 144,
note: "Third-generation packet exchanged from Larkspur to Mossbank."
}
];
const exchanges = [
{
id: "X01", batch: "B03", from: "common", to: "moss", cycle: "C02",
label: "Founders swap", detail: "Violet founder packet enters the Mossbank collection."
},
{
id: "X02", batch: "B05", from: "lark", to: "common", cycle: "C03",
label: "Bronze line moves", detail: "One Char packet is exchanged for Common Ground stock."
},
{
id: "X03", batch: "B08", from: "moss", to: "lark", cycle: "C05",
label: "Broad-leaf return", detail: "A Hush packet returns to Larkspur for breeding."
},
{
id: "X04", batch: "B10", from: "common", to: "lark", cycle: "C06",
label: "Third-gen transfer", detail: "The first Lumen packet is returned to its founding garden."
},
{
id: "X05", batch: "B12", from: "lark", to: "moss", cycle: "C07",
label: "Closing exchange", detail: "Vale completes the archive's final reciprocal transfer."
}
];
const batchMap = new Map(batches.map(batch => [batch.id, batch]));
const eventMap = new Map(exchanges.map(event => [event.batch, event]));
const alleleColors = {
C: "#ef7869",
G: "#e4b95a",
V: "#a88bd7"
};
const alleleNames = {
C: "Coral",
G: "Amber",
V: "Lilac"
};
const leafRank = { Broad: 3, Spear: 2, Split: 1 };
const patternRank = { Band: 3, Speck: 2, Plain: 1 };
function mixHex(a, b) {
const ca = new THREE.Color(a);
const cb = new THREE.Color(b);
const mixed = ca.clone().lerp(cb, .5);
return `#${mixed.getHexString()}`;
}
function bloomName(alleles) {
const key = [...alleles].sort().join("");
const names = {
"CC": "Coral",
"CG": "Apricot",
"CV": "Orchid",
"GG": "Amber",
"GV": "Bronze",
"VV": "Lilac"
};
return names[key] || "Mixed";
}
function dominant(alleles, rank) {
return [...alleles].sort((a, b) => rank[b] - rank[a])[0];
}
function bloomColor(batch) {
return mixHex(alleleColors[batch.alleles.bloom[0]], alleleColors[batch.alleles.bloom[1]]);
}
function parentText(batch) {
if (!batch.parents.length) return "founder";
return batch.parents.map(id => id.slice(1)).join(" × ");
}
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const viewport = document.getElementById("viewport");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x101713);
scene.fog = new THREE.Fog(0x101713, 19, 35);
const camera = new THREE.PerspectiveCamera(43, 1, .1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x101713, 1);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
viewport.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xc8ddca, 0x182019, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe0ac, 3.1);
sun.position.set(-7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 11;
sun.shadow.camera.bottom = -11;
sun.shadow.camera.near = .5;
sun.shadow.camera.far = 35;
sun.shadow.bias = -.0004;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x7fa4b3, 1.1);
rim.position.set(9, 6, -10);
scene.add(rim);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const plants = new Map();
const clickableMeshes = [];
const worldLabelRoot = document.getElementById("world-labels");
const soilMaterial = new THREE.MeshStandardMaterial({
color: 0x263028,
roughness: 1
});
const plotGroup = new THREE.Group();
const laneGroup = new THREE.Group();
const pedigreeGroup = new THREE.Group();
const exchangeGroup = new THREE.Group();
scene.add(plotGroup, laneGroup, pedigreeGroup, exchangeGroup);
function addBox(parent, scale, position, material, rotationY = 0) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(scale[0], scale[1], scale[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.y = rotationY;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Main voxel terrain.
addBox(scene, [30, .55, 16], [0, -.45, 0], new THREE.MeshStandardMaterial({
color: 0x172019,
roughness: 1
}));
const grid = new THREE.GridHelper(30, 30, 0x344239, 0x253129);
grid.position.y = -.165;
grid.material.transparent = true;
grid.material.opacity = .25;
scene.add(grid);
// Garden beds.
for (const garden of Object.values(gardens)) {
const bedMaterial = new THREE.MeshStandardMaterial({
color: garden.color,
roughness: .95
});
const borderMaterial = new THREE.MeshStandardMaterial({
color: garden.border,
roughness: .9
});
addBox(plotGroup, [3.35, .18, 4.35], [garden.x, -.12, 0], bedMaterial);
addBox(plotGroup, [3.5, .16, .12], [garden.x, .01, -2.14], borderMaterial);
addBox(plotGroup, [3.5, .16, .12], [garden.x, .01, 2.14], borderMaterial);
addBox(plotGroup, [.12, .16, 4.35], [garden.x - 1.69, .01, 0], borderMaterial);
addBox(plotGroup, [.12, .16, 4.35], [garden.x + 1.69, .01, 0], borderMaterial);
// Small voxel corner posts.
for (const x of [-1.68, 1.68]) {
for (const z of [-2.14, 2.14]) {
addBox(plotGroup, [.19, .42, .19], [garden.x + x, .18, z], borderMaterial);
addBox(plotGroup, [.24, .08, .24], [garden.x + x, .43, z], new THREE.MeshStandardMaterial({
color: 0xd5ad69,
roughness: .8
}));
}
}
}
// Pedigree lane markings.
for (let generation = 0; generation < 4; generation++) {
const x = -5.4 + generation * 3.6;
addBox(laneGroup, [.035, .025, 6.2], [x, -.13, 0], new THREE.MeshBasicMaterial({
color: 0x526052,
transparent: true,
opacity: .45
}));
for (let z = -2.8; z <= 2.8; z += .7) {
addBox(laneGroup, [.16, .025, .025], [x, -.12, z], new THREE.MeshBasicMaterial({
color: 0x735e3e,
transparent: true,
opacity: .38
}));
}
}
const gardenPositions = new Map();
for (const [gardenId, garden] of Object.entries(gardens)) {
const residents = batches.filter(batch => batch.garden === gardenId).sort((a, b) => a.id.localeCompare(b.id));
residents.forEach((batch, index) => {
const column = index % 2;
const row = Math.floor(index / 2);
gardenPositions.set(batch.id, new THREE.Vector3(
garden.x + (column === 0 ? -.78 : .78),
0,
(row - 1) * 1.36
));
});
}
const lineagePositions = new Map();
for (let generation = 0; generation < 4; generation++) {
const members = batches.filter(batch => batch.gen === generation);
members.forEach((batch, index) => {
lineagePositions.set(batch.id, new THREE.Vector3(
-5.4 + generation * 3.6,
0,
(index - (members.length - 1) / 2) * 2.35
));
});
}
function createPlant(batch) {
const group = new THREE.Group();
group.userData.batchId = batch.id;
group.userData.target = gardenPositions.get(batch.id).clone();
group.position.copy(group.userData.target);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0x2e382f,
roughness: 1
});
addBox(group, [1.28, .12, 1.28], [0, .015, 0], tileMaterial);
const stemMaterial = new THREE.MeshStandardMaterial({
color: 0x4f704f,
roughness: .92
});
const leafMaterial = new THREE.MeshStandardMaterial({
color: 0x64865d,
roughness: .9
});
const stemCount = 3 + Math.floor((batch.height - 120) / 18);
const stemStep = .235;
for (let i = 0; i < stemCount; i++) {
const mesh = addBox(
group,
[.17, .23, .17],
[0, .15 + (i + .5) * stemStep, 0],
stemMaterial
);
mesh.userData.batchId = batch.id;
clickableMeshes.push(mesh);
}
const leafType = dominant(batch.alleles.leaf, leafRank);
const leafLevels = [0.38, .59, .80];
for (const level of leafLevels) {
for (const side of [-1, 1]) {
if (leafType === "Broad") {
const a = addBox(group, [.49, .10, .27], [side * .37, level, 0], leafMaterial);
const b = addBox(group, [.31, .09, .20], [side * .50, level - .02, .16], leafMaterial);
a.userData.batchId = b.userData.batchId = batch.id;
clickableMeshes.push(a, b);
} else if (leafType === "Spear") {
const leaf = addBox(group, [.76, .08, .15], [side * .44, level, 0], leafMaterial, side * .16);
leaf.userData.batchId = batch.id;
clickableMeshes.push(leaf);
} else {
const a = addBox(group, [.29, .09, .19], [side * .35, level, -.14], leafMaterial);
const b = addBox(group, [.29, .09, .19], [side * .64, level, .13], leafMaterial);
a.userData.batchId = b.userData.batchId = batch.id;
clickableMeshes.push(a, b);
}
}
}
const flowerY = .15 + stemCount * stemStep + .08;
const flower = new THREE.Group();
flower.position.y = flowerY;
group.add(flower);
const mainBloom = bloomColor(batch);
const flowerMaterial = new THREE.MeshStandardMaterial({
color: mainBloom,
roughness: .65,
emissive: 0x000000,
emissiveIntensity: 0
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: "#f0dfb4",
roughness: .8,
emissive: 0x000000,
emissiveIntensity: 0
});
const centerMaterial = new THREE.MeshStandardMaterial({
color: "#d7aa4b",
roughness: .6,
emissive: 0x000000,
emissiveIntensity: 0
});
const pattern = dominant(batch.alleles.pattern, patternRank);
for (let i = 0; i < 8; i++) {
const angle = i / 8 * Math.PI * 2;
let radius = .34;
let material = flowerMaterial;
if (pattern === "Band" && i % 2 === 0) {
radius = .21;
material = accentMaterial;
}
if (pattern === "Speck" && i % 2 === 1) {
material = accentMaterial;
}
const petal = addBox(
flower,
[.25, .12, .25],
[Math.cos(angle) * radius, 0, Math.sin(angle) * radius],
material,
angle
);
petal.userData.batchId = batch.id;
clickableMeshes.push(petal);
}
const center = addBox(flower, [.26, .19, .26], [0, .05, 0], centerMaterial);
center.userData.batchId = batch.id;
clickableMeshes.push(center);
if (pattern === "Speck") {
for (let i = 0; i < 4; i++) {
const angle = i / 4 * Math.PI * 2 + .35;
const fleck = addBox(
flower,
[.09, .08, .09],
[Math.cos(angle) * .43, .04, Math.sin(angle) * .43],
accentMaterial
);
fleck.userData.batchId = batch.id;
clickableMeshes.push(fleck);
}
}
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0xefb865,
transparent: true,
opacity: .12,
depthWrite: false
});
const ring = new THREE.Group();
addBox(ring, [.75, .025, .045], [0, .10, -.68], ringMaterial);
addBox(ring, [.75, .025, .045], [0, .10, .68], ringMaterial);
addBox(ring, [.045, .025, .75], [-.68, .10, 0], ringMaterial);
addBox(ring, [.045, .025, .75], [.68, .10, 0], ringMaterial);
group.add(ring);
group.userData.flower = flower;
group.userData.ring = ring;
group.userData.ringMaterial = ringMaterial;
group.userData.flowerMaterials = [flowerMaterial, accentMaterial, centerMaterial];
group.userData.flowerMaterial = flowerMaterial;
group.userData.accentMaterial = accentMaterial;
group.userData.top = flowerY + .35;
const label = document.createElement("button");
label.className = "plant-label";
label.style.setProperty("--dot", mainBloom);
label.innerHTML = `<span class="label-dot"></span>${batch.id}`;
label.setAttribute("aria-label", `Select ${batch.name}, ${batch.id}`);
label.addEventListener("click", () => selectBatch(batch.id));
worldLabelRoot.appendChild(label);
group.userData.label = label;
scene.add(group);
plants.set(batch.id, group);
}
batches.forEach(createPlant);
// Decorative pollen voxels.
const pollen = [];
const pollenMaterial = new THREE.MeshBasicMaterial({
color: 0xd9bd78,
transparent: true,
opacity: .35
});
for (let i = 0; i < 26; i++) {
const mesh = addBox(
scene,
[.025, .025, .025],
[Math.sin(i * 2.13) * 8, .7 + (i % 7) * .25, Math.cos(i * 1.71) * 5],
pollenMaterial
);
mesh.castShadow = false;
pollen.push(mesh);
}
// -------------------------------------------------------------------------
// Pedigree and exchange graphics
// -------------------------------------------------------------------------
let mode = "garden";
let activeGeneration = "all";
let selectedId = "B10";
let hoveredId = null;
let traitCoding = true;
let pedigreeVisible = false;
let exchangeVisible = false;
let pedigreeLines = [];
function disposeGroup(group) {
while (group.children.length) {
const child = group.children[0];
group.remove(child);
if (child.geometry) child.geometry.dispose();
if (child.material) {
if (Array.isArray(child.material)) child.material.forEach(material => material.dispose());
else child.material.dispose();
}
}
}
function buildPedigreeLines() {
disposeGroup(pedigreeGroup);
pedigreeLines = [];
for (const child of batches) {
for (const parentId of child.parents) {
const parent = plants.get(parentId);
const offspring = plants.get(child.id);
const start = parent.userData.target.clone().add(new THREE.Vector3(0, .42, 0));
const end = offspring.userData.target.clone().add(new THREE.Vector3(0, .42, 0));
const distance = start.distanceTo(end);
const middle = start.clone().lerp(end, .5);
middle.y = 1.2 + distance * .065;
const curve = new THREE.QuadraticBezierCurve3(start, middle, end);
const geometry = new THREE.BufferGeometry().setFromPoints(curve.getPoints(48));
const material = new THREE.LineBasicMaterial({
color: 0x63766a,
transparent: true,
opacity: .24,
depthTest: false
});
const line = new THREE.Line(geometry, material);
line.renderOrder = 4;
line.userData.parentId = parentId;
line.userData.childId = child.id;
pedigreeGroup.add(line);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(.075, .24, 5),
new THREE.MeshBasicMaterial({
color: 0x63766a,
transparent: true,
opacity: .34,
depthTest: false
})
);
arrow.position.copy(curve.getPoint(.78));
const tangent = curve.getTangent(.78).normalize();
arrow.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), tangent);
arrow.renderOrder = 5;
arrow.userData.parentId = parentId;
arrow.userData.childId = child.id;
pedigreeGroup.add(arrow);
pedigreeLines.push({ line, arrow, parentId, childId: child.id });
}
}
}
function buildExchangeArrows() {
disposeGroup(exchangeGroup);
exchanges.forEach((event, index) => {
const from = gardens[event.from];
const to = gardens[event.to];
const offset = (index - 2) * .12;
const start = new THREE.Vector3(from.x + offset, .28, -.25);
const end = new THREE.Vector3(to.x + offset, .28, -.25);
const middle = start.clone().lerp(end, .5);
middle.y = 2.05 + index * .08;
const curve = new THREE.QuadraticBezierCurve3(start, middle, end);
const geometry = new THREE.BufferGeometry().setFromPoints(curve.getPoints(70));
const material = new THREE.LineDashedMaterial({
color: 0xe6aa55,
dashSize: .22,
gapSize: .13,
transparent: true,
opacity: .72,
depthTest: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
line.renderOrder = 8;
line.userData.eventId = event.id;
exchangeGroup.add(line);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(.11, .31, 6),
new THREE.MeshBasicMaterial({
color: 0xe6aa55,
transparent: true,
opacity: .85,
depthTest: false
})
);
arrow.position.copy(curve.getPoint(.9));
const tangent = curve.getTangent(.9).normalize();
arrow.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), tangent);
arrow.renderOrder = 9;
arrow.userData.eventId = event.id;
exchangeGroup.add(arrow);
});
}
buildPedigreeLines();
buildExchangeArrows();
// DOM world labels.
const gardenLabels = [];
for (const garden of Object.values(gardens)) {
const element = document.createElement("div");
element.className = "garden-label";
element.innerHTML = `${garden.name}<span>${garden.short} BED</span>`;
worldLabelRoot.appendChild(element);
gardenLabels.push({ element, position: new THREE.Vector3(garden.x, .05, -2.48) });
}
const generationLabels = [];
const generationNames = ["FOUNDERS", "FIRST CROSS", "SECOND CROSS", "THIRD GENERATION"];
for (let generation = 0; generation < 4; generation++) {
const element = document.createElement("div");
element.className = "generation-label";
element.textContent = `G${generation} · ${generationNames[generation]}`;
worldLabelRoot.appendChild(element);
generationLabels.push({
element,
position: new THREE.Vector3(-5.4 + generation * 3.6, .05, -3.05)
});
}
// -------------------------------------------------------------------------
// Camera controls implemented without addons
// -------------------------------------------------------------------------
const cameraState = {
theta: .52,
phi: .92,
radius: 19.5,
target: new THREE.Vector3(0, .55, 0)
};
function resetCamera() {
cameraState.theta = .52;
cameraState.phi = .92;
cameraState.radius = 19.5;
cameraState.target.set(0, .55, 0);
}
function updateCamera() {
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);
camera.updateMatrixWorld();
}
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let drag = null;
function raycastBatch(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 hit = raycaster.intersectObjects(clickableMeshes, false)[0];
return hit?.object.userData.batchId || null;
}
renderer.domElement.addEventListener("pointerdown", event => {
drag = {
startX: event.clientX,
startY: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
moved: false,
shift: event.shiftKey
};
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (drag) {
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
const distance = Math.hypot(event.clientX - drag.startX, event.clientY - drag.startY);
if (distance > 4) drag.moved = true;
if (drag.shift || event.shiftKey) {
const right = new THREE.Vector3(Math.cos(cameraState.theta), 0, -Math.sin(cameraState.theta));
const forward = new THREE.Vector3(Math.sin(cameraState.theta), 0, Math.cos(cameraState.theta));
cameraState.target.addScaledVector(right, -dx * cameraState.radius * .0012);
cameraState.target.addScaledVector(forward, -dy * cameraState.radius * .0012);
} else {
cameraState.theta -= dx * .006;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi + dy * .005, .42, 1.38);
}
drag.lastX = event.clientX;
drag.lastY = event.clientY;
} else {
const id = raycastBatch(event);
if (id !== hoveredId) {
hoveredId = id;
renderer.domElement.style.cursor = id ? "pointer" : "grab";
updateVisualState();
}
}
});
renderer.domElement.addEventListener("pointerup", event => {
if (drag && !drag.moved) {
const id = raycastBatch(event);
if (id) selectBatch(id);
}
drag = null;
});
renderer.domElement.addEventListener("pointercancel", () => {
drag = null;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * .001),
11,
27
);
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
document.getElementById("zoom-in").addEventListener("click", () => {
cameraState.radius = Math.max(11, cameraState.radius - 1.2);
});
document.getElementById("zoom-out").addEventListener("click", () => {
cameraState.radius = Math.min(27, cameraState.radius + 1.2);
});
document.getElementById("camera-reset").addEventListener("click", resetCamera);
document.getElementById("reset-view").addEventListener("click", () => {
resetCamera();
setMode("garden");
});
// -------------------------------------------------------------------------
// UI rendering
// -------------------------------------------------------------------------
const batchList = document.getElementById("batch-list");
const inspector = document.getElementById("inspector");
function ancestorsOf(id) {
const result = new Set();
const visit = batchId => {
const batch = batchMap.get(batchId);
if (!batch) return;
for (const parent of batch.parents) {
if (!result.has(parent)) {
result.add(parent);
visit(parent);
}
}
};
visit(id);
return result;
}
function descendantsOf(id) {
const result = new Set();
const visit = parentId => {
for (const batch of batches) {
if (batch.parents.includes(parentId) && !result.has(batch.id)) {
result.add(batch.id);
visit(batch.id);
}
}
};
visit(id);
return result;
}
function renderList() {
const query = document.getElementById("batch-search").value.trim().toLowerCase();
const visible = batches.filter(batch => {
const matchesGeneration = activeGeneration === "all" || batch.gen === Number(activeGeneration);
const matchesSearch = !query || batch.id.toLowerCase().includes(query) || batch.name.toLowerCase().includes(query);
return matchesGeneration && matchesSearch;
});
if (!visible.length) {
batchList.innerHTML = `<div class="list-empty">No batches match this view.</div>`;
return;
}
batchList.innerHTML = visible.map(batch => `
<div class="batch-row ${batch.id === selectedId ? "selected" : ""}" data-select="${batch.id}" role="button" tabindex="0">
<span class="batch-code">${batch.id}</span>
<div>
<div class="batch-name">${batch.name}</div>
<div class="batch-meta">${parentText(batch)} · ${gardens[batch.garden].short}</div>
</div>
<span class="trait-dot" style="--dot:${bloomColor(batch)}"></span>
<span class="generation-tag">G${batch.gen}</span>
</div>
`).join("");
}
batchList.addEventListener("click", event => {
const row = event.target.closest("[data-select]");
if (row) selectBatch(row.dataset.select);
});
batchList.addEventListener("keydown", event => {
if (event.key !== "Enter" && event.key !== " ") return;
const row = event.target.closest("[data-select]");
if (row) {
event.preventDefault();
selectBatch(row.dataset.select);
}
});
document.getElementById("batch-search").addEventListener("input", renderList);
function pedigreeSvg(batch) {
if (!batch.parents.length) {
return `
<div style="min-height:120px;display:grid;place-items:center;text-align:center">
<div>
<div style="width:42px;height:42px;margin:0 auto 10px;display:grid;place-items:center;border:1px solid #8c6b3e;border-radius:50%;background:#2b2419;color:#efb865;font:10px var(--mono)">${batch.id}</div>
<div style="color:#8e9c91;font-size:10px">Founding packet — no recorded parents</div>
</div>
</div>
`;
}
const parentXs = [88, 190];
const parentY = 76;
const selectedX = 248;
const selectedY = 132;
let content = `
<defs>
<marker id="pedigree-arrow" markerWidth="6" markerHeight="6" refX="5" refY="3" orient="auto">
<path d="M0,0 L6,3 L0,6 Z" fill="#8c7047"></path>
</marker>
</defs>
`;
batch.parents.forEach((parentId, side) => {
const parent = batchMap.get(parentId);
const px = parentXs[side];
const grandparents = parent.parents;
const gpPositions = new Map();
grandparents.forEach((gpId, gpIndex) => {
const gx = grandparents.length === 1
? px
: px + (gpIndex - (grandparents.length - 1) / 2) * 42;
gpPositions.set(gpId, gx);
content += `
<line x1="${gx}" y1="30" x2="${px}" y2="${parentY}" stroke="#405047" stroke-width="1"></line>
<circle cx="${gx}" cy="23" r="11" fill="#19231d" stroke="#4b5d50" stroke-width="1"></circle>
<text x="${gx}" y="26" text-anchor="middle" fill="#9ba99e" font-family="monospace" font-size="7">${gpId}</text>
`;
});
content += `
<line x1="${px}" y1="${parentY}" x2="${selectedX}" y2="${selectedY}" stroke="#9a7741" stroke-width="1.4" marker-end="url(#pedigree-arrow)"></line>
<circle cx="${px}" cy="${parentY}" r="15" fill="#29241b" stroke="#997643" stroke-width="1.3"></circle>
<text x="${px}" y="${parentY + 3}" text-anchor="middle" fill="#e0bd7d" font-family="monospace" font-size="8">${parentId}</text>
<text x="${px}" y="${parentY + 25}" text-anchor="middle" fill="#617067" font-size="7">${parent.name}</text>
`;
});
content += `
<circle cx="${selectedX}" cy="${selectedY}" r="18" fill="#392d1c" stroke="#efb865" stroke-width="1.7"></circle>
<text x="${selectedX}" y="${selectedY + 3}" text-anchor="middle" fill="#ffd391" font-family="monospace" font-size="9">${batch.id}</text>
<text x="${selectedX}" y="${selectedY + 27}" text-anchor="middle" fill="#a98a5d" font-size="7">selected</text>
`;
return `<svg viewBox="0 0 280 164" role="img" aria-label="Pedigree for ${batch.id}">${content}</svg>`;
}
function renderInspector() {
const batch = batchMap.get(selectedId);
const event = eventMap.get(batch.id);
const leaf = dominant(batch.alleles.leaf, leafRank);
const pattern = dominant(batch.alleles.pattern, patternRank);
const bloom = bloomName(batch.alleles.bloom);
const color = bloomColor(batch);
const parents = batch.parents.map(id => batchMap.get(id));
const midParent = parents.length ? (parents[0].height + parents[1].height) / 2 : null;
const bloomSource = parents.length
? `${alleleNames[batch.alleles.bloom[0]]} from ${parents[0].id} · ${alleleNames[batch.alleles.bloom[1]]} from ${parents[1].id}`
: "Founder baseline";
const leafSource = parents.length
? `${batch.alleles.leaf[0]} from ${parents[0].id} · ${batch.alleles.leaf[1]} from ${parents[1].id} → ${leaf} expression`
: "Founder baseline";
const patternSource = parents.length
? `${batch.alleles.pattern[0]} from ${parents[0].id} · ${batch.alleles.pattern[1]} from ${parents[1].id} → ${pattern} expression`
: "Founder baseline";
const heightSource = parents.length
? `Mid-parent estimate ${midParent} cm · recorded expression ${batch.height} cm`
: "Founder baseline height";
const exchangeMarkup = event ? `
<div class="exchange-callout">
<div class="event-id">${event.id} · ${event.cycle}</div>
<div class="route">
<span>${gardens[event.from].short}</span>
<span style="color:#806b47">→</span>
<span>${gardens[event.to].short}</span>
</div>
<p>${event.detail}</p>
</div>
` : `
<div class="no-exchange">No packet transfer is recorded for this batch. It remained with its originating garden.</div>
`;
const ancestorChips = [...ancestorsOf(batch.id)].map(id => {
const ancestor = batchMap.get(id);
return `<button class="ancestor-chip" data-select-batch="${id}" title="${ancestor.name}">${id} · ${ancestor.name}</button>`;
}).join("");
inspector.innerHTML = `
<div class="inspector">
<section class="passport">
<div class="passport-top">
<div>
<div class="batch-id">${batch.id} / GENERATION ${batch.gen}</div>
<h2 class="batch-large-name">${batch.name}</h2>
<div class="passport-location">${gardens[batch.garden].name}</div>
</div>
<div class="trait-orb" style="--orb:${color}" title="Visible bloom expression"></div>
</div>
<div class="passport-stats">
<div class="passport-stat"><span>Origin</span><strong>${gardens[batch.origin].short}</strong></div>
<div class="passport-stat"><span>Provenance</span><strong>${batch.parents.length ? "CROSS" : "FOUNDER"}</strong></div>
<div class="passport-stat"><span>Height</span><strong>${batch.height} CM</strong></div>
</div>
</section>
<section class="section">
<div class="section-heading">
<div>
<h2>Pedigree</h2>
<p>Parentage only. No visible trait is encoded here.</p>
</div>
<span class="section-number">01</span>
</div>
<div class="pedigree-card">
${pedigreeSvg(batch)}
<div class="pedigree-caption">
<span>PARENTS → OFFSPRING</span>
<button class="focus-button" data-mode-lineage>OPEN LINEAGE MAP →</button>
</div>
${ancestorChips ? `<div class="ancestor-chips">${ancestorChips}</div>` : ""}
</div>
</section>
<section class="section">
<div class="section-heading">
<div>
<h2>Visible inheritance</h2>
<p>Phenotype only. Expressions are traced to their contributing alleles.</p>
</div>
<span class="section-number">02</span>
</div>
<div class="trait-grid">
<div class="trait-card">
<div class="trait-card-top">
<div class="trait-swatch" style="--swatch:${color}"></div>
<div>
<div class="trait-label">Bloom</div>
<div class="trait-value">${bloom}</div>
</div>
</div>
<div class="allele-row">
${batch.alleles.bloom.map(allele => `<span class="allele" style="--allele-color:${alleleColors[allele]}"><i></i>${allele} · ${alleleNames[allele]}</span>`).join("")}
</div>
</div>
<div class="trait-card">
<div class="trait-card-top">
<div class="trait-swatch leaf"></div>
<div>
<div class="trait-label">Leaf form</div>
<div class="trait-value">${leaf}</div>
</div>
</div>
<div class="allele-row">
${batch.alleles.leaf.map(allele => `<span class="allele"><i style="--allele-color:#64865d"></i>${allele}</span>`).join("")}
</div>
</div>
<div class="trait-card">
<div class="trait-card-top">
<div class="trait-swatch pattern"></div>
<div>
<div class="trait-label">Pattern</div>
<div class="trait-value">${pattern}</div>
</div>
</div>
<div class="allele-row">
${batch.alleles.pattern.map(allele => `<span class="allele"><i style="--allele-color:#9b7b54"></i>${allele}</span>`).join("")}
</div>
</div>
<div class="trait-card">
<div class="trait-card-top">
<div class="trait-swatch height"></div>
<div>
<div class="trait-label">Height</div>
<div class="trait-value">${batch.height} cm</div>
</div>
</div>
</div>
<div class="trait-source">
<strong>Bloom:</strong> ${bloomSource}<br />
<strong>Leaf:</strong> ${leafSource}<br />
<strong>Pattern:</strong> ${patternSource}<br />
<strong>Height:</strong> ${heightSource}
</div>
</div>
</section>
<section class="section">
<div class="section-heading">
<div>
<h2>Exchange record</h2>
<p>Movement is independent of inherited traits.</p>
</div>
<span class="section-number">03</span>
</div>
${exchangeMarkup}
</section>
<section class="section">
<div class="section-heading">
<div>
<h2>Network exchange ledger</h2>
<p>All recorded transfers across the three gardens.</p>
</div>
<span class="section-number">04</span>
</div>
<div class="ledger">
${exchanges.map(item => `
<button class="event-row ${item.batch === selectedId ? "highlighted" : ""}" data-event-batch="${item.batch}">
<span class="event-id">${item.id}</span>
<span class="event-main">
<strong>${item.batch} · ${batchMap.get(item.batch).name}</strong>
<span>${gardens[item.from].short} → ${gardens[item.to].short} · ${item.label}</span>
</span>
<span class="event-cycle">${item.cycle}</span>
</button>
`).join("")}
</div>
<p class="legend-note">Pedigree answers “who produced this batch?” Traits answer “what can be seen?” Exchanges answer “where did the packet travel?”</p>
</section>
</div>
`;
}
inspector.addEventListener("click", event => {
const batchButton = event.target.closest("[data-select-batch]");
const eventButton = event.target.closest("[data-event-batch]");
const lineageButton = event.target.closest("[data-mode-lineage]");
if (batchButton) {
activeGeneration = "all";
syncGenerationControls();
selectBatch(batchButton.dataset.selectBatch);
}
if (eventButton) {
activeGeneration = "all";
syncGenerationControls();
selectBatch(eventButton.dataset.eventBatch);
}
if (lineageButton) {
setMode("lineage");
}
});
function selectBatch(id, reveal = false) {
if (!batchMap.has(id)) return;
selectedId = id;
if (reveal && activeGeneration !== "all") {
activeGeneration = "all";
syncGenerationControls();
}
renderList();
renderInspector();
updateVisibility();
updateVisualState();
}
function updateVisualState() {
const ancestors = ancestorsOf(selectedId);
const descendants = descendantsOf(selectedId);
for (const [id, plant] of plants) {
const relation = id === selectedId
? "selected"
: ancestors.has(id)
? "ancestor"
: descendants.has(id)
? "descendant"
: "other";
const ringMaterial = plant.userData.ringMaterial;
if (relation === "selected") {
ringMaterial.color.setHex(0xefb865);
ringMaterial.opacity = .95;
} else if (relation === "ancestor") {
ringMaterial.color.setHex(0xa9c49e);
ringMaterial.opacity = .58;
} else if (relation === "descendant") {
ringMaterial.color.setHex(0x739a8c);
ringMaterial.opacity = .3;
} else {
ringMaterial.color.setHex(0xa2b3a4);
ringMaterial.opacity = .10;
}
const isHovered = id === hoveredId;
for (const material of plant.userData.flowerMaterials) {
material.emissive.setHex(id === selectedId ? 0x6c3f12 : isHovered ? 0x28331b : 0x000000);
material.emissiveIntensity = id === selectedId ? .62 : isHovered ? .35 : 0;
}
plant.userData.label.classList.toggle("selected", id === selectedId);
}
for (const item of pedigreeLines) {
const inSelectedPath = ancestors.has(item.parentId) && ancestors.has(item.childId);
const touchesSelected = item.parentId === selectedId || item.childId === selectedId;
const color = inSelectedPath ? 0xefb865 : touchesSelected ? 0xc29450 : 0x63766a;
const opacity = inSelectedPath ? .88 : touchesSelected ? .68 : .18;
item.line.material.color.setHex(color);
item.line.material.opacity = opacity;
item.arrow.material.color.setHex(color);
item.arrow.material.opacity = Math.min(1, opacity + .08);
}
}
function syncGenerationControls() {
document.querySelectorAll("[data-gen-filter]").forEach(button => {
button.classList.toggle("active", button.dataset.genFilter === String(activeGeneration));
});
const caption = activeGeneration === "all"
? "All generations"
: `Generation ${activeGeneration}`;
document.getElementById("generation-caption").textContent = caption;
renderList();
updateVisibility();
updateVisualState();
}
function updateVisibility() {
for (const batch of batches) {
const plant = plants.get(batch.id);
const visible = activeGeneration === "all" || batch.gen === Number(activeGeneration);
plant.visible = visible;
plant.userData.label.style.display = visible ? "flex" : "none";
}
for (const item of pedigreeLines) {
const parent = batchMap.get(item.parentId);
const child = batchMap.get(item.childId);
const visible = activeGeneration === "all"
|| child.gen === Number(activeGeneration)
|| parent.gen === Number(activeGeneration);
item.line.visible = visible;
item.arrow.visible = visible;
}
for (const child of exchangeGroup.children) {
const event = exchanges.find(item => item.id === child.userData.eventId);
if (!event) continue;
child.visible = activeGeneration === "all"
|| batchMap.get(event.batch).gen === Number(activeGeneration);
}
}
document.querySelectorAll("[data-gen-filter]").forEach(button => {
button.addEventListener("click", () => {
activeGeneration = button.dataset.genFilter;
syncGenerationControls();
});
});
function setMode(nextMode) {
mode = nextMode;
document.querySelectorAll("[data-mode]").forEach(button => {
button.classList.toggle("active", button.dataset.mode === mode);
});
if (mode === "lineage") {
pedigreeVisible = true;
document.getElementById("pedigree-links").classList.add("active");
document.getElementById("pedigree-links").setAttribute("aria-pressed", "true");
}
plotGroup.visible = mode === "garden";
laneGroup.visible = mode === "lineage";
for (const batch of batches) {
const target = mode === "garden"
? gardenPositions.get(batch.id)
: lineagePositions.get(batch.id);
plants.get(batch.id).userData.target.copy(target);
}
buildPedigreeLines();
updateVisibility();
updateVisualState();
document.getElementById("stage-description").textContent = mode === "garden"
? "Garden beds show current holding sites. Switch to pedigree lanes to rearrange generations by ancestry."
: "Pedigree lanes separate parentage from the visible plant forms. Follow arrows from founders toward offspring.";
}
document.querySelectorAll("[data-mode]").forEach(button => {
button.addEventListener("click", () => setMode(button.dataset.mode));
});
document.getElementById("trait-coding").addEventListener("click", event => {
traitCoding = !traitCoding;
event.currentTarget.classList.toggle("active", traitCoding);
event.currentTarget.setAttribute("aria-pressed", String(traitCoding));
for (const batch of batches) {
const plant = plants.get(batch.id);
const original = bloomColor(batch);
plant.userData.flowerMaterial.color.set(traitCoding ? original : "#87988a");
plant.userData.accentMaterial.color.set(traitCoding ? "#f0dfb4" : "#a5afa4");
}
});
document.getElementById("pedigree-links").addEventListener("click", event => {
pedigreeVisible = !pedigreeVisible;
event.currentTarget.classList.toggle("active", pedigreeVisible);
event.currentTarget.setAttribute("aria-pressed", String(pedigreeVisible));
updateVisibility();
});
document.getElementById("exchange-trails").addEventListener("click", event => {
exchangeVisible = !exchangeVisible;
event.currentTarget.classList.toggle("active", exchangeVisible);
event.currentTarget.setAttribute("aria-pressed", String(exchangeVisible));
updateVisibility();
});
// Export a clean trace without Three.js-specific objects.
document.getElementById("export-trace").addEventListener("click", () => {
const trace = {
archive: "Linea / The Three Garden Exchange",
generated: new Date().toISOString(),
selectedBatch: selectedId,
batches: batches.map(batch => ({
id: batch.id,
name: batch.name,
generation: batch.gen,
parents: batch.parents,
originGarden: gardens[batch.origin].name,
currentGarden: gardens[batch.garden].name,
visibleExpression: {
bloom: bloomName(batch.alleles.bloom),
bloomColor: bloomColor(batch),
leaf: dominant(batch.alleles.leaf, leafRank),
pattern: dominant(batch.alleles.pattern, patternRank),
heightCm: batch.height
},
inheritedAlleles: batch.alleles
})),
exchanges
};
const blob = new Blob([JSON.stringify(trace, null, 2)], { type: "application/json" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "linea-seed-trace.json";
link.click();
URL.revokeObjectURL(url);
});
// -------------------------------------------------------------------------
// Resize, projection, and render loop
// -------------------------------------------------------------------------
function resize() {
const width = Math.max(1, viewport.clientWidth);
const height = Math.max(1, viewport.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
new ResizeObserver(resize).observe(viewport);
resize();
const projected = new THREE.Vector3();
function projectElement(element, position, offsetY = 0) {
projected.copy(position);
projected.y += offsetY;
projected.project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.visibility = visible ? "visible" : "hidden";
element.style.left = `${(projected.x * .5 + .5) * viewport.clientWidth}px`;
element.style.top = `${(-projected.y * .5 + .5) * viewport.clientHeight}px`;
}
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
for (const plant of plants.values()) {
plant.position.lerp(plant.userData.target, .075);
plant.userData.flower.rotation.z = Math.sin(elapsed * .85 + plant.position.x) * .025;
plant.userData.ring.rotation.y = elapsed * .18;
}
pollen.forEach((mesh, index) => {
mesh.position.y += Math.sin(elapsed * .5 + index) * .0009;
mesh.position.x += Math.sin(elapsed * .25 + index * 2) * .00035;
});
updateCamera();
for (const plant of plants.values()) {
if (!plant.visible) continue;
projectElement(plant.userData.label, plant.position, plant.userData.top);
}
for (const label of gardenLabels) {
label.element.style.display = mode === "garden" ? "block" : "none";
if (mode === "garden") projectElement(label.element, label.position);
}
for (const label of generationLabels) {
label.element.style.display = mode === "lineage" ? "block" : "none";
if (mode === "lineage") projectElement(label.element, label.position);
}
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
renderList();
renderInspector();
updateVisibility();
updateVisualState();
animate();
</script>
</body>
</html>
```