Prompt specification
Build or customize the Three.js 3D scene "Evidence-Aware Reconstruction Exhibit" 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: Evidence-Aware Reconstruction Exhibit
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/evidence-aware-reconstruction-exhibit-x3312
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts museum objects, provenance, and interpretation. Create an exhibit with detachable reconstructed pieces and confidence labels. Visitors can toggle known remains and proposed additions, retaining an explicit boundary between evidence and interpretation. Low-poly.
Working Three.js Starter (evidence-aware-reconstruction-exhibit-x3312):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Between Evidence and Interpretation — Museum Study</title>
<style>
:root {
--paper: #ede9df;
--paper-dark: #ded8cb;
--ink: #252723;
--muted: #6d6b63;
--line: rgba(37, 39, 35, 0.18);
--evidence: #bf6845;
--evidence-light: #e7c1a9;
--interpretation: #36b9bd;
--interpretation-dark: #13777c;
--panel: rgba(246, 243, 235, 0.94);
--shadow: 0 18px 55px rgba(39, 35, 27, 0.13);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
#scene:active {
cursor: grabbing;
}
.masthead {
position: fixed;
z-index: 5;
top: 26px;
left: 30px;
width: min(430px, calc(100vw - 440px));
pointer-events: none;
}
.eyebrow {
margin: 0 0 9px;
color: var(--evidence);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
max-width: 400px;
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(29px, 3.2vw, 48px);
font-weight: 400;
line-height: 0.98;
letter-spacing: -0.035em;
}
.dek {
max-width: 385px;
margin: 13px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.boundary {
position: fixed;
z-index: 5;
top: 27px;
left: 50%;
width: min(480px, 37vw);
padding: 11px 14px;
transform: translateX(-50%);
border: 1px solid var(--line);
border-radius: 3px;
background: rgba(246, 243, 235, 0.82);
box-shadow: 0 8px 30px rgba(39, 35, 27, 0.06);
backdrop-filter: blur(12px);
pointer-events: none;
}
.boundary-title {
margin-bottom: 7px;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.boundary-row {
display: flex;
gap: 18px;
font-size: 10px;
line-height: 1.35;
}
.boundary-key {
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.boundary-key i {
display: inline-block;
width: 18px;
height: 8px;
}
.boundary-key.evidence i {
background: var(--evidence);
}
.boundary-key.interpretation i {
border: 1px dashed var(--interpretation-dark);
background: rgba(54, 185, 189, 0.13);
}
.boundary-note {
margin-top: 8px;
color: var(--interpretation-dark);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.04em;
}
.panel {
position: fixed;
z-index: 8;
top: 24px;
right: 24px;
width: 338px;
max-height: calc(100vh - 48px);
overflow: auto;
padding: 19px;
border: 1px solid rgba(44, 42, 36, 0.16);
border-radius: 4px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(16px);
transition:
transform 250ms ease,
opacity 250ms ease;
scrollbar-width: thin;
scrollbar-color: #bdb7aa transparent;
}
body.panel-collapsed .panel {
transform: translateX(calc(100% + 30px));
opacity: 0;
pointer-events: none;
}
.panel-toggle {
position: fixed;
z-index: 10;
top: 24px;
right: 24px;
display: none;
width: 38px;
height: 38px;
padding: 0;
border: 1px solid var(--line);
border-radius: 3px;
background: var(--panel);
cursor: pointer;
box-shadow: var(--shadow);
}
.panel-toggle span,
.panel-toggle span::before,
.panel-toggle span::after {
display: block;
width: 17px;
height: 1px;
margin: auto;
background: var(--ink);
content: "";
}
.panel-toggle span::before {
transform: translateY(-6px);
}
.panel-toggle span::after {
transform: translateY(5px);
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 15px;
}
.panel-heading h2 {
margin: 0;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.panel-heading small {
color: var(--muted);
font-size: 9px;
}
.layer {
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
width: 100%;
margin: 0 0 8px;
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 3px;
background: rgba(255, 255, 255, 0.26);
cursor: pointer;
text-align: left;
transition:
background 150ms ease,
border-color 150ms ease;
}
.layer strong {
display: block;
margin-bottom: 3px;
font-size: 11px;
}
.layer small {
display: block;
color: var(--muted);
font-size: 9px;
line-height: 1.35;
}
.layer .switch {
position: relative;
width: 30px;
height: 17px;
border: 1px solid #aaa69c;
border-radius: 20px;
background: #cbc6bb;
transition: 150ms ease;
}
.layer .switch::after {
position: absolute;
top: 3px;
left: 3px;
width: 9px;
height: 9px;
border-radius: 50%;
background: white;
content: "";
transition: 150ms ease;
}
.layer.on.evidence {
border-color: rgba(191, 104, 69, 0.45);
background: rgba(191, 104, 69, 0.08);
}
.layer.on.evidence .switch {
border-color: var(--evidence);
background: var(--evidence);
}
.layer.on.interpretation {
border-color: rgba(19, 119, 124, 0.4);
background: rgba(54, 185, 189, 0.08);
}
.layer.on.interpretation .switch {
border-color: var(--interpretation-dark);
background: var(--interpretation-dark);
}
.layer.on .switch::after {
transform: translateX(13px);
}
.section {
margin-top: 18px;
padding-top: 16px;
border-top: 1px solid var(--line);
}
.section-title {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.section-title span {
color: var(--muted);
font-weight: 500;
letter-spacing: 0;
text-transform: none;
}
.evidence-row,
.piece-row {
position: relative;
display: grid;
grid-template-columns: 16px 1fr;
align-items: start;
gap: 8px;
padding: 8px 7px;
border-radius: 3px;
transition: background 150ms ease;
}
.evidence-row:hover,
.piece-row:hover,
.piece-row.selected {
background: rgba(48, 47, 42, 0.055);
}
.evidence-row input,
.piece-row input {
width: 13px;
height: 13px;
margin: 1px 0 0;
accent-color: var(--evidence);
}
.piece-row input {
accent-color: var(--interpretation-dark);
}
.row-copy {
min-width: 0;
}
.row-copy strong {
display: block;
font-size: 10px;
font-weight: 700;
}
.row-copy small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8.5px;
line-height: 1.35;
}
.piece-select {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 0;
border: 0;
background: transparent;
cursor: pointer;
text-align: left;
}
.confidence {
display: inline-flex;
min-width: 39px;
padding: 3px 5px;
border: 1px solid rgba(19, 119, 124, 0.25);
border-radius: 20px;
color: var(--interpretation-dark);
font-size: 9px;
font-weight: 800;
justify-content: center;
}
.meter {
height: 2px;
margin-top: 6px;
overflow: hidden;
background: rgba(19, 119, 124, 0.12);
}
.meter i {
display: block;
height: 100%;
background: var(--interpretation-dark);
}
.selected-card {
margin-top: 12px;
padding: 12px;
border: 1px solid rgba(19, 119, 124, 0.25);
background: rgba(54, 185, 189, 0.07);
}
.selected-card .selected-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.selected-card h3 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 18px;
font-weight: 400;
}
.selected-card p {
margin: 8px 0 11px;
color: var(--muted);
font-size: 9px;
line-height: 1.5;
}
.status {
display: inline-block;
margin-bottom: 8px;
color: var(--interpretation-dark);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.detach-button {
width: 100%;
padding: 9px 10px;
border: 1px solid var(--interpretation-dark);
border-radius: 2px;
background: var(--interpretation-dark);
color: white;
cursor: pointer;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.detach-button:hover {
background: #0d666a;
}
.method-note {
margin: 10px 0 0;
color: var(--muted);
font-size: 8.5px;
line-height: 1.55;
}
.method-note strong {
color: var(--ink);
}
.provenance {
position: fixed;
z-index: 5;
left: 30px;
bottom: 25px;
width: min(820px, calc(100vw - 430px));
padding: 15px 17px 14px;
border: 1px solid var(--line);
border-radius: 3px;
background: rgba(246, 243, 235, 0.9);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
}
.provenance-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.provenance-heading h2 {
margin: 0;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.provenance-heading span {
color: var(--muted);
font-size: 8.5px;
}
.timeline {
position: relative;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
}
.timeline::before {
position: absolute;
top: 5px;
right: 0;
left: 0;
height: 1px;
background: var(--evidence);
content: "";
opacity: 0.55;
}
.event {
position: relative;
padding-left: 13px;
}
.event::before {
position: absolute;
top: 1px;
left: 0;
width: 9px;
height: 9px;
border: 2px solid var(--evidence);
border-radius: 50%;
background: var(--paper);
content: "";
}
.event time {
display: block;
margin-bottom: 3px;
color: var(--evidence);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.08em;
}
.event strong {
display: block;
font-size: 9px;
}
.event small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8px;
line-height: 1.35;
}
.open-question {
grid-column: 1 / -1;
margin-top: 1px;
padding: 8px 10px 8px 13px;
border-left: 2px dashed var(--interpretation-dark);
background: rgba(54, 185, 189, 0.07);
}
.open-question strong {
color: var(--interpretation-dark);
}
.hint {
position: fixed;
z-index: 5;
right: 382px;
bottom: 28px;
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
font-size: 9px;
pointer-events: none;
}
.hint button {
padding: 7px 9px;
border: 1px solid var(--line);
border-radius: 2px;
background: rgba(246, 243, 235, 0.88);
color: var(--ink);
cursor: pointer;
font-size: 8px;
pointer-events: auto;
}
.scene-labels {
position: fixed;
z-index: 4;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.scene-label {
position: absolute;
display: flex;
align-items: center;
gap: 6px;
padding: 5px 7px;
transform: translate(-50%, -50%);
border: 1px solid rgba(19, 119, 124, 0.42);
border-radius: 2px;
background: rgba(239, 246, 243, 0.91);
color: var(--interpretation-dark);
box-shadow: 0 5px 18px rgba(39, 35, 27, 0.1);
font-size: 8px;
pointer-events: auto;
cursor: pointer;
white-space: nowrap;
}
.scene-label span {
font-weight: 850;
letter-spacing: 0.06em;
}
.scene-label strong {
padding-left: 6px;
border-left: 1px solid rgba(19, 119, 124, 0.25);
font-size: 10px;
}
.scene-label.selected {
border-color: var(--interpretation-dark);
box-shadow:
0 0 0 2px rgba(54, 185, 189, 0.13),
0 6px 20px rgba(39, 35, 27, 0.12);
}
.scene-label.evidence {
border-color: rgba(191, 104, 69, 0.5);
background: rgba(246, 238, 229, 0.93);
color: var(--evidence);
cursor: default;
}
.scene-label.evidence::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--evidence);
content: "";
}
.toast {
position: fixed;
z-index: 12;
top: 20px;
left: 50%;
padding: 9px 13px;
transform: translate(-50%, -15px);
border-radius: 2px;
background: var(--ink);
color: white;
opacity: 0;
font-size: 9px;
pointer-events: none;
transition: 180ms ease;
}
.toast.show {
transform: translate(-50%, 0);
opacity: 1;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
}
@media (max-width: 1050px) {
.boundary {
top: 25px;
left: 430px;
width: 310px;
transform: none;
}
.boundary-row {
flex-direction: column;
gap: 5px;
}
.provenance {
width: calc(100vw - 400px);
}
.hint {
display: none;
}
}
@media (max-width: 760px) {
.masthead {
top: 14px;
left: 14px;
width: calc(100vw - 78px);
}
.masthead .dek {
display: none;
}
h1 {
font-size: 31px;
}
.boundary {
top: 112px;
left: 14px;
width: calc(100vw - 28px);
}
.boundary-row {
flex-direction: row;
gap: 10px;
}
.boundary-note {
font-size: 8px;
}
.panel-toggle {
display: block;
}
.panel {
top: auto;
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
max-height: 48vh;
padding: 15px;
}
body.panel-collapsed .panel {
transform: translateY(calc(100% + 20px));
}
.provenance {
display: none;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive low-poly museum reconstruction. Drag to orbit, scroll to zoom, and select cyan proposed pieces."
></canvas>
<header class="masthead">
<p class="eyebrow">Museum Study 04 · Object MR-68.14</p>
<h1>Between Evidence<br />and Interpretation</h1>
<p class="dek">
A ceramic vessel reconstructed from four excavated sherds. Earthen-colored
fragments are documented evidence; translucent cyan forms are proposals.
</p>
</header>
<section class="boundary" aria-label="Evidence and interpretation legend">
<div class="boundary-title">A visible evidentiary boundary</div>
<div class="boundary-row">
<div class="boundary-key evidence"><i></i>Solid ochre · known remains</div>
<div class="boundary-key interpretation"><i></i>Dashed cyan · proposed additions</div>
</div>
<div class="boundary-note">
Cyan geometry is hypothesis, not recovered material.
</div>
</section>
<button class="panel-toggle" id="panelToggle" aria-label="Toggle exhibit controls">
<span></span>
</button>
<aside class="panel" id="controlPanel" aria-label="Exhibit controls">
<div class="panel-heading">
<h2>Exhibit Layers</h2>
<small>Study mode</small>
</div>
<button
class="layer evidence on"
id="evidenceLayer"
aria-pressed="true"
type="button"
>
<span>
<strong>Known remains</strong>
<small>Four documented ceramic sherds</small>
</span>
<span class="switch" aria-hidden="true"></span>
</button>
<button
class="layer interpretation on"
id="interpretationLayer"
aria-pressed="true"
type="button"
>
<span>
<strong>Proposed additions</strong>
<small>Four confidence-rated reconstruction segments</small>
</span>
<span class="switch" aria-hidden="true"></span>
</button>
<section class="section">
<div class="section-title">
Evidence register <span>Documented fragments</span>
</div>
<div id="evidenceList"></div>
</section>
<section class="section">
<div class="section-title">
Reconstruction pieces <span>Interpretive confidence</span>
</div>
<div id="pieceList"></div>
<div class="selected-card" id="selectedCard">
<div class="selected-top">
<h3 id="selectedTitle">Proposed base</h3>
<span class="confidence" id="selectedConfidence">78%</span>
</div>
<span class="status" id="selectedStatus">Attached to reconstruction</span>
<p id="selectedNote"></p>
<button class="detach-button" id="detachButton" type="button">
Detach for study
</button>
</div>
<p class="method-note">
<strong>How to read confidence:</strong> percentages summarize support from
profile continuity, joins, and surface comparison among interpretive
models. They are not probabilities of ownership or authenticity.
</p>
</section>
</aside>
<section class="provenance" aria-label="Provenance and custody record">
<div class="provenance-heading">
<h2>Provenance / custody record</h2>
<span>Documented chain separated from unresolved attribution</span>
</div>
<div class="timeline">
<div class="event">
<time>1968</time>
<strong>Excavation record</strong>
<small>Trench C, coastal survey. Field notebook and site photograph.</small>
</div>
<div class="event">
<time>1968–1994</time>
<strong>Municipal collection</strong>
<small>Accession MR-68.14. Transfer ledger and conservation card.</small>
</div>
<div class="event">
<time>1994–Now</time>
<strong>Study collection</strong>
<small>Current museum repository. Re-catalogued for study.</small>
</div>
<div class="event open-question">
<time>Open question · interpretation</time>
<strong>Place of manufacture remains unresolved.</strong>
<small>
A Levantine coastal workshop is one proposed model; no production
center has been established from the available record.
</small>
</div>
</div>
</section>
<div class="hint">
<span>Drag to orbit · Scroll to zoom · Select a cyan piece</span>
<button id="resetView" type="button">Reset view</button>
</div>
<div class="scene-labels" id="sceneLabels"></div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<div class="sr-only" id="liveStatus" aria-live="polite"></div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Renderer, scene, camera, and direct camera controls
// ---------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
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.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xede9df);
scene.fog = new THREE.Fog(0xede9df, 12, 25);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
60
);
const cameraState = {
theta: -0.42,
phi: 1.08,
radius: 7.35,
target: new THREE.Vector3(0, 1.12, 0)
};
const defaultCamera = { ...cameraState, target: cameraState.target.clone() };
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
updateCamera();
let dragging = false;
let dragMoved = false;
let pointerStartX = 0;
let pointerStartY = 0;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
dragMoved = false;
pointerStartX = event.clientX;
pointerStartY = event.clientY;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.focus({ preventScroll: true });
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (
Math.abs(event.clientX - pointerStartX) +
Math.abs(event.clientY - pointerStartY) >
5
) {
dragMoved = true;
}
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.55,
1.43
);
});
canvas.addEventListener("pointerup", (event) => {
dragging = false;
if (!dragMoved) {
const hit = pickPiece(event);
if (hit) selectPart(hit, true);
}
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.006,
4.6,
11
);
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
const step = 0.08;
let handled = true;
switch (event.key) {
case "ArrowLeft":
cameraState.theta += step;
break;
case "ArrowRight":
cameraState.theta -= step;
break;
case "ArrowUp":
cameraState.phi = Math.max(0.55, cameraState.phi - step);
break;
case "ArrowDown":
cameraState.phi = Math.min(1.43, cameraState.phi + step);
break;
case "+":
case "=":
cameraState.radius = Math.max(4.6, cameraState.radius - 0.4);
break;
case "-":
cameraState.radius = Math.min(11, cameraState.radius + 0.4);
break;
case "0":
resetView();
break;
default:
handled = false;
}
if (handled) event.preventDefault();
});
function resetView() {
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
cameraState.radius = defaultCamera.radius;
cameraState.target.copy(defaultCamera.target);
notify("View reset");
}
document.querySelector("#resetView").addEventListener("click", resetView);
// ---------------------------------------------------------------------
// Lighting and gallery architecture
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff8e9, 0x8b8579, 2.25));
const keyLight = new THREE.DirectionalLight(0xfff2d8, 3.15);
keyLight.position.set(-3.8, 7.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.bias = -0.0008;
scene.add(keyLight);
const fillLight = new THREE.PointLight(0x9fe5df, 10, 9, 2);
fillLight.position.set(4.3, 3.4, 3.8);
scene.add(fillLight);
const warmLight = new THREE.PointLight(0xffc29f, 7, 8, 2);
warmLight.position.set(-4, 2.3, 2.6);
scene.add(warmLight);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0xe7e1d5,
roughness: 0.96,
metalness: 0
});
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 32),
floorMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0xeeeae1,
roughness: 1
});
const backWall = new THREE.Mesh(
new THREE.PlaneGeometry(34, 12),
wallMaterial
);
backWall.position.set(0, 5.8, -5.25);
backWall.receiveShadow = true;
scene.add(backWall);
const leftWall = new THREE.Mesh(
new THREE.PlaneGeometry(22, 12),
wallMaterial
);
leftWall.position.set(-10.8, 5.8, 4);
leftWall.rotation.y = Math.PI / 2;
scene.add(leftWall);
const plinthMaterial = new THREE.MeshStandardMaterial({
color: 0xd8d1c4,
roughness: 0.78
});
const plinthBase = new THREE.Mesh(
new THREE.BoxGeometry(3.55, 0.26, 2.6),
plinthMaterial
);
plinthBase.position.y = 0.13;
plinthBase.castShadow = true;
plinthBase.receiveShadow = true;
scene.add(plinthBase);
const plinthTop = new THREE.Mesh(
new THREE.BoxGeometry(3.28, 0.16, 2.3),
new THREE.MeshStandardMaterial({
color: 0xf0ece3,
roughness: 0.83
})
);
plinthTop.position.y = 0.34;
plinthTop.castShadow = true;
plinthTop.receiveShadow = true;
scene.add(plinthTop);
const turntable = new THREE.Mesh(
new THREE.CylinderGeometry(1.28, 1.34, 0.065, 32),
new THREE.MeshStandardMaterial({
color: 0xc9c2b5,
roughness: 0.9
})
);
turntable.position.y = 0.45;
turntable.receiveShadow = true;
scene.add(turntable);
const exhibit = new THREE.Group();
exhibit.position.y = 0.49;
scene.add(exhibit);
const evidenceGroup = new THREE.Group();
const interpretationGroup = new THREE.Group();
exhibit.add(evidenceGroup, interpretationGroup);
// A thin cyan ring makes the proposed reconstruction boundary visible
// even when all proposed pieces are hidden.
const boundaryRing = new THREE.Mesh(
new THREE.TorusGeometry(1.49, 0.012, 3, 64),
new THREE.MeshBasicMaterial({
color: 0x36b9bd,
transparent: true,
opacity: 0.32,
depthWrite: false
})
);
boundaryRing.rotation.x = Math.PI / 2;
boundaryRing.position.y = 0.02;
exhibit.add(boundaryRing);
const floatingPoint = new THREE.Mesh(
new THREE.CylinderGeometry(0.66, 0.74, 0.07, 12),
new THREE.MeshStandardMaterial({
color: 0xded9cf,
roughness: 0.88
})
);
floatingPoint.position.set(1.63, 0.075, 1.18);
floatingPoint.receiveShadow = true;
scene.add(floatingPoint);
// ---------------------------------------------------------------------
// Vessel profile and geometry helpers
// ---------------------------------------------------------------------
const vesselProfile = [
{ y: 0.0, r: 0.28 },
{ y: 0.08, r: 0.4 },
{ y: 0.25, r: 0.49 },
{ y: 0.45, r: 0.57 },
{ y: 0.85, r: 0.66 },
{ y: 1.15, r: 0.65 },
{ y: 1.32, r: 0.61 },
{ y: 1.42, r: 0.52 },
{ y: 1.63, r: 0.31 },
{ y: 1.77, r: 0.25 },
{ y: 1.92, r: 0.31 }
];
function profileRadius(y) {
if (y <= vesselProfile[0].y) return vesselProfile[0].r;
if (y >= vesselProfile[vesselProfile.length - 1].y) {
return vesselProfile[vesselProfile.length - 1].r;
}
for (let i = 0; i < vesselProfile.length - 1; i++) {
const a = vesselProfile[i];
const b = vesselProfile[i + 1];
if (y >= a.y && y <= b.y) {
const t = (y - a.y) / (b.y - a.y);
return THREE.MathUtils.lerp(a.r, b.r, t);
}
}
return 0.5;
}
function createRevolvedPart(
profile,
{
radialSegments = 12,
radialOffset = 0.02,
thickness = 0.025
} = {}
) {
const positions = [];
const indices = [];
const stride = radialSegments + 1;
function addSurface(isInner) {
for (const point of profile) {
const radius =
point.r + radialOffset - (isInner ? thickness : 0);
for (let j = 0; j <= radialSegments; j++) {
const theta = (j / radialSegments) * Math.PI * 2;
positions.push(
Math.sin(theta) * radius,
point.y,
Math.cos(theta) * radius
);
}
}
}
addSurface(false);
addSurface(true);
const innerOffset = profile.length * stride;
for (let i = 0; i < profile.length - 1; i++) {
for (let j = 0; j < radialSegments; j++) {
const a = i * stride + j;
const b = (i + 1) * stride + j;
const c = (i + 1) * stride + j + 1;
const d = i * stride + j + 1;
indices.push(a, b, d, b, c, d);
const ia = innerOffset + a;
const ib = innerOffset + b;
const ic = innerOffset + c;
const id = innerOffset + d;
indices.push(ia, id, ib, ib, id, ic);
}
}
// Top and bottom rims.
for (let j = 0; j < radialSegments; j++) {
const b0 = j;
const b1 = j + 1;
const t0 = (profile.length - 1) * stride + j;
const t1 = (profile.length - 1) * stride + j + 1;
indices.push(
b0,
innerOffset + b0,
b1,
b1,
innerOffset + b0,
innerOffset + b1
);
indices.push(
t0,
t1,
innerOffset + t0,
t1,
innerOffset + t1,
innerOffset + t0
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
function deterministicNoise(index, seed) {
const value = Math.sin((index + 1) * 91.17 + seed * 17.31) * 43758.5453;
return (value - Math.floor(value)) * 2 - 1;
}
function createShardGeometry(
centerTheta,
centerY,
thetaSpan,
heightSpan,
seed
) {
const polygon = [
[-0.43, -0.18],
[-0.18, -0.3],
[0.36, -0.16],
[0.49, 0.12],
[0.12, 0.28],
[-0.34, 0.14]
];
const positions = [
Math.sin(centerTheta) * (profileRadius(centerY) + 0.052),
centerY,
Math.cos(centerTheta) * (profileRadius(centerY) + 0.052)
];
polygon.forEach(([tx, ty], index) => {
const theta = centerTheta + tx * thetaSpan;
const y = centerY + ty * heightSpan;
const radius =
profileRadius(y) +
0.045 +
deterministicNoise(index, seed) * 0.008;
positions.push(
Math.sin(theta) * radius,
y,
Math.cos(theta) * radius
);
});
const indices = [];
for (let i = 0; i < polygon.length; i++) {
indices.push(
0,
1 + i,
1 + ((i + 1) % polygon.length)
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
// ---------------------------------------------------------------------
// Evidence: solid, documented sherds
// ---------------------------------------------------------------------
const evidenceData = [
{
id: "E1",
title: "Base sherd",
detail: "Excavation no. T-C/14 · red slip",
theta: -0.62,
y: 0.2,
thetaSpan: 0.7,
heightSpan: 0.3,
color: 0xb95f3e
},
{
id: "E2",
title: "Lower-body sherd",
detail: "Excavation no. T-C/19 · partial band",
theta: 0.67,
y: 0.79,
thetaSpan: 0.82,
heightSpan: 0.47,
color: 0xc86c47
},
{
id: "E3",
title: "Shoulder sherd",
detail: "Excavation no. T-C/27 · abraded surface",
theta: 2.45,
y: 1.4,
thetaSpan: 0.65,
heightSpan: 0.34,
color: 0xaa5538
},
{
id: "E4",
title: "Rim sherd",
detail: "Excavation no. T-C/31 · profile preserved",
theta: -1.86,
y: 1.87,
thetaSpan: 0.72,
heightSpan: 0.24,
color: 0xc7794f
}
];
const evidenceItems = [];
evidenceData.forEach((item, index) => {
const group = new THREE.Group();
group.name = item.title;
const material = new THREE.MeshStandardMaterial({
color: item.color,
roughness: 0.93,
metalness: 0,
flatShading: true,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(
createShardGeometry(
item.theta,
item.y,
item.thetaSpan,
item.heightSpan,
index + 2
),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry, 16),
new THREE.LineBasicMaterial({
color: 0x633d2e,
transparent: true,
opacity: 0.5
})
);
group.add(edges);
evidenceGroup.add(group);
const record = {
...item,
group,
mesh,
enabled: true
};
evidenceItems.push(record);
});
// ---------------------------------------------------------------------
// Interpretation: translucent, confidence-rated proposed pieces
// ---------------------------------------------------------------------
const parts = [];
const clickableMeshes = [];
function addPartMaterial(group, confidence, id) {
const material = new THREE.MeshStandardMaterial({
color: 0x4bc9cb,
emissive: 0x0b6d70,
emissiveIntensity: 0.22,
roughness: 0.58,
metalness: 0.03,
transparent: true,
opacity: 0.11 + confidence * 0.0014,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(group.userData.sourceGeometry, 18),
new THREE.LineBasicMaterial({
color: 0x16888c,
transparent: true,
opacity: 0.42 + confidence * 0.003,
depthWrite: false
})
);
group.userData.material = material;
group.userData.edges = edges;
group.userData.id = id;
}
function makeRevolvedPart(data, profile, options) {
const group = new THREE.Group();
const geometry = createRevolvedPart(profile, options);
group.userData.sourceGeometry = geometry;
const material = new THREE.MeshStandardMaterial({
color: 0x4bc9cb,
emissive: 0x0b6d70,
emissiveIntensity: 0.22,
roughness: 0.58,
metalness: 0.03,
transparent: true,
opacity: 0.11 + data.confidence * 0.0014,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.userData.partId = data.id;
mesh.castShadow = false;
group.add(mesh);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 18),
new THREE.LineBasicMaterial({
color: 0x16888c,
transparent: true,
opacity: 0.42 + data.confidence * 0.003,
depthWrite: false
})
);
group.add(edges);
group.userData.material = material;
group.userData.edges = edges;
group.userData.mesh = mesh;
group.userData.id = data.id;
clickableMeshes.push(mesh);
return group;
}
const partDefinitions = [
{
id: "P-01",
title: "Proposed base",
confidence: 78,
level: "High support",
note:
"The lower profile is constrained by the base sherd and a continuous sediment line. The transition into the body remains partly inferred.",
profile: [
{ y: 0, r: 0.28 },
{ y: 0.08, r: 0.4 },
{ y: 0.25, r: 0.49 },
{ y: 0.45, r: 0.57 }
],
options: { radialOffset: 0.014, thickness: 0.023 },
minY: 0,
slot: [1.45, 1.58, 0.05]
},
{
id: "P-02",
title: "Proposed body",
confidence: 64,
level: "Moderate support",
note:
"Maximum diameter is estimated from two sherds and curvature matching. Decorative and surface continuities are not documented.",
profile: [
{ y: 0.34, r: 0.52 },
{ y: 0.55, r: 0.61 },
{ y: 0.85, r: 0.66 },
{ y: 1.15, r: 0.65 },
{ y: 1.32, r: 0.61 }
],
options: { radialOffset: 0.024, thickness: 0.025 },
minY: 0.34,
slot: [1.82, 1.31, 0.12]
},
{
id: "P-03",
title: "Proposed neck & lip",
confidence: 41,
level: "Low support",
note:
"The rim sherd establishes only a limited profile. This neck is one of several possible vessel forms and should not be treated as settled.",
profile: [
{ y: 1.2, r: 0.62 },
{ y: 1.42, r: 0.52 },
{ y: 1.63, r: 0.31 },
{ y: 1.77, r: 0.25 },
{ y: 1.92, r: 0.31 }
],
options: { radialOffset: 0.035, thickness: 0.025 },
minY: 1.2,
slot: [1.47, 1.05, -0.08]
},
{
id: "P-04",
title: "Proposed handle",
confidence: 27,
level: "Speculative",
note:
"A handle is included to test how the vessel may have been used. No surviving handle attachment is securely documented.",
minY: 0.76,
slot: [1.91, 0.78, -0.14]
}
];
partDefinitions.forEach((data, index) => {
let group;
if (data.id === "P-04") {
group = new THREE.Group();
const geometry = new THREE.TorusGeometry(
0.49,
0.065,
4,
14,
Math.PI * 1.56
);
group.userData.sourceGeometry = geometry;
const material = new THREE.MeshStandardMaterial({
color: 0x4bc9cb,
emissive: 0x0b6d70,
emissiveIntensity: 0.22,
roughness: 0.58,
transparent: true,
opacity: 0.11 + data.confidence * 0.0014,
depthWrite: false,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(0.47, 1.27, 0);
mesh.rotation.z = -0.12;
mesh.userData.partId = data.id;
group.add(mesh);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 18),
new THREE.LineBasicMaterial({
color: 0x16888c,
transparent: true,
opacity: 0.42 + data.confidence * 0.003,
depthWrite: false
})
);
edges.position.copy(mesh.position);
edges.rotation.copy(mesh.rotation);
group.add(edges);
group.userData.material = material;
group.userData.edges = edges;
group.userData.mesh = mesh;
group.userData.id = data.id;
clickableMeshes.push(mesh);
} else {
group = makeRevolvedPart(data, data.profile, data.options);
}
const anchor = new THREE.Object3D();
anchor.position.set(
0.54 + index * 0.02,
Math.min(data.minY + 0.28, 1.85),
0.48
);
group.add(anchor);
interpretationGroup.add(group);
parts.push({
...data,
group,
mesh: group.userData.mesh,
material: group.userData.material,
edges: group.userData.edges,
anchor,
enabled: true,
detached: false,
level: data.level
});
// A base disk makes the proposed base read as a closed support.
if (data.id === "P-01") {
const diskGeometry = new THREE.CircleGeometry(0.275, 12);
const disk = new THREE.Mesh(
diskGeometry,
group.userData.material
);
disk.rotation.x = -Math.PI / 2;
disk.position.y = 0.002;
disk.userData.partId = data.id;
group.add(disk);
clickableMeshes.push(disk);
}
});
// ---------------------------------------------------------------------
// Wall-mounted provenance record panels
// ---------------------------------------------------------------------
function wrapText(context, text, x, y, maxWidth, lineHeight) {
const words = text.split(" ");
let line = "";
let lineY = y;
for (const word of words) {
const test = line ? `${line} ${word}` : word;
if (context.measureText(test).width > maxWidth && line) {
context.fillText(line, x, lineY);
line = word;
lineY += lineHeight;
} else {
line = test;
}
}
if (line) context.fillText(line, x, lineY);
return lineY + lineHeight;
}
function createArchivePanel({
number,
heading,
title,
body,
x,
interpretation = false
}) {
const textureCanvas = document.createElement("canvas");
textureCanvas.width = 640;
textureCanvas.height = 320;
const context = textureCanvas.getContext("2d");
context.fillStyle = interpretation ? "#e7f0ed" : "#eee8dd";
context.fillRect(0, 0, 640, 320);
context.strokeStyle = interpretation ? "#278e92" : "#a65d43";
context.lineWidth = 4;
context.setLineDash(interpretation ? [12, 9] : []);
context.strokeRect(14, 14, 612, 292);
context.setLineDash([]);
context.fillStyle = interpretation ? "#278e92" : "#a65d43";
context.font = "700 20px system-ui, sans-serif";
context.fillText(number, 38, 56);
context.fillStyle = "#6a675e";
context.font = "600 16px system-ui, sans-serif";
context.fillText(heading.toUpperCase(), 38, 91);
context.fillStyle = "#252723";
context.font = "400 35px Georgia, serif";
wrapText(context, title, 38, 141, 555, 39);
context.fillStyle = interpretation ? "#236f73" : "#68645b";
context.font = "400 17px system-ui, sans-serif";
wrapText(context, body, 38, 220, 555, 25);
const texture = new THREE.CanvasTexture(textureCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const frame = new THREE.Mesh(
new THREE.BoxGeometry(2.42, 1.28, 0.08),
new THREE.MeshStandardMaterial({
color: 0xbeb6a7,
roughness: 0.9
})
);
frame.position.set(x, 3.22, -5.08);
frame.castShadow = true;
scene.add(frame);
const panel = new THREE.Mesh(
new THREE.PlaneGeometry(2.3, 1.15),
new THREE.MeshBasicMaterial({ map: texture })
);
panel.position.set(x, 3.22, -5.025);
scene.add(panel);
}
createArchivePanel({
number: "01",
heading: "Field record · documented",
title: "Excavation, 1968",
body: "Trench C · Coastal survey · Field notebook and site photograph",
x: -4.55
});
createArchivePanel({
number: "02",
heading: "Custody · documented",
title: "Municipal Museum",
body: "1968–1994 · Accession MR-68.14 · Transfer ledger",
x: -1.55
});
createArchivePanel({
number: "03",
heading: "Current record · documented",
title: "Study Collection",
body: "1994–Now · Museum repository · Re-catalogued for study",
x: 1.45
});
createArchivePanel({
number: "04",
heading: "Attribution · interpretation",
title: "Workshop Unresolved",
body: "A Levantine coastal workshop is proposed, but not established by the record.",
x: 4.45,
interpretation: true
});
const wallTitleCanvas = document.createElement("canvas");
wallTitleCanvas.width = 1024;
wallTitleCanvas.height = 128;
const wallTitleContext = wallTitleCanvas.getContext("2d");
wallTitleContext.clearRect(0, 0, 1024, 128);
wallTitleContext.fillStyle = "#706c62";
wallTitleContext.font = "700 24px system-ui, sans-serif";
wallTitleContext.letterSpacing = "5px";
wallTitleContext.fillText(
"PROVENANCE / DOCUMENTED CHAIN + OPEN QUESTION",
18,
72
);
const wallTitleTexture = new THREE.CanvasTexture(wallTitleCanvas);
wallTitleTexture.colorSpace = THREE.SRGBColorSpace;
const wallTitle = new THREE.Mesh(
new THREE.PlaneGeometry(6.4, 0.8),
new THREE.MeshBasicMaterial({
map: wallTitleTexture,
transparent: true
})
);
wallTitle.position.set(0, 4.25, -5.15);
scene.add(wallTitle);
// ---------------------------------------------------------------------
// Interface construction and state
// ---------------------------------------------------------------------
const evidenceList = document.querySelector("#evidenceList");
const pieceList = document.querySelector("#pieceList");
const selectedTitle = document.querySelector("#selectedTitle");
const selectedConfidence = document.querySelector("#selectedConfidence");
const selectedStatus = document.querySelector("#selectedStatus");
const selectedNote = document.querySelector("#selectedNote");
const detachButton = document.querySelector("#detachButton");
let evidenceLayerOn = true;
let interpretationLayerOn = true;
let selectedPart = parts[0];
const sceneLabels = [];
evidenceItems.forEach((item) => {
const row = document.createElement("label");
row.className = "evidence-row";
row.innerHTML = `
<input type="checkbox" checked aria-label="Show ${item.title}" />
<span class="row-copy">
<strong>${item.id} · ${item.title}</strong>
<small>${item.detail}</small>
</span>
`;
const checkbox = row.querySelector("input");
checkbox.addEventListener("change", () => {
item.enabled = checkbox.checked;
});
evidenceList.appendChild(row);
});
parts.forEach((part) => {
const row = document.createElement("div");
row.className = "piece-row";
row.dataset.id = part.id;
row.innerHTML = `
<input type="checkbox" checked aria-label="Show ${part.title}" />
<div class="row-copy">
<button class="piece-select" type="button">
<span>
<strong>${part.id} · ${part.title}</strong>
<small>${part.level}</small>
<span class="meter"><i style="width:${part.confidence}%"></i></span>
</span>
<span class="confidence">${part.confidence}%</span>
</button>
</div>
`;
const checkbox = row.querySelector("input");
checkbox.addEventListener("change", () => {
part.enabled = checkbox.checked;
});
row.querySelector(".piece-select").addEventListener("click", () => {
selectPart(part, true);
});
pieceList.appendChild(row);
});
function selectPart(part, reveal = false) {
selectedPart = part;
if (reveal) {
part.enabled = true;
interpretationLayerOn = true;
updateLayerButtons();
}
updateSelectionUI();
}
function updateSelectionUI() {
if (!selectedPart) return;
selectedTitle.textContent = selectedPart.title;
selectedConfidence.textContent = `${selectedPart.confidence}%`;
selectedStatus.textContent = selectedPart.detached
? "Detached for comparative study"
: "Attached to reconstruction";
selectedNote.textContent = selectedPart.note;
detachButton.textContent = selectedPart.detached
? "Reattach to reconstruction"
: "Detach for study";
document.querySelectorAll(".piece-row").forEach((row) => {
row.classList.toggle(
"selected",
row.dataset.id === selectedPart.id
);
});
sceneLabels.forEach((label) => {
if (label.partId) {
label.element.classList.toggle(
"selected",
label.partId === selectedPart.id
);
}
});
}
function toggleDetach(part = selectedPart) {
if (!part) return;
part.detached = !part.detached;
part.enabled = true;
interpretationLayerOn = true;
const checkbox = document.querySelector(
`.piece-row[data-id="${part.id}"] input`
);
if (checkbox) checkbox.checked = true;
updateLayerButtons();
updateSelectionUI();
notify(
part.detached
? `${part.title} detached for study`
: `${part.title} reattached`
);
}
detachButton.addEventListener("click", () => toggleDetach());
function updateLayerButtons() {
const evidenceButton = document.querySelector("#evidenceLayer");
const interpretationButton = document.querySelector(
"#interpretationLayer"
);
evidenceButton.classList.toggle("on", evidenceLayerOn);
evidenceButton.setAttribute("aria-pressed", String(evidenceLayerOn));
interpretationButton.classList.toggle(
"on",
interpretationLayerOn
);
interpretationButton.setAttribute(
"aria-pressed",
String(interpretationLayerOn)
);
evidenceGroup.visible = evidenceLayerOn;
interpretationGroup.visible = interpretationLayerOn;
}
document
.querySelector("#evidenceLayer")
.addEventListener("click", () => {
evidenceLayerOn = !evidenceLayerOn;
updateLayerButtons();
notify(
evidenceLayerOn
? "Known remains visible"
: "Known remains hidden"
);
});
document
.querySelector("#interpretationLayer")
.addEventListener("click", () => {
interpretationLayerOn = !interpretationLayerOn;
updateLayerButtons();
notify(
interpretationLayerOn
? "Proposed additions visible"
: "Proposed additions hidden"
);
});
updateLayerButtons();
updateSelectionUI();
// ---------------------------------------------------------------------
// Projected scene labels, implemented without external label addons
// ---------------------------------------------------------------------
const labelLayer = document.querySelector("#sceneLabels");
function createSceneLabel({
title,
value,
className,
anchor,
partId = null
}) {
const element = document.createElement(
partId ? "button" : "div"
);
element.className = `scene-label ${className}`;
element.innerHTML = `
<span>${title}</span>
${value ? `<strong>${value}</strong>` : ""}
`;
if (partId) {
element.type = "button";
element.addEventListener("click", () => {
const part = parts.find((candidate) => candidate.id === partId);
if (part) selectPart(part, true);
});
}
labelLayer.appendChild(element);
sceneLabels.push({ element, anchor, partId });
}
parts.forEach((part) => {
createSceneLabel({
title: `${part.id} · ${part.title}`,
value: `${part.confidence}%`,
className: "interpretation",
anchor: part.anchor,
partId: part.id
});
});
const evidenceAnchor = new THREE.Object3D();
evidenceAnchor.position.set(-0.52, 1.02, 0.64);
evidenceGroup.add(evidenceAnchor);
createSceneLabel({
title: "EVIDENCE · 4 DOCUMENTED SHERDS",
value: "",
className: "evidence",
anchor: evidenceAnchor
});
const projected = new THREE.Vector3();
function updateSceneLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
sceneLabels.forEach((label) => {
let visible = true;
if (label.partId) {
const part = parts.find((item) => item.id === label.partId);
visible =
interpretationLayerOn &&
part &&
part.enabled &&
part.group.visible;
} else {
visible = evidenceLayerOn && evidenceGroup.visible;
}
if (!visible) {
label.element.style.display = "none";
return;
}
label.anchor.getWorldPosition(projected);
projected.project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const onScreen =
projected.z > -1 &&
projected.z < 1 &&
x > -60 &&
x < width + 60 &&
y > -40 &&
y < height + 40;
label.element.style.display = onScreen ? "flex" : "none";
if (onScreen) {
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
});
}
// ---------------------------------------------------------------------
// Picking, messages, and responsive panel behavior
// ---------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function pickPiece(event) {
const rect = canvas.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const visibleMeshes = clickableMeshes.filter((mesh) => {
const part = parts.find((item) => item.id === mesh.userData.partId);
return (
interpretationLayerOn &&
part &&
part.enabled &&
part.group.visible
);
});
const intersections = raycaster.intersectObjects(
visibleMeshes,
false
);
return intersections.length
? parts.find(
(part) => part.id === intersections[0].object.userData.partId
)
: null;
}
canvas.addEventListener("dblclick", (event) => {
const part = pickPiece(event);
if (part) {
selectPart(part, true);
toggleDetach(part);
}
});
let toastTimer;
function notify(message) {
const toast = document.querySelector("#toast");
toast.textContent = message;
toast.classList.add("show");
document.querySelector("#liveStatus").textContent = message;
clearTimeout(toastTimer);
toastTimer = setTimeout(() => {
toast.classList.remove("show");
}, 2200);
}
const panelToggle = document.querySelector("#panelToggle");
panelToggle.addEventListener("click", () => {
document.body.classList.toggle("panel-collapsed");
});
// ---------------------------------------------------------------------
// Animation and resize
// ---------------------------------------------------------------------
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
updateCamera();
parts.forEach((part, index) => {
const attachedPosition = new THREE.Vector3(0, 0, 0);
const detachedPosition = new THREE.Vector3(
part.slot[0],
-part.minY + part.slot[2],
part.slot[1]
);
const targetPosition = part.detached
? detachedPosition
: attachedPosition;
part.group.position.lerp(targetPosition, 1 - Math.pow(0.001, delta));
const targetRotationY = part.detached ? -0.42 : 0;
const targetRotationZ = part.detached ? 0.16 : 0;
const targetRotationX = part.detached ? -0.08 : 0;
part.group.rotation.y = THREE.MathUtils.lerp(
part.group.rotation.y,
targetRotationY,
1 - Math.pow(0.002, delta)
);
part.group.rotation.z = THREE.MathUtils.lerp(
part.group.rotation.z,
targetRotationZ,
1 - Math.pow(0.002, delta)
);
part.group.rotation.x = THREE.MathUtils.lerp(
part.group.rotation.x,
targetRotationX,
1 - Math.pow(0.002, delta)
);
const selected = part.id === selectedPart.id;
const baseOpacity = 0.11 + part.confidence * 0.0014;
const targetOpacity = selected ? baseOpacity + 0.16 : baseOpacity;
part.material.opacity = THREE.MathUtils.lerp(
part.material.opacity,
targetOpacity,
1 - Math.pow(0.008, delta)
);
const edgeTarget =
0.42 + part.confidence * 0.003 + (selected ? 0.22 : 0);
part.edges.material.opacity = THREE.MathUtils.lerp(
part.edges.material.opacity,
edgeTarget,
1 - Math.pow(0.008, delta)
);
});
evidenceItems.forEach((item) => {
item.group.visible = evidenceLayerOn && item.enabled;
});
parts.forEach((part) => {
part.group.visible = interpretationLayerOn && part.enabled;
});
boundaryRing.material.opacity =
0.25 + Math.sin(elapsed * 0.75) * 0.055;
renderer.render(scene, camera);
updateSceneLabels();
}
animate();
</script>
</body>
</html>
```