Prompt specification
Build or customize the Three.js 3D scene "Decode an Unfamiliar Sign System" 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: Decode an Unfamiliar Sign System
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/decode-an-unfamiliar-sign-system-x3420
Scene Description Prompt:
Create a self-contained Three.js HTML scene, using cdnjs, around a low-poly puzzle for decoding an unfamiliar sign system. Three small dioramas show crates, doors, and arrows beside short sequences of original geometric symbols. Their meanings must follow one consistent mapping across all examples. Give the player several possible interpretations to place beneath a fourth scene, with evidence tiles showing which examples support each choice. Start with insufficient evidence so more than one mapping remains possible, then reveal another grounded example. Keep the symbols visually simple and distinct, and preserve unresolved ambiguity whenever the shown evidence does not identify a unique interpretation.
Working Three.js Starter (decode-an-unfamiliar-sign-system-x3420):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Wayfinder's Marks</title>
<style>
:root {
color-scheme: dark;
--bg: #07101b;
--panel: #0c1726;
--panel-2: #111f31;
--line: #26384d;
--text: #eef5fb;
--muted: #91a6bc;
--cyan: #65e2df;
--amber: #ffc46b;
--green: #7ee2a8;
--red: #ff8293;
--violet: #b4a4ff;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button {
font: inherit;
}
#app {
display: grid;
grid-template-columns: minmax(0, 1fr) 390px;
width: 100%;
height: 100dvh;
}
#stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background:
radial-gradient(circle at 45% 20%, rgba(48, 92, 122, 0.18), transparent 45%),
var(--bg);
isolation: isolate;
}
#stage canvas {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.brand {
position: absolute;
z-index: 5;
top: 22px;
left: 24px;
pointer-events: none;
}
.eyebrow {
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.brand h1 {
margin: 5px 0 3px;
font-size: clamp(19px, 2vw, 29px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.brand p {
margin: 0;
color: var(--muted);
font-size: 12px;
}
.stage-tools {
position: absolute;
z-index: 8;
top: 20px;
right: 18px;
display: flex;
gap: 8px;
}
.small-button {
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(11, 23, 38, 0.86);
color: var(--text);
padding: 8px 11px;
cursor: pointer;
font-size: 11px;
}
.small-button:hover {
border-color: var(--cyan);
color: var(--cyan);
}
.legend {
position: absolute;
z-index: 5;
left: 24px;
bottom: 20px;
display: flex;
gap: 13px;
align-items: center;
padding: 8px 11px;
border: 1px solid rgba(95, 126, 154, 0.24);
border-radius: 9px;
background: rgba(7, 16, 27, 0.72);
color: var(--muted);
font-size: 10px;
pointer-events: none;
}
.legend span {
white-space: nowrap;
}
.legend b {
color: var(--cyan);
font-size: 15px;
vertical-align: -1px;
}
#worldLabels {
position: absolute;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
transform: translate(-50%, -50%);
min-width: 116px;
padding: 7px 9px;
border: 1px solid rgba(105, 142, 174, 0.34);
border-radius: 8px;
background: rgba(7, 16, 27, 0.83);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
text-align: center;
backdrop-filter: blur(8px);
}
.world-label .label-title {
display: block;
color: var(--text);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.world-label .label-signs {
display: block;
margin-top: 3px;
color: var(--cyan);
font-size: 17px;
letter-spacing: 0.23em;
}
.world-label.target-label {
border-color: rgba(101, 226, 223, 0.54);
box-shadow: 0 0 28px rgba(101, 226, 223, 0.09);
}
#dropZone {
position: absolute;
z-index: 9;
width: min(540px, calc(100% - 34px));
transform: translateX(-50%);
border: 1px dashed rgba(101, 226, 223, 0.42);
border-radius: 12px;
background: rgba(8, 18, 31, 0.89);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(13px);
transition: border-color 150ms, background 150ms, transform 150ms;
}
#dropZone.drag-over {
border-color: var(--cyan);
background: rgba(23, 55, 68, 0.95);
transform: translateX(-50%) scale(1.012);
}
#placementEmpty {
padding: 12px 16px;
color: var(--muted);
text-align: center;
font-size: 11px;
}
#placementEmpty strong {
color: var(--cyan);
}
#placementContent {
padding: 12px 14px;
}
.placement-head {
display: flex;
justify-content: space-between;
gap: 12px;
align-items: flex-start;
}
.placement-head h3 {
margin: 0;
font-size: 12px;
letter-spacing: 0.03em;
}
.clear-button {
border: 0;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 10px;
}
.clear-button:hover {
color: var(--text);
}
.placement-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin-top: 10px;
}
.placement-map,
.target-reading {
padding: 8px 9px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(17, 31, 49, 0.74);
}
.placement-map b {
display: block;
color: var(--cyan);
font-size: 19px;
line-height: 1;
}
.placement-map span,
.target-reading span {
display: block;
margin-top: 4px;
color: var(--text);
font-size: 10px;
text-transform: capitalize;
}
.target-reading b {
display: block;
color: var(--amber);
font-size: 10px;
}
.placement-note {
margin-top: 9px;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
.placement-note.good {
color: var(--green);
}
.placement-note.bad {
color: var(--red);
}
aside {
z-index: 10;
min-height: 0;
overflow: auto;
padding: 22px 19px 28px;
border-left: 1px solid var(--line);
background:
linear-gradient(180deg, rgba(18, 32, 49, 0.68), transparent 230px),
var(--panel);
scrollbar-color: #31475d transparent;
}
aside h2 {
margin: 4px 0 7px;
font-size: 19px;
letter-spacing: -0.025em;
}
.rule {
margin: 0 0 15px;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.rule strong {
color: var(--text);
}
#statusBanner {
margin-bottom: 18px;
padding: 12px 13px;
border: 1px solid rgba(255, 196, 107, 0.34);
border-radius: 10px;
background: rgba(255, 196, 107, 0.07);
}
#statusBanner.unique {
border-color: rgba(126, 226, 168, 0.36);
background: rgba(126, 226, 168, 0.07);
}
.status-title {
color: var(--amber);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
}
#statusBanner.unique .status-title {
color: var(--green);
}
#statusText {
margin-top: 4px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin: 17px 0 9px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#candidateGrid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
}
.candidate {
position: relative;
min-height: 107px;
padding: 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(17, 31, 49, 0.68);
color: var(--text);
text-align: left;
cursor: pointer;
transition: border-color 140ms, background 140ms, transform 140ms;
}
.candidate:hover {
transform: translateY(-1px);
border-color: #4a6c89;
}
.candidate.selected {
border-color: var(--cyan);
background: rgba(31, 68, 76, 0.58);
box-shadow: inset 0 0 0 1px rgba(101, 226, 223, 0.16);
}
.candidate.fits::after {
content: "✓ fits";
position: absolute;
top: 8px;
right: 8px;
color: var(--green);
font-size: 9px;
font-weight: 800;
}
.candidate-title {
display: block;
margin-bottom: 7px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.map-row {
display: grid;
grid-template-columns: 22px 1fr;
align-items: center;
gap: 4px;
margin-top: 3px;
font-size: 10px;
text-transform: capitalize;
}
.map-row b {
color: var(--cyan);
font-size: 16px;
line-height: 1;
}
.candidate-pips {
display: flex;
gap: 4px;
margin-top: 8px;
}
.pip {
display: grid;
width: 19px;
height: 17px;
place-items: center;
border-radius: 4px;
background: #1b2b3e;
color: #6f8297;
font-size: 8px;
font-weight: 800;
}
.pip.yes {
background: rgba(126, 226, 168, 0.14);
color: var(--green);
}
.pip.no {
background: rgba(255, 130, 147, 0.11);
color: var(--red);
}
#evidenceList {
display: grid;
gap: 8px;
}
.empty-evidence {
padding: 15px;
border: 1px dashed var(--line);
border-radius: 9px;
color: var(--muted);
font-size: 10px;
text-align: center;
}
.evidence-tile {
padding: 10px 11px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(17, 31, 49, 0.58);
}
.evidence-top {
display: flex;
justify-content: space-between;
gap: 8px;
align-items: center;
}
.evidence-name {
font-size: 10px;
font-weight: 800;
}
.evidence-result {
font-size: 9px;
font-weight: 800;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.evidence-result.yes {
color: var(--green);
}
.evidence-result.no {
color: var(--red);
}
.evidence-detail {
display: flex;
justify-content: space-between;
gap: 8px;
margin-top: 7px;
color: var(--muted);
font-size: 9px;
}
.evidence-signs {
color: var(--cyan);
font-size: 14px;
letter-spacing: 0.14em;
}
#revealButton {
width: 100%;
margin-top: 18px;
padding: 12px 13px;
border: 1px solid rgba(255, 196, 107, 0.5);
border-radius: 9px;
background: rgba(255, 196, 107, 0.09);
color: var(--amber);
cursor: pointer;
font-size: 11px;
font-weight: 800;
}
#revealButton:hover:not(:disabled) {
background: rgba(255, 196, 107, 0.16);
border-color: var(--amber);
}
#revealButton:disabled {
color: var(--muted);
border-color: var(--line);
background: rgba(17, 31, 49, 0.55);
cursor: default;
}
.fine-print {
margin: 10px 2px 0;
color: #6f849a;
font-size: 9px;
line-height: 1.5;
}
#toast {
position: absolute;
z-index: 20;
top: 80px;
left: 50%;
transform: translate(-50%, -12px);
max-width: 90%;
padding: 10px 15px;
border: 1px solid rgba(255, 196, 107, 0.45);
border-radius: 9px;
background: rgba(10, 21, 35, 0.94);
color: var(--amber);
font-size: 11px;
opacity: 0;
pointer-events: none;
transition: opacity 180ms, transform 180ms;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
#loading {
position: absolute;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
background: var(--bg);
color: var(--muted);
font-size: 12px;
letter-spacing: 0.08em;
}
@media (max-width: 900px) {
body {
overflow: auto;
}
#app {
grid-template-columns: 1fr;
grid-template-rows: minmax(560px, 68dvh) auto;
height: auto;
}
aside {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.brand p,
.legend {
display: none;
}
.stage-tools {
top: 18px;
}
}
</style>
</head>
<body>
<div id="app">
<section id="stage" aria-label="Interactive low-poly sign-decoding diorama">
<div id="loading">BUILDING THE DIORAMA…</div>
<div class="brand">
<div class="eyebrow">Field decoding exercise</div>
<h1>The Wayfinder's Marks</h1>
<p>Three landmarks. One unknown alphabet.</p>
</div>
<div class="stage-tools">
<button id="resetView" class="small-button" type="button">Reset view</button>
</div>
<div id="worldLabels"></div>
<div id="dropZone" aria-label="Drop an interpretation beneath the target scene">
<div id="placementEmpty">
<strong>Drop an interpretation here</strong>
<br>or choose one from the field ledger
</div>
<div id="placementContent" hidden>
<div class="placement-head">
<h3 id="placementTitle"></h3>
<button id="clearPlacement" class="clear-button" type="button">clear</button>
</div>
<div class="placement-grid">
<div id="placementMapping"></div>
<div class="target-reading">
<b>Target panel reads</b>
<span id="targetReading"></span>
</div>
</div>
<div id="placementNote" class="placement-note"></div>
</div>
</div>
<div class="legend" aria-hidden="true">
<span>Solid marks:</span>
<span><b>△</b> triangle</span>
<span><b>●</b> circle</span>
<span><b>■</b> square</span>
</div>
<div id="toast" role="status"></div>
</section>
<aside>
<div class="eyebrow">Interpret the sign system</div>
<h2>Field ledger</h2>
<p class="rule">
<strong>Rule:</strong> each landmark's true sign occurs somewhere in its adjacent
strip. Position in the strip is not yet meaningful. Use the same one-to-one
mapping everywhere.
</p>
<div id="statusBanner">
<div id="statusTitle" class="status-title">Ambiguity preserved</div>
<div id="statusText"></div>
</div>
<div class="section-title">
<span>Possible interpretations</span>
<span>choose or drag</span>
</div>
<div id="candidateGrid"></div>
<div class="section-title">
<span>Evidence for placement</span>
<span id="evidenceCount">3 shown</span>
</div>
<div id="evidenceList"></div>
<button id="revealButton" type="button">Reveal one more grounded example</button>
<p class="fine-print">
The scene reports ambiguity from the visible evidence only. It never silently
selects an answer when more than one interpretation remains possible.
</p>
</aside>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const worldLabels = document.querySelector("#worldLabels");
const candidateGrid = document.querySelector("#candidateGrid");
const evidenceList = document.querySelector("#evidenceList");
const evidenceCount = document.querySelector("#evidenceCount");
const statusBanner = document.querySelector("#statusBanner");
const statusTitle = document.querySelector("#statusTitle");
const statusText = document.querySelector("#statusText");
const dropZone = document.querySelector("#dropZone");
const placementEmpty = document.querySelector("#placementEmpty");
const placementContent = document.querySelector("#placementContent");
const placementTitle = document.querySelector("#placementTitle");
const placementMapping = document.querySelector("#placementMapping");
const targetReading = document.querySelector("#targetReading");
const placementNote = document.querySelector("#placementNote");
const revealButton = document.querySelector("#revealButton");
const resetViewButton = document.querySelector("#resetView");
const clearPlacementButton = document.querySelector("#clearPlacement");
const toast = document.querySelector("#toast");
const GLYPH = {
triangle: "△",
circle: "●",
square: "■"
};
const OBJECT_GLYPH = {
crate: "▣",
door: "▯",
arrow: "→"
};
const hypotheses = [
{
id: "A",
map: { crate: "triangle", door: "circle", arrow: "square" }
},
{
id: "B",
map: { crate: "triangle", door: "square", arrow: "circle" }
},
{
id: "C",
map: { crate: "circle", door: "triangle", arrow: "square" }
},
{
id: "D",
map: { crate: "square", door: "triangle", arrow: "circle" }
},
{
id: "E",
map: { crate: "circle", door: "square", arrow: "triangle" }
},
{
id: "F",
map: { crate: "square", door: "door", arrow: "circle" }
}
];
// Correct the deliberately explicit final permutation so every hypothesis
// is a genuine bijection between the three signs and the three meanings.
hypotheses[5].map = { crate: "square", door: "circle", arrow: "triangle" };
const examples = [
{
id: "A",
name: "Crate landing",
object: "crate",
signs: ["triangle", "circle"]
},
{
id: "B",
name: "Door threshold",
object: "door",
signs: ["circle", "square"]
},
{
id: "C",
name: "Arrow post",
object: "arrow",
signs: ["square", "triangle"]
}
];
const revealedExample = {
id: "D",
name: "Arrow close-up",
object: "arrow",
signs: ["triangle"]
};
const targetSigns = ["triangle", "circle", "square"];
let selectedId = null;
let revealed = false;
let revealStartedAt = null;
function visibleExamples() {
return revealed ? [...examples, revealedExample] : examples;
}
function supports(hypothesis, example) {
return example.signs.includes(hypothesis.map[example.object]);
}
function compatibleHypotheses() {
const evidence = visibleExamples();
return hypotheses.filter(hypothesis =>
evidence.every(example => supports(hypothesis, example))
);
}
function mappingMarkup(hypothesis) {
return ["triangle", "circle", "square"]
.map(sign => `
<div class="map-row">
<b>${GLYPH[sign]}</b>
<span>${Object.keys(hypothesis.map).find(object => hypothesis.map[object] === sign)}</span>
</div>
`)
.join("");
}
function buildCandidates() {
candidateGrid.innerHTML = "";
for (const hypothesis of hypotheses) {
const card = document.createElement("button");
card.type = "button";
card.className = "candidate";
card.dataset.id = hypothesis.id;
card.draggable = true;
card.setAttribute("aria-pressed", "false");
card.innerHTML = `
<span class="candidate-title">Reading ${hypothesis.id}</span>
${mappingMarkup(hypothesis)}
<span class="candidate-pips"></span>
`;
card.addEventListener("click", () => selectHypothesis(hypothesis.id));
card.addEventListener("dragstart", event => {
event.dataTransfer.setData("text/plain", hypothesis.id);
event.dataTransfer.effectAllowed = "copy";
});
candidateGrid.appendChild(card);
}
}
function updateCandidates() {
const evidence = visibleExamples();
const fitting = compatibleHypotheses();
for (const card of candidateGrid.querySelectorAll(".candidate")) {
const hypothesis = hypotheses.find(h => h.id === card.dataset.id);
const supportCount = evidence.filter(example =>
supports(hypothesis, example)
).length;
const fits = supportCount === evidence.length;
card.classList.toggle("selected", selectedId === hypothesis.id);
card.classList.toggle("fits", fits);
card.setAttribute("aria-pressed", String(selectedId === hypothesis.id));
const pips = card.querySelector(".candidate-pips");
pips.innerHTML = evidence.map(example => {
const yes = supports(hypothesis, example);
return `
<span class="pip ${yes ? "yes" : "no"}"
title="${example.name}: ${yes ? "supports" : "clashes"}">
${example.id}
</span>
`;
}).join("");
}
evidenceCount.textContent = `${evidence.length} shown`;
const fittingIds = new Set(fitting.map(h => h.id));
if (fitting.length === 1) {
statusBanner.classList.add("unique");
statusTitle.textContent = "Evidence identifies one code";
statusText.textContent =
`Only interpretation ${fitting[0].id} fits every visible example. ` +
`Choose it and place it beneath the target panel.`;
} else {
statusBanner.classList.remove("unique");
statusTitle.textContent = "Ambiguity preserved";
statusText.textContent =
`${fitting.length} interpretations still fit all visible evidence ` +
`(${[...fittingIds].join(", ")}). The target cannot yet be read uniquely.`;
}
}
function selectHypothesis(id) {
selectedId = id;
const hypothesis = hypotheses.find(h => h.id === id);
const fitting = compatibleHypotheses();
placementEmpty.hidden = true;
placementContent.hidden = false;
placementTitle.textContent = `Interpretation ${hypothesis.id}`;
placementMapping.innerHTML = ["triangle", "circle", "square"]
.map(sign => `
<div class="placement-map">
<b>${GLYPH[sign]}</b>
<span>${Object.keys(hypothesis.map).find(object => hypothesis.map[object] === sign)}</span>
</div>
`)
.join("");
targetReading.textContent = targetSigns
.map(sign => Object.keys(hypothesis.map).find(object => hypothesis.map[object] === sign))
.join(" → ");
placementNote.className = "placement-note";
if (fitting.length > 1) {
placementNote.textContent =
`Provisional reading: ${fitting.length} interpretations still fit the ` +
`visible evidence, so this target reading is not unique.`;
} else if (fitting.some(h => h.id === id)) {
placementNote.textContent =
"Consistent with every visible example. This is the unique reading now supported.";
placementNote.classList.add("good");
} else {
placementNote.textContent =
"This placement conflicts with at least one visible example. Review the evidence tiles.";
placementNote.classList.add("bad");
}
updateCandidates();
updateEvidence();
}
function updateEvidence() {
const evidence = visibleExamples();
if (!selectedId) {
evidenceList.innerHTML = `
<div class="empty-evidence">
Select an interpretation to see which visible examples support or clash with it.
</div>
`;
return;
}
const hypothesis = hypotheses.find(h => h.id === selectedId);
evidenceList.innerHTML = evidence.map(example => {
const matchingSign = hypothesis.map[example.object];
const yes = supports(hypothesis, example);
return `
<article class="evidence-tile">
<div class="evidence-top">
<span class="evidence-name">
${example.id} · ${example.name}
</span>
<span class="evidence-result ${yes ? "yes" : "no"}">
${yes ? "supports" : "clashes"}
</span>
</div>
<div class="evidence-detail">
<span>
${OBJECT_GLYPH[example.object]} ${example.object}:
${GLYPH[matchingSign]}
</span>
<span class="evidence-signs">
${example.signs.map(sign => GLYPH[sign]).join(" ")}
</span>
</div>
</article>
`;
}).join("");
}
buildCandidates();
updateCandidates();
updateEvidence();
dropZone.addEventListener("dragover", event => {
event.preventDefault();
event.dataTransfer.dropEffect = "copy";
dropZone.classList.add("drag-over");
});
dropZone.addEventListener("dragleave", () => {
dropZone.classList.remove("drag-over");
});
dropZone.addEventListener("drop", event => {
event.preventDefault();
dropZone.classList.remove("drag-over");
const id = event.dataTransfer.getData("text/plain");
if (hypotheses.some(h => h.id === id)) {
selectHypothesis(id);
}
});
clearPlacementButton.addEventListener("click", () => {
selectedId = null;
placementEmpty.hidden = false;
placementContent.hidden = true;
updateCandidates();
updateEvidence();
});
let toastTimer;
function showToast(message) {
toast.textContent = message;
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 3400);
}
// ------------------------------------------------------------
// Three.js scene
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.domElement.setAttribute(
"aria-label",
"Three-dimensional puzzle scene. Drag to orbit, scroll to zoom."
);
renderer.domElement.tabIndex = 0;
stage.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07101b);
scene.fog = new THREE.Fog(0x07101b, 18, 34);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 80);
const hemi = new THREE.HemisphereLight(0xc5e9ff, 0x172033, 1.55);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xffe0ad, 2.8);
keyLight.position.set(-6, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 12;
keyLight.shadow.camera.bottom = -12;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5ee8ef, 1.25);
rimLight.position.set(8, 5, -8);
scene.add(rimLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(44, 34),
new THREE.MeshStandardMaterial({
color: 0x0b1725,
roughness: 0.96,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.28;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(34, 34, 0x294258, 0x15283a);
grid.position.y = -0.265;
grid.material.transparent = true;
grid.material.opacity = 0.48;
scene.add(grid);
const dustGeometry = new THREE.BufferGeometry();
const dustPositions = new Float32Array(180 * 3);
for (let i = 0; i < 180; i++) {
dustPositions[i * 3] = (Math.random() - 0.5) * 24;
dustPositions[i * 3 + 1] = Math.random() * 8;
dustPositions[i * 3 + 2] = (Math.random() - 0.5) * 18;
}
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0x80cfdc,
size: 0.035,
transparent: true,
opacity: 0.42,
depthWrite: false
})
);
scene.add(dust);
function material(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.04,
flatShading: true,
...extra
});
}
const materials = {
plinth: material(0x15263a),
plinthTop: material(0x20364a),
backdrop: material(0x102235),
frame: material(0x29445b),
crate: material(0xd99158),
crateDark: material(0x7d4f35),
door: material(0x3ca9a3),
doorDark: material(0x1f6669),
arrow: material(0xf2ba59),
pole: material(0x46566a),
sign: material(0x65e2df, {
emissive: 0x1a777a,
emissiveIntensity: 0.38,
roughness: 0.5
}),
target: material(0x65e2df, {
emissive: 0x17676a,
emissiveIntensity: 0.5
})
};
function addBox(parent, size, position, mat, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function symbolGeometry(type, size = 0.25) {
if (type === "circle") {
return new THREE.CircleGeometry(size * 0.52, 24);
}
if (type === "square") {
return new THREE.PlaneGeometry(size * 0.82, size * 0.82);
}
const shape = new THREE.Shape();
shape.moveTo(0, size * 0.62);
shape.lineTo(-size * 0.56, -size * 0.42);
shape.lineTo(size * 0.56, -size * 0.42);
shape.closePath();
return new THREE.ShapeGeometry(shape);
}
function createSymbolMesh(type, size, mat = materials.sign) {
const mesh = new THREE.Mesh(symbolGeometry(type, size), mat);
mesh.castShadow = true;
return mesh;
}
function createToken(type) {
const group = new THREE.Group();
const board = addBox(
group,
[0.45, 0.55, 0.075],
[0, 0.4, 0],
materials.frame
);
board.castShadow = true;
addBox(
group,
[0.26, 0.04, 0.12],
[0, 0.12, 0],
materials.pole
);
const symbol = createSymbolMesh(type, 0.25);
symbol.position.set(0, 0.41, 0.043);
group.add(symbol);
return group;
}
function createCrate() {
const group = new THREE.Group();
addBox(group, [1.0, 0.86, 0.86], [0, 0.56, 0], materials.crate);
for (const y of [0.28, 0.56, 0.84]) {
addBox(
group,
[1.08, 0.075, 0.08],
[0, y, 0.47],
materials.crateDark
);
addBox(
group,
[0.08, 0.75, 0.08],
[-0.43, y, 0.47],
materials.crateDark
);
}
addBox(group, [1.06, 0.07, 0.06], [0, 0.18, 0.47], materials.crateDark);
addBox(group, [1.06, 0.07, 0.06], [0, 0.94, 0.47], materials.crateDark);
return group;
}
function createDoor() {
const group = new THREE.Group();
addBox(group, [0.16, 1.75, 0.18], [-0.62, 1.0, 0], materials.frame);
addBox(group, [0.16, 1.75, 0.18], [0.62, 1.0, 0], materials.frame);
addBox(group, [1.4, 0.16, 0.18], [0, 1.86, 0], materials.frame);
const door = addBox(
group,
[1.02, 1.56, 0.13],
[-0.06, 0.91, 0.02],
materials.door
);
door.rotation.y = -0.13;
addBox(
group,
[0.67, 0.62, 0.055],
[-0.08, 1.05, 0.1],
materials.doorDark
);
const knob = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 8, 6),
materials.arrow
);
knob.position.set(0.3, 0.88, 0.13);
knob.castShadow = true;
group.add(knob);
addBox(group, [1.5, 0.14, 0.65], [0, 0.14, 0.11], materials.frame);
return group;
}
function createArrow() {
const group = new THREE.Group();
const base = new THREE.Mesh(
new THREE.CylinderGeometry(0.34, 0.42, 0.16, 6),
materials.frame
);
base.position.y = 0.22;
base.castShadow = true;
group.add(base);
const pole = new THREE.Mesh(
new THREE.CylinderGeometry(0.075, 0.095, 1.35, 6),
materials.pole
);
pole.position.y = 0.93;
pole.castShadow = true;
group.add(pole);
const shape = new THREE.Shape();
shape.moveTo(-0.58, -0.16);
shape.lineTo(0.08, -0.16);
shape.lineTo(0.08, -0.44);
shape.lineTo(0.7, 0);
shape.lineTo(0.08, 0.44);
shape.lineTo(0.08, 0.16);
shape.lineTo(-0.58, 0.16);
shape.closePath();
const arrow = new THREE.Mesh(
new THREE.ShapeGeometry(shape),
materials.arrow
);
arrow.position.set(-0.28, 1.46, 0.07);
arrow.castShadow = true;
group.add(arrow);
const plate = addBox(
group,
[1.32, 0.92, 0.08],
[-0.27, 1.44, 0.01],
materials.frame
);
plate.castShadow = false;
// Move the plate behind the arrow after creation.
group.remove(plate);
group.add(plate);
plate.position.z = 0.005;
return group;
}
function createPhysicalObject(type) {
if (type === "crate") return createCrate();
if (type === "door") return createDoor();
return createArrow();
}
function createDiorama(example, options = {}) {
const width = options.width || 3.25;
const group = new THREE.Group();
addBox(
group,
[width, 0.28, 2.35],
[0, -0.03, 0],
materials.plinth
);
addBox(
group,
[width - 0.12, 0.08, 2.23],
[0, 0.14, 0],
materials.plinthTop
);
addBox(
group,
[width - 0.16, 2.15, 0.11],
[0, 1.14, -1.0],
materials.backdrop
);
addBox(
group,
[width - 0.18, 0.055, 0.04],
[0, 2.15, -0.92],
materials.frame,
false
);
const object = createPhysicalObject(example.object);
object.position.set(-0.43, 0.16, -0.08);
group.add(object);
const tokenXs = example.signs.length === 1
? [0.64]
: [0.37, 0.93];
example.signs.forEach((sign, index) => {
const token = createToken(sign);
token.position.set(tokenXs[index], 0.17, 0.42);
group.add(token);
});
const marker = new THREE.Object3D();
marker.position.set(0, 2.53, -0.45);
group.add(marker);
return { group, marker };
}
const examplePositions = [
[-4.7, 0, -2.55],
[0, 0, -2.65],
[4.7, 0, -2.55]
];
const labelEntries = [];
function addWorldLabel(html, marker, className = "") {
const element = document.createElement("div");
element.className = `world-label ${className}`.trim();
element.innerHTML = html;
worldLabels.appendChild(element);
labelEntries.push({ element, marker });
return element;
}
examples.forEach((example, index) => {
const diorama = createDiorama(example);
diorama.group.position.set(...examplePositions[index]);
scene.add(diorama.group);
addWorldLabel(
`
<span class="label-title">${example.id} · ${example.object}s</span>
<span class="label-signs">
${example.signs.map(sign => GLYPH[sign]).join(" ")}
</span>
`,
diorama.marker
);
});
const targetGroup = new THREE.Group();
targetGroup.position.set(0, 0, 3.3);
addBox(
targetGroup,
[4.25, 0.3, 2.75],
[0, -0.02, 0],
materials.plinth
);
addBox(
targetGroup,
[4.12, 0.08, 2.62],
[0, 0.16, 0],
materials.plinthTop
);
addBox(
targetGroup,
[3.55, 2.05, 0.13],
[0, 1.15, -0.65],
materials.backdrop
);
addBox(
targetGroup,
[3.42, 0.055, 0.04],
[0, 2.13, -0.57],
materials.frame,
false
);
targetSigns.forEach((sign, index) => {
const x = (index - 1) * 0.83;
const symbol = createSymbolMesh(sign, 0.45, materials.target);
symbol.position.set(x, 1.45, -0.565);
targetGroup.add(symbol);
addBox(
targetGroup,
[0.67, 0.12, 0.45],
[x, 0.25, 0.7],
materials.frame,
false
);
});
const targetMarker = new THREE.Object3D();
targetMarker.position.set(0, 2.62, -0.45);
targetGroup.add(targetMarker);
const targetGroundMarker = new THREE.Object3D();
targetGroundMarker.position.set(0, 0.12, 1.52);
targetGroup.add(targetGroundMarker);
scene.add(targetGroup);
addWorldLabel(
`
<span class="label-title">04 · Unknown panel</span>
<span class="label-signs">△ ● ■</span>
`,
targetMarker,
"target-label"
);
const revealedDiorama = createDiorama(revealedExample, { width: 2.75 });
revealedDiorama.group.position.set(5.65, 0, 3.05);
revealedDiorama.group.visible = false;
scene.add(revealedDiorama.group);
addWorldLabel(
`
<span class="label-title">D · Arrow close-up</span>
<span class="label-signs">△</span>
`,
revealedDiorama.marker
);
revealButton.addEventListener("click", () => {
if (revealed) return;
revealed = true;
revealStartedAt = performance.now();
revealedDiorama.group.visible = true;
revealedDiorama.group.scale.setScalar(0.03);
revealedDiorama.group.position.y = -0.7;
revealButton.disabled = true;
revealButton.textContent = "Grounded example D revealed";
updateCandidates();
updateEvidence();
if (selectedId) {
selectHypothesis(selectedId);
}
showToast(
"New grounded evidence: an arrow marker is paired with a single △ sign."
);
});
// ------------------------------------------------------------
// Direct camera controls — no examples/addons are imported.
// ------------------------------------------------------------
let yaw = 0;
let pitch = 0.63;
let radius = 17.8;
const cameraTarget = new THREE.Vector3(0, 0.35, 0.35);
let dragging = false;
let pointerX = 0;
let pointerY = 0;
function updateCamera() {
camera.position.set(
cameraTarget.x + radius * Math.sin(yaw) * Math.cos(pitch),
cameraTarget.y + radius * Math.sin(pitch),
cameraTarget.z + radius * Math.cos(yaw) * Math.cos(pitch)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
yaw = 0;
pitch = 0.63;
radius = stage.clientWidth / stage.clientHeight < 0.95 ? 21.5 : 17.8;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", event => {
if (event.button !== 0) return;
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
yaw -= dx * 0.006;
pitch = THREE.MathUtils.clamp(pitch + dy * 0.0045, 0.28, 1.18);
updateCamera();
});
function endDrag(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.style.cursor = "grab";
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius + event.deltaY * 0.012,
10.5,
25
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("keydown", event => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
yaw += 0.08;
break;
case "ArrowRight":
yaw -= 0.08;
break;
case "ArrowUp":
pitch = THREE.MathUtils.clamp(pitch + 0.05, 0.28, 1.18);
break;
case "ArrowDown":
pitch = THREE.MathUtils.clamp(pitch - 0.05, 0.28, 1.18);
break;
case "+":
case "=":
radius = Math.max(10.5, radius - 0.8);
break;
case "-":
radius = Math.min(25, radius + 0.8);
break;
case "Home":
resetCamera();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
resetViewButton.addEventListener("click", resetCamera);
function resize() {
const width = Math.max(1, stage.clientWidth);
const height = Math.max(1, stage.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
new ResizeObserver(resize).observe(stage);
resize();
resetCamera();
const projected = new THREE.Vector3();
function projectMarker(marker) {
marker.getWorldPosition(projected);
projected.project(camera);
return {
x: (projected.x * 0.5 + 0.5) * stage.clientWidth,
y: (-projected.y * 0.5 + 0.5) * stage.clientHeight,
z: projected.z
};
}
function updateOverlays() {
for (const label of labelEntries) {
let visible = label.marker.parent.visible;
const position = projectMarker(label.marker);
visible = visible && position.z > -1 && position.z < 1;
label.element.style.display = visible ? "block" : "none";
label.element.style.left = `${position.x}px`;
label.element.style.top = `${position.y}px`;
}
const targetPosition = projectMarker(targetGroundMarker);
const zoneWidth = dropZone.offsetWidth || 400;
const x = THREE.MathUtils.clamp(
targetPosition.x,
zoneWidth / 2 + 10,
stage.clientWidth - zoneWidth / 2 - 10
);
const estimatedHeight = placementContent.hidden ? 56 : 156;
const y = THREE.MathUtils.clamp(
targetPosition.y + 18,
120,
Math.max(120, stage.clientHeight - estimatedHeight - 12)
);
dropZone.style.left = `${x}px`;
dropZone.style.top = `${y}px`;
}
function animate(now) {
requestAnimationFrame(animate);
if (revealStartedAt !== null) {
const t = THREE.MathUtils.clamp(
(now - revealStartedAt) / 950,
0,
1
);
const ease = 1 - Math.pow(1 - t, 3);
revealedDiorama.group.scale.setScalar(0.03 + 0.97 * ease);
revealedDiorama.group.position.y = -0.7 * (1 - ease);
if (t === 1) {
revealStartedAt = null;
}
}
dust.rotation.y += 0.00018;
updateOverlays();
renderer.render(scene, camera);
}
renderer.render(scene, camera);
updateOverlays();
document.querySelector("#loading").remove();
requestAnimationFrame(animate);
</script>
</body>
</html>
```