Prompt specification
Build or customize the Three.js 3D scene "Botanical teaching greenhouse" 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: Botanical teaching greenhouse
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/botanical-teaching-greenhouse-x0883
Scene Description Prompt:
A voxel teaching greenhouse with fictional plant traits and hidden genotype panels to reveal. Use Three.js from cdnjs in one HTML file.
Working Three.js Starter (botanical-teaching-greenhouse-x0883):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="An interactive voxel teaching greenhouse with fictional plant traits and hidden genotype panels."
/>
<title>Trait House — Voxel Teaching Greenhouse</title>
<style>
:root {
--ink: #17382f;
--ink-soft: #48685d;
--paper: #f7f5eb;
--paper-deep: #ece8d9;
--line: rgba(23, 56, 47, 0.14);
--green: #2f765b;
--green-dark: #225541;
--lime: #c8e66b;
--orange: #ec9b55;
--shadow: 0 18px 50px rgba(22, 52, 43, 0.14);
--radius: 18px;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
}
body {
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
button:focus-visible,
input:focus-visible {
outline: 3px solid rgba(236, 155, 85, 0.55);
outline-offset: 2px;
}
.topbar {
position: relative;
z-index: 20;
height: 74px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 22px;
border-bottom: 1px solid var(--line);
background:
linear-gradient(90deg, rgba(200, 230, 107, 0.16), transparent 35%),
var(--paper);
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 38px;
height: 38px;
flex: 0 0 auto;
border: 2px solid var(--ink);
background: var(--lime);
box-shadow: 4px 4px 0 var(--ink);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
background: var(--ink);
}
.brand-mark::before {
width: 4px;
height: 22px;
left: 15px;
top: 6px;
transform: rotate(27deg);
}
.brand-mark::after {
width: 12px;
height: 4px;
left: 10px;
top: 13px;
transform: rotate(-18deg);
box-shadow: 6px 7px 0 var(--ink);
}
.brand-copy {
min-width: 0;
}
.eyebrow {
margin: 0 0 2px;
color: var(--green);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: 20px;
line-height: 1;
letter-spacing: -0.03em;
}
.brand h1 span {
color: var(--green);
font-weight: 500;
}
.top-actions {
display: flex;
align-items: center;
gap: 8px;
}
.tool-button {
min-height: 38px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.58);
cursor: pointer;
font-size: 12px;
font-weight: 750;
transition:
transform 150ms ease,
background 150ms ease,
border-color 150ms ease;
}
.tool-button:hover {
transform: translateY(-1px);
border-color: rgba(23, 56, 47, 0.32);
background: white;
}
.tool-button[aria-pressed="true"] {
border-color: var(--green);
background: #e2efcf;
}
.compare-button {
display: flex;
align-items: center;
gap: 8px;
border-color: var(--ink);
background: var(--ink);
color: white;
}
.compare-button:hover {
background: var(--green-dark);
}
.count-badge {
min-width: 21px;
height: 21px;
display: grid;
place-items: center;
padding: 0 6px;
border-radius: 6px;
background: var(--lime);
color: var(--ink);
font-size: 10px;
font-weight: 900;
}
.layout {
height: calc(100% - 74px);
display: grid;
grid-template-columns: 326px minmax(0, 1fr);
}
.catalog {
position: relative;
z-index: 10;
min-height: 0;
display: flex;
flex-direction: column;
border-right: 1px solid var(--line);
background: var(--paper);
}
.catalog-head {
padding: 22px 20px 14px;
border-bottom: 1px solid var(--line);
}
.catalog-title-row {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 16px;
margin-bottom: 16px;
}
.catalog h2 {
margin: 0;
font-size: 19px;
letter-spacing: -0.025em;
}
.catalog-meta {
margin: 4px 0 0;
color: var(--ink-soft);
font-size: 12px;
line-height: 1.45;
}
.search-wrap {
position: relative;
}
.search-wrap::before {
content: "";
position: absolute;
left: 13px;
top: 50%;
width: 11px;
height: 11px;
border: 2px solid var(--ink-soft);
border-radius: 50%;
transform: translateY(-58%);
pointer-events: none;
}
.search-wrap::after {
content: "";
position: absolute;
left: 23px;
top: 19px;
width: 6px;
height: 2px;
background: var(--ink-soft);
transform: rotate(45deg);
pointer-events: none;
}
.search-wrap input {
width: 100%;
height: 40px;
padding: 0 12px 0 35px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.68);
color: var(--ink);
font-size: 12px;
}
.search-wrap input::placeholder {
color: #81948c;
}
.filter-row {
display: flex;
gap: 6px;
padding: 12px 20px;
overflow-x: auto;
border-bottom: 1px solid var(--line);
scrollbar-width: none;
}
.filter-row::-webkit-scrollbar {
display: none;
}
.filter-chip {
flex: 0 0 auto;
padding: 7px 9px;
border: 1px solid transparent;
border-radius: 8px;
background: var(--paper-deep);
color: var(--ink-soft);
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.03em;
}
.filter-chip:hover,
.filter-chip.active {
border-color: var(--ink);
background: var(--ink);
color: white;
}
.catalog-scroll {
min-height: 0;
flex: 1;
overflow-y: auto;
padding: 10px 12px 18px;
}
.specimen-card {
width: 100%;
display: grid;
grid-template-columns: 38px minmax(0, 1fr) auto;
align-items: center;
gap: 11px;
margin: 3px 0;
padding: 12px 10px;
border: 1px solid transparent;
border-radius: 13px;
background: transparent;
text-align: left;
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease,
border-color 150ms ease;
}
.specimen-card:hover {
transform: translateX(2px);
background: rgba(255, 255, 255, 0.72);
}
.specimen-card.selected {
border-color: var(--line);
background: white;
box-shadow: 0 7px 20px rgba(23, 56, 47, 0.08);
}
.plant-swatch {
position: relative;
width: 38px;
height: 38px;
border: 1px solid rgba(23, 56, 47, 0.15);
border-radius: 10px;
background:
linear-gradient(135deg, transparent 42%, rgba(255, 255, 255, 0.48) 43% 55%, transparent 56%),
var(--swatch);
}
.plant-swatch::before {
content: "";
position: absolute;
left: 17px;
bottom: 6px;
width: 4px;
height: 21px;
background: var(--ink);
transform: rotate(7deg);
}
.plant-swatch::after {
content: "";
position: absolute;
left: 10px;
bottom: 17px;
width: 13px;
height: 8px;
border-radius: 8px 1px 8px 1px;
background: var(--ink);
box-shadow: 7px 7px 0 -1px var(--ink);
}
.specimen-copy {
min-width: 0;
}
.specimen-id {
display: block;
margin-bottom: 3px;
color: var(--green);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.13em;
}
.specimen-name {
display: block;
overflow: hidden;
color: var(--ink);
font-size: 13px;
font-weight: 800;
text-overflow: ellipsis;
white-space: nowrap;
}
.specimen-sub {
display: block;
margin-top: 3px;
overflow: hidden;
color: var(--ink-soft);
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
.specimen-arrow {
color: #91a59c;
font-size: 18px;
}
.empty-state {
padding: 30px 18px;
color: var(--ink-soft);
font-size: 12px;
line-height: 1.6;
text-align: center;
}
.catalog-foot {
padding: 12px 20px;
border-top: 1px solid var(--line);
color: var(--ink-soft);
font-size: 10px;
line-height: 1.45;
}
.stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background: #dce9df;
isolation: isolate;
}
#scene {
position: absolute;
inset: 0;
}
#scene canvas {
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene canvas.dragging {
cursor: grabbing;
}
.stage-top {
position: absolute;
z-index: 5;
top: 18px;
left: 18px;
display: flex;
align-items: center;
gap: 8px;
pointer-events: none;
}
.exhibit-pill {
padding: 9px 11px;
border: 1px solid rgba(23, 56, 47, 0.13);
border-radius: 9px;
background: rgba(247, 245, 235, 0.88);
box-shadow: 0 6px 18px rgba(23, 56, 47, 0.08);
backdrop-filter: blur(10px);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.exhibit-pill span {
color: var(--green);
}
.camera-hint {
position: absolute;
z-index: 4;
top: 18px;
right: 18px;
padding: 8px 10px;
border-radius: 8px;
background: rgba(247, 245, 235, 0.7);
color: var(--ink-soft);
font-size: 10px;
pointer-events: none;
backdrop-filter: blur(8px);
}
.inspector {
position: absolute;
z-index: 8;
top: 58px;
right: 18px;
width: min(326px, calc(100% - 36px));
max-height: calc(100% - 132px);
overflow-y: auto;
padding: 18px;
border: 1px solid rgba(23, 56, 47, 0.14);
border-radius: var(--radius);
background: rgba(250, 249, 242, 0.95);
box-shadow: var(--shadow);
opacity: 0;
visibility: hidden;
transform: translateX(18px);
transition:
opacity 180ms ease,
transform 180ms ease,
visibility 180ms;
backdrop-filter: blur(18px);
scrollbar-width: thin;
}
.inspector.is-visible {
opacity: 1;
visibility: visible;
transform: translateX(0);
}
.inspector-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 14px;
}
.specimen-code {
color: var(--green);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.15em;
}
.icon-button {
width: 30px;
height: 30px;
display: grid;
place-items: center;
border: 1px solid var(--line);
border-radius: 8px;
background: transparent;
cursor: pointer;
font-size: 18px;
line-height: 1;
}
.icon-button:hover {
background: var(--paper-deep);
}
.inspector h2 {
margin: 0;
font-size: 25px;
letter-spacing: -0.045em;
}
.plant-description {
margin: 7px 0 14px;
color: var(--ink-soft);
font-size: 12px;
line-height: 1.55;
}
.badge-row {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-bottom: 17px;
}
.badge {
padding: 6px 8px;
border-radius: 7px;
background: #e6efdc;
color: var(--green-dark);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 0 8px;
color: var(--ink-soft);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.phenotype-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 7px;
margin-bottom: 17px;
}
.trait-cell {
min-height: 53px;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.55);
}
.trait-name {
display: block;
margin-bottom: 4px;
color: var(--ink-soft);
font-size: 8px;
font-weight: 900;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.trait-value {
display: block;
font-size: 11px;
font-weight: 800;
}
.genome-card {
overflow: hidden;
border: 1px solid rgba(37, 83, 66, 0.17);
border-radius: 12px;
background: #e9f0e1;
}
.genome-card-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 11px 12px;
border-bottom: 1px solid rgba(37, 83, 66, 0.12);
}
.genome-card-head strong {
font-size: 10px;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.locked-label {
color: var(--green);
font-size: 8px;
font-weight: 900;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.genome-card-body {
padding: 12px;
}
.masked-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
}
.marker {
min-width: 0;
text-align: center;
}
.marker-locus {
display: block;
margin-bottom: 5px;
color: var(--green);
font-size: 9px;
font-weight: 950;
}
.marker-code {
display: block;
overflow: hidden;
padding: 7px 3px;
border-radius: 6px;
background: rgba(23, 56, 47, 0.08);
color: var(--ink);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
font-weight: 850;
text-overflow: ellipsis;
white-space: nowrap;
}
.marker-code.masked {
color: transparent;
text-shadow: 0 0 7px rgba(23, 56, 47, 0.55);
user-select: none;
}
.marker-note {
display: block;
margin-top: 5px;
color: var(--ink-soft);
font-size: 8px;
line-height: 1.3;
}
.genome-note {
margin: 10px 0 0;
color: var(--ink-soft);
font-size: 9px;
line-height: 1.45;
}
.reveal-button,
.primary-action {
width: 100%;
min-height: 39px;
margin-top: 10px;
border: 0;
border-radius: 9px;
background: var(--ink);
color: white;
cursor: pointer;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.03em;
}
.reveal-button:hover,
.primary-action:hover {
background: var(--green-dark);
}
.reveal-button.revealed {
border: 1px solid rgba(37, 83, 66, 0.22);
background: rgba(255, 255, 255, 0.5);
color: var(--green-dark);
}
.inspector-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 9px;
}
.secondary-action {
min-height: 37px;
padding: 0 10px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.55);
cursor: pointer;
font-size: 9px;
font-weight: 850;
}
.secondary-action:hover {
background: white;
}
.secondary-action.active {
border-color: var(--green);
background: #e2efcf;
}
.legend {
position: absolute;
z-index: 4;
left: 18px;
bottom: 18px;
display: flex;
align-items: center;
gap: 10px;
padding: 9px 11px;
border: 1px solid rgba(23, 56, 47, 0.12);
border-radius: 10px;
background: rgba(247, 245, 235, 0.83);
color: var(--ink-soft);
font-size: 9px;
backdrop-filter: blur(10px);
pointer-events: none;
}
.legend-swatches {
display: flex;
gap: 4px;
}
.legend-swatch {
width: 11px;
height: 11px;
border: 1px solid rgba(23, 56, 47, 0.16);
border-radius: 3px;
}
.camera-controls {
position: absolute;
z-index: 7;
bottom: 18px;
left: 50%;
display: flex;
align-items: center;
gap: 3px;
padding: 4px;
border: 1px solid rgba(23, 56, 47, 0.15);
border-radius: 11px;
background: rgba(247, 245, 235, 0.9);
box-shadow: 0 8px 25px rgba(23, 56, 47, 0.11);
transform: translateX(-50%);
backdrop-filter: blur(12px);
}
.camera-controls button {
width: 34px;
height: 32px;
display: grid;
place-items: center;
border: 0;
border-radius: 7px;
background: transparent;
cursor: pointer;
font-size: 17px;
font-weight: 750;
}
.camera-controls button:hover {
background: var(--paper-deep);
}
.camera-controls .control-divider {
width: 1px;
height: 20px;
margin: 0 2px;
background: var(--line);
}
.hover-tip {
position: absolute;
z-index: 9;
display: none;
padding: 7px 9px;
border-radius: 7px;
background: var(--ink);
color: white;
font-size: 10px;
font-weight: 750;
pointer-events: none;
transform: translate(12px, 12px);
box-shadow: 0 8px 20px rgba(23, 56, 47, 0.18);
}
.toast {
position: absolute;
z-index: 30;
left: 50%;
top: 68px;
max-width: calc(100% - 40px);
padding: 10px 13px;
border-radius: 9px;
background: var(--ink);
color: white;
font-size: 11px;
font-weight: 750;
opacity: 0;
pointer-events: none;
transform: translate(-50%, -8px);
transition:
opacity 180ms ease,
transform 180ms ease;
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
dialog {
width: min(780px, calc(100% - 32px));
max-height: min(760px, calc(100% - 32px));
padding: 0;
overflow: hidden;
border: 1px solid rgba(23, 56, 47, 0.18);
border-radius: 20px;
background: var(--paper);
color: var(--ink);
box-shadow: 0 30px 100px rgba(10, 35, 28, 0.3);
}
dialog::backdrop {
background: rgba(16, 42, 34, 0.47);
backdrop-filter: blur(5px);
}
.dialog-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
padding: 22px 24px 18px;
border-bottom: 1px solid var(--line);
}
.dialog-head h2 {
margin: 0;
font-size: 25px;
letter-spacing: -0.04em;
}
.dialog-head p {
margin: 5px 0 0;
color: var(--ink-soft);
font-size: 12px;
line-height: 1.5;
}
.dialog-body {
max-height: calc(100vh - 150px);
overflow-y: auto;
padding: 22px 24px 26px;
}
.guide-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
}
.guide-card {
padding: 15px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.5);
}
.guide-step {
width: 28px;
height: 28px;
display: grid;
place-items: center;
margin-bottom: 11px;
border-radius: 7px;
background: var(--lime);
font-size: 11px;
font-weight: 900;
}
.guide-card h3 {
margin: 0 0 6px;
font-size: 13px;
}
.guide-card p {
margin: 0;
color: var(--ink-soft);
font-size: 11px;
line-height: 1.55;
}
.science-note {
margin-top: 16px;
padding: 15px 16px;
border-left: 4px solid var(--orange);
border-radius: 0 10px 10px 0;
background: #f3e9d8;
color: #5e5545;
font-size: 11px;
line-height: 1.6;
}
.compare-wrap {
overflow-x: auto;
}
.compare-table {
width: 100%;
min-width: 560px;
border-collapse: collapse;
font-size: 11px;
}
.compare-table th,
.compare-table td {
padding: 12px;
border-bottom: 1px solid var(--line);
text-align: left;
vertical-align: top;
}
.compare-table th:first-child,
.compare-table td:first-child {
width: 125px;
color: var(--ink-soft);
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.compare-table thead th {
color: var(--ink);
font-size: 14px;
}
.compare-table .table-swatch {
display: inline-block;
width: 10px;
height: 10px;
margin-right: 7px;
border-radius: 3px;
vertical-align: -1px;
}
.compare-empty {
padding: 40px 20px;
color: var(--ink-soft);
font-size: 12px;
line-height: 1.6;
text-align: center;
}
@media (max-width: 1000px) {
.layout {
grid-template-columns: 286px minmax(0, 1fr);
}
.catalog-head,
.filter-row {
padding-left: 16px;
padding-right: 16px;
}
.camera-hint {
display: none;
}
.legend {
display: none;
}
}
@media (max-width: 760px) {
body {
overflow: auto;
}
.topbar {
height: 66px;
padding: 0 14px;
}
.brand h1 {
font-size: 17px;
}
.brand .eyebrow {
display: none;
}
.brand-mark {
width: 32px;
height: 32px;
}
.top-actions {
gap: 5px;
}
.tool-button {
min-height: 34px;
padding: 0 9px;
font-size: 10px;
}
#annotations-button,
#guide-button {
display: none;
}
.layout {
height: auto;
min-height: calc(100% - 66px);
display: flex;
flex-direction: column;
}
.stage {
order: -1;
height: 68vh;
min-height: 500px;
}
.catalog {
min-height: 460px;
border-top: 1px solid var(--line);
border-right: 0;
}
.catalog-scroll {
max-height: 390px;
}
.inspector {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 45%;
padding: 15px;
}
.inspector h2 {
font-size: 21px;
}
.stage-top {
top: 10px;
left: 10px;
}
.camera-controls {
bottom: 12px;
}
.guide-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 440px) {
.compare-button span.button-label {
display: none;
}
.inspector {
max-height: 48%;
}
.phenotype-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div class="brand-copy">
<p class="eyebrow">Voxel botany learning lab</p>
<h1>Trait <span>House</span></h1>
</div>
</div>
<div class="top-actions">
<button class="tool-button" id="guide-button" type="button">Guide</button>
<button
class="tool-button"
id="annotations-button"
type="button"
aria-pressed="true"
>
Labels on
</button>
<button class="tool-button compare-button" id="compare-button" type="button">
<span class="button-label">Compare</span>
<span class="count-badge" id="compare-count">0</span>
</button>
</div>
</header>
<div class="layout">
<aside class="catalog" aria-label="Specimen catalog">
<div class="catalog-head">
<div class="catalog-title-row">
<div>
<h2>Specimen index</h2>
<p class="catalog-meta">Explore observable traits and hidden story-genotypes.</p>
</div>
</div>
<div class="search-wrap">
<input
id="search-input"
type="search"
placeholder="Search a specimen…"
aria-label="Search specimens"
autocomplete="off"
/>
</div>
</div>
<div class="filter-row" id="filter-row" aria-label="Filter specimens">
<button class="filter-chip active" type="button" data-filter="All">All</button>
<button class="filter-chip" type="button" data-filter="Bloom">Bloom</button>
<button class="filter-chip" type="button" data-filter="Fan">Fan</button>
<button class="filter-chip" type="button" data-filter="Frond">Frond</button>
<button class="filter-chip" type="button" data-filter="Clover">Clover</button>
<button class="filter-chip" type="button" data-filter="Rosette">Rosette</button>
</div>
<div class="catalog-scroll" id="catalog-list"></div>
<div class="catalog-foot">
All specimens and loci are fictional teaching constructs, not real botanical genetics.
</div>
</aside>
<main class="stage" id="stage">
<div id="scene" aria-label="Interactive three-dimensional voxel greenhouse"></div>
<div class="stage-top" aria-hidden="true">
<div class="exhibit-pill">Exhibit 04 <span>/</span> Trait greenhouse</div>
</div>
<div class="camera-hint">Drag to orbit · Scroll to zoom · Click a plant</div>
<aside class="inspector" id="inspector" aria-live="polite" aria-hidden="true"></aside>
<div class="hover-tip" id="hover-tip"></div>
<div class="toast" id="toast" role="status"></div>
<div class="legend" aria-hidden="true">
<span>Fictional pigments</span>
<div class="legend-swatches">
<span class="legend-swatch" style="background:#d84f96"></span>
<span class="legend-swatch" style="background:#e9a74e"></span>
<span class="legend-swatch" style="background:#a9cf54"></span>
<span class="legend-swatch" style="background:#527eb4"></span>
<span class="legend-swatch" style="background:#ef735f"></span>
<span class="legend-swatch" style="background:#65c8c2"></span>
</div>
</div>
<div class="camera-controls" aria-label="Camera controls">
<button id="zoom-out" type="button" aria-label="Zoom out">−</button>
<button id="zoom-in" type="button" aria-label="Zoom in">+</button>
<span class="control-divider"></span>
<button id="reset-camera" type="button" aria-label="Reset camera" title="Reset camera">⌂</button>
</div>
</main>
</div>
<dialog id="guide-dialog">
<div class="dialog-head">
<div>
<p class="eyebrow">Quick field guide</p>
<h2>How to use the greenhouse</h2>
<p>Observe first, then reveal the hidden story-genotype.</p>
</div>
<form method="dialog">
<button class="icon-button" type="submit" aria-label="Close guide">×</button>
</form>
</div>
<div class="dialog-body">
<div class="guide-grid">
<article class="guide-card">
<div class="guide-step">1</div>
<h3>Orbit the exhibit</h3>
<p>Drag the greenhouse to rotate your view. Use the wheel or +/− controls to zoom.</p>
</article>
<article class="guide-card">
<div class="guide-step">2</div>
<h3>Inspect a specimen</h3>
<p>Click a voxel plant or its catalog entry to compare visible traits with the concealed markers.</p>
</article>
<article class="guide-card">
<div class="guide-step">3</div>
<h3>Reveal and compare</h3>
<p>Unlock each fictional genotype, then place up to three specimens in the comparison table.</p>
</article>
</div>
<div class="science-note">
<strong>Teaching note:</strong> the names, loci, pigment pathways, inheritance patterns,
and environment responses in this greenhouse are invented for visual learning. They
should not be interpreted as descriptions of real plants or real DNA.
</div>
</div>
</dialog>
<dialog id="compare-dialog">
<div class="dialog-head">
<div>
<p class="eyebrow">Side-by-side study</p>
<h2>Specimen comparison</h2>
<p>Compare visible phenotypes across up to three plants.</p>
</div>
<form method="dialog">
<button class="icon-button" type="submit" aria-label="Close comparison">×</button>
</form>
</div>
<div class="dialog-body" id="compare-body"></div>
</dialog>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Fictional teaching data
// -------------------------------------------------------------------------
const plants = [
{
id: "VX-101",
name: "Prismfrond",
subtitle: "A magenta mosaic fan fern",
description:
"Stepped magenta leaf modules form a broad fan. The alternating light and dark pixels make this the greenhouse's clearest mosaic-pattern example.",
leaf: "Fan",
pigment: "Magenta",
pattern: "Mosaic",
water: "Low",
bloom: "None",
height: "Tall",
color: "#d84f96",
accent: "#f5a6cd",
form: "fan",
heightValue: 2.3,
genome: [
["L", "FAN-2", "Broad fan modules"],
["P", "MAG-1", "Magenta pigment"],
["W", "DRY-2", "Low-water tolerance"],
["B", "BLM-0", "No bloom trigger"]
]
},
{
id: "VX-102",
name: "Lumenleaf",
subtitle: "An amber paddle plant",
description:
"Tall amber paddles sit above a sturdy stem. Its uniform color and high water preference distinguish it from neighboring mosaic specimens.",
leaf: "Paddle",
pigment: "Amber",
pattern: "Uniform",
water: "High",
bloom: "None",
height: "Medium",
color: "#e9a74e",
accent: "#f5cd78",
form: "paddle",
heightValue: 1.75,
genome: [
["L", "PAD-3", "Upright paddle leaves"],
["P", "AMB-4", "Amber pigment"],
["W", "WET-1", "High water preference"],
["B", "BLM-0", "No bloom trigger"]
]
},
{
id: "VX-103",
name: "Pixel Clover",
subtitle: "A lime four-pixel clover",
description:
"A compact clover crown grows from a short stem. Its lime mosaic and small bell bloom are easy to compare with the larger fan species.",
leaf: "Clover",
pigment: "Lime",
pattern: "Mosaic",
water: "Medium",
bloom: "Bell",
height: "Short",
color: "#a9cf54",
accent: "#d8ed77",
form: "clover",
heightValue: 1.18,
genome: [
["L", "CLO-2", "Four-part leaf crown"],
["P", "LIM-3", "Lime pigment"],
["W", "MID-2", "Medium water preference"],
["B", "BEL-1", "Bell bloom trigger"]
]
},
{
id: "VX-104",
name: "Cobalt Fern",
subtitle: "A blue modular frond",
description:
"Thin side fronds and tiny cobalt pixels create a cool, uniform specimen. This plant shows the tallest canopy in the teaching collection.",
leaf: "Frond",
pigment: "Cobalt",
pattern: "Uniform",
water: "High",
bloom: "None",
height: "Tall",
color: "#527eb4",
accent: "#77a1cf",
form: "frond",
heightValue: 2.5,
genome: [
["L", "FRN-4", "Fine side fronds"],
["P", "COB-2", "Cobalt pigment"],
["W", "WET-1", "High water preference"],
["B", "BLM-0", "No bloom trigger"]
]
},
{
id: "VX-105",
name: "Embercap",
subtitle: "A coral rosette with a disk bloom",
description:
"A low rosette transitions from coral to warm cream toward its center. The square disk bloom is triggered by this specimen's dry habitat marker.",
leaf: "Rosette",
pigment: "Coral",
pattern: "Gradient",
water: "Low",
bloom: "Disk",
height: "Medium",
color: "#ef735f",
accent: "#ffd0a7",
form: "rosette",
heightValue: 1.55,
genome: [
["L", "ROS-2", "Radial leaf rosette"],
["P", "COR-5", "Coral pigment"],
["W", "DRY-2", "Low-water tolerance"],
["B", "DSK-1", "Disk bloom trigger"]
]
},
{
id: "VX-106",
name: "Mistbloom",
subtitle: "A cyan fan with a bell bloom",
description:
"Soft cyan fan leaves shift toward pale mint at the tips. Its patterned canopy and hanging bell bloom combine two notable classroom traits.",
leaf: "Fan",
pigment: "Cyan",
pattern: "Gradient",
water: "Medium",
bloom: "Bell",
height: "Tall",
color: "#65c8c2",
accent: "#c9f0df",
form: "fan",
heightValue: 2.2,
genome: [
["L", "FAN-3", "Wide fan modules"],
["P", "CYA-2", "Cyan pigment"],
["W", "MID-2", "Medium water preference"],
["B", "BEL-1", "Bell bloom trigger"]
]
}
];
const plantById = new Map(plants.map((plant) => [plant.id, plant]));
// -------------------------------------------------------------------------
// DOM state
// -------------------------------------------------------------------------
const stage = document.querySelector("#stage");
const sceneContainer = document.querySelector("#scene");
const catalogList = document.querySelector("#catalog-list");
const inspector = document.querySelector("#inspector");
const hoverTip = document.querySelector("#hover-tip");
const searchInput = document.querySelector("#search-input");
const compareCount = document.querySelector("#compare-count");
const compareBody = document.querySelector("#compare-body");
const compareDialog = document.querySelector("#compare-dialog");
const guideDialog = document.querySelector("#guide-dialog");
const annotationsButton = document.querySelector("#annotations-button");
const toast = document.querySelector("#toast");
let selectedId = null;
let activeFilter = "All";
let searchTerm = "";
let annotationsVisible = true;
let compareIds = [];
const revealedGenomes = new Set();
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9df);
scene.fog = new THREE.Fog(0xdce9df, 17, 36);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 80);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneContainer.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xf4fff4, 0x78917f, 2.2);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff2c9, 3.1);
sun.position.set(7, 13, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(1536, 1536);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbadbff, 0.75);
fill.position.set(-8, 7, -6);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const clickableMeshes = [];
const plantGroups = new Map();
const plantVisuals = new Map();
const annotationObjects = [];
const orbit = {
target: new THREE.Vector3(0, 1.65, 0),
desiredTarget: new THREE.Vector3(0, 1.65, 0),
theta: 0.72,
desiredTheta: 0.72,
phi: 1.02,
desiredPhi: 1.02,
radius: 14.4,
desiredRadius: 14.4
};
const materials = {
foundation: new THREE.MeshStandardMaterial({
color: 0xb9c8b8,
roughness: 0.95
}),
frame: new THREE.MeshStandardMaterial({
color: 0x31594b,
roughness: 0.66,
metalness: 0.08
}),
frameLight: new THREE.MeshStandardMaterial({
color: 0x547566,
roughness: 0.72
}),
glass: new THREE.MeshPhongMaterial({
color: 0xbfe8df,
transparent: true,
opacity: 0.13,
depthWrite: false,
side: THREE.DoubleSide,
shininess: 35
}),
soil: new THREE.MeshStandardMaterial({
color: 0x493d31,
roughness: 1
}),
planter: new THREE.MeshStandardMaterial({
color: 0xe4d9b7,
roughness: 0.9
}),
planterEdge: new THREE.MeshStandardMaterial({
color: 0xf3ebcf,
roughness: 0.88
}),
stem: new THREE.MeshStandardMaterial({
color: 0x376b45,
roughness: 0.86
}),
path: new THREE.MeshStandardMaterial({
color: 0xcbd0b9,
roughness: 0.95
})
};
function addBox(
parent,
width,
height,
depth,
x,
y,
z,
material,
plantId = null,
castShadow = true
) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
if (plantId) {
mesh.userData.plantId = plantId;
clickableMeshes.push(mesh);
}
return mesh;
}
function addBeam(parent, start, end, thickness, material) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const midpoint = new THREE.Vector3()
.addVectors(start, end)
.multiplyScalar(0.5);
const beam = addBox(
parent,
thickness,
length,
thickness,
midpoint.x,
midpoint.y,
midpoint.z,
material
);
beam.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return beam;
}
function createVoxelFloor() {
const tileMaterials = [
new THREE.MeshStandardMaterial({ color: 0xe2dfc9, roughness: 0.98 }),
new THREE.MeshStandardMaterial({ color: 0xd7ddc7, roughness: 0.98 }),
new THREE.MeshStandardMaterial({ color: 0xe8e4cf, roughness: 0.98 })
];
for (let x = -5; x <= 5; x++) {
for (let z = -4; z <= 4; z++) {
const material =
(Math.abs(x + z) % 3 === 0
? tileMaterials[2]
: tileMaterials[(x + z + 20) % 2]);
addBox(
scene,
0.96,
0.12,
0.96,
x,
0,
z,
material,
null,
false
);
}
}
addBox(
scene,
12.2,
0.32,
10.2,
0,
-0.23,
0,
materials.foundation,
null,
false
);
addBox(scene, 10.2, 0.035, 0.7, 0, 0.075, 0, materials.path, null, false);
addBox(scene, 0.7, 0.035, 7.2, 0, 0.075, 0, materials.path, null, false);
}
function createGreenhouse() {
const width = 9.6;
const depth = 7.2;
const eave = 4.05;
const ridge = 5.85;
const xPosts = [-4.8, -3.2, -1.6, 0, 1.6, 3.2, 4.8];
const zPosts = [-3.6, -1.8, 0, 1.8, 3.6];
// Foundation and low perimeter curb.
addBox(scene, 10.15, 0.24, 7.75, 0, 0.04, 0, materials.foundation);
addBox(scene, width + 0.12, 0.18, depth + 0.12, 0, 0.16, 0, materials.frameLight);
// Side and end glass.
const sideGlass = addBox(
scene,
0.045,
3.8,
depth,
-4.8,
2.1,
0,
materials.glass,
null,
false
);
sideGlass.castShadow = false;
const sideGlass2 = sideGlass.clone();
sideGlass2.position.x = 4.8;
scene.add(sideGlass2);
addBox(
scene,
width,
3.8,
0.045,
0,
2.1,
-3.6,
materials.glass,
null,
false
);
addBox(
scene,
width,
3.8,
0.045,
0,
2.1,
3.6,
materials.glass,
null,
false
);
// Front and back vertical posts.
for (const z of [-3.6, 3.6]) {
for (const x of xPosts) {
addBox(scene, 0.12, 4.05, 0.12, x, 2.12, z, materials.frame);
}
}
// Side vertical posts.
for (const x of [-4.8, 4.8]) {
for (const z of zPosts) {
addBox(scene, 0.12, 4.05, 0.12, x, 2.12, z, materials.frame);
}
}
// Horizontal rails.
for (const y of [0.55, 2.05, 4.05]) {
addBox(scene, 9.72, 0.1, 0.1, 0, y, -3.6, materials.frameLight);
addBox(scene, 9.72, 0.1, 0.1, 0, y, 3.6, materials.frameLight);
addBox(scene, 0.1, 0.1, 7.3, -4.8, y, 0, materials.frameLight);
addBox(scene, 0.1, 0.1, 7.3, 4.8, y, 0, materials.frameLight);
}
// Roof panes.
const roofAngle = Math.atan2(ridge - eave, 4.8);
const roofSections = [-2.7, -0.9, 0.9, 2.7];
for (const z of roofSections) {
const leftRoof = addBox(
scene,
5.06,
0.045,
1.76,
-2.41,
(ridge + eave) / 2,
z,
materials.glass,
null,
false
);
leftRoof.rotation.z = roofAngle;
const rightRoof = addBox(
scene,
5.06,
0.045,
1.76,
2.41,
(ridge + eave) / 2,
z,
materials.glass,
null,
false
);
rightRoof.rotation.z = -roofAngle;
}
// Long roof rails and ridge.
addBox(scene, 0.12, 0.12, 7.4, 0, ridge, 0, materials.frame);
addBox(scene, 0.12, 0.12, 7.4, -4.8, eave, 0, materials.frame);
addBox(scene, 0.12, 0.12, 7.4, 4.8, eave, 0, materials.frame);
// Gable rafters.
for (const z of [-3.6, 3.6]) {
addBeam(
scene,
new THREE.Vector3(-4.8, eave, z),
new THREE.Vector3(0, ridge, z),
0.12,
materials.frame
);
addBeam(
scene,
new THREE.Vector3(0, ridge, z),
new THREE.Vector3(4.8, eave, z),
0.12,
materials.frame
);
}
// Small voxel vents along the rear wall.
for (const x of [-3.2, 3.2]) {
addBox(scene, 1.1, 0.62, 0.08, x, 3.0, -3.64, materials.frameLight);
addBox(scene, 0.92, 0.43, 0.1, x, 3.0, -3.69, materials.glass, null, false);
}
}
function createOutsideDetails() {
const shrubMat = new THREE.MeshStandardMaterial({
color: 0x668f68,
roughness: 0.95
});
const trunkMat = new THREE.MeshStandardMaterial({
color: 0x76533d,
roughness: 1
});
const shrubs = [
[-6.1, 0.8, -3.3, 1.2],
[6.0, 0.6, -3.7, 0.9],
[-5.9, 0.65, 3.5, 0.8],
[5.8, 1.0, 3.5, 1.25]
];
for (const [x, y, z, s] of shrubs) {
addBox(scene, 0.22 * s, 0.8 * s, 0.22 * s, x, y * 0.45, z, trunkMat);
addBox(scene, 0.9 * s, 0.7 * s, 0.9 * s, x, y + 0.2, z, shrubMat);
addBox(scene, 0.65 * s, 0.55 * s, 0.65 * s, x - 0.25 * s, y + 0.45, z, shrubMat);
}
const cloudMat = new THREE.MeshBasicMaterial({ color: 0xf5f3e7 });
const cloudPositions = [
[-7, 8.4, -7, 1.2],
[7.5, 9.1, -5, 1.5],
[1.5, 8.8, -9, 0.9]
];
for (const [x, y, z, scale] of cloudPositions) {
addBox(scene, 1.6 * scale, 0.55 * scale, 0.65 * scale, x, y, z, cloudMat, null, false);
addBox(scene, 0.8 * scale, 0.75 * scale, 0.65 * scale, x - 0.35 * scale, y + 0.2, z, cloudMat, null, false);
addBox(scene, 0.9 * scale, 0.6 * scale, 0.65 * scale, x + 0.45 * scale, y + 0.1, z, cloudMat, null, false);
}
}
function makeLeafMaterial(color) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.77,
metalness: 0.02
});
}
function createPlantSign(parent, plant) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 88;
const context = canvas.getContext("2d");
context.fillStyle = "#f8f4df";
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "#17382f";
context.fillRect(0, 0, 13, canvas.height);
context.fillStyle = "#2f765b";
context.font = "bold 25px system-ui, sans-serif";
context.fillText(plant.id, 28, 37);
context.fillStyle = "#48685d";
context.font = "bold 17px system-ui, sans-serif";
context.fillText(plant.name.toUpperCase(), 28, 66);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
});
const sign = new THREE.Sprite(material);
sign.position.set(0, 0.68, 0.76);
sign.scale.set(0.78, 0.27, 1);
sign.userData.plantId = plant.id;
parent.add(sign);
clickableMeshes.push(sign);
annotationObjects.push(sign);
}
function createPlant(plant, position) {
const group = new THREE.Group();
group.position.copy(position);
group.userData.plantId = plant.id;
scene.add(group);
plantGroups.set(plant.id, group);
addBox(group, 1.42, 0.28, 1.42, 0, 0.2, 0, materials.planter, plant.id);
addBox(group, 1.52, 0.09, 1.52, 0, 0.36, 0, materials.planterEdge, plant.id);
addBox(group, 1.21, 0.055, 1.21, 0, 0.415, 0, materials.soil, plant.id);
const visual = new THREE.Group();
visual.position.y = 0.43;
visual.userData.phase = plants.indexOf(plant) * 0.93;
group.add(visual);
plantVisuals.set(plant.id, visual);
const height = plant.heightValue;
const stemCount = Math.max(4, Math.round(height / 0.27));
const segmentHeight = height / stemCount;
for (let i = 0; i < stemCount; i++) {
addBox(
visual,
0.13,
segmentHeight + 0.025,
0.13,
0,
segmentHeight * (i + 0.5),
0,
materials.stem,
plant.id
);
}
const baseColor = new THREE.Color(plant.color);
const accentColor = new THREE.Color(plant.accent);
function leafColor(level, index) {
if (plant.pattern === "Mosaic") {
return (level + index) % 3 === 0 ? accentColor : baseColor;
}
if (plant.pattern === "Gradient") {
const t = Math.min(1, Math.max(0, level / 6));
return baseColor.clone().lerp(accentColor, t);
}
return baseColor;
}
if (plant.form === "fan") {
for (let level = 0; level < 5; level++) {
const y = 0.18 + level * (height - 0.35) / 5;
const span = 0.39 + level * 0.075;
const mat = makeLeafMaterial(leafColor(level, 0));
addBox(
visual,
0.58,
0.13,
0.2,
-span / 2,
y,
0,
mat,
plant.id
);
addBox(
visual,
0.58,
0.13,
0.2,
span / 2,
y,
0,
makeLeafMaterial(leafColor(level, 1)),
plant.id
);
addBox(
visual,
0.24,
0.15,
0.23,
0,
y + 0.08,
0,
mat,
plant.id
);
}
}
if (plant.form === "frond") {
for (let level = 0; level < 7; level++) {
const y = 0.22 + level * (height - 0.4) / 7;
const side = level % 2 === 0 ? -1 : 1;
const mat = makeLeafMaterial(leafColor(level, side));
addBox(
visual,
0.42,
0.09,
0.09,
side * 0.24,
y,
0,
mat,
plant.id
);
addBox(
visual,
0.18,
0.16,
0.18,
side * 0.47,
y + 0.035,
0,
mat,
plant.id
);
addBox(
visual,
0.15,
0.13,
0.15,
side * 0.28,
y + 0.11,
0.12,
mat,
plant.id
);
}
addBox(
visual,
0.22,
0.25,
0.2,
0,
height - 0.02,
0,
makeLeafMaterial(plant.accent),
plant.id
);
}
if (plant.form === "paddle") {
for (let level = 0; level < 4; level++) {
const y = 0.5 + level * 0.32;
const side = level % 2 === 0 ? -1 : 1;
const mat = makeLeafMaterial(leafColor(level, side));
addBox(
visual,
0.27,
0.56,
0.2,
side * 0.28,
y,
0,
mat,
plant.id
);
addBox(
visual,
0.18,
0.43,
0.18,
side * 0.1,
y + 0.12,
0,
mat,
plant.id
);
}
addBox(
visual,
0.34,
0.35,
0.25,
0,
height - 0.05,
0,
makeLeafMaterial(plant.accent),
plant.id
);
}
if (plant.form === "clover") {
const crownY = height - 0.03;
for (let i = 0; i < 4; i++) {
const angle = (i / 4) * Math.PI * 2 + Math.PI / 4;
const x = Math.cos(angle) * 0.25;
const z = Math.sin(angle) * 0.25;
const mat = makeLeafMaterial(leafColor(i, i));
const leaf = addBox(
visual,
0.39,
0.13,
0.23,
x,
crownY,
z,
mat,
plant.id
);
leaf.rotation.y = -angle;
const tip = addBox(
visual,
0.19,
0.14,
0.2,
x * 1.42,
crownY + 0.01,
z * 1.42,
makeLeafMaterial(plant.accent),
plant.id
);
tip.rotation.y = -angle;
}
addBox(
visual,
0.2,
0.18,
0.2,
0,
crownY + 0.04,
0,
makeLeafMaterial(plant.accent),
plant.id
);
}
if (plant.form === "rosette") {
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const mat = makeLeafMaterial(leafColor(i, i));
const leaf = addBox(
visual,
0.63,
0.16,
0.25,
Math.cos(angle) * 0.32,
0.2 + (i % 2) * 0.08,
Math.sin(angle) * 0.32,
mat,
plant.id
);
leaf.rotation.y = -angle;
const tip = addBox(
visual,
0.25,
0.14,
0.23,
Math.cos(angle) * 0.6,
0.23 + (i % 2) * 0.08,
Math.sin(angle) * 0.6,
makeLeafMaterial(plant.accent),
plant.id
);
tip.rotation.y = -angle;
}
addBox(
visual,
0.3,
height - 0.25,
0.3,
0,
(height - 0.25) / 2,
0,
materials.stem,
plant.id
);
}
// Flower forms.
if (plant.bloom !== "None") {
const flowerY = height + 0.12;
const flowerColor = new THREE.Color(plant.accent);
if (plant.bloom === "Bell") {
addBox(
visual,
0.32,
0.32,
0.32,
0,
flowerY,
0,
makeLeafMaterial(flowerColor),
plant.id
);
addBox(
visual,
0.48,
0.16,
0.44,
0,
flowerY + 0.12,
0,
makeLeafMaterial(flowerColor),
plant.id
);
addBox(
visual,
0.24,
0.28,
0.24,
0,
flowerY - 0.24,
0,
makeLeafMaterial(flowerColor),
plant.id
);
}
if (plant.bloom === "Disk") {
addBox(
visual,
0.34,
0.18,
0.34,
0,
flowerY,
0,
makeLeafMaterial(flowerColor),
plant.id
);
for (let i = 0; i < 4; i++) {
const angle = (i / 4) * Math.PI * 2;
addBox(
visual,
0.3,
0.12,
0.22,
Math.cos(angle) * 0.3,
flowerY,
Math.sin(angle) * 0.3,
makeLeafMaterial(plant.color),
plant.id
);
}
}
}
createPlantSign(group, plant);
}
function createSelectionMarker() {
const group = new THREE.Group();
const markerMaterial = new THREE.MeshBasicMaterial({
color: 0xec9b55,
transparent: true,
opacity: 0.95
});
const half = 0.89;
const thickness = 0.055;
const y = 0.08;
addBox(group, 1.78, thickness, thickness, 0, y, -half, markerMaterial);
addBox(group, 1.78, thickness, thickness, 0, y, half, markerMaterial);
addBox(group, thickness, thickness, 1.78, -half, y, 0, markerMaterial);
addBox(group, thickness, thickness, 1.78, half, y, 0, markerMaterial);
scene.add(group);
return group;
}
function createPollen() {
const count = 42;
const positions = new Float32Array(count * 3);
for (let i = 0; i < count; i++) {
positions[i * 3] = (Math.random() - 0.5) * 9;
positions[i * 3 + 1] = 0.8 + Math.random() * 4;
positions[i * 3 + 2] = (Math.random() - 0.5) * 6;
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
const material = new THREE.PointsMaterial({
color: 0xfff5bd,
size: 0.075,
sizeAttenuation: true,
transparent: true,
opacity: 0.65
});
const points = new THREE.Points(geometry, material);
scene.add(points);
return points;
}
createVoxelFloor();
createGreenhouse();
createOutsideDetails();
const plantPositions = [
[-2.85, 0.08, -1.85],
[0, 0.08, -1.85],
[2.85, 0.08, -1.85],
[-2.85, 0.08, 1.85],
[0, 0.08, 1.85],
[2.85, 0.08, 1.85]
];
plants.forEach((plant, index) => {
createPlant(plant, new THREE.Vector3(...plantPositions[index]));
});
const selectionMarker = createSelectionMarker();
const pollen = createPollen();
// -------------------------------------------------------------------------
// Interface rendering
// -------------------------------------------------------------------------
function showToast(message) {
toast.textContent = message;
toast.classList.add("show");
clearTimeout(showToast.timer);
showToast.timer = setTimeout(() => toast.classList.remove("show"), 2200);
}
function renderCatalog() {
const filtered = plants.filter((plant) => {
const matchesFilter =
activeFilter === "All" ||
(activeFilter === "Bloom"
? plant.bloom !== "None"
: plant.leaf === activeFilter);
const query = searchTerm.trim().toLowerCase();
const matchesSearch =
!query ||
plant.name.toLowerCase().includes(query) ||
plant.id.toLowerCase().includes(query) ||
plant.pigment.toLowerCase().includes(query);
return matchesFilter && matchesSearch;
});
if (!filtered.length) {
catalogList.innerHTML = `
<div class="empty-state">
No specimens match this filter.<br />
Try another leaf form or pigment name.
</div>
`;
return;
}
catalogList.innerHTML = filtered
.map(
(plant) => `
<button
class="specimen-card ${selectedId === plant.id ? "selected" : ""}"
type="button"
data-id="${plant.id}"
>
<span class="plant-swatch" style="--swatch:${plant.color}"></span>
<span class="specimen-copy">
<span class="specimen-id">${plant.id}</span>
<span class="specimen-name">${plant.name}</span>
<span class="specimen-sub">${plant.pigment} · ${plant.leaf} · ${plant.bloom}</span>
</span>
<span class="specimen-arrow" aria-hidden="true">›</span>
</button>
`
)
.join("");
catalogList.querySelectorAll(".specimen-card").forEach((button) => {
button.addEventListener("click", () => {
selectPlant(button.dataset.id, true);
});
});
}
function traitCell(label, value) {
return `
<div class="trait-cell">
<span class="trait-name">${label}</span>
<span class="trait-value">${value}</span>
</div>
`;
}
function renderInspector() {
if (!selectedId) {
inspector.classList.remove("is-visible");
inspector.setAttribute("aria-hidden", "true");
return;
}
const plant = plantById.get(selectedId);
const revealed = revealedGenomes.has(plant.id);
const compared = compareIds.includes(plant.id);
inspector.innerHTML = `
<div class="inspector-head">
<span class="specimen-code">${plant.id}</span>
<button class="icon-button" type="button" id="close-inspector" aria-label="Close inspector">×</button>
</div>
<h2>${plant.name}</h2>
<p class="plant-description">${plant.description}</p>
<div class="badge-row">
<span class="badge">${plant.leaf} leaf</span>
<span class="badge">${plant.pigment}</span>
<span class="badge">${plant.bloom === "None" ? "Non-blooming" : `${plant.bloom} bloom`}</span>
</div>
<p class="section-label">Observable phenotype</p>
<div class="phenotype-grid">
${traitCell("Leaf form", plant.leaf)}
${traitCell("Pigment", plant.pigment)}
${traitCell("Pattern", plant.pattern)}
${traitCell("Water", plant.water)}
${traitCell("Height", plant.height)}
${traitCell("Bloom", plant.bloom)}
</div>
<div class="genome-card">
<div class="genome-card-head">
<strong>Hidden story-genotype</strong>
<span class="locked-label">${revealed ? "Decoded" : "Encrypted"}</span>
</div>
<div class="genome-card-body">
<div class="masked-grid">
${plant.genome
.map(
([locus, code, note]) => `
<div class="marker">
<span class="marker-locus">${locus}</span>
<span class="marker-code ${revealed ? "" : "masked"}">
${revealed ? code : "████"}
</span>
<span class="marker-note">${revealed ? note : "Hidden marker"}</span>
</div>
`
)
.join("")}
</div>
<p class="genome-note">
${
revealed
? "Story-loci decoded. These invented markers explain the visible teaching traits."
: "Reveal the fictional markers to connect this plant's visible traits to its hidden story-genotype."
}
</p>
<button
class="reveal-button ${revealed ? "revealed" : ""}"
id="reveal-genome"
type="button"
>
${revealed ? "✓ Genotype revealed" : "Reveal hidden genotype"}
</button>
</div>
</div>
<div class="inspector-actions">
<button class="secondary-action" id="focus-plant" type="button">Focus plant</button>
<button
class="secondary-action ${compared ? "active" : ""}"
id="toggle-compare"
type="button"
>
${compared ? "✓ In comparison" : "+ Compare"}
</button>
</div>
`;
inspector.classList.add("is-visible");
inspector.setAttribute("aria-hidden", "false");
document.querySelector("#close-inspector").addEventListener("click", () => {
selectPlant(null, false);
});
document.querySelector("#reveal-genome").addEventListener("click", () => {
revealedGenomes.add(plant.id);
renderInspector();
showToast(`${plant.name}'s fictional genotype decoded.`);
});
document.querySelector("#focus-plant").addEventListener("click", () => {
focusPlant(plant.id);
});
document.querySelector("#toggle-compare").addEventListener("click", () => {
toggleCompare(plant.id);
});
}
function selectPlant(id, focus = false) {
selectedId = id;
renderCatalog();
renderInspector();
if (id) {
const group = plantGroups.get(id);
selectionMarker.position.set(group.position.x, 0.11, group.position.z);
selectionMarker.visible = true;
if (focus) {
focusPlant(id);
}
} else {
selectionMarker.visible = false;
}
}
function focusPlant(id) {
const group = plantGroups.get(id);
if (!group) return;
orbit.desiredTarget.set(group.position.x, group.position.y + 1.0, group.position.z);
orbit.desiredRadius = 8.2;
}
function toggleCompare(id) {
if (compareIds.includes(id)) {
compareIds = compareIds.filter((item) => item !== id);
showToast(`${plantById.get(id).name} removed from comparison.`);
} else {
if (compareIds.length >= 3) {
showToast("Comparison space is full. Remove a specimen first.");
return;
}
compareIds.push(id);
showToast(`${plantById.get(id).name} added to comparison.`);
}
compareCount.textContent = compareIds.length;
renderInspector();
}
function renderComparison() {
if (!compareIds.length) {
compareBody.innerHTML = `
<div class="compare-empty">
No specimens selected yet.<br />
Open a plant and choose <strong>+ Compare</strong> to build a table.
</div>
`;
return;
}
const selectedPlants = compareIds.map((id) => plantById.get(id));
const rows = [
["Leaf form", "leaf"],
["Pigment", "pigment"],
["Pattern", "pattern"],
["Water", "water"],
["Height", "height"],
["Bloom", "bloom"]
];
compareBody.innerHTML = `
<div class="compare-wrap">
<table class="compare-table">
<thead>
<tr>
<th>Trait</th>
${selectedPlants
.map(
(plant) => `
<th>
<span class="table-swatch" style="background:${plant.color}"></span>
${plant.name}
</th>
`
)
.join("")}
</tr>
</thead>
<tbody>
${rows
.map(
([label, key]) => `
<tr>
<td>${label}</td>
${selectedPlants.map((plant) => `<td>${plant[key]}</td>`).join("")}
</tr>
`
)
.join("")}
</tbody>
</table>
</div>
`;
}
// -------------------------------------------------------------------------
// Camera and pointer interaction
// -------------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const canvas = renderer.domElement;
let dragging = false;
let dragPointerId = null;
let dragStartX = 0;
let dragStartY = 0;
let previousX = 0;
let previousY = 0;
let dragDistance = 0;
function setRayFromEvent(event) {
const rect = canvas.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);
}
function pickPlant(event) {
setRayFromEvent(event);
const intersections = raycaster.intersectObjects(clickableMeshes, false);
for (const intersection of intersections) {
const id = intersection.object.userData.plantId;
if (id) return id;
}
return null;
}
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
dragPointerId = event.pointerId;
dragStartX = event.clientX;
dragStartY = event.clientY;
previousX = event.clientX;
previousY = event.clientY;
dragDistance = 0;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
hoverTip.style.display = "none";
});
canvas.addEventListener("pointermove", (event) => {
if (dragging && event.pointerId === dragPointerId) {
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
dragDistance += Math.abs(deltaX) + Math.abs(deltaY);
orbit.desiredTheta -= deltaX * 0.0065;
orbit.desiredPhi = THREE.MathUtils.clamp(
orbit.desiredPhi - deltaY * 0.005,
0.47,
1.38
);
return;
}
const id = pickPlant(event);
canvas.style.cursor = id ? "pointer" : "grab";
if (id) {
const rect = stage.getBoundingClientRect();
hoverTip.textContent = plantById.get(id).name;
hoverTip.style.left = `${event.clientX - rect.left}px`;
hoverTip.style.top = `${event.clientY - rect.top}px`;
hoverTip.style.display = "block";
} else {
hoverTip.style.display = "none";
}
});
function endDrag(event) {
if (!dragging || event.pointerId !== dragPointerId) return;
const isClick =
Math.abs(event.clientX - dragStartX) +
Math.abs(event.clientY - dragStartY) <
7 &&
dragDistance < 12;
dragging = false;
dragPointerId = null;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (isClick) {
const id = pickPlant(event);
if (id) {
selectPlant(id, false);
}
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("pointerleave", () => {
if (!dragging) hoverTip.style.display = "none";
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.desiredRadius = THREE.MathUtils.clamp(
orbit.desiredRadius + event.deltaY * 0.008,
5.2,
21
);
},
{ passive: false }
);
function resetCamera() {
orbit.desiredTarget.set(0, 1.65, 0);
orbit.desiredTheta = 0.72;
orbit.desiredPhi = 1.02;
orbit.desiredRadius = 14.4;
}
document.querySelector("#zoom-in").addEventListener("click", () => {
orbit.desiredRadius = Math.max(5.2, orbit.desiredRadius - 1.1);
});
document.querySelector("#zoom-out").addEventListener("click", () => {
orbit.desiredRadius = Math.min(21, orbit.desiredRadius + 1.1);
});
document.querySelector("#reset-camera").addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Interface controls
// -------------------------------------------------------------------------
document.querySelector("#filter-row").addEventListener("click", (event) => {
const button = event.target.closest("[data-filter]");
if (!button) return;
activeFilter = button.dataset.filter;
document.querySelectorAll(".filter-chip").forEach((chip) => {
chip.classList.toggle("active", chip === button);
});
renderCatalog();
});
searchInput.addEventListener("input", () => {
searchTerm = searchInput.value;
renderCatalog();
});
annotationsButton.addEventListener("click", () => {
annotationsVisible = !annotationsVisible;
annotationObjects.forEach((object) => {
object.visible = annotationsVisible;
});
annotationsButton.textContent = annotationsVisible ? "Labels on" : "Labels off";
annotationsButton.setAttribute("aria-pressed", String(annotationsVisible));
});
document.querySelector("#guide-button").addEventListener("click", () => {
guideDialog.showModal();
});
document.querySelector("#compare-button").addEventListener("click", () => {
renderComparison();
compareDialog.showModal();
});
document.addEventListener("keydown", (event) => {
if (event.key === "Escape" && selectedId && !guideDialog.open && !compareDialog.open) {
selectPlant(null, false);
}
if (event.key === "?" && !guideDialog.open && !compareDialog.open) {
guideDialog.showModal();
}
});
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function resizeRenderer() {
const width = stage.clientWidth;
const height = stage.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resizeRenderer);
resizeObserver.observe(stage);
resizeRenderer();
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
orbit.theta += (orbit.desiredTheta - orbit.theta) * 0.085;
orbit.phi += (orbit.desiredPhi - orbit.phi) * 0.085;
orbit.radius += (orbit.desiredRadius - orbit.radius) * 0.085;
orbit.target.lerp(orbit.desiredTarget, 0.085);
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
if (!reducedMotion) {
plantVisuals.forEach((visual) => {
const phase = visual.userData.phase;
visual.rotation.z = Math.sin(time * 0.72 + phase) * 0.017;
visual.rotation.x = Math.cos(time * 0.61 + phase) * 0.009;
});
const pollenPositions = pollen.geometry.attributes.position.array;
for (let i = 0; i < pollenPositions.length; i += 3) {
pollenPositions[i + 1] += 0.0015;
pollenPositions[i] += Math.sin(time * 0.4 + i) * 0.0007;
if (pollenPositions[i + 1] > 5) {
pollenPositions[i + 1] = 0.8;
}
}
pollen.geometry.attributes.position.needsUpdate = true;
}
if (selectionMarker.visible) {
const pulse = reducedMotion ? 1 : 1 + Math.sin(time * 3) * 0.025;
selectionMarker.scale.set(pulse, 1, pulse);
}
renderer.render(scene, camera);
}
renderCatalog();
renderComparison();
selectPlant("VX-101", false);
animate();
</script>
</body>
</html>
```