Prompt specification
Build or customize the Three.js 3D scene "Seed envelope identity system" 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 envelope identity system
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/seed-envelope-identity-system-x1101
Scene Description Prompt:
Seed envelope identity system. Display seeds, labeled envelopes, and a small parent-plant marker sharing one identifier; show separate date and variety fields without implying that appearance alone establishes identity. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (seed-envelope-identity-system-x1101):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Seed Envelope Identity System</title>
<style>
:root {
--page: #d9d4c8;
--paper: #f5f1e7;
--paper-2: #ebe5d7;
--ink: #193a34;
--muted: #68756f;
--line: #cfc8b8;
--green: #346f5d;
--teal: #176b64;
--teal-soft: #dce9e3;
--coral: #bd684d;
--gold: #c99a3b;
--shadow: 0 16px 40px rgba(37, 50, 43, 0.13);
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--page);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button,
input,
select {
font: inherit;
}
.app {
display: grid;
grid-template-rows: 78px minmax(0, 1fr);
height: 100vh;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
background: rgba(247, 243, 233, 0.96);
border-bottom: 1px solid rgba(69, 81, 72, 0.14);
z-index: 5;
}
.brand {
display: flex;
align-items: center;
min-width: 0;
gap: 13px;
}
.brand-mark {
position: relative;
width: 42px;
height: 42px;
flex: 0 0 auto;
}
.brand-mark span {
position: absolute;
display: block;
width: 17px;
height: 17px;
border-radius: 2px;
box-shadow: 0 4px 9px rgba(25, 58, 52, 0.18);
}
.brand-mark span:nth-child(1) {
left: 1px;
top: 3px;
background: var(--green);
}
.brand-mark span:nth-child(2) {
left: 20px;
top: 3px;
background: var(--teal);
}
.brand-mark span:nth-child(3) {
left: 11px;
top: 22px;
background: var(--coral);
}
.brand-copy {
min-width: 0;
}
.eyebrow {
margin: 0 0 4px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: clamp(18px, 2vw, 25px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.header-record {
display: flex;
align-items: center;
gap: 12px;
flex: 0 0 auto;
padding: 10px 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.38);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(23, 107, 100, 0.12);
}
.header-record small {
display: block;
margin-bottom: 2px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
}
.header-record strong {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 14px;
letter-spacing: 0.04em;
}
.workspace {
display: grid;
grid-template-columns: 322px minmax(0, 1fr);
gap: 12px;
min-height: 0;
padding: 12px;
}
.record {
min-height: 0;
overflow: auto;
padding: 20px;
border: 1px solid rgba(70, 83, 73, 0.13);
border-radius: 20px;
background:
linear-gradient(rgba(247, 243, 233, 0.96), rgba(247, 243, 233, 0.96)),
repeating-linear-gradient(
90deg,
transparent 0 24px,
rgba(25, 58, 52, 0.04) 24px 25px
);
box-shadow: var(--shadow);
scrollbar-width: thin;
scrollbar-color: #bdb7a9 transparent;
}
.record-heading {
padding-bottom: 18px;
border-bottom: 1px solid var(--line);
}
.id-value {
margin: 6px 0 9px;
color: var(--teal);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: clamp(24px, 2.1vw, 31px);
font-weight: 850;
letter-spacing: -0.045em;
overflow-wrap: anywhere;
}
.record-heading p:last-child {
margin: 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.fields {
display: grid;
gap: 9px;
padding: 17px 0;
}
.field {
display: grid;
grid-template-columns: 38px minmax(0, 1fr);
align-items: center;
gap: 11px;
padding: 12px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.48);
}
.field-symbol {
display: grid;
place-items: center;
width: 38px;
height: 38px;
border-radius: 9px;
background: var(--teal-soft);
color: var(--teal);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 13px;
font-weight: 900;
}
.field:nth-child(2) .field-symbol {
background: #eee2ca;
color: #95671d;
}
.field label {
display: block;
margin-bottom: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.field strong {
display: block;
font-size: 14px;
line-height: 1.25;
}
.notice {
display: grid;
grid-template-columns: 27px 1fr;
gap: 10px;
padding: 13px;
border: 1px solid #d9b49f;
border-radius: 12px;
background: #f4e7dc;
}
.notice-icon {
display: grid;
place-items: center;
width: 27px;
height: 27px;
border-radius: 6px;
background: var(--coral);
color: white;
font-size: 14px;
font-weight: 900;
}
.notice strong {
display: block;
margin-bottom: 4px;
font-size: 12px;
}
.notice p {
margin: 0;
color: #6f5144;
font-size: 11px;
line-height: 1.5;
}
.artifact-list {
padding: 18px 0 15px;
}
.artifact-item {
display: grid;
grid-template-columns: 30px minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
padding: 9px 0;
}
.artifact-number {
color: #9b9a8d;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
}
.artifact-item strong {
display: block;
font-size: 12px;
}
.artifact-item small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
.linked-check {
display: grid;
place-items: center;
width: 21px;
height: 21px;
border-radius: 50%;
background: var(--teal-soft);
color: var(--teal);
font-size: 11px;
font-weight: 900;
}
.record-logic {
padding-top: 14px;
border-top: 1px solid var(--line);
}
.logic-line {
display: flex;
align-items: center;
gap: 8px;
margin-top: 9px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
}
.logic-line b {
color: var(--ink);
}
.viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
border: 1px solid rgba(70, 83, 73, 0.13);
border-radius: 20px;
background: #ded9cd;
box-shadow: var(--shadow);
isolation: isolate;
}
.canvas-host {
position: absolute;
inset: 0;
}
.canvas-host canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.scene-title {
position: absolute;
z-index: 2;
top: 19px;
left: 21px;
max-width: 330px;
pointer-events: none;
}
.scene-title .eyebrow {
margin-bottom: 5px;
color: #58675f;
}
.scene-title h2 {
margin: 0;
font-size: clamp(18px, 2.2vw, 29px);
line-height: 1.08;
letter-spacing: -0.035em;
}
.scene-title p {
margin: 7px 0 0;
color: #617068;
font-size: 12px;
}
.field-chips {
position: absolute;
z-index: 2;
top: 19px;
right: 20px;
display: flex;
gap: 8px;
pointer-events: none;
}
.field-chip {
min-width: 118px;
padding: 9px 11px;
border: 1px solid rgba(57, 80, 69, 0.18);
border-radius: 10px;
background: rgba(247, 243, 233, 0.9);
box-shadow: 0 7px 20px rgba(41, 54, 47, 0.08);
backdrop-filter: blur(7px);
}
.field-chip span {
display: block;
margin-bottom: 3px;
color: var(--muted);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.14em;
}
.field-chip strong {
font-size: 11px;
}
.legend {
position: absolute;
z-index: 2;
left: 19px;
bottom: 17px;
display: flex;
flex-wrap: wrap;
gap: 7px;
max-width: 470px;
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border: 1px solid rgba(57, 80, 69, 0.16);
border-radius: 7px;
background: rgba(247, 243, 233, 0.86);
color: #4f5f57;
font-size: 9px;
font-weight: 700;
backdrop-filter: blur(6px);
}
.swatch {
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--teal);
}
.swatch.paper {
background: #e4d7b5;
border: 1px solid #b9a981;
}
.swatch.dashed {
width: 14px;
height: 3px;
border-radius: 0;
background: repeating-linear-gradient(
90deg,
var(--teal) 0 4px,
transparent 4px 7px
);
}
.swatch.warning {
background: var(--coral);
}
.reset-button {
position: absolute;
z-index: 4;
right: 18px;
bottom: 17px;
display: flex;
align-items: center;
gap: 7px;
padding: 9px 11px;
border: 1px solid rgba(57, 80, 69, 0.19);
border-radius: 9px;
background: rgba(247, 243, 233, 0.92);
color: var(--ink);
cursor: pointer;
font-size: 10px;
font-weight: 800;
box-shadow: 0 6px 18px rgba(41, 54, 47, 0.08);
transition: transform 140ms ease, background 140ms ease;
}
.reset-button:hover {
transform: translateY(-1px);
background: #fffaf0;
}
.reset-button:active {
transform: translateY(0);
}
.reset-icon {
color: var(--teal);
font-size: 17px;
line-height: 0.8;
}
.interaction-hint {
position: absolute;
z-index: 2;
right: 125px;
bottom: 24px;
color: rgba(47, 68, 59, 0.67);
font-size: 9px;
font-weight: 750;
pointer-events: none;
}
.tooltip {
position: absolute;
z-index: 8;
width: 218px;
padding: 12px 13px;
border: 1px solid rgba(46, 69, 59, 0.18);
border-radius: 10px;
background: rgba(250, 247, 238, 0.96);
box-shadow: 0 12px 30px rgba(30, 48, 40, 0.17);
pointer-events: none;
opacity: 0;
transform: translateY(5px);
transition: opacity 120ms ease, transform 120ms ease;
}
.tooltip.visible {
opacity: 1;
transform: translateY(0);
}
.tooltip strong {
display: block;
margin-bottom: 4px;
font-size: 12px;
}
.tooltip span {
display: block;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.tooltip code {
display: block;
margin-top: 7px;
color: var(--teal);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
font-weight: 800;
}
@media (max-width: 900px) {
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100vh;
grid-template-rows: 74px auto;
}
.header-record {
display: none;
}
.workspace {
grid-template-columns: 1fr;
grid-template-rows: auto 650px;
}
.record {
overflow: visible;
}
}
@media (max-width: 560px) {
.topbar {
padding: 0 15px;
}
.workspace {
padding: 7px;
gap: 7px;
}
.record {
padding: 17px;
}
.viewport {
min-height: 600px;
}
.field-chips {
top: auto;
right: auto;
left: 15px;
bottom: 75px;
flex-direction: column;
}
.field-chip {
min-width: 125px;
}
.interaction-hint {
display: none;
}
.legend {
right: 12px;
bottom: 15px;
max-width: 250px;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<span></span>
<span></span>
<span></span>
</div>
<div class="brand-copy">
<p class="eyebrow">Seed Archive</p>
<h1>Envelope identity system</h1>
</div>
</div>
<div class="header-record">
<span class="status-dot" aria-hidden="true"></span>
<div>
<small>ACTIVE CATALOG RECORD</small>
<strong>VGL-0427-AR</strong>
</div>
</div>
</header>
<main class="workspace">
<aside class="record" aria-label="Catalog record details">
<section class="record-heading">
<p class="eyebrow">Shared identifier</p>
<div class="id-value">VGL-0427-AR</div>
<p>
One assigned catalog record links the seed lot, labeled envelopes,
and parent-plant marker.
</p>
</section>
<section class="fields" aria-label="Separate record fields">
<div class="field">
<div class="field-symbol" aria-hidden="true">D</div>
<div>
<label>Date</label>
<strong>2025-04-18</strong>
</div>
</div>
<div class="field">
<div class="field-symbol" aria-hidden="true">V</div>
<div>
<label>Variety</label>
<strong>Painted Hill bean</strong>
</div>
</div>
</section>
<section class="notice">
<div class="notice-icon" aria-hidden="true">!</div>
<div>
<strong>Appearance is not identity.</strong>
<p>
The ID is assigned to the catalog record. Date and variety are
independent metadata fields. Matching color, shape, or size alone
does not verify a field or establish a record link.
</p>
</div>
</section>
<section class="artifact-list" aria-label="Linked artifacts">
<p class="eyebrow">Record-linked artifacts</p>
<div class="artifact-item">
<span class="artifact-number">01</span>
<div>
<strong>Seed lot</strong>
<small>7 specimens in the record</small>
</div>
<span class="linked-check" aria-label="Linked">✓</span>
</div>
<div class="artifact-item">
<span class="artifact-number">02</span>
<div>
<strong>Labeled envelopes</strong>
<small>3 envelopes carrying the ID</small>
</div>
<span class="linked-check" aria-label="Linked">✓</span>
</div>
<div class="artifact-item">
<span class="artifact-number">03</span>
<div>
<strong>Parent-plant marker</strong>
<small>1 retained marker carrying the ID</small>
</div>
<span class="linked-check" aria-label="Linked">✓</span>
</div>
</section>
<section class="record-logic">
<p class="eyebrow">Record logic</p>
<div class="logic-line">
<b>ID</b><span>→</span><span>artifact label</span>
</div>
<div class="logic-line">
<b>Appearance</b><span>→</span><span>illustration only</span>
</div>
</section>
</aside>
<section class="viewport" id="viewport" aria-label="Interactive voxel display">
<div class="canvas-host" id="canvasHost"></div>
<div class="scene-title">
<p class="eyebrow">Linked material record</p>
<h2>One ID, three artifact forms</h2>
<p>Seed specimens, envelope labels, and a retained plant marker.</p>
</div>
<div class="field-chips" aria-label="Separate metadata fields">
<div class="field-chip">
<span>DATE</span>
<strong>2025-04-18</strong>
</div>
<div class="field-chip">
<span>VARIETY</span>
<strong>Painted Hill bean</strong>
</div>
</div>
<div class="legend" aria-label="Scene legend">
<div class="legend-item">
<span class="swatch"></span>
Shared catalog ID
</div>
<div class="legend-item">
<span class="swatch paper"></span>
Physical artifact
</div>
<div class="legend-item">
<span class="swatch dashed"></span>
Record link
</div>
<div class="legend-item">
<span class="swatch warning"></span>
Appearance is illustrative
</div>
</div>
<div class="interaction-hint">Drag to orbit · Scroll to zoom</div>
<button class="reset-button" id="resetButton" type="button">
<span class="reset-icon" aria-hidden="true">↺</span>
Reset view
</button>
<div class="tooltip" id="tooltip" role="status">
<strong id="tooltipTitle"></strong>
<span id="tooltipText"></span>
<code>VGL-0427-AR</code>
</div>
</section>
</main>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const RECORD_ID = "VGL-0427-AR";
const RECORD_DATE = "2025-04-18";
const RECORD_VARIETY = "Painted Hill bean";
const host = document.getElementById("canvasHost");
const viewport = document.getElementById("viewport");
const tooltip = document.getElementById("tooltip");
const tooltipTitle = document.getElementById("tooltipTitle");
const tooltipText = document.getElementById("tooltipText");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xded9cd);
scene.fog = new THREE.Fog(0xded9cd, 19, 34);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Voxel scene showing seeds, labeled envelopes, and a parent plant marker linked by one catalog identifier"
);
host.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-7, 7, 4, -4, 0.1, 100);
const target = new THREE.Vector3(0, 1.15, 0);
const view = {
theta: 0.29,
phi: 0.52,
zoom: 1
};
const viewGoal = {
theta: 0.29,
phi: 0.52,
zoom: 1
};
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.92,
metalness: 0,
flatShading: true
})
);
}
return materialCache.get(color);
}
function block(parent, size, position, color, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material(color)
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function canvasTexture(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function makePanelTexture(lines, background, foreground, accent) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
if (accent) {
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 18, canvas.height);
}
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
if (lines.length === 1) {
let size = 79;
ctx.font = `800 ${size}px monospace`;
while (ctx.measureText(lines[0]).width > 900 && size > 35) {
size -= 2;
ctx.font = `800 ${size}px monospace`;
}
ctx.fillText(lines[0], 521, 132);
} else {
let firstSize = 58;
let secondSize = 43;
ctx.font = `800 ${firstSize}px sans-serif`;
while (ctx.measureText(lines[0]).width > 910 && firstSize > 26) {
firstSize -= 2;
ctx.font = `800 ${firstSize}px sans-serif`;
}
ctx.font = `800 ${secondSize}px monospace`;
while (ctx.measureText(lines[1]).width > 910 && secondSize > 24) {
secondSize -= 1;
ctx.font = `800 ${secondSize}px monospace`;
}
ctx.fillText(lines[0], 521, 78);
ctx.fillText(lines[1], 521, 168);
}
return canvasTexture(canvas);
}
function makeLabel(lines, width, height, options = {}) {
const group = new THREE.Group();
const background = options.background ?? "#176b64";
const foreground = options.foreground ?? "#f7f1df";
const accent = options.accent ?? "#e1b957";
block(
group,
[width, height, 0.075],
[0, 0, 0],
background,
false
);
const texture = makePanelTexture(
lines,
background,
foreground,
accent
);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(width * 0.98, height * 0.94),
new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false
})
);
face.position.z = 0.041;
group.add(face);
return group;
}
function makeStationCard(title, x) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(247, 243, 233, 0.96)";
ctx.fillRect(0, 16, 1024, 224);
ctx.strokeStyle = "rgba(31, 72, 61, 0.22)";
ctx.lineWidth = 5;
ctx.strokeRect(3, 19, 1018, 218);
ctx.fillStyle = "#193a34";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 58px sans-serif";
ctx.fillText(title, 512, 86);
ctx.fillStyle = "#176b64";
ctx.font = "800 43px monospace";
ctx.fillText(RECORD_ID, 512, 171);
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: canvasTexture(canvas),
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
})
);
sprite.position.set(x, 3.25, -0.2);
sprite.scale.set(2.82, 0.705, 1);
sprite.renderOrder = 20;
scene.add(sprite);
return sprite;
}
function makeSeed(parent, x, z, rotation, scale = 1) {
const seed = new THREE.Group();
seed.position.set(x, 0.42, z);
seed.rotation.y = rotation;
seed.scale.setScalar(scale);
block(seed, [0.38, 0.21, 0.27], [0, 0, 0], 0x68432d);
block(seed, [0.23, 0.08, 0.19], [0.035, 0.13, 0], 0x86583a);
block(seed, [0.09, 0.065, 0.08], [-0.08, 0.17, 0.075], 0xd8bf7b);
block(seed, [0.16, 0.055, 0.06], [-0.05, 0.015, 0.145], 0x9b7047);
parent.add(seed);
return seed;
}
function makeEnvelope(parent, x, z, rotation) {
const envelope = new THREE.Group();
envelope.position.set(x, 1.15, z);
envelope.rotation.y = rotation;
block(envelope, [0.98, 0.74, 0.15], [0, 0, 0], 0xe9dfc6);
block(envelope, [0.90, 0.66, 0.035], [0, 0, 0.085], 0xf2ead7);
// Stepped voxel flap.
for (let i = 0; i < 7; i++) {
const offset = i - 3;
block(
envelope,
[0.145, 0.105, 0.045],
[offset * 0.126, 0.275 - Math.abs(offset) * 0.063, 0.12],
0xcbb98e
);
}
// Small stamp block.
block(envelope, [0.15, 0.17, 0.045], [0.31, 0.15, 0.13], 0xd8ad52);
block(envelope, [0.075, 0.075, 0.025], [0.31, 0.15, 0.158], 0xa76f37);
const idLabel = makeLabel(
[RECORD_ID],
0.88,
0.25,
{
background: "#176b64",
foreground: "#fff8e8",
accent: "#e1b957"
}
);
idLabel.position.set(0, -0.205, 0.12);
envelope.add(idLabel);
parent.add(envelope);
return envelope;
}
// Lighting.
scene.add(new THREE.HemisphereLight(0xfff8e8, 0x687467, 2.05));
const sun = new THREE.DirectionalLight(0xfff2d4, 3.3);
sun.position.set(-5, 11, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -11;
sun.shadow.camera.right = 11;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0007;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d8d2, 1.1);
fill.position.set(8, 6, -5);
scene.add(fill);
// Voxel ground.
const floor = new THREE.Group();
scene.add(floor);
const floorColors = [0xd8d2c3, 0xddd7c9, 0xd4cdbd];
for (let x = -7; x <= 7; x++) {
for (let z = -4; z <= 4; z++) {
const color = floorColors[Math.abs(x + z) % floorColors.length];
block(
floor,
[0.92, 0.08, 0.92],
[x * 0.96, -0.075, z * 0.96],
color,
false
);
}
}
// Dotted record-link path, made from visible voxel blocks.
const linkPath = new THREE.Group();
scene.add(linkPath);
for (let i = 0; i < 22; i++) {
block(
linkPath,
[0.13, 0.065, 0.13],
[-3.45 + i * 0.32, -0.01, -0.77],
i % 2 === 0 ? 0x176b64 : 0x4b8b7f,
false
);
}
// Seed station.
const seedStation = new THREE.Group();
seedStation.userData.station = "seeds";
scene.add(seedStation);
block(seedStation, [2.75, 0.23, 1.72], [0, 0.15, 0], 0xb9825f);
block(seedStation, [2.48, 0.12, 1.44], [0, 0.32, 0], 0xe2cf9e);
// Tray border, assembled from blocks.
block(seedStation, [2.75, 0.22, 0.13], [0, 0.42, 0.80], 0xc18a62);
block(seedStation, [2.75, 0.22, 0.13], [0, 0.42, -0.80], 0xc18a62);
block(seedStation, [0.13, 0.22, 1.47], [-1.31, 0.42, 0], 0xc18a62);
block(seedStation, [0.13, 0.22, 1.47], [1.31, 0.42, 0], 0xc18a62);
makeSeed(seedStation, -0.93, 0.14, 0.22, 0.93);
makeSeed(seedStation, -0.52, -0.32, 1.10, 0.90);
makeSeed(seedStation, -0.14, 0.24, 2.15, 0.86);
makeSeed(seedStation, 0.27, -0.25, 0.54, 1.00);
makeSeed(seedStation, 0.77, 0.22, 1.65, 0.91);
makeSeed(seedStation, -0.38, 0.48, 2.55, 0.78);
makeSeed(seedStation, 0.45, 0.52, 0.88, 0.80);
const seedLabel = makeLabel(
["SEED LOT", RECORD_ID],
1.72,
0.43,
{
background: "#f0e3c7",
foreground: "#193a34",
accent: "#176b64"
}
);
seedLabel.position.set(0, 0.48, 0.88);
seedStation.add(seedLabel);
// Envelope station.
const envelopeStation = new THREE.Group();
envelopeStation.userData.station = "envelopes";
scene.add(envelopeStation);
block(envelopeStation, [2.75, 0.23, 1.42], [0, 0.15, 0], 0x8b6e50);
block(envelopeStation, [2.52, 0.10, 1.22], [0, 0.31, 0], 0xb99c75);
// Voxel supports.
for (const x of [-0.82, 0, 0.82]) {
block(envelopeStation, [0.13, 0.72, 0.16], [x, 0.67, -0.12], 0x6f5a46);
block(envelopeStation, [0.37, 0.10, 0.24], [x, 0.39, -0.03], 0x7f6650);
}
makeEnvelope(envelopeStation, -0.82, -0.02, 0.10);
makeEnvelope(envelopeStation, 0.00, 0.12, 0.00);
makeEnvelope(envelopeStation, 0.82, -0.02, -0.10);
const envelopeSetLabel = makeLabel(
["ENVELOPE SET", RECORD_ID],
2.12,
0.37,
{
background: "#176b64",
foreground: "#fff8e8",
accent: "#e1b957"
}
);
envelopeSetLabel.position.set(0, 0.43, 0.73);
envelopeStation.add(envelopeSetLabel);
// Parent-plant station.
const plantStation = new THREE.Group();
plantStation.userData.station = "plant";
scene.add(plantStation);
const plant = new THREE.Group();
plant.position.set(-0.18, 0, 0);
plantStation.add(plant);
// Stacked voxel pot.
block(plant, [0.80, 0.37, 0.80], [0, 0.47, 0], 0xb9684d);
block(plant, [1.00, 0.16, 1.00], [0, 0.70, 0], 0xc97858);
block(plant, [0.84, 0.08, 0.84], [0, 0.81, 0], 0x493a2e);
// Stem.
for (let i = 0; i < 6; i++) {
block(
plant,
[0.12, 0.25, 0.12],
[0, 0.96 + i * 0.23, 0],
i < 3 ? 0x386f4f : 0x477f59
);
}
// Stepped voxel leaves.
block(plant, [0.34, 0.13, 0.31], [-0.20, 1.25, 0], 0x4f865e);
block(plant, [0.27, 0.13, 0.29], [-0.42, 1.30, 0], 0x5e9367);
block(plant, [0.17, 0.12, 0.24], [-0.58, 1.34, 0], 0x6b9c6e);
block(plant, [0.34, 0.13, 0.31], [0.20, 1.61, 0], 0x3f7954);
block(plant, [0.27, 0.13, 0.29], [0.42, 1.66, 0], 0x568a5d);
block(plant, [0.17, 0.12, 0.24], [0.58, 1.70, 0], 0x65956a);
block(plant, [0.29, 0.12, 0.27], [-0.17, 1.88, 0], 0x568c5e);
block(plant, [0.17, 0.18, 0.17], [0, 2.28, 0], 0x79a66f);
// Parent marker stake and ID plate.
block(plantStation, [0.12, 1.75, 0.12], [0.95, 1.18, -0.02], 0x80664d);
const parentLabel = makeLabel(
["PARENT", RECORD_ID],
1.33,
0.43,
{
background: "#176b64",
foreground: "#fff8e8",
accent: "#e1b957"
}
);
parentLabel.position.set(0.91, 2.10, 0.06);
plantStation.add(parentLabel);
// Floating station cards all repeat the same identifier.
makeStationCard("SEED SPECIMENS", -4.12);
makeStationCard("LABELED ENVELOPES", 0.00);
makeStationCard("PARENT-PLANT MARKER", 4.12);
const interactiveRoots = [seedStation, envelopeStation, plantStation];
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const hoverInfo = {
seeds: {
title: "Seed lot",
text: "Seven visible voxel seed specimens, linked as one catalog record."
},
envelopes: {
title: "Labeled envelope set",
text: "Three envelopes each carry the same assigned catalog identifier."
},
plant: {
title: "Parent-plant marker",
text: "A small retained plant and marker sharing the assigned record ID."
}
};
function stationForObject(object) {
let current = object;
while (current) {
if (current.userData && current.userData.station) {
return current.userData.station;
}
current = current.parent;
}
return null;
}
function updatePointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function showTooltip(event, stationName) {
const info = hoverInfo[stationName];
const rect = viewport.getBoundingClientRect();
tooltipTitle.textContent = info.title;
tooltipText.textContent = info.text;
const left = Math.min(
Math.max(10, event.clientX - rect.left + 14),
Math.max(10, rect.width - 232)
);
const top = Math.min(
Math.max(10, event.clientY - rect.top + 14),
Math.max(10, rect.height - 108)
);
tooltip.style.left = `${left}px`;
tooltip.style.top = `${top}px`;
tooltip.classList.add("visible");
}
function hideTooltip() {
tooltip.classList.remove("visible");
}
function pick(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveRoots, true);
if (hits.length) {
const stationName = stationForObject(hits[0].object);
if (stationName) {
showTooltip(event, stationName);
renderer.domElement.style.cursor = "help";
return;
}
}
hideTooltip();
renderer.domElement.style.cursor = "grab";
}
// Direct camera controls: no examples/addons are used.
let pointerDown = false;
let dragMoved = false;
let lastX = 0;
let lastY = 0;
renderer.domElement.style.cursor = "grab";
renderer.domElement.addEventListener("pointerdown", (event) => {
pointerDown = true;
dragMoved = false;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
hideTooltip();
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointerDown) {
pick(event);
return;
}
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.abs(dx) + Math.abs(dy) > 2) {
dragMoved = true;
}
lastX = event.clientX;
lastY = event.clientY;
viewGoal.theta = THREE.MathUtils.clamp(
viewGoal.theta - dx * 0.006,
-0.85,
0.85
);
viewGoal.phi = THREE.MathUtils.clamp(
viewGoal.phi + dy * 0.005,
0.36,
0.92
);
});
function endPointer(event) {
pointerDown = false;
renderer.domElement.style.cursor = "grab";
if (!dragMoved && event) {
pick(event);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", () => endPointer(null));
renderer.domElement.addEventListener("pointerleave", hideTooltip);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
viewGoal.zoom = THREE.MathUtils.clamp(
viewGoal.zoom - event.deltaY * 0.001,
0.76,
1.48
);
},
{ passive: false }
);
function resetView() {
viewGoal.theta = 0.29;
viewGoal.phi = 0.52;
viewGoal.zoom = 1;
}
document.getElementById("resetButton").addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
function resize() {
const rect = host.getBoundingClientRect();
const width = Math.max(1, rect.width);
const height = Math.max(1, rect.height);
const aspect = width / height;
// Keep the full three-station arrangement visible on narrow screens.
const visibleHeight = Math.max(8.15, 13.6 / aspect);
camera.left = (-visibleHeight * aspect) / 2;
camera.right = (visibleHeight * aspect) / 2;
camera.top = visibleHeight / 2;
camera.bottom = -visibleHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(host);
resize();
function updateCamera() {
const radius = 18;
const cosPhi = Math.cos(view.phi);
camera.position.set(
target.x + Math.sin(view.theta) * cosPhi * radius,
target.y + Math.sin(view.phi) * radius,
target.z + Math.cos(view.theta) * cosPhi * radius
);
camera.lookAt(target);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
function animate() {
const smoothing = 0.12;
view.theta += (viewGoal.theta - view.theta) * smoothing;
view.phi += (viewGoal.phi - view.phi) * smoothing;
view.zoom += (viewGoal.zoom - view.zoom) * smoothing;
updateCamera();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```