Prompt specification
Build or customize the Three.js 3D scene "Microbiology data interpretation desk" 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: Microbiology data interpretation desk
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/microbiology-data-interpretation-desk-x0831
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing microbial colony sampling. Compose several synthetic dish images as 3D plaques beside count summaries and uncertainty markers; emphasize sampling differences without specifying real organism handling or incubation methods. Voxel style.
Working Three.js Starter (microbiology-data-interpretation-desk-x0831):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Microbial Colony Sampling — Voxel Atlas</title>
<style>
:root {
--bg: #07111d;
--panel: #0c1d2b;
--panel-2: #102638;
--line: #244357;
--text: #e8f4f4;
--muted: #8299a6;
--mint: #62e9c6;
--amber: #ffc857;
--pink: #ff6f91;
--focus: #ffc857;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: "Courier New", Courier, monospace;
}
button,
canvas {
font: inherit;
}
button {
color: inherit;
}
.app {
display: grid;
grid-template-rows: 76px minmax(0, 1fr) 48px;
width: 100%;
height: 100%;
}
header {
position: relative;
z-index: 10;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
border-bottom: 1px solid var(--line);
background: #081522;
}
.brand {
display: flex;
align-items: center;
gap: 16px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 38px;
height: 38px;
flex: 0 0 auto;
background: var(--mint);
box-shadow:
8px 0 0 #1d7f6c,
0 8px 0 #1d7f6c,
8px 8px 0 #0b1823;
}
.brand-mark::after {
content: "";
position: absolute;
width: 8px;
height: 8px;
left: 7px;
top: 7px;
background: #07111d;
}
.title-block {
min-width: 0;
}
.eyebrow {
margin: 0 0 6px;
color: var(--mint);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
overflow: hidden;
font-size: clamp(16px, 2vw, 24px);
line-height: 1;
letter-spacing: -0.04em;
white-space: nowrap;
text-overflow: ellipsis;
}
.header-meta {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
flex-wrap: wrap;
}
.chip {
min-height: 30px;
display: inline-flex;
align-items: center;
gap: 8px;
padding: 0 11px;
border: 1px solid var(--line);
background: #0c1c29;
color: #b9cbd0;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
}
.chip::before {
content: "";
width: 7px;
height: 7px;
background: var(--mint);
}
.reset {
min-height: 32px;
padding: 0 13px;
border: 1px solid #486274;
border-radius: 0;
background: #102638;
cursor: pointer;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
box-shadow: 3px 3px 0 #050b12;
}
.reset:hover,
.reset:focus-visible {
border-color: var(--mint);
background: #153044;
outline: none;
}
main {
display: grid;
grid-template-columns: 278px minmax(0, 1fr);
min-height: 0;
}
aside {
position: relative;
z-index: 5;
min-height: 0;
overflow: auto;
padding: 22px 20px;
border-right: 1px solid var(--line);
background: #091724;
scrollbar-width: thin;
scrollbar-color: var(--line) transparent;
}
aside section + section {
margin-top: 26px;
padding-top: 22px;
border-top: 1px solid var(--line);
}
.section-label {
margin: 0 0 12px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.14em;
text-transform: uppercase;
}
aside h2 {
margin: 0 0 14px;
font-size: 24px;
line-height: 1.05;
letter-spacing: -0.06em;
}
.range-box {
display: grid;
grid-template-columns: 1fr 1fr;
border: 1px solid var(--line);
background: #0d2030;
}
.range-stat {
padding: 13px;
}
.range-stat + .range-stat {
border-left: 1px solid var(--line);
}
.range-stat span {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.1em;
}
.range-stat strong {
display: block;
font-size: 28px;
line-height: 1;
}
.range-stat:last-child strong {
color: var(--mint);
}
.note {
margin: 12px 0 0;
color: #91a6b0;
font-size: 11px;
line-height: 1.55;
}
.pair-list {
display: grid;
gap: 8px;
}
.pair-row {
width: 100%;
padding: 10px;
border: 1px solid #1f3a4b;
border-radius: 0;
background: #0c1d2a;
text-align: left;
cursor: pointer;
}
.pair-row:hover,
.pair-row:focus-visible,
.pair-row.active {
border-color: #527286;
background: #102638;
outline: none;
}
.pair-top {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin-bottom: 8px;
}
.pair-name {
color: #c6d7dc;
font-size: 11px;
font-weight: 700;
}
.pair-difference {
color: var(--text);
font-size: 18px;
font-weight: 700;
}
.pair-track {
height: 6px;
background: #193040;
}
.pair-fill {
height: 100%;
background: var(--mint);
}
.pair-state {
display: block;
margin-top: 7px;
color: var(--muted);
font-size: 8px;
letter-spacing: 0.08em;
}
.legend {
display: grid;
gap: 12px;
}
.legend-item {
display: grid;
grid-template-columns: 28px 1fr;
align-items: center;
gap: 10px;
color: #a9bbc3;
font-size: 10px;
line-height: 1.35;
}
.legend-tile {
width: 22px;
height: 22px;
background: var(--mint);
box-shadow:
5px -5px 0 #b9ffec,
6px 4px 0 #1b816d;
}
.legend-frame {
width: 24px;
height: 24px;
border: 5px solid var(--amber);
background: transparent;
}
.legend-marker {
position: relative;
width: 24px;
height: 24px;
}
.legend-marker::before {
content: "";
position: absolute;
left: 11px;
top: 2px;
width: 4px;
height: 20px;
background: var(--amber);
}
.legend-marker::after {
content: "";
position: absolute;
left: 5px;
top: 10px;
width: 16px;
height: 5px;
background: #f2fbff;
box-shadow: 0 -8px 0 var(--amber), 0 8px 0 var(--amber);
}
.disclaimer {
padding: 12px;
border-left: 3px solid var(--mint);
background: #0e2230;
color: #9fb2bb;
font-size: 10px;
line-height: 1.55;
}
.stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background: var(--bg);
}
.stage canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
touch-action: none;
}
.stage canvas:focus-visible {
box-shadow: inset 0 0 0 2px var(--mint);
}
.stage-top-left {
position: absolute;
z-index: 3;
top: 18px;
left: 20px;
padding: 8px 10px;
border-left: 3px solid var(--mint);
background: #081522dd;
color: #9fb3bc;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
pointer-events: none;
}
.focus-readout {
position: absolute;
z-index: 3;
top: 18px;
right: 20px;
width: min(310px, calc(100% - 40px));
padding: 12px 14px;
border: 1px solid var(--line);
border-top: 3px solid var(--focus);
background: #081522e8;
pointer-events: none;
}
.focus-readout .focus-kicker {
display: block;
margin-bottom: 7px;
color: var(--muted);
font-size: 8px;
letter-spacing: 0.14em;
}
.focus-readout strong {
display: block;
color: var(--focus);
font-size: 15px;
letter-spacing: 0.03em;
}
.focus-readout p {
margin: 7px 0 0;
color: #9fb2bb;
font-size: 9px;
line-height: 1.5;
}
.stage-scale {
position: absolute;
z-index: 3;
right: 20px;
bottom: 18px;
display: flex;
align-items: flex-end;
gap: 8px;
color: #607987;
font-size: 8px;
letter-spacing: 0.1em;
pointer-events: none;
}
.scale-bar {
width: 78px;
height: 7px;
border-bottom: 2px solid #78919d;
background:
linear-gradient(
90deg,
transparent 24.5%,
#78919d 24.5%,
#78919d 26%,
transparent 26%,
transparent 49.5%,
#78919d 49.5%,
#78919d 51%,
transparent 51%,
transparent 74.5%,
#78919d 74.5%,
#78919d 76%,
transparent 76%
);
}
footer {
position: relative;
z-index: 10;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 0 20px;
border-top: 1px solid var(--line);
background: #081522;
color: #8299a6;
font-size: 9px;
letter-spacing: 0.05em;
}
.controls {
display: flex;
gap: 18px;
flex-wrap: wrap;
}
.controls span {
white-space: nowrap;
}
.controls b {
color: #c4d3d7;
}
.footer-note {
text-align: right;
}
@media (max-width: 1050px) {
main {
grid-template-columns: 236px minmax(0, 1fr);
}
aside {
padding: 18px 16px;
}
aside h2 {
font-size: 21px;
}
.chip.optional {
display: none;
}
}
@media (max-width: 760px) {
.app {
grid-template-rows: 66px minmax(0, 1fr) 44px;
}
main {
grid-template-columns: 1fr;
}
aside {
display: none;
}
header {
padding: 0 14px;
}
.header-meta .chip {
display: none;
}
.focus-readout {
top: 12px;
right: 12px;
width: 240px;
}
.stage-top-left {
top: 12px;
left: 12px;
}
footer {
padding: 0 12px;
}
.footer-note {
display: none;
}
}
</style>
</head>
<body>
<div class="app">
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div class="title-block">
<p class="eyebrow">Synthetic dataset / spatial count atlas</p>
<h1>MICROBIAL COLONY SAMPLING</h1>
</div>
</div>
<div class="header-meta">
<div class="chip">3 VOXEL WINDOWS</div>
<div class="chip optional">UNCERTAINTY ENABLED</div>
<button class="reset" id="resetView" type="button">RESET VIEW</button>
</div>
</header>
<main>
<aside>
<section>
<p class="section-label">Dataset 07 / count overview</p>
<h2>Count spread<br />across windows.</h2>
<div class="range-box">
<div class="range-stat">
<span>LOWEST</span>
<strong>27</strong>
</div>
<div class="range-stat">
<span>HIGHEST</span>
<strong>73</strong>
</div>
</div>
<p class="note">
Each raised tile represents one synthetic count on a fixed
10 × 10 image grid.
</p>
</section>
<section>
<p class="section-label">Pairwise difference</p>
<div class="pair-list" id="pairList"></div>
<p class="note" id="pairSummary"></p>
</section>
<section>
<p class="section-label">Encoding</p>
<div class="legend">
<div class="legend-item">
<div class="legend-tile" aria-hidden="true"></div>
<span>One raised voxel tile<br />= one synthetic count</span>
</div>
<div class="legend-item">
<div class="legend-frame" aria-hidden="true"></div>
<span>Colored frame<br />= sampling window ID</span>
</div>
<div class="legend-item">
<div class="legend-marker" aria-hidden="true"></div>
<span>Vertical bar and caps<br />= displayed uncertainty interval</span>
</div>
</div>
</section>
<section>
<p class="section-label">Scope</p>
<div class="disclaimer">
Illustrative count visualization only. No organism-specific,
handling, media, incubation, or procedural parameters are shown.
</div>
</section>
</aside>
<section class="stage" id="stage" aria-label="Interactive 3D colony sampling comparison">
<div class="stage-top-left">ORTHOGRAPHIC / VOXEL PLATES / 01—03</div>
<div
class="focus-readout"
id="focusReadout"
style="--focus: #ffc857"
aria-live="polite"
>
<span class="focus-kicker">PINNED WINDOW</span>
<strong id="focusName">02 / CORE</strong>
<p id="focusDetail">COUNT 73 / UI 61—85 / 73% GRID OCCUPANCY</p>
</div>
<div class="stage-scale" aria-hidden="true">
<span>0</span>
<div class="scale-bar"></div>
<span>100 CELLS</span>
</div>
</section>
</main>
<footer>
<div class="controls">
<span><b>DRAG</b> INSPECT</span>
<span><b>SCROLL</b> ZOOM</span>
<span><b>CLICK</b> PIN WINDOW</span>
<span><b>R</b> RESET</span>
</div>
<div class="footer-note">SYNTHETIC COUNTS ONLY · SPATIAL COMPARISON, NO PROTOCOL DETAILS</div>
</footer>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const focusReadout = document.getElementById("focusReadout");
const focusName = document.getElementById("focusName");
const focusDetail = document.getElementById("focusDetail");
const pairList = document.getElementById("pairList");
const pairSummary = document.getElementById("pairSummary");
const samples = [
{
id: "01",
code: "A",
location: "WEST EDGE",
count: 27,
low: 20,
high: 35,
accent: "#62e9c6",
seed: 1107,
x: -8.8
},
{
id: "02",
code: "B",
location: "CORE",
count: 73,
low: 61,
high: 85,
accent: "#ffc857",
seed: 2209,
x: 0
},
{
id: "03",
code: "C",
location: "EAST EDGE",
count: 44,
low: 34,
high: 55,
accent: "#ff6f91",
seed: 3301,
x: 8.8
}
];
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Three-dimensional synthetic colony plaques. Drag to inspect, scroll to zoom, and click a plaque to pin it."
);
stage.insertBefore(renderer.domElement, stage.firstChild);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#07111d");
const camera = new THREE.OrthographicCamera(-14, 14, 8, -8, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, -0.05, 0);
const hemisphere = new THREE.HemisphereLight(0xd7f7ff, 0x08111a, 2.0);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.2);
keyLight.position.set(-9, 13, 13);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -18;
keyLight.shadow.camera.right = 18;
keyLight.shadow.camera.top = 13;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 45;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5ca9ff, 1.4);
rimLight.position.set(12, 4, -5);
scene.add(rimLight);
const fillLight = new THREE.PointLight(0x62e9c6, 15, 25, 2);
fillLight.position.set(-10, 3, 7);
scene.add(fillLight);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const unitPlane = new THREE.PlaneGeometry(1, 1);
const interactive = [];
const sampleObjects = [];
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.04,
...options
});
}
function addBox(parent, size, position, material, castShadow = true, receiveShadow = true) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function addPlane(parent, size, position, material) {
const mesh = new THREE.Mesh(unitPlane, material);
mesh.scale.set(size[0], size[1], 1);
mesh.position.set(position[0], position[1], position[2]);
parent.add(mesh);
return mesh;
}
function makeCanvasTexture(width, height, painter) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
painter(context, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
return texture;
}
function makeSummaryTexture(sample) {
return makeCanvasTexture(768, 1080, (ctx, width, height) => {
ctx.fillStyle = "#0c1e2c";
ctx.fillRect(0, 0, width, height);
// Subtle pixel-grid texture.
ctx.fillStyle = "rgba(98,233,198,0.025)";
for (let x = 0; x < width; x += 64) {
ctx.fillRect(x, 0, 1, height);
}
for (let y = 0; y < height; y += 64) {
ctx.fillRect(0, y, width, 1);
}
ctx.fillStyle = sample.accent;
ctx.fillRect(0, 0, width, 14);
ctx.strokeStyle = sample.accent;
ctx.lineWidth = 9;
ctx.strokeRect(5, 5, width - 10, height - 10);
ctx.fillStyle = "#eaf5f4";
ctx.font = '700 34px "Courier New", monospace';
ctx.fillText(`WINDOW ${sample.id}`, 52, 65);
ctx.fillStyle = sample.accent;
ctx.font = '700 24px "Courier New", monospace';
ctx.fillText(sample.location, 54, 112);
ctx.fillStyle = "#29475a";
ctx.fillRect(52, 148, 560, 3);
ctx.fillStyle = "#829ca8";
ctx.font = '700 21px "Courier New", monospace';
ctx.fillText("OBSERVED COUNT", 52, 226);
ctx.fillStyle = "#f0fbfa";
ctx.font = '900 150px "Courier New", monospace';
ctx.fillText(String(sample.count), 48, 385);
ctx.fillStyle = "#829ca8";
ctx.font = '700 21px "Courier New", monospace';
ctx.fillText("INTERVAL / 95% UI", 52, 486);
ctx.fillStyle = "#f0fbfa";
ctx.font = '700 61px "Courier New", monospace';
ctx.fillText(`${sample.low}—${sample.high}`, 50, 566);
ctx.fillStyle = "#829ca8";
ctx.font = '700 21px "Courier New", monospace';
ctx.fillText("UNCERTAINTY", 52, 676);
ctx.fillStyle = sample.accent;
ctx.font = '700 66px "Courier New", monospace';
ctx.fillText(`± ${((sample.high - sample.low) / 2).toFixed(1)}`, 50, 758);
ctx.fillStyle = "#29475a";
ctx.fillRect(52, 846, 560, 3);
ctx.fillStyle = "#718d99";
ctx.font = '700 19px "Courier New", monospace';
ctx.fillText("SYNTHETIC COUNT MODEL", 52, 905);
ctx.fillText(`${sample.count} / 100 CELLS`, 52, 950);
});
}
function makePlateLabelTexture(sample, top = true) {
return makeCanvasTexture(1024, 190, (ctx, width, height) => {
ctx.clearRect(0, 0, width, height);
ctx.textAlign = "center";
if (top) {
ctx.fillStyle = sample.accent;
ctx.font = '900 66px "Courier New", monospace';
ctx.fillText(
`${sample.id} / ${sample.location}`,
width / 2,
86
);
ctx.fillStyle = "#8ca5b0";
ctx.font = '700 25px "Courier New", monospace';
ctx.fillText("SYNTHETIC WINDOW", width / 2, 143);
} else {
ctx.fillStyle = "#dceceb";
ctx.font = '900 54px "Courier New", monospace';
ctx.fillText(
`${sample.count} TILES / ${sample.count}%`,
width / 2,
80
);
ctx.fillStyle = sample.accent;
ctx.font = '700 25px "Courier New", monospace';
ctx.fillText("ONE TILE = ONE COUNT", width / 2, 137);
}
});
}
function mulberry32(seed) {
return function random() {
let t = seed += 0x6D2B79F5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
};
}
function shuffledGrid(seed) {
const random = mulberry32(seed);
const cells = Array.from({ length: 100 }, (_, index) => ({
column: index % 10,
row: Math.floor(index / 10)
}));
for (let i = cells.length - 1; i > 0; i--) {
const j = Math.floor(random() * (i + 1));
[cells[i], cells[j]] = [cells[j], cells[i]];
}
return { cells, random };
}
const colonyMaterial = standardMaterial("#62e9c6", {
emissive: "#14705f",
emissiveIntensity: 0.18,
roughness: 0.48
});
const colonyCapMaterial = standardMaterial("#b7ffeb", {
emissive: "#4bbaa2",
emissiveIntensity: 0.12,
roughness: 0.4
});
const darkMaterial = standardMaterial("#0d2231");
const innerMaterial = standardMaterial("#081722");
const gridMaterial = standardMaterial("#193849", {
emissive: "#07131d",
emissiveIntensity: 0.1
});
function buildSample(sample, index) {
const group = new THREE.Group();
group.position.x = sample.x;
scene.add(group);
const dishX = -2.2;
const cardX = 2.15;
const backMaterial = standardMaterial("#0e2535", {
emissive: sample.accent,
emissiveIntensity: 0.015
});
const frameMaterial = standardMaterial(sample.accent, {
emissive: sample.accent,
emissiveIntensity: 0.08,
roughness: 0.4,
metalness: 0.08
});
const markerMaterial = standardMaterial(sample.accent, {
emissive: sample.accent,
emissiveIntensity: 0.25,
roughness: 0.35
});
const markerRangeMaterial = standardMaterial(sample.accent, {
emissive: sample.accent,
emissiveIntensity: 0.16,
transparent: true,
opacity: 0.62,
roughness: 0.35
});
const board = addBox(
group,
[5.3, 5.3, 0.34],
[dishX, 0, -0.18],
backMaterial
);
board.userData.sampleIndex = index;
interactive.push(board);
addBox(
group,
[4.95, 4.95, 0.14],
[dishX, 0, 0.06],
innerMaterial,
false,
true
);
// Bright frame rails.
addBox(group, [5.3, 0.13, 0.12], [dishX, 2.59, 0.15], frameMaterial);
addBox(group, [5.3, 0.13, 0.12], [dishX, -2.59, 0.15], frameMaterial);
addBox(group, [0.13, 5.3, 0.12], [dishX - 2.59, 0, 0.15], frameMaterial);
addBox(group, [0.13, 5.3, 0.12], [dishX + 2.59, 0, 0.15], frameMaterial);
// Larger voxel corner blocks.
for (const sx of [-1, 1]) {
for (const sy of [-1, 1]) {
addBox(
group,
[0.28, 0.28, 0.18],
[dishX + sx * 2.55, sy * 2.55, 0.19],
frameMaterial
);
}
}
// Fixed 10 × 10 image grid.
for (let i = 0; i <= 10; i++) {
const p = -2.475 + i * 0.495;
addBox(
group,
[0.014, 4.95, 0.012],
[dishX + p, 0, 0.142],
gridMaterial,
false,
false
);
addBox(
group,
[4.95, 0.014, 0.012],
[dishX, p, 0.142],
gridMaterial,
false,
false
);
}
// One raised voxel tile per synthetic count.
const { cells, random } = shuffledGrid(sample.seed);
for (let i = 0; i < sample.count; i++) {
const cell = cells[i];
const jitterX = (random() - 0.5) * 0.035;
const jitterY = (random() - 0.5) * 0.035;
const width = 0.22 + random() * 0.045;
const depth = 0.13 + random() * 0.10;
const height = 0.22 + random() * 0.045;
const x = dishX + (cell.column - 4.5) * 0.495 + jitterX;
const y = (4.5 - cell.row) * 0.495 + jitterY;
const z = 0.16 + depth / 2;
addBox(
group,
[width, height, depth],
[x, y, z],
colonyMaterial,
true,
false
);
if (random() > 0.68) {
addBox(
group,
[width * 0.53, height * 0.53, 0.065],
[x, y, z + depth / 2 + 0.032],
colonyCapMaterial,
true,
false
);
}
}
// Top and bottom identification plaques.
const topPlaque = addBox(
group,
[4.55, 0.72, 0.18],
[dishX, 2.99, -0.02],
darkMaterial
);
topPlaque.userData.sampleIndex = index;
interactive.push(topPlaque);
const topLabel = makePlateLabelTexture(sample, true);
addPlane(
group,
[4.35, 0.62],
[dishX, 2.99, 0.09],
new THREE.MeshBasicMaterial({
map: topLabel,
transparent: true,
depthWrite: false,
toneMapped: false
})
);
const bottomPlaque = addBox(
group,
[4.55, 0.72, 0.18],
[dishX, -2.99, -0.02],
darkMaterial
);
bottomPlaque.userData.sampleIndex = index;
interactive.push(bottomPlaque);
const bottomLabel = makePlateLabelTexture(sample, false);
addPlane(
group,
[4.35, 0.62],
[dishX, -2.99, 0.09],
new THREE.MeshBasicMaterial({
map: bottomLabel,
transparent: true,
depthWrite: false,
toneMapped: false
})
);
// Structural connector between image plaque and count card.
addBox(
group,
[0.55, 0.42, 0.20],
[0.48, 0.1, -0.08],
frameMaterial
);
// Summary card body and textured face.
const card = addBox(
group,
[3.42, 4.95, 0.34],
[cardX, 0.25, -0.06],
backMaterial
);
card.userData.sampleIndex = index;
interactive.push(card);
const summaryTexture = makeSummaryTexture(sample);
const cardFace = addPlane(
group,
[3.25, 4.80],
[cardX, 0.25, 0.125],
new THREE.MeshBasicMaterial({
map: summaryTexture,
toneMapped: false
})
);
cardFace.userData.sampleIndex = index;
interactive.push(cardFace);
// Physical uncertainty interval marker beside the numeric summary.
const markerX = cardX + 1.08;
const markerBottom = -1.55;
const markerHeight = 2.70;
const mapY = value => markerBottom + (value / 100) * markerHeight;
addBox(
group,
[0.035, markerHeight, 0.04],
[markerX, markerBottom + markerHeight / 2, 0.19],
gridMaterial,
false,
false
);
const intervalLength =
((sample.high - sample.low) / 100) * markerHeight;
addBox(
group,
[0.11, intervalLength, 0.075],
[markerX, (mapY(sample.low) + mapY(sample.high)) / 2, 0.225],
markerRangeMaterial,
false,
false
);
addBox(
group,
[0.27, 0.06, 0.09],
[markerX, mapY(sample.low), 0.25],
markerMaterial,
false,
false
);
addBox(
group,
[0.27, 0.06, 0.09],
[markerX, mapY(sample.high), 0.25],
markerMaterial,
false,
false
);
addBox(
group,
[0.25, 0.11, 0.10],
[markerX, mapY(sample.count), 0.27],
standardMaterial("#f1fffb", {
emissive: sample.accent,
emissiveIntensity: 0.12
}),
false,
false
);
// Small zero / hundred ticks.
addBox(
group,
[0.17, 0.035, 0.05],
[markerX, markerBottom, 0.20],
gridMaterial,
false,
false
);
addBox(
group,
[0.17, 0.035, 0.05],
[markerX, markerBottom + markerHeight, 0.20],
gridMaterial,
false,
false
);
// Ground pedestal.
addBox(
group,
[5.75, 0.28, 1.20],
[dishX, -3.40, -0.25],
standardMaterial("#0b1b28")
);
addBox(
group,
[3.75, 0.20, 1.02],
[cardX, -3.40, -0.25],
standardMaterial("#0b1b28")
);
sampleObjects.push({
group,
backMaterial,
frameMaterial
});
}
samples.forEach(buildSample);
// Environment: a dark wall and a sparse voxel floor grid.
const wall = new THREE.Mesh(
new THREE.PlaneGeometry(60, 30),
standardMaterial("#081724", {
roughness: 1,
metalness: 0
})
);
wall.position.set(0, 2, -1.6);
wall.receiveShadow = true;
scene.add(wall);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(60, 32),
standardMaterial("#07131f", {
roughness: 0.95,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.set(0, -3.57, 0);
floor.receiveShadow = true;
scene.add(floor);
const floorGrid = new THREE.GridHelper(44, 22, 0x1a3c4d, 0x102b3a);
floorGrid.position.y = -3.55;
floorGrid.material.transparent = true;
floorGrid.material.opacity = 0.42;
scene.add(floorGrid);
// Pairwise comparison panel.
const pairDefinitions = [
{ a: samples[1], b: samples[0] },
{ a: samples[1], b: samples[2] },
{ a: samples[2], b: samples[0] }
];
const maximumDifference = Math.max(
...pairDefinitions.map(pair => Math.abs(pair.a.count - pair.b.count))
);
for (const pair of pairDefinitions) {
const difference = Math.abs(pair.a.count - pair.b.count);
const separated =
pair.a.high < pair.b.low ||
pair.b.high < pair.a.low;
const button = document.createElement("button");
button.type = "button";
button.className = "pair-row";
button.dataset.sample = String(samples.indexOf(pair.a));
button.innerHTML = `
<div class="pair-top">
<span class="pair-name">
${pair.a.code} / ${pair.b.code}
</span>
<span class="pair-difference">+${difference}</span>
</div>
<div class="pair-track">
<div
class="pair-fill"
style="width:${(difference / maximumDifference) * 100}%;
background:${pair.a.accent};">
</div>
</div>
<span class="pair-state">
${separated ? "INTERVALS SEPARATED" : "INTERVALS OVERLAP"}
</span>
`;
button.addEventListener("click", () => {
selectedIndex = samples.indexOf(pair.a);
updateFocus();
});
pairList.appendChild(button);
}
pairSummary.textContent =
"The core window is separated from both edge windows under the displayed synthetic intervals.";
// Camera and interaction state.
const view = {
yaw: 0,
pitch: 0.11,
zoom: 1,
targetYaw: 0,
targetPitch: 0.11,
targetZoom: 1
};
let selectedIndex = 1;
let hoveredIndex = null;
function updateFocus() {
const index = hoveredIndex !== null ? hoveredIndex : selectedIndex;
const sample = samples[index];
focusReadout.style.setProperty("--focus", sample.accent);
focusReadout.querySelector(".focus-kicker").textContent =
hoveredIndex !== null ? "HOVERED WINDOW" : "PINNED WINDOW";
focusName.textContent = `${sample.id} / ${sample.location}`;
focusDetail.textContent =
`COUNT ${sample.count} / UI ${sample.low}—${sample.high} / ` +
`${sample.count}% GRID OCCUPANCY`;
document.querySelectorAll(".pair-row").forEach((row, rowIndex) => {
const pair = pairDefinitions[rowIndex];
row.classList.toggle(
"active",
samples.indexOf(pair.a) === index ||
samples.indexOf(pair.b) === index
);
});
}
function resize() {
const width = Math.max(1, stage.clientWidth);
const height = Math.max(1, stage.clientHeight);
const aspect = width / height;
renderer.setSize(width, height, false);
const requiredWidth = 27.6;
const worldHeight = Math.max(14.6, requiredWidth / aspect);
camera.left = (-worldHeight * aspect) / 2;
camera.right = (worldHeight * aspect) / 2;
camera.top = worldHeight / 2;
camera.bottom = -worldHeight / 2;
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
resize();
function resetView() {
view.targetYaw = 0;
view.targetPitch = 0.11;
view.targetZoom = 1;
}
document.getElementById("resetView").addEventListener("click", resetView);
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let pointerDown = false;
let moved = false;
let lastX = 0;
let lastY = 0;
let downX = 0;
let downY = 0;
function setPointerFromEvent(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pickSample(event) {
setPointerFromEvent(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactive, false);
return hits.length ? hits[0].object.userData.sampleIndex : null;
}
renderer.domElement.addEventListener("pointerdown", event => {
pointerDown = true;
moved = false;
lastX = event.clientX;
lastY = event.clientY;
downX = event.clientX;
downY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (pointerDown) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (
Math.abs(event.clientX - downX) +
Math.abs(event.clientY - downY) > 4
) {
moved = true;
}
view.targetYaw = THREE.MathUtils.clamp(
view.targetYaw - dx * 0.0032,
-0.32,
0.32
);
view.targetPitch = THREE.MathUtils.clamp(
view.targetPitch + dy * 0.0018,
-0.02,
0.27
);
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.style.cursor = "grabbing";
} else {
const index = pickSample(event);
if (index !== hoveredIndex) {
hoveredIndex = index;
renderer.domElement.style.cursor =
index === null ? "grab" : "pointer";
updateFocus();
}
}
});
renderer.domElement.addEventListener("pointerup", event => {
pointerDown = false;
renderer.domElement.style.cursor = "grab";
if (!moved) {
const index = pickSample(event);
if (index !== null) {
selectedIndex = index;
updateFocus();
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = false;
renderer.domElement.style.cursor = "grab";
});
renderer.domElement.addEventListener("pointerleave", () => {
if (!pointerDown) {
hoveredIndex = null;
renderer.domElement.style.cursor = "grab";
updateFocus();
}
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
view.targetZoom = THREE.MathUtils.clamp(
view.targetZoom * Math.exp(-event.deltaY * 0.001),
0.78,
1.52
);
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener("keydown", event => {
const key = event.key.toLowerCase();
if (key === "arrowleft") {
view.targetYaw = THREE.MathUtils.clamp(
view.targetYaw - 0.04,
-0.32,
0.32
);
}
if (key === "arrowright") {
view.targetYaw = THREE.MathUtils.clamp(
view.targetYaw + 0.04,
-0.32,
0.32
);
}
if (key === "arrowup") {
view.targetPitch = THREE.MathUtils.clamp(
view.targetPitch + 0.025,
-0.02,
0.27
);
}
if (key === "arrowdown") {
view.targetPitch = THREE.MathUtils.clamp(
view.targetPitch - 0.025,
-0.02,
0.27
);
}
if (key === "+" || key === "=") {
view.targetZoom = THREE.MathUtils.clamp(
view.targetZoom * 1.08,
0.78,
1.52
);
}
if (key === "-") {
view.targetZoom = THREE.MathUtils.clamp(
view.targetZoom / 1.08,
0.78,
1.52
);
}
if (key === "r") {
resetView();
}
event.preventDefault();
});
function updateCamera() {
const distance = 24;
const horizontal = Math.cos(view.pitch) * distance;
camera.position.set(
cameraTarget.x + Math.sin(view.yaw) * horizontal,
cameraTarget.y + Math.sin(view.pitch) * distance,
cameraTarget.z + Math.cos(view.yaw) * horizontal
);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
camera.lookAt(cameraTarget);
}
function animate() {
requestAnimationFrame(animate);
view.yaw += (view.targetYaw - view.yaw) * 0.12;
view.pitch += (view.targetPitch - view.pitch) * 0.12;
view.zoom += (view.targetZoom - view.zoom) * 0.12;
updateCamera();
const activeIndex = hoveredIndex !== null
? hoveredIndex
: selectedIndex;
sampleObjects.forEach((object, index) => {
const active = index === activeIndex;
object.backMaterial.emissiveIntensity = active ? 0.11 : 0.015;
object.frameMaterial.emissiveIntensity = active ? 0.30 : 0.08;
});
renderer.render(scene, camera);
}
updateFocus();
animate();
</script>
</body>
</html>
```