Prompt specification
Build or customize the Three.js 3D scene "Multilingual Museum Label Framework" 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: Multilingual Museum Label Framework
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/multilingual-museum-label-framework-x3431
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring equivalent meaning across languages and representations. Build a museum display with slots for verified translations of short spatial descriptions. Keep language labels separate from geometry and require source checking before inserting real-language examples. Voxel style.
Acceptance checks: Run entirely inside a sandbox allowing scripts with no fetch, external scripts other than the allowed Three.js module, navigation, or native form submission. Separate language labels from voxel geometry. Start with empty translation slots. Demonstrate verification with a transparent local workflow: a reviewer checks a reference separately, then can record the source and explicit confirmation through buttons before any real-language example is inserted. Never claim that an unchecked entry was verified.
Return a single complete HTML document. It must work in a sandbox that allows scripts, with the cdnjs Three.js r160 module and inline CSS. Use procedural geometry and local button handlers; no native form submission, pointer lock, remote assets, or runtime network requests besides Three.js.
Working Three.js Starter (multilingual-museum-label-framework-x3431):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light">
<link rel="icon" href="data:,">
<title>Museum of Parallel Meaning — Voxel Translations</title>
<style>
:root {
--paper: #f1eee6;
--paper-deep: #e4dfd3;
--ink: #17212b;
--muted: #66717c;
--line: #d7d1c5;
--white: #fffdf8;
--navy: #101923;
--navy-soft: #1b2937;
--gold: #e8b84b;
--green: #237a57;
--red: #a33b36;
--shadow: 0 24px 70px rgba(28, 34, 40, 0.14);
--radius: 24px;
}
* {
box-sizing: border-box;
}
html {
background: var(--paper);
}
body {
margin: 0;
min-width: 320px;
min-height: 100vh;
color: var(--ink);
background:
linear-gradient(rgba(23, 33, 43, 0.035) 1px, transparent 1px),
linear-gradient(90deg, rgba(23, 33, 43, 0.035) 1px, transparent 1px),
var(--paper);
background-size: 28px 28px;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
line-height: 1.45;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
button:focus-visible,
input:focus-visible,
canvas:focus-visible {
outline: 3px solid rgba(232, 184, 75, 0.9);
outline-offset: 3px;
}
.masthead {
width: min(1500px, calc(100% - 32px));
margin: 0 auto;
min-height: 78px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
border-bottom: 1px solid var(--line);
}
.wordmark {
display: flex;
align-items: center;
gap: 12px;
font-size: 0.76rem;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.wordmark-mark {
width: 34px;
height: 34px;
display: grid;
place-items: center;
color: #fff9e8;
background: var(--ink);
box-shadow: 5px 5px 0 var(--gold);
letter-spacing: 0;
}
.exhibit-meta {
color: var(--muted);
font-size: 0.72rem;
font-weight: 750;
letter-spacing: 0.13em;
text-transform: uppercase;
text-align: right;
}
main {
width: min(1500px, calc(100% - 32px));
margin: 22px auto 30px;
}
.gallery-grid {
display: grid;
grid-template-columns: minmax(0, 1.35fr) minmax(380px, 0.8fr);
gap: 18px;
align-items: stretch;
}
.stage-wrap {
position: relative;
min-height: 720px;
overflow: hidden;
isolation: isolate;
border-radius: var(--radius);
background: var(--navy);
box-shadow: var(--shadow);
}
#stage-host {
position: absolute;
inset: 0;
}
#stage-host canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage-host canvas:active {
cursor: grabbing;
}
.webgl-fallback {
position: absolute;
inset: 0;
display: grid;
place-items: center;
padding: 40px;
color: #f5f0e5;
background: var(--navy);
text-align: center;
}
.webgl-fallback[hidden] {
display: none;
}
.stage-top {
position: absolute;
z-index: 3;
top: 20px;
left: 20px;
right: 20px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
pointer-events: none;
}
.stage-chip {
display: inline-flex;
align-items: center;
gap: 9px;
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 999px;
color: #e9edf0;
background: rgba(10, 17, 24, 0.66);
backdrop-filter: blur(10px);
font-size: 0.68rem;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.stage-chip::before {
content: "";
width: 7px;
height: 7px;
background: var(--gold);
box-shadow: 0 0 14px rgba(232, 184, 75, 0.8);
}
.stage-tools {
display: flex;
gap: 7px;
pointer-events: auto;
}
.stage-tool {
min-width: 38px;
height: 38px;
padding: 0 11px;
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 11px;
color: #eef1f2;
background: rgba(10, 17, 24, 0.72);
backdrop-filter: blur(10px);
cursor: pointer;
font-size: 0.8rem;
font-weight: 750;
}
.stage-tool:hover {
border-color: rgba(232, 184, 75, 0.7);
color: var(--gold);
}
.stage-caption {
position: absolute;
z-index: 3;
left: 22px;
right: 22px;
bottom: 22px;
display: flex;
align-items: end;
justify-content: space-between;
gap: 20px;
color: #f7f4eb;
pointer-events: none;
}
.caption-copy {
max-width: 560px;
padding: 22px 24px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 18px;
background: linear-gradient(135deg, rgba(8, 14, 20, 0.87), rgba(8, 14, 20, 0.62));
backdrop-filter: blur(12px);
}
.eyebrow {
margin: 0 0 7px;
color: var(--gold);
font-size: 0.68rem;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.caption-copy h1 {
margin: 0;
max-width: 520px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(2rem, 4vw, 4.25rem);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.045em;
}
.caption-copy p:last-child {
margin: 13px 0 0;
color: #c9d0d6;
font-size: 0.88rem;
}
.legend {
min-width: 170px;
padding: 15px 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 16px;
background: rgba(8, 14, 20, 0.72);
backdrop-filter: blur(12px);
color: #d7dde1;
font-size: 0.76rem;
}
.legend-title {
margin-bottom: 9px;
color: #87939d;
font-size: 0.63rem;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 6px;
}
.legend-swatch {
width: 13px;
height: 13px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.meaning-panel {
min-height: 720px;
padding: 24px;
border: 1px solid rgba(23, 33, 43, 0.08);
border-radius: var(--radius);
background: rgba(255, 253, 248, 0.95);
box-shadow: var(--shadow);
}
.panel-kicker {
margin: 0 0 7px;
color: var(--muted);
font-size: 0.68rem;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.meaning-panel h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(1.8rem, 3vw, 2.55rem);
font-weight: 500;
line-height: 1.03;
letter-spacing: -0.035em;
}
.panel-intro {
margin: 11px 0 20px;
color: var(--muted);
font-size: 0.88rem;
}
.relation-tabs {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
margin-bottom: 16px;
}
.relation-tab {
min-height: 52px;
padding: 9px 8px;
border: 1px solid var(--line);
border-radius: 12px;
background: transparent;
cursor: pointer;
font-size: 0.76rem;
font-weight: 750;
transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.relation-tab:hover {
transform: translateY(-1px);
border-color: #9d9587;
}
.relation-tab[aria-pressed="true"] {
border-color: var(--ink);
color: #fff;
background: var(--ink);
}
.proposition-card {
padding: 18px;
border: 1px solid var(--line);
border-radius: 17px;
background: #f7f3ea;
}
.proposition-label {
margin-bottom: 6px;
color: var(--muted);
font-size: 0.65rem;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.proposition-card p {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 1.25rem;
line-height: 1.25;
}
.spatial-diagram {
position: relative;
width: 100%;
height: 104px;
margin-top: 14px;
overflow: hidden;
border-radius: 12px;
background:
linear-gradient(rgba(23, 33, 43, 0.055) 1px, transparent 1px),
linear-gradient(90deg, rgba(23, 33, 43, 0.055) 1px, transparent 1px),
#eee9de;
background-size: 16px 16px;
}
.diagram-node {
position: absolute;
width: 35px;
height: 35px;
border-radius: 5px;
box-shadow:
inset -5px -5px 0 rgba(0, 0, 0, 0.12),
inset 3px 3px 0 rgba(255, 255, 255, 0.22),
0 6px 10px rgba(23, 33, 43, 0.12);
transition: transform 200ms ease, left 200ms ease, top 200ms ease;
}
.spatial-diagram[data-relation="above"] .diagram-node.first {
left: calc(50% - 17px);
top: 10px;
}
.spatial-diagram[data-relation="above"] .diagram-node.second {
left: calc(50% - 17px);
top: 59px;
}
.spatial-diagram[data-relation="left"] .diagram-node.first {
left: calc(50% - 62px);
top: 35px;
}
.spatial-diagram[data-relation="left"] .diagram-node.second {
left: calc(50% + 27px);
top: 35px;
}
.spatial-diagram[data-relation="front"] .diagram-node.first {
left: calc(50% - 9px);
top: 51px;
transform: scale(1.08);
box-shadow:
inset -5px -5px 0 rgba(0, 0, 0, 0.12),
inset 3px 3px 0 rgba(255, 255, 255, 0.22),
0 11px 13px rgba(23, 33, 43, 0.18);
}
.spatial-diagram[data-relation="front"] .diagram-node.second {
left: calc(50% - 43px);
top: 17px;
transform: scale(0.86);
}
.slots-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 16px;
margin: 22px 0 10px;
}
.slots-heading h3 {
margin: 0;
font-size: 0.78rem;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.slot-count {
color: var(--muted);
font-size: 0.74rem;
}
.slot-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.slot-card {
min-width: 0;
min-height: 152px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 14px;
background: var(--white);
transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.slot-card:hover {
transform: translateY(-2px);
border-color: #aaa294;
}
.slot-card.selected {
border-color: var(--ink);
box-shadow: inset 0 0 0 1px var(--ink);
}
.slot-card[data-verified="true"] {
border-color: #91b9a7;
background: #f6fbf8;
}
.slot-pick {
width: 100%;
padding: 0;
border: 0;
background: transparent;
cursor: pointer;
text-align: left;
}
.slot-language-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.slot-language {
font-size: 0.79rem;
font-weight: 820;
}
.slot-code {
color: #8a8172;
font-size: 0.64rem;
font-weight: 850;
letter-spacing: 0.12em;
}
.slot-status {
display: inline-block;
margin-top: 10px;
color: var(--muted);
font-size: 0.64rem;
font-weight: 800;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.slot-status.source-recorded {
color: #946b16;
}
.slot-status.confirmed {
color: var(--green);
}
.slot-translation {
min-height: 43px;
margin: 8px 0 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 1rem;
line-height: 1.25;
overflow-wrap: anywhere;
}
.slot-translation:empty::before {
content: "Empty — awaiting review";
color: #9a9285;
font-family: ui-sans-serif, system-ui, sans-serif;
font-size: 0.74rem;
font-style: italic;
}
.slot-source {
margin: 7px 0 0;
color: var(--muted);
font-size: 0.63rem;
line-height: 1.35;
overflow-wrap: anywhere;
}
.review-station {
display: grid;
grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
gap: 28px;
margin-top: 18px;
padding: 28px;
border: 1px solid rgba(23, 33, 43, 0.08);
border-radius: var(--radius);
background: var(--white);
box-shadow: var(--shadow);
}
.review-badge {
display: inline-flex;
align-items: center;
gap: 8px;
margin-bottom: 13px;
padding: 7px 10px;
border: 1px solid #d7c28f;
border-radius: 999px;
color: #7f5e16;
background: #fff8df;
font-size: 0.66rem;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.review-badge::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: currentColor;
}
.review-badge[data-state="confirmed"] {
color: var(--green);
border-color: #9fc5b4;
background: #eff9f4;
}
.review-intro h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(2rem, 4vw, 3.2rem);
font-weight: 500;
line-height: 1;
letter-spacing: -0.04em;
}
.review-copy {
margin: 13px 0 19px;
color: var(--muted);
font-size: 0.87rem;
}
.draft-card {
padding: 16px;
border: 1px dashed #bfb6a5;
border-radius: 14px;
background: #f8f5ee;
}
.draft-label {
margin-bottom: 7px;
color: var(--muted);
font-size: 0.63rem;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.draft-translation {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 1.22rem;
line-height: 1.35;
overflow-wrap: anywhere;
}
.draft-disclaimer {
margin: 11px 0 0;
color: #8a6b26;
font-size: 0.7rem;
font-weight: 700;
}
.workflow {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.workflow-step {
display: flex;
flex-direction: column;
min-width: 0;
padding: 18px;
border: 1px solid var(--line);
border-radius: 16px;
background: #faf7f0;
}
.step-heading {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 14px;
}
.step-number {
width: 27px;
height: 27px;
display: grid;
place-items: center;
flex: 0 0 auto;
border-radius: 8px;
color: #fff;
background: var(--ink);
font-size: 0.73rem;
font-weight: 850;
}
.step-heading h3 {
margin: 0;
font-size: 0.83rem;
font-weight: 850;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.check-row {
display: flex;
align-items: flex-start;
gap: 9px;
color: #3c4650;
font-size: 0.79rem;
font-weight: 680;
cursor: pointer;
}
.check-row input {
width: 17px;
height: 17px;
margin: 1px 0 0;
flex: 0 0 auto;
accent-color: var(--green);
}
.field-label {
display: block;
margin: 15px 0 6px;
color: var(--muted);
font-size: 0.64rem;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.source-input {
width: 100%;
min-height: 42px;
padding: 10px 11px;
border: 1px solid #cfc7b8;
border-radius: 10px;
color: var(--ink);
background: #fff;
font-size: 0.78rem;
}
.source-input::placeholder {
color: #a49c8f;
}
.field-help {
margin: 7px 0 0;
color: var(--muted);
font-size: 0.66rem;
line-height: 1.4;
}
.action-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 15px;
}
.action-button {
min-height: 40px;
padding: 9px 14px;
border: 1px solid var(--ink);
border-radius: 10px;
color: #fff;
background: var(--ink);
cursor: pointer;
font-size: 0.75rem;
font-weight: 800;
}
.action-button.secondary {
color: var(--ink);
background: transparent;
}
.action-button:hover:not(:disabled) {
transform: translateY(-1px);
}
.action-button:disabled {
cursor: not-allowed;
opacity: 0.36;
}
.action-button.confirm {
border-color: var(--green);
background: var(--green);
}
.review-status {
min-height: 38px;
margin: 13px 0 0;
padding: 9px 10px;
border-radius: 9px;
color: #705b28;
background: #f8efd6;
font-size: 0.69rem;
line-height: 1.4;
}
.review-status.confirmed {
color: #245f47;
background: #e7f5ee;
}
.source-receipt {
margin: 9px 0 0;
color: var(--muted);
font-size: 0.67rem;
line-height: 1.4;
overflow-wrap: anywhere;
}
.footer-note {
width: min(1500px, calc(100% - 32px));
margin: 0 auto 28px;
display: flex;
justify-content: space-between;
gap: 24px;
color: #777066;
font-size: 0.68rem;
}
.footer-note strong {
color: #4f4941;
}
@media (max-width: 1120px) {
.gallery-grid {
grid-template-columns: 1fr;
}
.stage-wrap,
.meaning-panel {
min-height: 680px;
}
.meaning-panel {
min-height: auto;
}
}
@media (max-width: 780px) {
.masthead,
main,
.footer-note {
width: min(100% - 20px, 1500px);
}
.masthead {
min-height: 68px;
}
.exhibit-meta {
display: none;
}
main {
margin-top: 12px;
}
.stage-wrap {
min-height: 610px;
}
.stage-caption {
align-items: stretch;
flex-direction: column;
}
.legend {
display: none;
}
.caption-copy h1 {
font-size: clamp(2.1rem, 11vw, 3.2rem);
}
.meaning-panel,
.review-station {
padding: 18px;
}
.slot-grid,
.workflow,
.review-station {
grid-template-columns: 1fr;
}
.review-station {
gap: 22px;
}
.footer-note {
flex-direction: column;
gap: 8px;
}
}
@media (max-width: 430px) {
.slot-grid {
grid-template-columns: 1fr;
}
.relation-tab {
min-height: 58px;
font-size: 0.69rem;
}
.stage-top {
align-items: flex-start;
}
.stage-chip {
max-width: 170px;
line-height: 1.3;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
}
}
</style>
</head>
<body>
<header class="masthead">
<div class="wordmark">
<span class="wordmark-mark" aria-hidden="true">M</span>
<span>Museum of Parallel Meaning</span>
</div>
<div class="exhibit-meta">Exhibit 04 · Voxel translations · Local review protocol</div>
</header>
<main>
<section class="gallery-grid" aria-label="Voxel translation gallery">
<div class="stage-wrap">
<div id="stage-host">
<div id="webgl-fallback" class="webgl-fallback" hidden>
<div>
<strong>WebGL is unavailable in this sandbox.</strong>
<p>The translation review workflow remains available below.</p>
</div>
</div>
</div>
<div class="stage-top">
<div class="stage-chip">Procedural voxel study / Live</div>
<div class="stage-tools" aria-label="Camera controls">
<button class="stage-tool" id="rotate-left" type="button" aria-label="Rotate view left">↶</button>
<button class="stage-tool" id="zoom-out" type="button" aria-label="Zoom out">−</button>
<button class="stage-tool" id="zoom-in" type="button" aria-label="Zoom in">+</button>
<button class="stage-tool" id="reset-camera" type="button" aria-label="Reset camera view">Reset</button>
</div>
</div>
<div class="stage-caption">
<div class="caption-copy">
<p class="eyebrow">Geometric witness</p>
<h1>One arrangement.<br>Many ways to say it.</h1>
<p id="relation-caption">The amber cube is above the blue cube.</p>
</div>
<div class="legend" aria-label="Current exhibit colors">
<div class="legend-title">Selected relation</div>
<div class="legend-row">
<span class="legend-swatch" id="legend-first" style="background:#f4a62a"></span>
<span id="legend-first-name">amber</span>
</div>
<div class="legend-row">
<span class="legend-swatch" id="legend-second" style="background:#3c83f6"></span>
<span id="legend-second-name">blue</span>
</div>
<div class="legend-row" style="margin-top:12px;color:#87939d">Drag to orbit · scroll to zoom</div>
</div>
</div>
</div>
<aside class="meaning-panel" aria-labelledby="slots-title">
<p class="panel-kicker">Parallel reading room</p>
<h2 id="slots-title">Translation slots</h2>
<p class="panel-intro">
Choose a spatial proposition, then review candidate wording. Every slot begins empty and is populated only after a source is recorded and a reviewer confirms the wording.
</p>
<div class="relation-tabs" aria-label="Spatial proposition">
<button class="relation-tab" type="button" data-relation="above" aria-pressed="true">01 · Above</button>
<button class="relation-tab" type="button" data-relation="left" aria-pressed="false">02 · Left of</button>
<button class="relation-tab" type="button" data-relation="front" aria-pressed="false">03 · In front</button>
</div>
<article class="proposition-card">
<div class="proposition-label">English source proposition</div>
<p id="english-proposition">The amber cube is above the blue cube.</p>
<div id="spatial-diagram" class="spatial-diagram" data-relation="above" aria-label="Schematic arrangement of two cubes"></div>
</article>
<div class="slots-heading">
<h3>Language slots</h3>
<span id="slot-count" class="slot-count" aria-live="polite">0 / 6 confirmed</span>
</div>
<div id="translation-slots" class="slot-grid" aria-label="Translation slots"></div>
</aside>
</section>
<section class="review-station" aria-labelledby="review-title">
<div class="review-intro">
<div id="candidate-badge" class="review-badge" data-state="unverified">Unverified draft</div>
<h2 id="review-title">Nothing enters a slot by default.</h2>
<p class="review-copy">
Check an approved reference separately. Record its citation here, compare the candidate with the English proposition, and then use the confirmation button. The gallery never opens or inspects the reference.
</p>
<div class="draft-card">
<div id="draft-language" class="draft-label">Spanish / candidate draft</div>
<p id="candidate-translation" class="draft-translation" dir="auto">El cubo ámbar está encima del cubo azul.</p>
<p class="draft-disclaimer">Candidate wording only — not a confirmed translation.</p>
</div>
</div>
<div>
<div class="workflow">
<article class="workflow-step">
<div class="step-heading">
<span class="step-number">1</span>
<h3>Record a source</h3>
</div>
<label class="check-row" for="reference-check">
<input id="reference-check" type="checkbox">
<span>I checked an approved reference separately.</span>
</label>
<label class="field-label" for="source-input">Reference source</label>
<input
id="source-input"
class="source-input"
type="text"
autocomplete="off"
spellcheck="false"
placeholder="Title, URL, DOI, or local dossier reference"
>
<p class="field-help">A local citation only. Recording a source does not insert the translation.</p>
<div class="action-row">
<button id="record-source" class="action-button secondary" type="button" disabled>Record source</button>
</div>
<p id="source-receipt" class="source-receipt">No local source receipt.</p>
</article>
<article class="workflow-step">
<div class="step-heading">
<span class="step-number">2</span>
<h3>Confirm the wording</h3>
</div>
<label class="check-row" for="meaning-check">
<input id="meaning-check" type="checkbox">
<span>I compared this wording with the English proposition and confirmed the same spatial relation.</span>
</label>
<p class="field-help">
The second button is the only action that inserts real-language wording into a slot. Unchecking either review condition removes the confirmed wording.
</p>
<div class="action-row">
<button id="confirm-translation" class="action-button confirm" type="button" disabled>Confirm and insert</button>
</div>
<p id="review-status" class="review-status" aria-live="polite">No source recorded. The slot remains empty.</p>
</article>
</div>
</div>
</section>
</main>
<footer class="footer-note">
<span><strong>Separation rule:</strong> language labels and review metadata are HTML layers; the Three.js canvas contains procedural geometry only.</span>
<span>No automatic verification · No saved entries · Empty on every fresh load</span>
</footer>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const LANGUAGES = [
{ code: "es", name: "Spanish", native: "Español", direction: "ltr" },
{ code: "fr", name: "French", native: "Français", direction: "ltr" },
{ code: "de", name: "German", native: "Deutsch", direction: "ltr" },
{ code: "ja", name: "Japanese", native: "日本語", direction: "ltr" },
{ code: "ar", name: "Arabic", native: "العربية", direction: "rtl" },
{ code: "sw", name: "Swahili", native: "Kiswahili", direction: "ltr" }
];
const PROPOSITIONS = {
above: {
label: "Above",
english: "The amber cube is above the blue cube.",
caption: "Amber rests above blue.",
firstName: "amber",
secondName: "blue",
firstColor: "#f4a62a",
secondColor: "#3c83f6",
translations: {
es: "El cubo ámbar está encima del cubo azul.",
fr: "Le cube ambre est au-dessus du cube bleu.",
de: "Der bernsteinfarbene Würfel ist über dem blauen Würfel.",
ja: "琥珀色の立方体は青い立方体の上にあります。",
ar: "المكعب الكهرماني فوق المكعب الأزرق.",
sw: "Kijengo cha jua kime juu ya kijengo cha bluu."
}
},
left: {
label: "Left of",
english: "The green cube is left of the yellow cube.",
caption: "Green sits to the left of yellow.",
firstName: "green",
secondName: "yellow",
firstColor: "#42d392",
secondColor: "#ffd84a",
translations: {
es: "El cubo verde está a la izquierda del cubo amarillo.",
fr: "Le cube vert est à gauche du cube jaune.",
de: "Der grüne Würfel ist links vom gelben Würfel.",
ja: "緑色の立方体は黄色の立方体の左にあります。",
ar: "المكعب الأخضر على يسار المكعب الأصفر.",
sw: "Kijengo cha kijani kime kushoto ya kijengo cha njano."
}
},
front: {
label: "In front",
english: "From the viewer's position, the violet cube is in front of the cyan cube.",
caption: "From the displayed viewpoint, violet sits in front of cyan.",
firstName: "violet",
secondName: "cyan",
firstColor: "#a96bff",
secondColor: "#38d9e6",
translations: {
es: "Desde la posición del observador, el cubo violeta está delante del cubo cian.",
fr: "Du point de vue de l'observateur, le cube violet est devant le cube cyan.",
de: "Aus der Sicht des Betrachters liegt der violette Würfel vor dem cyanfarbenen Würfel.",
ja: "観測者の位置から見て、紫色の立方体はシアン色の立方体の前にあります。",
ar: "من موقع المشاهد، المكعب البنفسجي أمام المكعب السماوي.",
sw: "Kutoka nafasi ya mtazamaji, kijengo cha zambaraza kime mbele ya kijengo cha buluu."
}
}
};
const state = {
relation: "above",
language: "es",
records: {}
};
for (const relation of Object.keys(PROPOSITIONS)) {
state.records[relation] = {};
for (const language of LANGUAGES) {
state.records[relation][language.code] = {
referenceChecked: false,
source: "",
sourceRecorded: false,
meaningChecked: false,
confirmed: false,
output: ""
};
}
}
const elements = {
relationButtons: [...document.querySelectorAll("[data-relation]")],
englishProposition: document.getElementById("english-proposition"),
relationCaption: document.getElementById("relation-caption"),
diagram: document.getElementById("spatial-diagram"),
slots: document.getElementById("translation-slots"),
slotCount: document.getElementById("slot-count"),
candidateBadge: document.getElementById("candidate-badge"),
draftLanguage: document.getElementById("draft-language"),
candidateTranslation: document.getElementById("candidate-translation"),
referenceCheck: document.getElementById("reference-check"),
sourceInput: document.getElementById("source-input"),
recordSource: document.getElementById("record-source"),
sourceReceipt: document.getElementById("source-receipt"),
meaningCheck: document.getElementById("meaning-check"),
confirmTranslation: document.getElementById("confirm-translation"),
reviewStatus: document.getElementById("review-status"),
legendFirst: document.getElementById("legend-first"),
legendSecond: document.getElementById("legend-second"),
legendFirstName: document.getElementById("legend-first-name"),
legendSecondName: document.getElementById("legend-second-name"),
stageHost: document.getElementById("stage-host"),
fallback: document.getElementById("webgl-fallback"),
rotateLeft: document.getElementById("rotate-left"),
rotateRight: document.getElementById("rotate-right"),
zoomIn: document.getElementById("zoom-in"),
zoomOut: document.getElementById("zoom-out"),
resetCamera: document.getElementById("reset-camera")
};
let sceneApi = null;
function currentRecord() {
return state.records[state.relation][state.language];
}
function currentLanguage() {
return LANGUAGES.find((language) => language.code === state.language);
}
function currentProposition() {
return PROPOSITIONS[state.relation];
}
function currentCandidate() {
return currentProposition().translations[state.language];
}
function renderDiagram() {
const proposition = currentProposition();
elements.diagram.replaceChildren();
elements.diagram.dataset.relation = state.relation;
elements.diagram.setAttribute("aria-label", `Schematic arrangement: ${proposition.caption}`);
for (let index = 0; index < 2; index += 1) {
const node = document.createElement("span");
node.className = `diagram-node ${index === 0 ? "first" : "second"}`;
node.style.background = index === 0 ? proposition.firstColor : proposition.secondColor;
node.setAttribute("aria-hidden", "true");
elements.diagram.append(node);
}
}
function renderSlots() {
const proposition = currentProposition();
elements.slots.replaceChildren();
let confirmedCount = 0;
for (const language of LANGUAGES) {
const record = state.records[state.relation][language.code];
if (record.confirmed) confirmedCount += 1;
const card = document.createElement("article");
card.className = "slot-card";
card.dataset.language = language.code;
card.dataset.verified = String(record.confirmed);
card.setAttribute("aria-label", `Translation slot for ${language.name}`);
if (state.language === language.code) card.classList.add("selected");
const picker = document.createElement("button");
picker.className = "slot-pick";
picker.type = "button";
picker.setAttribute("aria-label", `Review ${language.name} candidate`);
const languageRow = document.createElement("span");
languageRow.className = "slot-language-row";
const languageName = document.createElement("span");
languageName.className = "slot-language";
languageName.textContent = language.name;
const languageCode = document.createElement("span");
languageCode.className = "slot-code";
languageCode.textContent = language.code.toUpperCase();
languageRow.append(languageName, languageCode);
picker.append(languageRow);
picker.addEventListener("click", () => {
state.language = language.code;
renderAll();
});
const status = document.createElement("span");
status.className = "slot-status";
if (record.confirmed) {
status.classList.add("confirmed");
status.textContent = "Reviewer-confirmed";
} else if (record.sourceRecorded) {
status.classList.add("source-recorded");
status.textContent = "Source recorded · not inserted";
} else {
status.textContent = "Awaiting review";
}
const output = document.createElement("p");
output.className = "slot-translation";
output.dir = language.direction;
output.textContent = record.confirmed ? record.output : "";
const source = document.createElement("p");
source.className = "slot-source";
source.textContent = record.sourceRecorded
? `Recorded source: ${record.source}`
: "";
card.append(picker, status, output, source);
elements.slots.append(card);
}
elements.slotCount.textContent = `${confirmedCount} / ${LANGUAGES.length} confirmed`;
elements.slots.setAttribute(
"aria-label",
`${confirmedCount} of ${LANGUAGES.length} slots confirmed for the ${proposition.label.toLowerCase()} proposition`
);
}
function renderReview() {
const language = currentLanguage();
const proposition = currentProposition();
const record = currentRecord();
const candidate = currentCandidate();
elements.draftLanguage.textContent = `${language.name} / ${language.native} · candidate draft`;
elements.candidateTranslation.textContent = candidate;
elements.candidateTranslation.dir = language.direction;
elements.referenceCheck.checked = record.referenceChecked;
elements.meaningCheck.checked = record.meaningChecked;
if (document.activeElement !== elements.sourceInput) {
elements.sourceInput.value = record.sourceRecorded ? record.source : "";
}
if (record.confirmed) {
elements.candidateBadge.dataset.state = "confirmed";
elements.candidateBadge.textContent = "Reviewer-confirmed";
elements.reviewStatus.classList.add("confirmed");
elements.reviewStatus.textContent = `Confirmed and inserted into the ${language.name} slot.`;
} else if (record.sourceRecorded) {
elements.candidateBadge.dataset.state = "source-recorded";
elements.candidateBadge.textContent = "Source recorded · wording not confirmed";
elements.reviewStatus.classList.remove("confirmed");
elements.reviewStatus.textContent = `Source recorded. The ${language.name} wording is still not inserted.`;
} else {
elements.candidateBadge.dataset.state = "unverified";
elements.candidateBadge.textContent = "Unverified draft";
elements.reviewStatus.classList.remove("confirmed");
elements.reviewStatus.textContent = `No source recorded. The ${language.name} slot remains empty.`;
}
elements.sourceReceipt.textContent = record.sourceRecorded
? `Local receipt: ${record.source}`
: "No local source receipt.";
elements.recordSource.disabled =
!record.referenceChecked ||
!elements.sourceInput.value.trim() ||
record.sourceRecorded;
elements.recordSource.textContent = record.sourceRecorded ? "Source recorded" : "Record source";
elements.confirmTranslation.disabled =
!record.sourceRecorded ||
!record.referenceChecked ||
!record.meaningChecked ||
record.confirmed;
elements.confirmTranslation.textContent = record.confirmed ? "Confirmed" : "Confirm and insert";
elements.englishProposition.textContent = proposition.english;
elements.relationCaption.textContent = proposition.caption;
elements.legendFirst.style.background = proposition.firstColor;
elements.legendSecond.style.background = proposition.secondColor;
elements.legendFirstName.textContent = proposition.firstName;
elements.legendSecondName.textContent = proposition.secondName;
}
function renderAll() {
renderSlots();
renderReview();
}
function selectRelation(relation) {
state.relation = relation;
for (const button of elements.relationButtons) {
button.setAttribute("aria-pressed", String(button.dataset.relation === relation));
}
renderDiagram();
renderAll();
if (sceneApi) sceneApi.setRelation(relation);
}
elements.relationButtons.forEach((button) => {
button.addEventListener("click", () => selectRelation(button.dataset.relation));
});
elements.referenceCheck.addEventListener("change", () => {
const record = currentRecord();
record.referenceChecked = elements.referenceCheck.checked;
if (!record.referenceChecked) {
record.source = "";
record.sourceRecorded = false;
record.meaningChecked = false;
record.confirmed = false;
record.output = "";
}
renderAll();
});
elements.meaningCheck.addEventListener("change", () => {
const record = currentRecord();
record.meaningChecked = elements.meaningCheck.checked;
if (!record.meaningChecked) {
record.confirmed = false;
record.output = "";
}
renderAll();
});
elements.sourceInput.addEventListener("input", () => {
const record = currentRecord();
if (record.sourceRecorded && elements.sourceInput.value !== record.source) {
record.source = "";
record.sourceRecorded = false;
record.meaningChecked = false;
record.confirmed = false;
record.output = "";
renderSlots();
}
renderReview();
});
elements.recordSource.addEventListener("click", () => {
const record = currentRecord();
const source = elements.sourceInput.value.trim();
if (!record.referenceChecked || !source || record.sourceRecorded) return;
record.source = source;
record.sourceRecorded = true;
record.referenceChecked = true;
record.confirmed = false;
record.output = "";
renderAll();
});
elements.confirmTranslation.addEventListener("click", () => {
const record = currentRecord();
if (
!record.sourceRecorded ||
!record.referenceChecked ||
!record.meaningChecked ||
record.confirmed
) {
return;
}
record.output = currentCandidate();
record.confirmed = true;
renderAll();
});
renderDiagram();
renderAll();
function buildScene() {
const host = elements.stageHost;
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.16;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("role", "img");
renderer.domElement.setAttribute(
"aria-label",
"Procedural voxel gallery showing three spatial relations. Drag to orbit and scroll to zoom."
);
renderer.domElement.tabIndex = 0;
host.append(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x101923);
scene.fog = new THREE.Fog(0x101923, 13, 24);
const camera = new THREE.OrthographicCamera(-5, 5, 4, -4, 0.1, 60);
const target = new THREE.Vector3(0, 1.2, 0);
const cameraState = {
yaw: 0,
pitch: 0.46,
zoom: 1,
width: 1,
height: 1
};
const ambient = new THREE.HemisphereLight(0xe8f1ff, 0x1b222c, 2.2);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight(0xffefd0, 4.2);
keyLight.position.set(4.5, 9, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1536, 1536);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const coolLight = new THREE.DirectionalLight(0x7ea8ff, 1.8);
coolLight.position.set(-6, 5, 4);
scene.add(coolLight);
const warmLight = new THREE.PointLight(0xffbd57, 18, 14, 2);
warmLight.position.set(0, 5.5, 1.5);
scene.add(warmLight);
function box(width, height, depth, material, x, y, z, castShadow = true, receiveShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(width, height, depth), material);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
scene.add(mesh);
return mesh;
}
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x17212b,
roughness: 0.92,
metalness: 0.02
});
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0x182431,
roughness: 0.95,
metalness: 0.01
});
const tileMaterialA = new THREE.MeshStandardMaterial({
color: 0x22303c,
roughness: 0.86
});
const tileMaterialB = new THREE.MeshStandardMaterial({
color: 0x1c2935,
roughness: 0.9
});
const plinthMaterial = new THREE.MeshStandardMaterial({
color: 0x263441,
roughness: 0.62,
metalness: 0.08
});
const plinthTopMaterial = new THREE.MeshStandardMaterial({
color: 0x344551,
roughness: 0.52,
metalness: 0.12
});
const darkTrimMaterial = new THREE.MeshStandardMaterial({
color: 0x0c131a,
roughness: 0.7,
metalness: 0.16
});
box(14, 0.36, 7, floorMaterial, 0, -0.26, 0, false, true);
box(14, 6.2, 0.28, wallMaterial, 0, 2.65, -3.45, false, true);
box(0.34, 6.3, 6.8, wallMaterial, -6.85, 2.65, 0, false, true);
box(0.34, 6.3, 6.8, wallMaterial, 6.85, 2.65, 0, false, true);
const tileGeometry = new THREE.BoxGeometry(0.82, 0.045, 0.7);
for (let x = -6; x <= 6; x += 1) {
for (let z = -2; z <= 2; z += 1) {
const tile = new THREE.Mesh(
tileGeometry,
(x + z) % 2 === 0 ? tileMaterialA : tileMaterialB
);
tile.position.set(x * 0.92, -0.055, z * 0.88);
tile.receiveShadow = true;
scene.add(tile);
}
}
const reliefMaterial = new THREE.MeshStandardMaterial({
color: 0x263a48,
roughness: 0.72,
metalness: 0.04
});
const reliefAccent = new THREE.MeshStandardMaterial({
color: 0x344f62,
emissive: 0x172d3b,
emissiveIntensity: 0.4,
roughness: 0.6
});
const reliefPattern = [1, 3, 1, 0, 2, 2, 0, 1, 2, 1, 0, 0, 1, 2, 3, 1];
for (let index = 0; index < reliefPattern.length; index += 1) {
const height = [0.42, 0.72, 1.02][reliefPattern[index]];
const relief = new THREE.Mesh(
new THREE.BoxGeometry(0.58, height, 0.22),
index % 4 === 0 ? reliefAccent : reliefMaterial
);
relief.position.set(-5.3 + index * 0.72, 3.7 + height / 2, -3.24);
relief.castShadow = true;
scene.add(relief);
}
for (const x of [-5.9, 5.9]) {
for (let index = 0; index < 5; index += 1) {
const block = new THREE.Mesh(
new THREE.BoxGeometry(0.44, 0.44, 0.44),
index % 2 ? reliefMaterial : reliefAccent
);
block.position.set(x, 0.05 + index * 0.45, -2.9);
block.castShadow = true;
scene.add(block);
}
}
const lightStripMaterial = new THREE.MeshStandardMaterial({
color: 0xffe6aa,
emissive: 0xffc75b,
emissiveIntensity: 1.5,
roughness: 0.4
});
for (const x of [-2.7, 2.7]) {
box(2.1, 0.07, 0.22, lightStripMaterial, x, 5.42, -2.85, false, false);
}
const voxelGeometry = new THREE.BoxGeometry(0.235, 0.235, 0.235);
const objectRecords = [];
const markerGroups = {};
const caseGroups = {};
const relationVisuals = {
above: {
subjectColor: 0xf4a62a,
referenceColor: 0x3c83f6,
subjectPosition: [0, 1.9, 0],
referencePosition: [0, 0.82, 0],
motionAxis: "y",
caseX: -3.15
},
left: {
subjectColor: 0x42d392,
referenceColor: 0xffd84a,
subjectPosition: [-0.73, 0.82, 0],
referencePosition: [0.73, 0.82, 0],
motionAxis: "x",
caseX: 0
},
front: {
subjectColor: 0xa96bff,
referenceColor: 0x38d9e6,
subjectPosition: [0, 0.82, 0.68],
referencePosition: [0, 0.82, -0.68],
motionAxis: "z",
caseX: 3.15
}
};
function makeVoxelCube(color) {
const group = new THREE.Group();
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.46,
metalness: 0.07
});
for (let x = 0; x < 3; x += 1) {
for (let y = 0; y < 3; y += 1) {
for (let z = 0; z < 3; z += 1) {
const cell = new THREE.Mesh(voxelGeometry, material);
cell.position.set((x - 1) * 0.245, (y - 1) * 0.245, (z - 1) * 0.245);
cell.castShadow = true;
cell.receiveShadow = true;
group.add(cell);
}
}
}
group.userData.material = material;
group.userData.baseColor = new THREE.Color(color);
return group;
}
for (const relation of Object.keys(relationVisuals)) {
const visual = relationVisuals[relation];
const caseGroup = new THREE.Group();
caseGroup.position.x = visual.caseX;
scene.add(caseGroup);
caseGroups[relation] = caseGroup;
const plinth = new THREE.Mesh(
new THREE.BoxGeometry(2.55, 0.44, 2.25),
plinthMaterial
);
plinth.position.y = 0.16;
plinth.castShadow = true;
plinth.receiveShadow = true;
caseGroup.add(plinth);
const plinthTop = new THREE.Mesh(
new THREE.BoxGeometry(2.38, 0.08, 2.08),
plinthTopMaterial
);
plinthTop.position.y = 0.42;
plinthTop.castShadow = true;
plinthTop.receiveShadow = true;
caseGroup.add(plinthTop);
const frontTrim = new THREE.Mesh(
new THREE.BoxGeometry(2.08, 0.12, 0.08),
darkTrimMaterial
);
frontTrim.position.set(0, 0.18, 1.17);
caseGroup.add(frontTrim);
const subject = makeVoxelCube(visual.subjectColor);
subject.position.set(...visual.subjectPosition);
caseGroup.add(subject);
const reference = makeVoxelCube(visual.referenceColor);
reference.position.set(...visual.referencePosition);
caseGroup.add(reference);
objectRecords.push({
relation,
role: "subject",
group: subject,
material: subject.userData.material,
baseColor: subject.userData.baseColor,
basePosition: subject.position.clone(),
motionAxis: visual.motionAxis
});
objectRecords.push({
relation,
role: "reference",
group: reference,
material: reference.userData.material,
baseColor: reference.userData.baseColor,
basePosition: reference.position.clone(),
motionAxis: null
});
const markerMaterial = new THREE.MeshStandardMaterial({
color: 0xf3c75c,
emissive: 0xd59c2c,
emissiveIntensity: 0.8,
roughness: 0.42
});
const markerGroup = new THREE.Group();
const markerPositions = [
[-1.11, 0.48, -0.96],
[1.11, 0.48, -0.96],
[-1.11, 0.48, 0.96],
[1.11, 0.48, 0.96]
];
for (const [x, y, z] of markerPositions) {
const marker = new THREE.Mesh(
new THREE.BoxGeometry(0.2, 0.05, 0.2),
markerMaterial
);
marker.position.set(x, y, z);
markerGroup.add(marker);
}
markerGroup.visible = false;
caseGroup.add(markerGroup);
markerGroups[relation] = markerGroup;
}
const mutedColor = new THREE.Color(0x34414c);
function setRelation(relation) {
for (const object of objectRecords) {
const active = object.relation === relation;
object.material.color.copy(object.baseColor);
if (!active) object.material.color.lerp(mutedColor, 0.7);
object.material.emissive.copy(active ? object.baseColor : new THREE.Color(0x000000));
object.material.emissiveIntensity = active ? 0.12 : 0;
object.group.scale.setScalar(active ? 1 : 0.96);
}
for (const key of Object.keys(markerGroups)) {
markerGroups[key].visible = key === relation;
}
}
function applyCamera() {
const aspect = cameraState.width / cameraState.height;
const viewHeight = Math.max(6.65, 9.55 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
const radius = 12;
camera.position.set(
target.x + Math.sin(cameraState.yaw) * radius * Math.cos(cameraState.pitch),
target.y + Math.sin(cameraState.pitch) * radius,
target.z + Math.cos(cameraState.yaw) * radius * Math.cos(cameraState.pitch)
);
camera.lookAt(target);
}
function resize() {
cameraState.width = Math.max(1, host.clientWidth);
cameraState.height = Math.max(1, host.clientHeight);
renderer.setSize(cameraState.width, cameraState.height, false);
applyCamera();
}
if ("ResizeObserver" in window) {
const observer = new ResizeObserver(resize);
observer.observe(host);
} else {
window.addEventListener("resize", resize);
}
function resetCamera() {
cameraState.yaw = 0;
cameraState.pitch = 0.46;
cameraState.zoom = 1;
applyCamera();
}
function rotateCamera(amount) {
cameraState.yaw = THREE.MathUtils.clamp(cameraState.yaw + amount, -0.72, 0.72);
applyCamera();
}
function zoomCamera(factor) {
cameraState.zoom = THREE.MathUtils.clamp(cameraState.zoom * factor, 0.78, 1.42);
applyCamera();
}
let drag = null;
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
drag = {
pointerId: event.pointerId,
x: event.clientX,
y: event.clientY,
yaw: cameraState.yaw,
pitch: cameraState.pitch
};
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!drag || event.pointerId !== drag.pointerId) return;
const deltaX = event.clientX - drag.x;
const deltaY = event.clientY - drag.y;
cameraState.yaw = THREE.MathUtils.clamp(drag.yaw - deltaX * 0.005, -0.72, 0.72);
cameraState.pitch = THREE.MathUtils.clamp(drag.pitch + deltaY * 0.004, 0.2, 0.86);
applyCamera();
});
function endDrag(event) {
if (!drag || event.pointerId !== drag.pointerId) return;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
drag = null;
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoomCamera(event.deltaY > 0 ? 0.92 : 1.08);
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") {
event.preventDefault();
rotateCamera(-0.14);
} else if (event.key === "ArrowRight") {
event.preventDefault();
rotateCamera(0.14);
} else if (event.key === "+" || event.key === "=") {
event.preventDefault();
zoomCamera(1.08);
} else if (event.key === "-") {
event.preventDefault();
zoomCamera(0.92);
} else if (event.key === "0") {
event.preventDefault();
resetCamera();
}
});
resize();
setRelation(state.relation);
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function animate(time) {
requestAnimationFrame(animate);
const elapsed = time * 0.001;
for (const object of objectRecords) {
object.group.position.copy(object.basePosition);
if (!reducedMotion && object.relation === state.relation && object.role === "subject") {
const offset = Math.sin(elapsed * 1.55) * 0.055;
object.group.position[object.motionAxis] += offset;
}
}
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
return {
setRelation,
resetCamera,
rotateCamera,
zoomCamera
};
}
try {
sceneApi = buildScene();
sceneApi.setRelation(state.relation);
} catch (error) {
elements.fallback.hidden = false;
console.warn("The procedural scene could not be initialized.", error);
}
elements.resetCamera.addEventListener("click", () => {
if (sceneApi) sceneApi.resetCamera();
});
elements.rotateLeft.addEventListener("click", () => {
if (sceneApi) sceneApi.rotateCamera(-0.18);
});
elements.rotateRight?.addEventListener("click", () => {
if (sceneApi) sceneApi.rotateCamera(0.18);
});
elements.zoomIn.addEventListener("click", () => {
if (sceneApi) sceneApi.zoomCamera(1.1);
});
elements.zoomOut.addEventListener("click", () => {
if (sceneApi) sceneApi.zoomCamera(0.9);
});
</script>
</body>
</html>
```