Prompt specification
Build or customize the Three.js 3D scene "Riverbank fossil excavation diorama" 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: Riverbank fossil excavation diorama
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/riverbank-fossil-excavation-diorama-x1147
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring fossil preservation. Build a small outcrop with embedded shell impressions, a gridded excavation tray, and labeled finds; preserve specimen positions and stratigraphic relationships during inspection. Voxel style.
Working Three.js Starter (riverbank-fossil-excavation-diorama-x1147):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>STRATA — Fossil Preservation Field Station</title>
<style>
:root {
--bg: #071114;
--panel: rgba(10, 24, 27, 0.9);
--panel-solid: #0c1c20;
--line: rgba(123, 181, 178, 0.2);
--line-strong: rgba(123, 181, 178, 0.42);
--text: #dce9e5;
--muted: #7e9b97;
--mint: #8de0c6;
--amber: #e1ae6b;
--danger: #e9826b;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
#leaders,
#labels {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
overflow: hidden;
}
#leaders {
z-index: 3;
}
#labels {
z-index: 4;
}
.topbar {
position: fixed;
z-index: 10;
top: 0;
left: 0;
right: 0;
min-height: 76px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 16px 22px;
pointer-events: none;
background: linear-gradient(
180deg,
rgba(4, 12, 14, 0.92) 0%,
rgba(4, 12, 14, 0.65) 65%,
transparent 100%
);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
width: 42px;
height: 42px;
position: relative;
border: 1px solid var(--line-strong);
background:
linear-gradient(90deg, transparent 48%, var(--line) 49%, var(--line) 52%, transparent 53%),
linear-gradient(0deg, transparent 48%, var(--line) 49%, var(--line) 52%, transparent 53%);
transform: rotate(45deg);
box-shadow: inset 0 0 20px rgba(141, 224, 198, 0.05);
}
.brand-mark::after {
content: "";
position: absolute;
inset: 11px;
border: 1px solid var(--mint);
opacity: 0.8;
}
.eyebrow,
.mono,
.section-title,
.pin,
.hud,
.find-id,
.layer-code,
.readout-grid,
.integrity,
.toggle-row,
.status-chip {
font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.eyebrow {
color: var(--mint);
font-size: 10px;
letter-spacing: 0.19em;
text-transform: uppercase;
margin-bottom: 4px;
}
h1 {
margin: 0;
font-size: 21px;
line-height: 1;
letter-spacing: 0.08em;
font-weight: 650;
}
.subtitle {
color: var(--muted);
font-size: 11px;
margin-top: 6px;
}
.top-actions {
display: flex;
align-items: center;
gap: 9px;
pointer-events: auto;
}
.status-chip {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid var(--line);
background: rgba(9, 25, 27, 0.72);
color: #a7c4be;
font-size: 10px;
letter-spacing: 0.08em;
}
.status-dot {
width: 7px;
height: 7px;
background: var(--mint);
box-shadow: 0 0 10px rgba(141, 224, 198, 0.75);
}
.ghost-button,
.small-button {
border: 1px solid var(--line-strong);
background: rgba(12, 30, 32, 0.82);
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
color 160ms ease;
}
.ghost-button {
min-height: 36px;
padding: 0 13px;
font-size: 11px;
letter-spacing: 0.04em;
}
.ghost-button:hover,
.small-button:hover {
border-color: rgba(141, 224, 198, 0.72);
background: rgba(23, 48, 48, 0.9);
color: #f0fff9;
}
.panel {
position: fixed;
z-index: 12;
top: 88px;
right: 18px;
bottom: 18px;
width: 318px;
padding: 16px;
overflow: auto;
scrollbar-width: thin;
scrollbar-color: #31504f transparent;
background:
linear-gradient(135deg, rgba(16, 36, 38, 0.94), rgba(7, 19, 22, 0.92)),
var(--panel);
border: 1px solid var(--line);
box-shadow: 0 18px 70px rgba(0, 0, 0, 0.35);
backdrop-filter: blur(15px);
}
.panel::-webkit-scrollbar {
width: 5px;
}
.panel::-webkit-scrollbar-thumb {
background: #31504f;
}
.panel-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
padding-bottom: 14px;
border-bottom: 1px solid var(--line);
}
.section-title {
margin: 0 0 6px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.panel-title {
font-size: 15px;
font-weight: 600;
letter-spacing: 0.02em;
}
.micro {
color: var(--muted);
font-size: 10px;
line-height: 1.5;
}
.panel-section {
padding: 15px 0;
border-bottom: 1px solid var(--line);
}
.panel-section:last-child {
border-bottom: 0;
padding-bottom: 0;
}
.find-list {
display: grid;
gap: 7px;
}
.find-row {
width: 100%;
display: grid;
grid-template-columns: 48px 1fr auto;
align-items: center;
gap: 9px;
padding: 9px;
text-align: left;
border: 1px solid transparent;
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
transition: 150ms ease;
}
.find-row:hover {
background: rgba(141, 224, 198, 0.05);
border-color: rgba(141, 224, 198, 0.18);
}
.find-row.active {
background: rgba(141, 224, 198, 0.09);
border-color: rgba(141, 224, 198, 0.48);
}
.find-id {
color: var(--mint);
font-size: 11px;
}
.find-name {
display: block;
font-size: 11px;
font-weight: 600;
}
.find-layer {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
.layer-swatch {
width: 9px;
height: 9px;
box-shadow: 0 0 8px currentColor;
}
.layer-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6px;
}
.layer-button {
min-height: 47px;
padding: 8px 9px;
display: grid;
grid-template-columns: 10px 1fr;
align-items: center;
gap: 8px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.02);
cursor: pointer;
text-align: left;
}
.layer-button:hover,
.layer-button.active {
border-color: rgba(141, 224, 198, 0.48);
background: rgba(141, 224, 198, 0.065);
}
.layer-code {
display: block;
font-size: 10px;
color: var(--text);
}
.layer-name {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 8px;
white-space: nowrap;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 7px 0;
color: #9eb5b1;
font-size: 10px;
}
.switch {
appearance: none;
width: 30px;
height: 16px;
margin: 0;
border: 1px solid #42615f;
border-radius: 20px;
background: #14292b;
position: relative;
cursor: pointer;
}
.switch::after {
content: "";
position: absolute;
width: 10px;
height: 10px;
top: 2px;
left: 2px;
background: #66837f;
border-radius: 50%;
transition: 150ms ease;
}
.switch:checked {
border-color: var(--mint);
background: rgba(141, 224, 198, 0.18);
}
.switch:checked::after {
left: 16px;
background: var(--mint);
box-shadow: 0 0 8px rgba(141, 224, 198, 0.45);
}
.inspector {
margin-top: 13px;
border: 1px solid rgba(141, 224, 198, 0.22);
background: rgba(141, 224, 198, 0.035);
}
.inspector-top {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 11px;
border-bottom: 1px solid var(--line);
}
.inspector-title {
font-size: 11px;
font-weight: 650;
}
.inspector-body {
padding: 11px;
}
.readout-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
font-size: 9px;
}
.readout-grid span {
display: block;
color: var(--muted);
margin-bottom: 3px;
font-size: 8px;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.readout-grid b {
color: #c9dad5;
font-weight: 500;
}
.integrity {
margin-top: 12px;
padding-top: 10px;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid var(--line);
color: var(--mint);
font-size: 9px;
letter-spacing: 0.08em;
}
.small-button {
margin-top: 10px;
width: 100%;
min-height: 30px;
padding: 6px 10px;
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.bottom-hud {
position: fixed;
z-index: 9;
left: 20px;
right: 356px;
bottom: 17px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 20px;
pointer-events: none;
}
.hud-card {
display: flex;
align-items: center;
gap: 11px;
padding: 10px 12px;
background: rgba(6, 17, 19, 0.72);
border: 1px solid var(--line);
color: var(--muted);
font-size: 9px;
letter-spacing: 0.04em;
backdrop-filter: blur(8px);
}
.mouse-icon {
width: 16px;
height: 23px;
border: 1px solid #6f918c;
border-radius: 9px;
position: relative;
}
.mouse-icon::before {
content: "";
position: absolute;
width: 2px;
height: 5px;
top: 3px;
left: 6px;
background: var(--mint);
}
.lock-mark {
color: var(--mint);
font-size: 15px;
}
.compass {
position: relative;
width: 34px;
height: 34px;
border: 1px solid var(--line-strong);
border-radius: 50%;
}
.compass::before {
content: "N";
position: absolute;
top: -9px;
left: 12px;
padding: 0 2px;
background: #071114;
color: var(--amber);
font-size: 8px;
}
.compass::after {
content: "";
position: absolute;
left: 15px;
top: 7px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-bottom: 10px solid var(--mint);
}
.pin {
position: absolute;
min-width: 106px;
max-width: 168px;
padding: 7px 9px;
transform: translate(-50%, -50%);
pointer-events: auto;
cursor: pointer;
color: var(--text);
background: rgba(6, 18, 20, 0.9);
border: 1px solid rgba(141, 224, 198, 0.25);
box-shadow: 0 7px 22px rgba(0, 0, 0, 0.32);
text-align: left;
transition:
opacity 160ms ease,
border-color 160ms ease,
background 160ms ease;
}
.pin:hover,
.pin.selected {
border-color: var(--mint);
background: rgba(12, 35, 35, 0.96);
}
.pin-id {
display: block;
color: var(--mint);
font-size: 9px;
letter-spacing: 0.08em;
}
.pin-name {
display: block;
margin-top: 2px;
font-size: 9px;
white-space: nowrap;
}
.pin-layer {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 7px;
letter-spacing: 0.05em;
}
#tooltip {
position: fixed;
z-index: 20;
display: none;
pointer-events: none;
padding: 6px 8px;
color: #dff5ee;
background: rgba(4, 13, 15, 0.92);
border: 1px solid var(--line-strong);
font: 9px "SFMono-Regular", Consolas, monospace;
letter-spacing: 0.04em;
}
.hidden {
display: none !important;
}
@media (max-width: 850px) {
.topbar {
min-height: 64px;
padding: 12px;
}
.brand-mark {
width: 34px;
height: 34px;
}
.brand-mark::after {
inset: 8px;
}
h1 {
font-size: 16px;
}
.subtitle,
.status-chip {
display: none;
}
.panel {
top: auto;
left: 10px;
right: 10px;
bottom: 10px;
width: auto;
max-height: 39vh;
padding: 12px;
}
.bottom-hud {
left: 10px;
right: 10px;
bottom: calc(39vh + 20px);
}
.hud-card:last-child {
display: none;
}
.pin {
min-width: 88px;
max-width: 125px;
padding: 5px 7px;
}
.pin-name {
font-size: 8px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel fossil outcrop"></canvas>
<svg id="leaders" aria-hidden="true"></svg>
<div id="labels" aria-label="Fossil labels"></div>
<div id="tooltip"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<div class="eyebrow">Field station / specimen block 07</div>
<h1>STRATA</h1>
<div class="subtitle">Fossil preservation · in-situ inspection archive</div>
</div>
</div>
<div class="top-actions">
<div class="status-chip">
<span class="status-dot"></span>
POSITION LOCK ACTIVE
</div>
<button class="ghost-button" id="resetView">Reset view</button>
</div>
</header>
<aside class="panel">
<div class="panel-header">
<div>
<div class="section-title">Excavation register</div>
<div class="panel-title">Shell impression suite</div>
</div>
<div class="micro">04 FINDS<br />04 LAYERS</div>
</div>
<section class="panel-section">
<div class="section-title">Labeled finds</div>
<div class="find-list" id="findList"></div>
</section>
<section class="panel-section">
<div class="section-title">Stratigraphic context</div>
<div class="micro" style="margin-bottom: 10px">
Focus dims context only. Specimen coordinates remain locked.
</div>
<div class="layer-grid" id="layerGrid"></div>
</section>
<section class="panel-section">
<div class="section-title">Inspection layers</div>
<label class="toggle-row">
<span>Find labels</span>
<input class="switch" id="labelsToggle" type="checkbox" checked />
</label>
<label class="toggle-row">
<span>Stratigraphic datum</span>
<input class="switch" id="datumToggle" type="checkbox" checked />
</label>
<label class="toggle-row">
<span>Context veil</span>
<input class="switch" id="veilToggle" type="checkbox" checked />
</label>
</section>
<section class="panel-section">
<div class="section-title">Selected specimen</div>
<div class="inspector">
<div class="inspector-top">
<span class="inspector-title" id="inspectTitle">F-02 / Ammonite</span>
<span class="micro" id="inspectCode">SPEC-02</span>
</div>
<div class="inspector-body">
<div class="readout-grid" id="readouts"></div>
<div class="integrity">
<span>● PRESERVED IN SITU</span>
<span id="inspectDepth">DATUM 1.60 m</span>
</div>
<button class="small-button" id="focusSelected">Inspect selected specimen</button>
</div>
</div>
</section>
<section class="panel-section">
<div class="section-title">Archive note</div>
<div class="micro">
The outcrop is a single registered block. Camera movement changes the viewing
transform only; fossils, matrix, layer order, and stratigraphic datum are never
translated or reordered.
</div>
</section>
</aside>
<div class="bottom-hud">
<div class="hud-card">
<span class="mouse-icon" aria-hidden="true"></span>
<span>DRAG TO ORBIT · SHIFT-DRAG TO PAN · SCROLL TO ZOOM · CLICK A FIND</span>
</div>
<div class="hud-card">
<span class="lock-mark">⌖</span>
<span>LOCAL COORDINATES LOCKED<br />RELATIONSHIPS PRESERVED</span>
<span class="compass" aria-hidden="true"></span>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.getElementById("scene");
const labelsLayer = document.getElementById("labels");
const leadersLayer = document.getElementById("leaders");
const tooltip = document.getElementById("tooltip");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071114);
scene.fog = new THREE.Fog(0x071114, 18, 37);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xb8e5df, 0x382c22, 1.65);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff0d2, 3.2);
key.position.set(-5, 11, 8);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -12;
key.shadow.camera.right = 12;
key.shadow.camera.top = 12;
key.shadow.camera.bottom = -12;
key.shadow.camera.near = 0.5;
key.shadow.camera.far = 35;
key.shadow.bias = -0.0008;
scene.add(key);
const rim = new THREE.DirectionalLight(0x74c9bd, 2.1);
rim.position.set(9, 7, -9);
scene.add(rim);
const warm = new THREE.PointLight(0xd89057, 18, 13, 2);
warm.position.set(-4, 4, 5);
scene.add(warm);
const state = {
selectedId: "F-02",
focusedLayer: "all",
showLabels: true,
showDatum: true,
useVeil: true
};
const layers = [
{
id: "L1",
name: "Basal sand",
short: "BASAL SAND",
color: 0xc4935d,
css: "#c4935d",
depth: "0.80 m",
age: "Pleistocene"
},
{
id: "L2",
name: "Blue-grey shale",
short: "BLUE SHALE",
color: 0x718a87,
css: "#718a87",
depth: "1.60 m",
age: "Pliocene"
},
{
id: "L3",
name: "Iron-rich silt",
short: "IRON SILT",
color: 0xae6e49,
css: "#ae6e49",
depth: "2.40 m",
age: "Miocene"
},
{
id: "L4",
name: "Calcareous cap",
short: "CALC CAP",
color: 0xc2aa7a,
css: "#c2aa7a",
depth: "3.20 m",
age: "Oligocene"
}
];
const finds = [
{
id: "F-01",
code: "SPEC-01",
name: "Lamellib valve",
taxon: "Bivalve impression",
type: "bivalve",
layerId: "L1",
position: new THREE.Vector3(-4.45, 0.63, 2.12),
rotation: -0.18,
size: 1.18,
orientation: "090° / left valve",
preservation: "Compression",
offset: [-35, 58]
},
{
id: "F-02",
code: "SPEC-02",
name: "Ammonite",
taxon: "Coiled cephalopod",
type: "ammonite",
layerId: "L2",
position: new THREE.Vector3(-2.55, 1.43, 2.12),
rotation: 0.12,
size: 1.05,
orientation: "024° / planispiral",
preservation: "Pyrite trace",
offset: [-52, -56]
},
{
id: "F-03",
code: "SPEC-03",
name: "Brachiopod",
taxon: "Bivalved shell",
type: "brachiopod",
layerId: "L3",
position: new THREE.Vector3(-0.65, 2.28, 2.12),
rotation: -0.38,
size: 1.02,
orientation: "112° / pedicle down",
preservation: "Carbon film",
offset: [38, -57]
},
{
id: "F-04",
code: "SPEC-04",
name: "Turritellid",
taxon: "Gastropod impression",
type: "gastropod",
layerId: "L4",
position: new THREE.Vector3(1.25, 3.10, 2.12),
rotation: 0.31,
size: 0.95,
orientation: "167° / dextral",
preservation: "Fine sand cast",
offset: [53, 24]
}
];
const layerById = Object.fromEntries(layers.map((layer) => [layer.id, layer]));
const findById = Object.fromEntries(finds.map((find) => [find.id, find]));
let seed = 78431;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function makeBox(width, height, depth, material, x, y, z, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// Work surface.
const tableMaterial = new THREE.MeshStandardMaterial({
color: 0x101a1c,
roughness: 0.94,
metalness: 0.02
});
const table = new THREE.Mesh(new THREE.PlaneGeometry(60, 60), tableMaterial);
table.rotation.x = -Math.PI / 2;
table.position.y = -0.24;
table.receiveShadow = true;
scene.add(table);
// Gridded excavation tray.
const trayMaterial = new THREE.MeshStandardMaterial({
color: 0x243c3d,
roughness: 0.72,
metalness: 0.18
});
const trayEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x345354,
roughness: 0.58,
metalness: 0.24
});
makeBox(13.4, 0.26, 8.8, trayMaterial, -0.8, 0, 0);
makeBox(13.4, 0.36, 0.18, trayEdgeMaterial, -0.8, 0.27, -4.4);
makeBox(13.4, 0.36, 0.18, trayEdgeMaterial, -0.8, 0.27, 4.4);
makeBox(0.18, 0.36, 8.8, trayEdgeMaterial, -7.5, 0.27, 0);
makeBox(0.18, 0.36, 8.8, trayEdgeMaterial, 5.9, 0.27, 0);
const gridVertices = [];
for (let x = -7.4; x <= 5.81; x += 0.55) {
gridVertices.push(x, 0.136, -4.3, x, 0.136, 4.3);
}
for (let z = -4.3; z <= 4.31; z += 0.55) {
gridVertices.push(-7.4, 0.136, z, 5.8, 0.136, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridVertices, 3)
);
const grid = new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: 0x83aaa3,
transparent: true,
opacity: 0.25
})
);
scene.add(grid);
// A thicker every-fifth grid line.
const majorVertices = [];
for (let x = -7.4; x <= 5.81; x += 2.75) {
majorVertices.push(x, 0.14, -4.3, x, 0.14, 4.3);
}
for (let z = -4.3; z <= 4.31; z += 2.75) {
majorVertices.push(-7.4, 0.14, z, 5.8, 0.14, z);
}
const majorGridGeometry = new THREE.BufferGeometry();
majorGridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(majorVertices, 3)
);
const majorGrid = new THREE.LineSegments(
majorGridGeometry,
new THREE.LineBasicMaterial({
color: 0xb2d3cb,
transparent: true,
opacity: 0.35
})
);
scene.add(majorGrid);
// Voxel outcrop, one InstancedMesh per stratigraphic layer.
const outcropGroup = new THREE.Group();
scene.add(outcropGroup);
const layerMeshes = {};
const cellSize = 0.55;
const layerHeight = 0.8;
const baseY = 0.15;
const xStart = -5.45;
const zStart = -2.35;
function occupied(ix, iz, layerIndex) {
if (layerIndex >= 2 && (ix < 1 || ix > 12)) return false;
if (layerIndex >= 3 && (ix < 2 || ix > 11)) return false;
if (iz === 8 && ix === 0) return false;
if (iz === 8 && ix === 13 && layerIndex < 2) return false;
if (iz === 7 && layerIndex === 3 && ix < 3) return false;
if (iz === 6 && layerIndex === 2 && ix > 11) return false;
return true;
}
layers.forEach((layer, layerIndex) => {
const positions = [];
for (let ix = 0; ix < 14; ix++) {
for (let iz = 0; iz < 9; iz++) {
if (!occupied(ix, iz, layerIndex)) continue;
positions.push({
x: xStart + ix * cellSize,
y: baseY + layerIndex * layerHeight + layerHeight / 2,
z: zStart + iz * cellSize
});
}
}
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96,
metalness: 0.01,
transparent: true,
opacity: 1
});
const mesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(1, 1, 1),
material,
positions.length
);
const dummy = new THREE.Object3D();
const baseColor = new THREE.Color(layer.color);
positions.forEach((position, index) => {
dummy.position.set(position.x, position.y, position.z);
dummy.scale.set(cellSize * 0.94, layerHeight * 0.97, cellSize * 0.94);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
const variation = (random() - 0.5) * 0.075;
const instanceColor = baseColor.clone().offsetHSL(0, 0, variation);
mesh.setColorAt(index, instanceColor);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.userData.layerId = layer.id;
layerMeshes[layer.id] = mesh;
outcropGroup.add(mesh);
});
// Small voxel debris on the exposed tray.
const debrisMaterial = new THREE.MeshStandardMaterial({
color: 0x7f654a,
roughness: 1
});
const debris = new THREE.InstancedMesh(
new THREE.BoxGeometry(1, 1, 1),
debrisMaterial,
74
);
const debrisDummy = new THREE.Object3D();
for (let i = 0; i < 74; i++) {
let x;
let z;
do {
x = -6.9 + random() * 12.1;
z = -3.85 + random() * 7.7;
} while (x < 2.45 && x > -5.7 && z < 2.25 && z > -2.6);
const size = 0.055 + random() * 0.13;
debrisDummy.position.set(x, 0.17 + size / 2, z);
debrisDummy.scale.set(size, size * (0.5 + random()), size);
debrisDummy.rotation.y = random() * Math.PI;
debrisDummy.updateMatrix();
debris.setMatrixAt(i, debrisDummy.matrix);
}
debris.instanceMatrix.needsUpdate = true;
debris.castShadow = true;
debris.receiveShadow = true;
scene.add(debris);
// Voxel fossil construction helpers.
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
function createCubeMesh(transforms, material, id) {
const mesh = new THREE.InstancedMesh(cubeGeometry, material, transforms.length);
const dummy = new THREE.Object3D();
transforms.forEach((transform, index) => {
dummy.position.set(transform.x, transform.y, transform.z);
dummy.scale.set(transform.sx, transform.sy, transform.sz);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.userData.findId = id;
return mesh;
}
function fossilTransforms(type, size) {
const rim = [];
const interior = [];
if (type === "bivalve") {
const step = 0.105 * size;
for (let ix = -8; ix <= 8; ix++) {
for (let iy = -6; iy <= 6; iy++) {
const x = ix * step;
const y = iy * step * 0.9 + 0.07 * size;
const ellipse =
(x / (0.69 * size)) ** 2 +
((y - 0.04 * size) / (0.43 * size)) ** 2;
if (ellipse > 1) continue;
const target = ellipse > 0.64 ? rim : interior;
target.push({
x,
y,
z: target === rim ? 0.025 * size : -0.035 * size,
sx: 0.108 * size,
sy: 0.108 * size,
sz: 0.085 * size
});
}
}
}
if (type === "ammonite") {
const turns = Math.PI * 4.2;
for (let i = 0; i < 105; i++) {
const t = (i / 104) * turns;
const radius = (0.07 + t * 0.028) * size;
const x = Math.cos(t) * radius;
const y = Math.sin(t) * radius;
rim.push({
x,
y,
z: 0.024 * size,
sx: 0.105 * size,
sy: 0.105 * size,
sz: 0.082 * size
});
}
for (let ix = -2; ix <= 2; ix++) {
for (let iy = -2; iy <= 2; iy++) {
if (ix * ix + iy * iy > 5) continue;
interior.push({
x: ix * 0.075 * size,
y: iy * 0.075 * size,
z: -0.025 * size,
sx: 0.078 * size,
sy: 0.078 * size,
sz: 0.07 * size
});
}
}
}
if (type === "brachiopod") {
const step = 0.095 * size;
for (let iy = -6; iy <= 6; iy++) {
const taper = 0.58 - Math.max(0, iy) * 0.025;
for (let ix = -6; ix <= 6; ix++) {
const x = ix * step;
const y = iy * step;
const ellipse =
(x / (taper * size)) ** 2 +
((y + 0.03 * size) / (0.5 * size)) ** 2;
if (ellipse > 1) continue;
const target = ellipse > 0.62 ? rim : interior;
target.push({
x,
y,
z: target === rim ? 0.018 * size : -0.038 * size,
sx: 0.096 * size,
sy: 0.096 * size,
sz: 0.078 * size
});
}
}
}
if (type === "gastropod") {
const turns = Math.PI * 4.5;
for (let i = 0; i < 112; i++) {
const t = (i / 111) * turns;
const radius = (0.06 + t * 0.027) * size;
const x = Math.cos(t) * radius * 0.72;
const y = Math.sin(t) * radius * 1.24 + 0.03 * size;
rim.push({
x,
y,
z: 0.024 * size,
sx: 0.098 * size,
sy: 0.098 * size,
sz: 0.08 * size
});
}
interior.push({
x: 0,
y: -0.04 * size,
z: -0.03 * size,
sx: 0.23 * size,
sy: 0.16 * size,
sz: 0.065 * size
});
}
return { rim, interior };
}
function createCornerFrame(parent, width, height) {
const frame = new THREE.Group();
const material = new THREE.MeshBasicMaterial({
color: 0x8de0c6,
transparent: true,
opacity: 0.95,
depthTest: false
});
const h = 0.13;
const t = 0.022;
const z = 0.105;
const x = width / 2;
const y = height / 2;
const pieces = [
[-x, y, h, t],
[-x + h / 2, y, t, h],
[x - h / 2, y, h, t],
[x, y, t, h],
[-x, -y, h, t],
[-x + h / 2, -y, t, h],
[x - h / 2, -y, h, t],
[x, -y, t, h]
];
pieces.forEach(([px, py, sx, sy]) => {
const mesh = new THREE.Mesh(cubeGeometry, material);
mesh.position.set(px, py, z);
mesh.scale.set(sx, sy, t);
mesh.renderOrder = 10;
frame.add(mesh);
});
frame.visible = false;
parent.add(frame);
return frame;
}
const fossilObjects = {};
const pickables = [];
finds.forEach((find) => {
const group = new THREE.Group();
group.position.copy(find.position);
group.rotation.z = find.rotation;
group.userData.findId = find.id;
const transforms = fossilTransforms(find.type, find.size);
const rimMaterial = new THREE.MeshStandardMaterial({
color: 0xd8c89d,
roughness: 0.88,
metalness: 0.02,
transparent: true,
opacity: 1
});
const interiorMaterial = new THREE.MeshStandardMaterial({
color: 0x604735,
roughness: 1,
metalness: 0,
transparent: true,
opacity: 1
});
const rimMesh = createCubeMesh(transforms.rim, rimMaterial, find.id);
const interiorMesh = createCubeMesh(
transforms.interior,
interiorMaterial,
find.id
);
group.add(interiorMesh, rimMesh);
scene.add(group);
const width =
find.type === "bivalve"
? 1.65 * find.size
: find.type === "brachiopod"
? 1.15 * find.size
: 1.22 * find.size;
const height =
find.type === "bivalve"
? 1.1 * find.size
: find.type === "gastropod"
? 1.5 * find.size
: 1.18 * find.size;
const frame = createCornerFrame(group, width, height);
fossilObjects[find.id] = {
group,
rimMesh,
interiorMesh,
rimMaterial,
interiorMaterial,
frame
};
pickables.push(rimMesh, interiorMesh);
});
// Stratigraphic datum and relationship tethers.
const datumGroup = new THREE.Group();
scene.add(datumGroup);
function makeDashedLine(points, color, opacity = 0.62) {
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineDashedMaterial({
color,
dashSize: 0.12,
gapSize: 0.09,
transparent: true,
opacity
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
datumGroup.add(line);
return line;
}
function textSprite(text, accent = "#8de0c6") {
const c = document.createElement("canvas");
c.width = 512;
c.height = 112;
const ctx = c.getContext("2d");
ctx.fillStyle = "rgba(5, 16, 18, 0.88)";
ctx.fillRect(0, 0, c.width, c.height);
ctx.strokeStyle = accent;
ctx.lineWidth = 5;
ctx.strokeRect(3, 3, c.width - 6, c.height - 6);
ctx.fillStyle = accent;
ctx.font = "600 31px monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, c.width / 2, c.height / 2);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false
})
);
sprite.scale.set(1.48, 0.325, 1);
sprite.renderOrder = 8;
return sprite;
}
const datumX = 2.48;
const datumZ = 2.13;
layers.forEach((layer, index) => {
const centerY = baseY + index * layerHeight + layerHeight / 2;
makeDashedLine(
[
new THREE.Vector3(datumX, centerY - layerHeight / 2, datumZ),
new THREE.Vector3(datumX, centerY + layerHeight / 2, datumZ)
],
layer.color,
0.82
);
const sprite = textSprite(`${layer.id} ${layer.short}`, layer.css);
sprite.position.set(3.22, centerY, datumZ + 0.04);
datumGroup.add(sprite);
});
const relationshipLines = {};
finds.forEach((find) => {
const layer = layerById[find.layerId];
const line = makeDashedLine(
[
new THREE.Vector3(find.position.x + 0.25, find.position.y, find.position.z),
new THREE.Vector3(datumX, find.position.y, find.position.z)
],
layer.color,
0.58
);
relationshipLines[find.id] = line;
const marker = new THREE.Mesh(
cubeGeometry,
new THREE.MeshBasicMaterial({ color: layer.color })
);
marker.position.copy(find.position);
marker.position.z += 0.12;
marker.scale.setScalar(0.09);
datumGroup.add(marker);
});
// Physical scale bar on the open side of the tray.
const scaleGroup = new THREE.Group();
const scaleLight = new THREE.MeshStandardMaterial({
color: 0xd4ded7,
roughness: 0.8
});
const scaleDark = new THREE.MeshStandardMaterial({
color: 0x26383a,
roughness: 0.8
});
for (let i = 0; i < 10; i++) {
const segment = new THREE.Mesh(
cubeGeometry,
i % 2 === 0 ? scaleLight : scaleDark
);
segment.position.set(3.04 + i * 0.16, 0.21, 3.25);
segment.scale.set(0.16, 0.06, 0.16);
segment.castShadow = true;
scaleGroup.add(segment);
}
const scaleLabel = textSprite("0 1 m", "#aac2bd");
scaleLabel.position.set(3.84, 0.58, 3.25);
scaleLabel.scale.set(1.2, 0.265, 1);
scaleGroup.add(scaleLabel);
scene.add(scaleGroup);
// UI generation.
const findList = document.getElementById("findList");
const layerGrid = document.getElementById("layerGrid");
finds.forEach((find) => {
const layer = layerById[find.layerId];
const button = document.createElement("button");
button.className = "find-row";
button.dataset.id = find.id;
button.innerHTML = `
<span class="find-id">${find.id}</span>
<span>
<span class="find-name">${find.name}</span>
<span class="find-layer">${layer.id} · ${layer.name}</span>
</span>
<span class="layer-swatch" style="background:${layer.css};color:${layer.css}"></span>
`;
button.addEventListener("click", () => selectFind(find.id));
findList.appendChild(button);
});
const allLayerButton = document.createElement("button");
allLayerButton.className = "layer-button active";
allLayerButton.dataset.layer = "all";
allLayerButton.innerHTML = `
<span class="layer-swatch" style="background:#8de0c6;color:#8de0c6"></span>
<span>
<span class="layer-code">FULL BLOCK</span>
<span class="layer-name">All context</span>
</span>
`;
allLayerButton.addEventListener("click", () => focusLayer("all"));
layerGrid.appendChild(allLayerButton);
layers.forEach((layer) => {
const button = document.createElement("button");
button.className = "layer-button";
button.dataset.layer = layer.id;
button.innerHTML = `
<span class="layer-swatch" style="background:${layer.css};color:${layer.css}"></span>
<span>
<span class="layer-code">${layer.id}</span>
<span class="layer-name">${layer.name}</span>
</span>
`;
button.addEventListener("click", () => focusLayer(layer.id));
layerGrid.appendChild(button);
});
// Screen-space labels and leader lines.
const labelObjects = {};
finds.forEach((find) => {
const layer = layerById[find.layerId];
const line = document.createElementNS(
"http://www.w3.org/2000/svg",
"line"
);
line.setAttribute("stroke", layer.css);
line.setAttribute("stroke-width", "1");
line.setAttribute("stroke-opacity", "0.62");
leadersLayer.appendChild(line);
const pin = document.createElement("button");
pin.className = "pin";
pin.type = "button";
pin.innerHTML = `
<span class="pin-id">${find.id} / ${layer.id}</span>
<span class="pin-name">${find.name}</span>
<span class="pin-layer">${layer.short} · ${layer.depth}</span>
`;
pin.addEventListener("click", () => selectFind(find.id));
labelsLayer.appendChild(pin);
labelObjects[find.id] = { line, pin };
});
function updateInspectionPanel(find) {
const layer = layerById[find.layerId];
document.getElementById("inspectTitle").textContent =
`${find.id} / ${find.name}`;
document.getElementById("inspectCode").textContent = find.code;
document.getElementById("inspectDepth").textContent =
`DATUM ${layer.depth}`;
document.getElementById("readouts").innerHTML = `
<div><span>Taxonomic group</span><b>${find.taxon}</b></div>
<div><span>Matrix</span><b>${layer.name}</b></div>
<div><span>Orientation</span><b>${find.orientation}</b></div>
<div><span>Preservation</span><b>${find.preservation}</b></div>
<div><span>Sequence</span><b>${layer.id} · ${layer.age}</b></div>
<div><span>Registration</span><b>${find.code}</b></div>
`;
}
function applyContext() {
layers.forEach((layer) => {
const mesh = layerMeshes[layer.id];
const active =
state.focusedLayer === "all" ||
state.focusedLayer === layer.id;
const opacity = state.useVeil && !active ? 0.16 : 1;
mesh.material.opacity = opacity;
mesh.material.depthWrite = opacity > 0.9;
mesh.material.needsUpdate = true;
});
finds.forEach((find) => {
const fossil = fossilObjects[find.id];
const active =
state.focusedLayer === "all" ||
state.focusedLayer === find.layerId;
const opacity = state.useVeil && !active ? 0.17 : 1;
fossil.rimMaterial.opacity = opacity;
fossil.interiorMaterial.opacity = opacity;
fossil.rimMaterial.depthWrite = opacity > 0.9;
fossil.interiorMaterial.depthWrite = opacity > 0.9;
fossil.rimMaterial.needsUpdate = true;
fossil.interiorMaterial.needsUpdate = true;
});
document.querySelectorAll(".layer-button").forEach((button) => {
button.classList.toggle("active", button.dataset.layer === state.focusedLayer);
});
}
function selectFind(id) {
state.selectedId = id;
const find = findById[id];
document.querySelectorAll(".find-row").forEach((row) => {
row.classList.toggle("active", row.dataset.id === id);
});
finds.forEach((item) => {
const fossil = fossilObjects[item.id];
const selected = item.id === id;
fossil.frame.visible = selected;
fossil.rimMaterial.emissive.setHex(selected ? 0x1a4b42 : 0x000000);
fossil.rimMaterial.emissiveIntensity = selected ? 0.58 : 0;
fossil.rimMaterial.needsUpdate = true;
const label = labelObjects[item.id];
label.pin.classList.toggle("selected", selected);
label.line.setAttribute("stroke-width", selected ? "2.2" : "1");
});
updateInspectionPanel(find);
}
function focusLayer(id) {
state.focusedLayer = id;
applyContext();
}
document.getElementById("labelsToggle").addEventListener("change", (event) => {
state.showLabels = event.target.checked;
labelsLayer.classList.toggle("hidden", !state.showLabels);
leadersLayer.classList.toggle("hidden", !state.showLabels);
});
document.getElementById("datumToggle").addEventListener("change", (event) => {
state.showDatum = event.target.checked;
datumGroup.visible = state.showDatum;
});
document.getElementById("veilToggle").addEventListener("change", (event) => {
state.useVeil = event.target.checked;
applyContext();
});
// Custom camera controls: camera transform only; no specimen transforms change.
const controls = {
target: new THREE.Vector3(-0.65, 1.95, 0.15),
desiredTarget: new THREE.Vector3(-0.65, 1.95, 0.15),
radius: 14.2,
desiredRadius: 14.2,
theta: 0.57,
desiredTheta: 0.57,
phi: 1.04,
desiredPhi: 1.04
};
function resetView() {
controls.desiredTarget.set(-0.65, 1.95, 0.15);
controls.desiredRadius = 14.2;
controls.desiredTheta = 0.57;
controls.desiredPhi = 1.04;
}
document.getElementById("resetView").addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
document.getElementById("focusSelected").addEventListener("click", () => {
const find = findById[state.selectedId];
controls.desiredTarget.copy(find.position);
controls.desiredRadius = 7.6;
controls.desiredTheta = 0.43;
controls.desiredPhi = 1.08;
});
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
const pointerState = {
down: false,
button: 0,
x: 0,
y: 0,
startX: 0,
startY: 0,
moved: false
};
function setPointer(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;
}
function raycastFinds(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickables, false);
return hits.length ? hits[0].object.userData.findId : null;
}
canvas.addEventListener("pointerdown", (event) => {
pointerState.down = true;
pointerState.button = event.button;
pointerState.x = event.clientX;
pointerState.y = event.clientY;
pointerState.startX = event.clientX;
pointerState.startY = event.clientY;
pointerState.moved = false;
canvas.setPointerCapture(event.pointerId);
tooltip.style.display = "none";
});
canvas.addEventListener("pointermove", (event) => {
if (pointerState.down) {
const dx = event.clientX - pointerState.x;
const dy = event.clientY - pointerState.y;
pointerState.x = event.clientX;
pointerState.y = event.clientY;
if (
Math.hypot(
event.clientX - pointerState.startX,
event.clientY - pointerState.startY
) > 4
) {
pointerState.moved = true;
}
if (pointerState.button === 2 || event.shiftKey) {
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrixWorld,
0
);
const up = new THREE.Vector3().setFromMatrixColumn(
camera.matrixWorld,
1
);
const scale = controls.radius * 0.0014;
controls.desiredTarget.addScaledVector(right, -dx * scale);
controls.desiredTarget.addScaledVector(up, dy * scale);
} else {
controls.desiredTheta -= dx * 0.006;
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi - dy * 0.005,
0.48,
1.42
);
}
return;
}
const hit = raycastFinds(event);
canvas.style.cursor = hit ? "pointer" : "grab";
if (hit) {
const find = findById[hit];
const layer = layerById[find.layerId];
tooltip.textContent = `${find.id} · ${find.name} · ${layer.id}`;
tooltip.style.display = "block";
tooltip.style.left = `${event.clientX + 13}px`;
tooltip.style.top = `${event.clientY + 13}px`;
} else {
tooltip.style.display = "none";
}
});
canvas.addEventListener("pointerup", (event) => {
if (!pointerState.moved && pointerState.button === 0) {
const hit = raycastFinds(event);
if (hit) selectFind(hit);
}
pointerState.down = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
pointerState.down = false;
});
canvas.addEventListener("pointerleave", () => {
tooltip.style.display = "none";
});
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.desiredRadius = THREE.MathUtils.clamp(
controls.desiredRadius * Math.exp(event.deltaY * 0.001),
5.4,
24
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetView();
if (event.key >= "1" && event.key <= "4") {
selectFind(`F-0${event.key}`);
}
if (event.key.toLowerCase() === "l") {
const toggle = document.getElementById("labelsToggle");
toggle.checked = !toggle.checked;
toggle.dispatchEvent(new Event("change"));
}
});
const projected = new THREE.Vector3();
function updateLabels() {
finds.forEach((find) => {
const label = labelObjects[find.id];
projected.copy(find.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
label.pin.style.display = visible ? "block" : "none";
label.line.style.display = visible ? "block" : "none";
if (!visible) return;
const width = window.innerWidth;
const height = window.innerHeight;
const px = (projected.x * 0.5 + 0.5) * width;
const py = (-projected.y * 0.5 + 0.5) * height;
let endX = px + find.offset[0];
let endY = py + find.offset[1];
const panelGuard = width > 850 ? width - 335 : 12;
endX = THREE.MathUtils.clamp(endX, 72, Math.max(72, panelGuard));
endY = THREE.MathUtils.clamp(endY, 92, height - 75);
label.pin.style.left = `${endX}px`;
label.pin.style.top = `${endY}px`;
label.line.setAttribute("x1", px);
label.line.setAttribute("y1", py);
label.line.setAttribute("x2", endX);
label.line.setAttribute("y2", endY);
const dimmed =
state.focusedLayer !== "all" &&
state.focusedLayer !== find.layerId;
label.pin.style.opacity = dimmed && state.useVeil ? "0.36" : "1";
label.line.setAttribute(
"stroke-opacity",
dimmed && state.useVeil ? "0.18" : "0.68"
);
});
}
function resize() {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const damping = 1 - Math.exp(-dt * 8);
controls.target.lerp(controls.desiredTarget, damping);
controls.radius = THREE.MathUtils.lerp(
controls.radius,
controls.desiredRadius,
damping
);
controls.theta = THREE.MathUtils.lerp(
controls.theta,
controls.desiredTheta,
damping
);
controls.phi = THREE.MathUtils.lerp(
controls.phi,
controls.desiredPhi,
damping
);
const spherical = new THREE.Spherical(
controls.radius,
controls.phi,
controls.theta
);
camera.position.setFromSpherical(spherical).add(controls.target);
camera.lookAt(controls.target);
const selectedFrame = fossilObjects[state.selectedId]?.frame;
if (selectedFrame) {
selectedFrame.children.forEach((piece, index) => {
piece.material.opacity = 0.72 + Math.sin(clock.elapsedTime * 2.4 + index) * 0.18;
});
}
updateLabels();
renderer.render(scene, camera);
}
selectFind("F-02");
applyContext();
animate();
</script>
</body>
</html>
```