Prompt specification
Build or customize the Three.js 3D scene "Museum Guide With Ambiguous References" 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: Museum Guide With Ambiguous References
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/museum-guide-with-ambiguous-references-x3411
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing references to objects in context. Build an exhibit containing similar statues and plaques. Highlight candidate referents for phrases such as the tall one, then add context that resolves the ambiguity. Voxel style.
Working Three.js Starter (museum-guide-with-ambiguous-references-x3411):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Reference Lab — A Voxel Exhibit</title>
<style>
:root {
--ink: #171a22;
--ink-2: #222733;
--paper: #eeeae0;
--muted: #aeb4bf;
--yellow: #f4c84d;
--green: #65d69b;
--line: rgba(255, 255, 255, 0.12);
--shadow: 0 18px 55px rgba(11, 14, 20, 0.24);
}
* {
box-sizing: border-box;
}
[hidden] {
display: none !important;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--ink);
color: var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button {
font: inherit;
}
button:focus-visible {
outline: 3px solid var(--yellow);
outline-offset: 3px;
}
.app {
display: grid;
grid-template-rows: 66px minmax(0, 1fr);
width: 100%;
height: 100%;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
background: #12151c;
border-bottom: 1px solid var(--line);
z-index: 5;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
font-weight: 850;
letter-spacing: 0.08em;
font-size: 13px;
}
.brand small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.16em;
}
.voxel-mark {
position: relative;
width: 31px;
height: 31px;
}
.voxel-mark i {
position: absolute;
display: block;
width: 14px;
height: 14px;
background: var(--yellow);
box-shadow: inset -3px -3px rgba(0, 0, 0, 0.14);
}
.voxel-mark i:nth-child(1) {
left: 1px;
top: 1px;
}
.voxel-mark i:nth-child(2) {
right: 1px;
top: 1px;
background: #e88861;
}
.voxel-mark i:nth-child(3) {
left: 1px;
bottom: 1px;
background: var(--green);
}
.voxel-mark i:nth-child(4) {
right: 1px;
bottom: 1px;
background: #5c9bd1;
}
.header-meta {
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
letter-spacing: 0.13em;
text-align: right;
}
main {
display: grid;
grid-template-columns: minmax(0, 1fr) 380px;
min-height: 0;
}
#stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background: #d8d5ca;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#stage canvas:active {
cursor: grabbing;
}
.stage-heading {
position: absolute;
z-index: 2;
top: 24px;
left: 26px;
max-width: 390px;
pointer-events: none;
color: var(--ink);
}
.stage-kicker {
display: inline-flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
padding: 7px 9px;
background: rgba(20, 24, 31, 0.9);
color: var(--paper);
border-radius: 3px;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
}
.stage-kicker::before {
content: "";
width: 7px;
height: 7px;
background: var(--yellow);
box-shadow: 0 0 0 3px rgba(244, 200, 77, 0.2);
}
.stage-heading h1 {
margin: 0;
font-size: clamp(26px, 3vw, 42px);
line-height: 0.98;
letter-spacing: -0.05em;
}
.stage-heading p {
margin: 11px 0 0;
max-width: 330px;
color: #535963;
font-size: 12px;
line-height: 1.5;
}
.stage-tools {
position: absolute;
z-index: 3;
top: 24px;
right: 22px;
display: flex;
gap: 8px;
}
.tool-button {
border: 1px solid rgba(20, 24, 31, 0.2);
background: rgba(244, 241, 232, 0.85);
color: var(--ink);
padding: 10px 12px;
border-radius: 4px;
cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.06em;
backdrop-filter: blur(8px);
}
.tool-button:hover {
background: var(--yellow);
border-color: var(--ink);
}
.stage-status {
position: absolute;
z-index: 2;
left: 24px;
bottom: 22px;
max-width: min(570px, calc(100% - 48px));
display: flex;
align-items: center;
gap: 13px;
padding: 12px 14px;
background: rgba(20, 24, 31, 0.92);
border: 1px solid rgba(255, 255, 255, 0.11);
border-radius: 5px;
box-shadow: var(--shadow);
backdrop-filter: blur(9px);
pointer-events: none;
}
.status-number {
display: grid;
place-items: center;
flex: 0 0 auto;
width: 29px;
height: 29px;
background: var(--yellow);
color: var(--ink);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
font-weight: 900;
}
.status-copy strong {
display: block;
margin-bottom: 3px;
color: var(--paper);
font-size: 11px;
letter-spacing: 0.02em;
}
.status-copy span {
display: block;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
.controls-hint {
position: absolute;
z-index: 2;
right: 22px;
bottom: 22px;
color: rgba(23, 26, 34, 0.68);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
letter-spacing: 0.04em;
text-align: right;
pointer-events: none;
}
aside {
min-height: 0;
overflow-y: auto;
background: var(--ink);
border-left: 1px solid var(--line);
scrollbar-width: thin;
scrollbar-color: #414755 transparent;
}
.panel-section {
padding: 24px;
border-bottom: 1px solid var(--line);
}
.eyebrow {
margin-bottom: 10px;
color: var(--yellow);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.phrase-tabs {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
margin-bottom: 22px;
}
.phrase-tab {
min-width: 0;
padding: 9px 5px;
border: 1px solid var(--line);
border-radius: 3px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.phrase-tab:hover,
.phrase-tab.active {
border-color: var(--yellow);
background: var(--yellow);
color: var(--ink);
}
#phraseTitle {
margin: 0 0 10px;
font-size: 34px;
line-height: 1;
letter-spacing: -0.045em;
}
.utterance {
margin: 0;
color: #c5cad2;
font-size: 13px;
line-height: 1.55;
}
.speaker {
color: var(--yellow);
font-weight: 750;
}
.steps {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin: 22px 0;
}
.step {
position: relative;
padding: 10px 8px 10px 34px;
border: 1px solid var(--line);
color: #767d8b;
font-size: 9px;
font-weight: 800;
line-height: 1.25;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.step span {
position: absolute;
top: 9px;
left: 9px;
display: grid;
place-items: center;
width: 18px;
height: 18px;
background: #313642;
color: #aeb4bf;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
}
.step.active {
border-color: rgba(244, 200, 77, 0.45);
color: var(--paper);
}
.step.active span {
background: var(--yellow);
color: var(--ink);
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 0 10px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#candidateCount {
color: var(--yellow);
}
.candidate-list {
display: grid;
gap: 7px;
margin-bottom: 14px;
}
.candidate {
display: grid;
grid-template-columns: 14px 1fr auto;
align-items: center;
gap: 10px;
width: 100%;
padding: 10px;
border: 1px solid var(--line);
border-radius: 4px;
background: rgba(255, 255, 255, 0.025);
color: var(--paper);
cursor: pointer;
text-align: left;
transition: 140ms ease;
}
.candidate:hover,
.candidate.active {
border-color: var(--yellow);
background: rgba(244, 200, 77, 0.08);
transform: translateX(-2px);
}
.candidate.resolved {
border-color: var(--green);
background: rgba(101, 214, 155, 0.09);
}
.candidate-swatch {
width: 12px;
height: 12px;
background: var(--swatch);
box-shadow: inset -3px -3px rgba(0, 0, 0, 0.18);
}
.candidate strong {
display: block;
font-size: 11px;
letter-spacing: 0.05em;
}
.candidate small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
.candidate-tag {
padding: 4px 6px;
background: #313642;
color: #b9bec8;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
font-weight: 800;
text-transform: uppercase;
}
.candidate.resolved .candidate-tag {
background: var(--green);
color: var(--ink);
}
.primary-button {
width: 100%;
padding: 13px 15px;
border: 0;
border-radius: 4px;
background: var(--yellow);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 900;
letter-spacing: 0.04em;
transition: 140ms ease;
}
.primary-button:hover {
background: #ffdc6b;
transform: translateY(-1px);
}
.context-card,
.result-card {
margin-top: 13px;
padding: 14px;
border-radius: 4px;
}
.context-card {
border: 1px solid rgba(244, 200, 77, 0.35);
background: rgba(244, 200, 77, 0.075);
}
.result-card {
border: 1px solid rgba(101, 214, 155, 0.42);
background: rgba(101, 214, 155, 0.075);
}
.card-kicker {
margin-bottom: 8px;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
font-weight: 900;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.context-card .card-kicker {
color: var(--yellow);
}
.result-card .card-kicker {
color: var(--green);
}
.context-card p,
.result-card p {
margin: 0;
color: #d8dce2;
font-size: 11px;
line-height: 1.55;
}
.source {
display: block;
margin-top: 10px;
color: #858c99;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
line-height: 1.4;
text-transform: uppercase;
}
.result-title {
margin: 0 0 5px;
color: var(--green);
font-size: 19px;
letter-spacing: -0.02em;
}
.text-button {
margin-top: 12px;
padding: 0;
border: 0;
background: transparent;
color: var(--yellow);
cursor: pointer;
font-size: 10px;
font-weight: 850;
}
.object-list {
display: grid;
gap: 7px;
}
.object-row {
display: grid;
grid-template-columns: 13px 1fr auto;
align-items: center;
gap: 10px;
padding: 8px 0;
border: 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
background: transparent;
color: var(--paper);
cursor: pointer;
text-align: left;
}
.object-row:hover,
.object-row.active {
color: var(--yellow);
}
.object-row .candidate-swatch {
width: 11px;
height: 11px;
}
.object-row strong {
display: block;
font-size: 10px;
letter-spacing: 0.06em;
}
.object-row small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8px;
}
.object-code {
color: #7e8591;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
}
.selection-note {
margin: 12px 0 0;
color: #858c99;
font-size: 9px;
line-height: 1.5;
}
#loading {
position: absolute;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #d8d5ca;
color: var(--ink);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
font-weight: 900;
letter-spacing: 0.13em;
}
@media (max-width: 980px) {
html,
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100%;
grid-template-rows: 66px auto;
}
main {
display: block;
}
#stage {
height: 64vh;
min-height: 460px;
}
aside {
overflow: visible;
}
.controls-hint {
display: none;
}
}
@media (max-width: 560px) {
header {
padding: 0 15px;
}
.header-meta {
display: none;
}
.stage-heading {
top: 18px;
left: 18px;
}
.stage-heading h1 {
font-size: 28px;
}
.stage-tools {
top: 18px;
right: 14px;
}
.tool-button {
padding: 9px;
font-size: 8px;
}
.stage-status {
left: 14px;
bottom: 14px;
max-width: calc(100% - 28px);
}
}
</style>
</head>
<body>
<div class="app">
<header>
<div class="brand">
<div class="voxel-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div>
REFERENCE LAB
<small>MUSEUM OF ORDINARY, EXTRAORDINARY WORDS</small>
</div>
</div>
<div class="header-meta">
EXHIBIT 04 / VOXEL REFERENCE STUDIES<br />
THREE.JS CORE · LIVE INTERACTIVE DISPLAY
</div>
</header>
<main>
<section id="stage" aria-label="Interactive voxel museum exhibit">
<div id="loading">ASSEMBLING THE GALLERY…</div>
<div class="stage-heading">
<div class="stage-kicker">LIVE REFERENCE EXHIBIT</div>
<h1>Which figure<br />was meant?</h1>
<p>
Similar objects create uncertain references. Add the curator’s
context to narrow the possible referents.
</p>
</div>
<div class="stage-tools">
<button class="tool-button" id="resetView" type="button">
RESET VIEW
</button>
</div>
<div class="stage-status" aria-live="polite">
<div class="status-number" id="statusNumber">1</div>
<div class="status-copy">
<strong id="statusTitle">IDENTIFY THE CANDIDATES</strong>
<span id="statusText"></span>
</div>
</div>
<div class="controls-hint">
DRAG TO ORBIT · SCROLL TO ZOOM<br />
CLICK A STATUE TO INSPECT IT
</div>
</section>
<aside aria-label="Reference analysis controls">
<section class="panel-section">
<div class="eyebrow">Reference resolution / 04</div>
<div class="phrase-tabs" id="phraseTabs" aria-label="Choose a phrase"></div>
<h2 id="phraseTitle">“the tall one”</h2>
<p class="utterance">
<span class="speaker" id="speaker">Director:</span>
<span id="utterance"></span>
</p>
<div class="steps">
<div class="step active" id="stepOne">
<span>1</span> Candidate referents
</div>
<div class="step" id="stepTwo">
<span>2</span> Resolve with context
</div>
</div>
<div class="section-label">
<span>Candidate referents</span>
<span id="candidateCount"></span>
</div>
<div class="candidate-list" id="candidateList"></div>
<button class="primary-button" id="contextButton" type="button">
ADD CURATOR CONTEXT →
</button>
<div class="context-card" id="contextCard" hidden>
<div class="card-kicker">Context clue</div>
<p id="contextText"></p>
<span class="source" id="contextSource"></span>
</div>
<div class="result-card" id="resultCard" hidden>
<div class="card-kicker">Resolved reference</div>
<h3 class="result-title" id="resultTitle"></h3>
<p id="resultText"></p>
<button class="text-button" id="nextButton" type="button">
TRY THE NEXT PHRASE →
</button>
</div>
</section>
<section class="panel-section">
<div class="section-label">
<span>Collection objects</span>
<span>CLICK TO FOCUS</span>
</div>
<div class="object-list" id="objectList"></div>
<p class="selection-note" id="selectionNote">
Yellow frames mark every object that can satisfy the current phrase.
</p>
</section>
</aside>
</main>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Exhibit data
// -------------------------------------------------------------------------
const objectDefs = [
{
id: "cloud",
name: "CLOUD",
code: "P-01",
x: -5.6,
color: 0xe7e4dc,
swatch: "#e7e4dc",
material: "Pale limestone",
height: 3.25,
cue: "Square pale silhouette",
detail: "CLOUD is tall, pale, and has no crest or silver belt."
},
{
id: "ember",
name: "EMBER",
code: "P-02",
x: -2.8,
color: 0xc9624d,
swatch: "#c9624d",
material: "Red terracotta",
height: 3.25,
cue: "Red crest",
detail: "EMBER is tall and carries a small crimson crest on its chest."
},
{
id: "moss",
name: "MOSS",
code: "P-03",
x: 0,
color: 0x3d6b57,
swatch: "#3d6b57",
material: "Deep green stone",
height: 2.7,
cue: "Green plaque",
detail: "MOSS is the green, medium-height figure in the center."
},
{
id: "tide",
name: "TIDE",
code: "P-04",
x: 2.8,
color: 0x4f83b7,
swatch: "#4f83b7",
material: "Blue stone",
height: 2.3,
cue: "Bright blue cap",
detail: "TIDE is the small blue figure wearing a bright blue cap."
},
{
id: "ink",
name: "INK",
code: "P-05",
x: 5.6,
color: 0x292b34,
swatch: "#292b34",
material: "Black basalt",
height: 3.25,
cue: "Silver belt",
detail: "INK is tall and dark, with a reflective silver belt."
}
];
const scenarios = [
{
id: "tall",
tab: "Tall",
phrase: "the tall one",
speaker: "Director:",
utterance: "“Bring the tall one to the north alcove.”",
candidates: ["cloud", "ember", "ink"],
context:
"Only the tall figure with a RED CREST is scheduled for the north alcove.",
source: "North alcove docket · 14:08",
target: "ember",
reason:
"CLOUD and INK are also tall, but EMBER is the only candidate wearing a red crest."
},
{
id: "left",
tab: "Left",
phrase: "the one on the left",
speaker: "Visitor:",
utterance: "“Please move the one on the left of the green plaque.”",
candidates: ["cloud", "ember"],
context:
"EMBER is immediately to the left of the green plaque. CLOUD is farther away.",
source: "Green plaque locator",
target: "ember",
reason:
"Both CLOUD and EMBER are on the left side of the green plaque, but only EMBER is immediately beside it."
},
{
id: "dark",
tab: "Dark",
phrase: "the dark one",
speaker: "Conservator:",
utterance: "“Choose the dark one for the restoration bay.”",
candidates: ["moss", "ink"],
context:
"The restoration docket specifies the dark figure with the SILVER BELT.",
source: "Restoration docket · item 9",
target: "ink",
reason:
"MOSS and INK are both dark. The silver belt uniquely identifies INK."
},
{
id: "blue",
tab: "Blue",
phrase: "the blue one",
speaker: "Teacher:",
utterance: "“Point to the blue one before the gallery closes.”",
candidates: ["tide"],
context:
"The catalogue identifies TIDE by its bright blue cap.",
source: "Gallery catalogue · colour index",
target: "tide",
reason:
"The phrase is already unique: TIDE is the only blue figure in the collection."
}
];
const objectById = new Map(objectDefs.map((object) => [object.id, object]));
let activeScenario = scenarios[0];
let phase = "candidates";
let selectedObjectId = activeScenario.candidates[0];
// -------------------------------------------------------------------------
// Three.js setup
// -------------------------------------------------------------------------
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d5ca);
scene.fog = new THREE.Fog(0xd8d5ca, 18, 35);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 80);
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "WEBGL COULD NOT BE STARTED";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel exhibit containing five statues and museum plaques"
);
stage.prepend(renderer.domElement);
const view = {
target: new THREE.Vector3(0, 1.35, 0),
radius: 15.6,
theta: 0.32,
phi: 1.08
};
let cameraGoal = null;
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
view.target.x + view.radius * sinPhi * Math.sin(view.theta),
view.target.y + view.radius * Math.cos(view.phi),
view.target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(view.target);
}
updateCamera();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff9ec, 0x59616c, 1.75));
const keyLight = new THREE.DirectionalLight(0xfff0d7, 3.2);
keyLight.position.set(4, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x9bbdff, 0.8);
fillLight.position.set(-8, 6, 2);
scene.add(fillLight);
const contextSpotTarget = new THREE.Object3D();
scene.add(contextSpotTarget);
const contextSpot = new THREE.SpotLight(
0x85f0b5,
0,
14,
0.43,
0.75,
1.2
);
contextSpot.position.set(0, 7, 2);
contextSpot.target = contextSpotTarget;
scene.add(contextSpot);
// -------------------------------------------------------------------------
// Materials and helpers
// -------------------------------------------------------------------------
const standardMaterial = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
...options
});
function addBox(parent, size, position, material, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function makeCanvasTexture(width, height, draw) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
draw(context, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function drawWrappedText(
context,
text,
x,
y,
maxWidth,
lineHeight,
maxLines = 4
) {
const words = text.split(" ");
let line = "";
let lineCount = 0;
for (const word of words) {
const test = line ? `${line} ${word}` : word;
if (
context.measureText(test).width > maxWidth &&
line &&
lineCount < maxLines
) {
context.fillText(line, x, y + lineCount * lineHeight);
line = word;
lineCount += 1;
} else {
line = test;
}
}
if (lineCount < maxLines) {
context.fillText(line, x, y + lineCount * lineHeight);
}
}
// -------------------------------------------------------------------------
// Gallery architecture
// -------------------------------------------------------------------------
function buildArchitecture() {
const floorMaterial = standardMaterial(0xcfcbc0);
const wallMaterial = standardMaterial(0xe4e0d5);
const trimMaterial = standardMaterial(0x363c45);
const lightMaterial = standardMaterial(0xfff0c4, {
emissive: 0xffd889,
emissiveIntensity: 0.35
});
addBox(scene, [23.5, 0.3, 10.4], [0, -0.18, 0], floorMaterial);
addBox(scene, [23.5, 6.5, 0.25], [0, 3.08, -4.8], wallMaterial);
addBox(scene, [23.5, 0.35, 0.45], [0, 5.95, -4.72], trimMaterial);
addBox(scene, [0.45, 6.3, 10], [-11.52, 3.0, 0], wallMaterial);
addBox(scene, [0.45, 6.3, 10], [11.52, 3.0, 0], wallMaterial);
const tileMaterial = standardMaterial(0xbab6ad);
for (let x = -10.5; x <= 10.5; x += 1.5) {
addBox(
scene,
[0.025, 0.018, 10.1],
[x, 0.012, 0],
tileMaterial,
{ castShadow: false }
);
}
for (let z = -4; z <= 4; z += 1.5) {
addBox(
scene,
[23.1, 0.018, 0.025],
[0, 0.013, z],
tileMaterial,
{ castShadow: false }
);
}
// Voxel columns and overhead beams.
for (const x of [-9.3, -3.1, 3.1, 9.3]) {
addBox(scene, [0.6, 5.7, 0.65], [x, 2.75, -4.25], trimMaterial);
addBox(scene, [0.9, 0.22, 0.9], [x, 5.55, -4.1], lightMaterial);
}
for (const x of [-6, 0, 6]) {
addBox(scene, [0.55, 0.25, 5.3], [x, 5.7, -1.7], trimMaterial);
addBox(
scene,
[0.32, 0.12, 3.6],
[x, 5.54, -1.25],
lightMaterial
);
}
// Decorative wall blocks.
const wallColors = [0xc9624d, 0x3d6b57, 0x4f83b7, 0x292b34];
wallColors.forEach((color, index) => {
const x = -7.2 + index * 4.8;
addBox(
scene,
[1.4, 1.4, 0.18],
[x, 3.75, -4.56],
standardMaterial(color)
);
addBox(
scene,
[0.62, 0.62, 0.22],
[x + 0.37, 4.05, -4.43],
standardMaterial(0xf0eadc)
);
});
const wallTextTexture = makeCanvasTexture(1024, 256, (ctx, w, h) => {
ctx.fillStyle = "#20242d";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#f4c84d";
ctx.fillRect(40, 36, 18, 18);
ctx.fillRect(66, 36, 18, 18);
ctx.fillRect(40, 62, 18, 18);
ctx.fillRect(66, 62, 18, 18);
ctx.fillStyle = "#f4f0e6";
ctx.font = "900 54px monospace";
ctx.fillText("REFERENCE GALLERY", 112, 80);
ctx.fillStyle = "#aeb4bf";
ctx.font = "700 25px monospace";
ctx.fillText(
"ORDINARY OBJECTS, EXTRAORDINARY WORDS",
112,
128
);
ctx.fillStyle = "#f4c84d";
ctx.font = "700 20px monospace";
ctx.fillText("EXHIBIT 04 / MEANING IN CONTEXT", 112, 180);
});
const wallText = new THREE.Mesh(
new THREE.PlaneGeometry(7.8, 1.95),
new THREE.MeshBasicMaterial({ map: wallTextTexture })
);
wallText.position.set(0, 4.45, -4.455);
scene.add(wallText);
}
buildArchitecture();
// -------------------------------------------------------------------------
// Statues, plaques, and candidate markers
// -------------------------------------------------------------------------
const statueRecords = new Map();
const pickables = [];
function createPlaqueTexture(def) {
return makeCanvasTexture(512, 320, (ctx, w, h) => {
ctx.fillStyle = "#f1ede3";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#252a33";
ctx.fillRect(0, 0, w, 54);
ctx.fillStyle = def.swatch;
ctx.fillRect(0, 54, 18, h - 54);
ctx.fillStyle = "#f4c84d";
ctx.fillRect(w - 66, 17, 36, 20);
ctx.fillStyle = "#f5f1e8";
ctx.font = "900 22px monospace";
ctx.fillText("MUSEUM OF REFERENCES", 38, 36);
ctx.fillStyle = "#20242c";
ctx.font = "900 72px monospace";
ctx.fillText(def.name, 39, 145);
ctx.fillStyle = "#737984";
ctx.font = "800 23px monospace";
ctx.fillText(def.code, 40, 188);
ctx.fillStyle = "#20242c";
ctx.font = "700 25px monospace";
ctx.fillText(def.material.toUpperCase(), 40, 230);
ctx.fillStyle = "#737984";
ctx.font = "700 21px monospace";
ctx.fillText(`${def.height.toFixed(2)} M`, 40, 269);
ctx.fillStyle = def.swatch;
ctx.fillRect(w - 132, 97, 92, 92);
ctx.strokeStyle = "#20242c";
ctx.lineWidth = 8;
ctx.strokeRect(w - 132, 97, 92, 92);
});
}
function buildStatue(def) {
const group = new THREE.Group();
group.position.set(def.x, 0.56, -0.75);
group.userData.objectId = def.id;
scene.add(group);
const materials = [];
function trackedMaterial(color, options = {}) {
const material = standardMaterial(color, options);
materials.push({
material,
baseColor: material.color.clone(),
baseEmissive: material.emissive.clone()
});
return material;
}
const mainMaterial = trackedMaterial(def.color);
const skinMaterial = trackedMaterial(
def.id === "ink" ? 0xb98468 : 0xd7a47c
);
const darkMaterial = trackedMaterial(0x25272d);
const hairMaterial = trackedMaterial(
def.id === "cloud" ? 0xc9c7c0 :
def.id === "ember" ? 0x462d2b :
def.id === "moss" ? 0x4a392c :
def.id === "tide" ? 0x243c54 : 0x202128
);
const scale = def.height / 3.25;
const footHeight = 0.2;
const legHeight = 0.82 * scale;
const torsoHeight = 1.15 * scale;
const headSize = 0.68 * scale;
const torsoBottom = footHeight + legHeight;
const torsoCenter = torsoBottom + torsoHeight / 2;
const headCenter = torsoBottom + torsoHeight + 0.1 + headSize / 2;
function statueBox(size, position, material) {
const mesh = addBox(group, size, position, material);
mesh.userData.objectId = def.id;
pickables.push(mesh);
return mesh;
}
// Feet.
statueBox([0.38, footHeight, 0.58], [-0.25, footHeight / 2, 0.07], darkMaterial);
statueBox([0.38, footHeight, 0.58], [0.25, footHeight / 2, 0.07], darkMaterial);
// Legs.
statueBox(
[0.3, legHeight, 0.36],
[-0.23, footHeight + legHeight / 2, 0],
mainMaterial
);
statueBox(
[0.3, legHeight, 0.36],
[0.23, footHeight + legHeight / 2, 0],
mainMaterial
);
// Torso.
statueBox(
[0.92, torsoHeight, 0.54],
[0, torsoCenter, 0],
mainMaterial
);
// Arms and hands.
const armHeight = 1.04 * scale;
statueBox(
[0.27, armHeight, 0.38],
[-0.58, torsoCenter - 0.03, 0],
mainMaterial
);
statueBox(
[0.27, armHeight, 0.38],
[0.58, torsoCenter - 0.03, 0],
mainMaterial
);
statueBox(
[0.28, 0.27, 0.38],
[-0.58, torsoCenter - armHeight / 2 - 0.05, 0],
skinMaterial
);
statueBox(
[0.28, 0.27, 0.38],
[0.58, torsoCenter - armHeight / 2 - 0.05, 0],
skinMaterial
);
// Neck and head.
statueBox(
[0.31, 0.18, 0.34],
[0, torsoBottom + torsoHeight + 0.07, 0],
skinMaterial
);
statueBox(
[headSize, headSize, 0.64],
[0, headCenter, 0],
skinMaterial
);
// Hair or cap.
statueBox(
[headSize + 0.05, 0.18 * scale, 0.68],
[0, headCenter + headSize / 2, 0],
hairMaterial
);
if (def.id === "tide") {
statueBox(
[0.85, 0.28, 0.76],
[0, headCenter + headSize / 2 + 0.12, 0],
trackedMaterial(0x65b5e6)
);
}
// Face pixels.
statueBox(
[0.085, 0.085, 0.045],
[-0.15 * scale, headCenter + 0.04, 0.342],
darkMaterial
);
statueBox(
[0.085, 0.085, 0.045],
[0.15 * scale, headCenter + 0.04, 0.342],
darkMaterial
);
statueBox(
[0.18, 0.045, 0.045],
[0, headCenter - 0.17, 0.342],
darkMaterial
);
// EMBER's red crest.
if (def.id === "ember") {
statueBox(
[0.31, 0.31, 0.15],
[0, torsoCenter + 0.22, 0.34],
trackedMaterial(0x9f1f31, { roughness: 0.55 })
);
statueBox(
[0.12, 0.12, 0.17],
[0, torsoCenter + 0.22, 0.37],
trackedMaterial(0xf2b84b)
);
}
// INK's silver belt.
if (def.id === "ink") {
statueBox(
[0.98, 0.14, 0.59],
[0, torsoBottom + 0.15, 0],
trackedMaterial(0xbfc5cc, {
metalness: 0.72,
roughness: 0.3
})
);
}
// Plinth.
const plinthMaterial = standardMaterial(0xeeeae0);
addBox(
scene,
[2.05, 0.56, 2.0],
[def.x, 0.28, -0.75],
plinthMaterial
);
addBox(
scene,
[1.75, 0.08, 1.7],
[def.x, 0.59, -0.75],
standardMaterial(0xd1cdc2)
);
// Physical museum plaque.
const plaqueTexture = createPlaqueTexture(def);
const plaqueSide = standardMaterial(0x303640);
const plaqueFront = new THREE.MeshStandardMaterial({
map: plaqueTexture,
roughness: 0.72
});
const plaqueMaterials = [
plaqueSide,
plaqueSide,
plaqueSide,
plaqueSide,
plaqueFront,
plaqueSide
];
const plaque = new THREE.Mesh(
new THREE.BoxGeometry(1.78, 0.88, 0.12),
plaqueMaterials
);
plaque.position.set(def.x, 0.99, 1.0);
plaque.castShadow = true;
plaque.receiveShadow = true;
scene.add(plaque);
addBox(
scene,
[0.11, 0.56, 0.11],
[def.x - 0.58, 0.3, 1.02],
plaqueSide
);
addBox(
scene,
[0.11, 0.56, 0.11],
[def.x + 0.58, 0.3, 1.02],
plaqueSide
);
const marker = createCandidateMarker(def);
statueRecords.set(def.id, {
def,
group,
materials,
marker
});
}
function createCandidateMarker(def) {
const group = new THREE.Group();
group.position.set(def.x, 0.65, -0.75);
group.visible = false;
scene.add(group);
const material = new THREE.MeshBasicMaterial({
color: 0xf4c84d,
transparent: true,
opacity: 0.6,
depthWrite: false
});
const height = def.height * 0.72;
const xOffset = 0.83;
const zOffset = 0.63;
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
addBox(
group,
[0.065, height, 0.065],
[sx * xOffset, height / 2, sz * zOffset],
material,
{ castShadow: false, receiveShadow: false }
);
addBox(
group,
[0.26, 0.065, 0.065],
[sx * (xOffset - 0.1), height, sz * zOffset],
material,
{ castShadow: false, receiveShadow: false }
);
addBox(
group,
[0.065, 0.065, 0.25],
[sx * xOffset, height, sz * (zOffset - 0.1)],
material,
{ castShadow: false, receiveShadow: false }
);
}
}
const floaters = [];
for (let index = 0; index < 3; index += 1) {
const floater = addBox(
group,
[0.17 - index * 0.025, 0.17 - index * 0.025, 0.17 - index * 0.025],
[index * 0.22 - 0.22, def.height + 0.8 + index * 0.12, 0],
material,
{ castShadow: false, receiveShadow: false }
);
floaters.push({
mesh: floater,
baseY: floater.position.y
});
}
group.userData.material = material;
group.userData.floaters = floaters;
return group;
}
objectDefs.forEach(buildStatue);
// -------------------------------------------------------------------------
// Context sign in the gallery
// -------------------------------------------------------------------------
const contextSign = new THREE.Group();
contextSign.visible = false;
scene.add(contextSign);
const contextBoard = addBox(
contextSign,
[2.9, 1.2, 0.13],
[0, 0, 0],
standardMaterial(0x20242d)
);
const contextFaceMaterial = new THREE.MeshBasicMaterial({
transparent: true
});
const contextFace = new THREE.Mesh(
new THREE.PlaneGeometry(2.84, 1.14),
contextFaceMaterial
);
contextFace.position.z = 0.071;
contextSign.add(contextFace);
addBox(
contextSign,
[0.12, 0.45, 0.12],
[0, -0.77, 0],
standardMaterial(0xf4c84d)
);
contextSign.userData.baseY = 4.55;
function updateContextSign(scenario) {
const texture = makeCanvasTexture(768, 300, (ctx, w, h) => {
ctx.fillStyle = "#20242d";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#f4c84d";
ctx.fillRect(0, 0, w, 45);
ctx.fillStyle = "#20242d";
ctx.font = "900 23px monospace";
ctx.fillText("CONTEXT NOTE", 28, 31);
ctx.fillStyle = "#f4f0e6";
ctx.font = "800 28px monospace";
drawWrappedText(ctx, scenario.context, 28, 91, w - 56, 40, 3);
ctx.fillStyle = "#99a1ad";
ctx.font = "700 18px monospace";
ctx.fillText(scenario.source.toUpperCase(), 28, 265);
});
if (contextFaceMaterial.map) {
contextFaceMaterial.map.dispose();
}
contextFaceMaterial.map = texture;
contextFaceMaterial.needsUpdate = true;
const target = objectById.get(scenario.target);
contextSign.position.set(target.x, contextSign.userData.baseY, -0.55);
}
// -------------------------------------------------------------------------
// Interface
// -------------------------------------------------------------------------
const phraseTabs = document.getElementById("phraseTabs");
const phraseTitle = document.getElementById("phraseTitle");
const utterance = document.getElementById("utterance");
const speaker = document.getElementById("speaker");
const candidateList = document.getElementById("candidateList");
const candidateCount = document.getElementById("candidateCount");
const contextButton = document.getElementById("contextButton");
const contextCard = document.getElementById("contextCard");
const contextText = document.getElementById("contextText");
const contextSource = document.getElementById("contextSource");
const resultCard = document.getElementById("resultCard");
const resultTitle = document.getElementById("resultTitle");
const resultText = document.getElementById("resultText");
const objectList = document.getElementById("objectList");
const selectionNote = document.getElementById("selectionNote");
const statusNumber = document.getElementById("statusNumber");
const statusTitle = document.getElementById("statusTitle");
const statusText = document.getElementById("statusText");
const stepOne = document.getElementById("stepOne");
const stepTwo = document.getElementById("stepTwo");
scenarios.forEach((scenario) => {
const button = document.createElement("button");
button.className = "phrase-tab";
button.type = "button";
button.dataset.scenario = scenario.id;
button.textContent = scenario.tab;
button.addEventListener("click", () => selectScenario(scenario));
phraseTabs.append(button);
});
function buildObjectList() {
objectList.innerHTML = "";
objectDefs.forEach((def) => {
const button = document.createElement("button");
button.className = "object-row";
button.type = "button";
button.dataset.objectId = def.id;
button.innerHTML = `
<span class="candidate-swatch" style="--swatch:${def.swatch}"></span>
<span>
<strong>${def.name}</strong>
<small>${def.material} · ${def.cue}</small>
</span>
<span class="object-code">${def.code}</span>
`;
button.addEventListener("click", () => {
selectObject(def.id);
focusObject(def.id);
});
objectList.append(button);
});
}
buildObjectList();
function selectScenario(scenario) {
activeScenario = scenario;
phase = "candidates";
selectedObjectId = scenario.candidates[0];
phraseTitle.textContent = `“${scenario.phrase}”`;
speaker.textContent = scenario.speaker;
utterance.textContent = scenario.utterance;
contextCard.hidden = true;
resultCard.hidden = true;
contextButton.textContent = "ADD CURATOR CONTEXT →";
stepOne.classList.add("active");
stepTwo.classList.remove("active");
statusNumber.textContent = "1";
statusTitle.textContent = "IDENTIFY THE CANDIDATES";
statusText.textContent =
scenario.candidates.length > 1
? `${scenario.candidates.length} objects satisfy the wording before context is considered.`
: "This description already identifies one object in the collection.";
[...phraseTabs.children].forEach((button) => {
button.classList.toggle("active", button.dataset.scenario === scenario.id);
});
applyHighlights();
renderCandidateList();
updateObjectSelection();
}
function renderCandidateList() {
candidateList.innerHTML = "";
candidateCount.textContent = `${activeScenario.candidates.length} possible`;
activeScenario.candidates.forEach((id, index) => {
const def = objectById.get(id);
const button = document.createElement("button");
button.type = "button";
button.className = "candidate";
button.dataset.objectId = id;
if (phase === "context" && id === activeScenario.target) {
button.classList.add("resolved");
}
button.innerHTML = `
<span class="candidate-swatch" style="--swatch:${def.swatch}"></span>
<span>
<strong>${def.name}</strong>
<small>${def.material} · ${def.height.toFixed(2)} m · ${def.cue}</small>
</span>
<span class="candidate-tag">
${
phase === "context" && id === activeScenario.target
? "MATCH"
: `CANDIDATE ${String.fromCharCode(65 + index)}`
}
</span>
`;
button.addEventListener("click", () => {
selectObject(id);
focusObject(id);
});
candidateList.append(button);
});
}
function selectObject(id) {
selectedObjectId = id;
updateObjectSelection();
}
function updateObjectSelection() {
[...objectList.children].forEach((button) => {
button.classList.toggle(
"active",
button.dataset.objectId === selectedObjectId
);
});
[...candidateList.children].forEach((button) => {
button.classList.toggle(
"active",
button.dataset.objectId === selectedObjectId
);
});
const selected = objectById.get(selectedObjectId);
if (selected) {
selectionNote.textContent =
phase === "context"
? `Resolved referent: ${selected.name}. ${selected.detail}`
: `Inspecting ${selected.name}. ${selected.detail}`;
}
}
function applyHighlights() {
statueRecords.forEach((record, id) => {
const isCandidate = activeScenario.candidates.includes(id);
const isTarget = phase === "context" && id === activeScenario.target;
const visible = phase === "candidates" ? isCandidate : isTarget;
record.marker.visible = visible;
record.marker.userData.material.color.set(
isTarget ? 0x65d69b : 0xf4c84d
);
record.marker.userData.material.opacity = isTarget ? 0.82 : 0.56;
record.materials.forEach(({ material }) => {
material.emissive.set(
isTarget ? 0x236d4b : isCandidate ? 0x5e4c11 : 0x000000
);
material.emissiveIntensity = isTarget ? 0.22 : isCandidate ? 0.1 : 0;
});
});
if (phase === "context") {
updateContextSign(activeScenario);
contextSign.visible = true;
const target = objectById.get(activeScenario.target);
contextSpotTarget.position.set(target.x, 1.8, -0.75);
contextSpot.position.set(target.x, 6.8, 1.2);
contextSpot.intensity = 22;
} else {
contextSign.visible = false;
contextSpot.intensity = 0;
}
}
contextButton.addEventListener("click", () => {
if (phase === "candidates") {
phase = "context";
contextText.textContent = activeScenario.context;
contextSource.textContent = `Source: ${activeScenario.source}`;
contextCard.hidden = false;
const target = objectById.get(activeScenario.target);
resultTitle.textContent = target.name;
resultText.textContent = activeScenario.reason;
resultCard.hidden = false;
contextButton.textContent = "REOPEN CANDIDATES ↺";
stepOne.classList.remove("active");
stepTwo.classList.add("active");
statusNumber.textContent = "2";
statusTitle.textContent = "CONTEXT RESOLVES THE REFERENCE";
statusText.textContent = `${target.name} is the unique object satisfying the phrase plus contextual clue.`;
applyHighlights();
renderCandidateList();
updateObjectSelection();
focusObject(activeScenario.target);
} else {
selectScenario(activeScenario);
}
});
document.getElementById("nextButton").addEventListener("click", () => {
const currentIndex = scenarios.indexOf(activeScenario);
selectScenario(scenarios[(currentIndex + 1) % scenarios.length]);
});
// -------------------------------------------------------------------------
// Custom camera controls
// -------------------------------------------------------------------------
function focusObject(id) {
const def = objectById.get(id);
cameraGoal = {
target: new THREE.Vector3(def.x * 0.72, 1.55, -0.05),
radius: 9.2,
theta: 0.28,
phi: 1.08
};
}
function resetView() {
cameraGoal = {
target: new THREE.Vector3(0, 1.35, 0),
radius: 15.6,
theta: 0.32,
phi: 1.08
};
}
document.getElementById("resetView").addEventListener("click", resetView);
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let dragging = false;
let pointerMoved = false;
let previousX = 0;
let previousY = 0;
function updatePointer(event) {
const bounds = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - bounds.left) / bounds.width) * 2 - 1;
pointer.y = -((event.clientY - bounds.top) / bounds.height) * 2 + 1;
}
function pickObject(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickables, false);
if (hits.length) {
const id = hits[0].object.userData.objectId;
selectObject(id);
focusObject(id);
}
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerMoved = false;
previousX = event.clientX;
previousY = event.clientY;
cameraGoal = null;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (dragging) {
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
if (Math.abs(deltaX) + Math.abs(deltaY) > 2) {
pointerMoved = true;
}
view.theta -= deltaX * 0.006;
view.phi = THREE.MathUtils.clamp(
view.phi - deltaY * 0.005,
0.58,
1.34
);
previousX = event.clientX;
previousY = event.clientY;
} else {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickables, false);
renderer.domElement.style.cursor = hits.length ? "pointer" : "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
const wasDragging = dragging;
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
if (wasDragging && !pointerMoved) {
pickObject(event);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraGoal = null;
view.radius = THREE.MathUtils.clamp(
view.radius * Math.exp(event.deltaY * 0.001),
7.5,
22
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLButtonElement) {
return;
}
if (event.key === "ArrowLeft") {
view.theta -= 0.09;
} else if (event.key === "ArrowRight") {
view.theta += 0.09;
} else if (event.key === "ArrowUp") {
view.phi = Math.max(0.58, view.phi - 0.07);
} else if (event.key === "ArrowDown") {
view.phi = Math.min(1.34, view.phi + 0.07);
} else if (event.key === "+" || event.key === "=") {
view.radius = Math.max(7.5, view.radius - 0.6);
} else if (event.key === "-" || event.key === "_") {
view.radius = Math.min(22, view.radius + 0.6);
} else if (event.key.toLowerCase() === "r") {
resetView();
}
});
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
if (!width || !height) {
return;
}
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
new ResizeObserver(resize).observe(stage);
resize();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
if (cameraGoal) {
view.target.lerp(cameraGoal.target, 0.075);
view.radius += (cameraGoal.radius - view.radius) * 0.075;
view.theta += (cameraGoal.theta - view.theta) * 0.075;
view.phi += (cameraGoal.phi - view.phi) * 0.075;
const settled =
view.target.distanceTo(cameraGoal.target) < 0.015 &&
Math.abs(view.radius - cameraGoal.radius) < 0.02 &&
Math.abs(view.theta - cameraGoal.theta) < 0.002 &&
Math.abs(view.phi - cameraGoal.phi) < 0.002;
if (settled) {
cameraGoal = null;
}
}
updateCamera();
statueRecords.forEach((record, index) => {
const marker = record.marker;
if (!marker.visible) {
return;
}
marker.userData.material.opacity =
phase === "context"
? 0.74 + Math.sin(elapsed * 3 + index) * 0.08
: 0.48 + Math.sin(elapsed * 2.5 + index) * 0.12;
marker.userData.floaters.forEach((floater, floaterIndex) => {
floater.mesh.position.y =
floater.baseY +
Math.sin(elapsed * 2.4 + index + floaterIndex * 0.8) * 0.09;
floater.mesh.rotation.y = elapsed * 1.2 + floaterIndex;
});
});
if (contextSign.visible) {
contextSign.position.y =
contextSign.userData.baseY + Math.sin(elapsed * 1.8) * 0.045;
}
renderer.render(scene, camera);
}
selectScenario(activeScenario);
renderer.setAnimationLoop(animate);
loading.hidden = true;
</script>
</body>
</html>
```