Prompt specification
Build or customize the Three.js 3D scene "Same Marker Different Map Legends" 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: Same Marker Different Map Legends
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/same-marker-different-map-legends-x3418
Scene Description Prompt:
Show two identical miniature maps where one symbol has different declared meanings. Require the viewer to inspect the legend before interpreting a marked location. Use Three.js from cdnjs in a single HTML file, with visible voxel blocks.
Working Three.js Starter (same-marker-different-map-legends-x3418):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Same Ground — Different Records</title>
<style>
:root {
color-scheme: dark;
--bg: #0b1211;
--panel: #121c1a;
--panel-2: #17221f;
--line: rgba(220, 237, 226, 0.14);
--line-strong: rgba(220, 237, 226, 0.26);
--text: #edf3ec;
--muted: #98aaa2;
--gold: #e9c96b;
--green: #82b99b;
--red: #e18a78;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-width: 320px;
min-height: 100vh;
color: var(--text);
background:
radial-gradient(circle at 15% 0%, rgba(65, 109, 92, 0.18), transparent 34rem),
radial-gradient(circle at 90% 20%, rgba(177, 137, 55, 0.08), transparent 30rem),
linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
var(--bg);
background-size: auto, auto, 32px 32px, 32px 32px, auto;
}
button {
font: inherit;
}
.page {
width: min(1420px, calc(100% - 40px));
margin: 0 auto;
padding: 54px 0 38px;
}
.hero {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 36px;
align-items: end;
margin-bottom: 30px;
}
.eyebrow,
.plate-label,
.legend-kicker,
.coordinate,
.control-hint,
.protocol,
.choice-tag,
.status,
footer {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.eyebrow {
margin-bottom: 13px;
color: var(--gold);
font-size: 0.72rem;
font-weight: 700;
}
h1 {
max-width: 780px;
margin: 0;
font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
font-size: clamp(2.5rem, 6vw, 5.8rem);
font-weight: 500;
line-height: 0.94;
letter-spacing: -0.045em;
}
.hero-copy {
max-width: 690px;
margin: 20px 0 0;
color: var(--muted);
font-size: clamp(1rem, 1.5vw, 1.18rem);
line-height: 1.65;
}
.protocol {
width: 260px;
padding: 18px 20px;
border: 1px solid var(--line-strong);
border-radius: 16px;
color: var(--muted);
background: rgba(14, 24, 21, 0.78);
font-size: 0.69rem;
line-height: 1.8;
}
.protocol strong {
display: block;
margin-bottom: 7px;
color: var(--text);
font-size: 0.74rem;
}
.protocol span {
display: block;
}
.protocol .step {
color: var(--gold);
}
.map-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
}
.map-card {
overflow: hidden;
border: 1px solid var(--line);
border-radius: 22px;
background: rgba(18, 28, 26, 0.88);
box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
}
.map-card-head {
display: flex;
justify-content: space-between;
gap: 18px;
align-items: center;
padding: 18px 20px;
border-bottom: 1px solid var(--line);
}
.plate-label {
display: block;
margin-bottom: 5px;
color: var(--gold);
font-size: 0.66rem;
font-weight: 700;
}
.map-card h2 {
margin: 0;
font-size: 1rem;
font-weight: 600;
letter-spacing: -0.01em;
}
.match-badge {
flex: none;
padding: 7px 10px;
border: 1px solid var(--line);
border-radius: 999px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.58rem;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.viewport {
position: relative;
height: clamp(360px, 40vw, 490px);
overflow: hidden;
background: #101916;
isolation: isolate;
}
.viewport canvas {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
.viewport canvas:focus-visible {
box-shadow: inset 0 0 0 2px var(--gold);
}
.viewport canvas.dragging {
cursor: grabbing;
}
.coordinate,
.control-hint {
position: absolute;
z-index: 2;
pointer-events: none;
font-size: 0.6rem;
}
.coordinate {
top: 16px;
left: 16px;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 11px;
border: 1px solid rgba(233, 201, 107, 0.28);
border-radius: 10px;
color: var(--gold);
background: rgba(9, 15, 13, 0.72);
backdrop-filter: blur(10px);
}
.coordinate b {
color: var(--text);
font-weight: 600;
}
.control-hint {
right: 15px;
bottom: 14px;
color: rgba(224, 237, 228, 0.5);
font-size: 0.52rem;
}
.legend-wrap {
border-top: 1px solid var(--line);
}
.legend-trigger {
width: 100%;
display: grid;
grid-template-columns: auto 1fr auto;
gap: 14px;
align-items: center;
padding: 17px 20px;
border: 0;
color: var(--text);
background: transparent;
text-align: left;
cursor: pointer;
}
.legend-trigger:hover {
background: rgba(255, 255, 255, 0.025);
}
.legend-trigger:focus-visible {
outline: 2px solid var(--gold);
outline-offset: -4px;
}
.legend-symbol {
width: 38px;
height: 38px;
display: grid;
place-items: center;
border: 1px solid rgba(233, 201, 107, 0.3);
border-radius: 10px;
color: var(--gold);
background: rgba(233, 201, 107, 0.07);
font-size: 1.1rem;
}
.legend-kicker {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-size: 0.56rem;
}
.legend-trigger strong {
font-size: 0.92rem;
font-weight: 600;
}
.legend-status {
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.57rem;
letter-spacing: 0.08em;
}
.legend-trigger.inspected .legend-status {
color: var(--green);
}
.legend-body {
padding: 0 20px 20px;
border-top: 1px solid var(--line);
background: rgba(255, 255, 255, 0.018);
}
.legend-body[hidden] {
display: none;
}
.legend-row {
display: grid;
grid-template-columns: 42px 1fr;
gap: 14px;
align-items: center;
padding: 18px 0 10px;
}
.legend-row > span {
color: var(--gold);
font-size: 1.65rem;
text-align: center;
}
.legend-row small {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.56rem;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.legend-row strong {
font-size: 1.12rem;
font-weight: 600;
}
.legend-body p {
margin: 0;
color: var(--muted);
font-size: 0.82rem;
line-height: 1.55;
}
.decoder {
margin-top: 18px;
padding: 24px;
border: 1px solid var(--line);
border-radius: 22px;
background: rgba(18, 28, 26, 0.88);
}
.decoder-top {
display: flex;
justify-content: space-between;
gap: 24px;
align-items: start;
margin-bottom: 18px;
}
.decoder h2 {
margin: 0 0 7px;
font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
font-size: clamp(1.55rem, 3vw, 2.3rem);
font-weight: 500;
letter-spacing: -0.025em;
}
.decoder-top p {
max-width: 690px;
margin: 0;
color: var(--muted);
line-height: 1.55;
}
.status {
flex: none;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 999px;
color: var(--muted);
font-size: 0.58rem;
}
.status.ready {
border-color: rgba(130, 185, 155, 0.35);
color: var(--green);
background: rgba(130, 185, 155, 0.06);
}
.choices {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.choice {
display: grid;
grid-template-columns: auto 1fr auto auto 1fr;
gap: 10px;
align-items: center;
padding: 15px;
border: 1px solid var(--line);
border-radius: 14px;
color: var(--text);
background: rgba(255, 255, 255, 0.018);
text-align: left;
cursor: pointer;
transition:
border-color 150ms ease,
background 150ms ease,
transform 150ms ease;
}
.choice:not(:disabled):hover {
border-color: var(--line-strong);
background: rgba(255, 255, 255, 0.04);
transform: translateY(-1px);
}
.choice:focus-visible {
outline: 2px solid var(--gold);
outline-offset: 2px;
}
.choice:disabled {
opacity: 0.36;
cursor: not-allowed;
}
.choice.selected {
border-color: var(--gold);
background: rgba(233, 201, 107, 0.07);
}
.choice.correct {
border-color: var(--green);
background: rgba(130, 185, 155, 0.09);
}
.choice.incorrect {
border-color: var(--red);
background: rgba(225, 138, 120, 0.08);
}
.choice-tag {
display: grid;
place-items: center;
width: 26px;
height: 26px;
border: 1px solid var(--line-strong);
border-radius: 7px;
color: var(--gold);
font-size: 0.64rem;
}
.choice-value {
font-size: 0.88rem;
font-weight: 600;
}
.choice-arrow {
color: var(--muted);
}
.feedback {
min-height: 25px;
margin: 15px 0 0;
color: var(--muted);
font-size: 0.86rem;
line-height: 1.5;
}
.feedback[data-tone="correct"] {
color: var(--green);
}
.feedback[data-tone="wrong"] {
color: var(--red);
}
footer {
display: flex;
justify-content: space-between;
gap: 20px;
margin-top: 18px;
color: rgba(204, 220, 211, 0.45);
font-size: 0.55rem;
line-height: 1.7;
}
@media (max-width: 900px) {
.hero {
grid-template-columns: 1fr;
}
.protocol {
width: 100%;
}
.map-grid,
.choices {
grid-template-columns: 1fr;
}
.viewport {
height: 430px;
}
}
@media (max-width: 560px) {
.page {
width: min(100% - 22px, 1420px);
padding-top: 30px;
}
.hero {
margin-bottom: 20px;
}
.map-card-head,
.decoder-top {
align-items: flex-start;
}
.match-badge,
.status {
display: none;
}
.viewport {
height: 350px;
}
.choice {
grid-template-columns: auto 1fr;
}
.choice-arrow {
display: none;
}
.choice-value:nth-of-type(2) {
grid-column: 2;
}
.decoder {
padding: 18px;
}
footer {
display: block;
}
}
@media (prefers-reduced-motion: reduce) {
* {
scroll-behavior: auto !important;
transition: none !important;
}
}
</style>
</head>
<body>
<main class="page">
<header class="hero">
<div>
<div class="eyebrow">Field Archive / Cartographic Ambiguity</div>
<h1>Same ground.<br>Different records.</h1>
<p class="hero-copy">
These two miniature surveys use identical terrain and an identical yellow
diamond. Their declared legends do not. Inspect both records before
interpreting the marked location.
</p>
</div>
<aside class="protocol" aria-label="Instructions">
<strong>Interpretation protocol</strong>
<span><span class="step">01</span> Inspect Plate A's legend</span>
<span><span class="step">02</span> Inspect Plate B's legend</span>
<span><span class="step">03</span> Compare the declaration</span>
</aside>
</header>
<section class="map-grid" aria-label="Two matching voxel maps">
<article class="map-card">
<div class="map-card-head">
<div>
<span class="plate-label">Plate A</span>
<h2>North quadrangle</h2>
</div>
<span class="match-badge">Matched terrain</span>
</div>
<div class="viewport" id="viewA">
<span class="coordinate">◆ <b>K7</b></span>
<span class="control-hint">Drag to orbit · Scroll to zoom</span>
</div>
<div class="legend-wrap">
<button
class="legend-trigger"
id="legendTriggerA"
type="button"
aria-expanded="false"
aria-controls="legendBodyA"
data-map="A"
>
<span class="legend-symbol">◆</span>
<span>
<span class="legend-kicker">Plate A declaration</span>
<strong>Inspect legend</strong>
</span>
<span class="legend-status">Sealed</span>
</button>
<div class="legend-body" id="legendBodyA" hidden>
<div class="legend-row">
<span>◆</span>
<div>
<small>Declared meaning</small>
<strong>Supply cache</strong>
</div>
</div>
<p>The yellow diamond identifies a verified supply cache.</p>
</div>
</div>
</article>
<article class="map-card">
<div class="map-card-head">
<div>
<span class="plate-label">Plate B</span>
<h2>North quadrangle</h2>
</div>
<span class="match-badge">Matched terrain</span>
</div>
<div class="viewport" id="viewB">
<span class="coordinate">◆ <b>K7</b></span>
<span class="control-hint">Drag to orbit · Scroll to zoom</span>
</div>
<div class="legend-wrap">
<button
class="legend-trigger"
id="legendTriggerB"
type="button"
aria-expanded="false"
aria-controls="legendBodyB"
data-map="B"
>
<span class="legend-symbol">◆</span>
<span>
<span class="legend-kicker">Plate B declaration</span>
<strong>Inspect legend</strong>
</span>
<span class="legend-status">Sealed</span>
</button>
<div class="legend-body" id="legendBodyB" hidden>
<div class="legend-row">
<span>◆</span>
<div>
<small>Declared meaning</small>
<strong>Hazard</strong>
</div>
</div>
<p>The yellow diamond identifies an unstable ground hazard.</p>
</div>
</div>
</article>
</section>
<section class="decoder" aria-labelledby="decoderTitle">
<div class="decoder-top">
<div>
<h2 id="decoderTitle">Decode the marked location</h2>
<p id="unlockText">
Both legends must be inspected before the marked location can be interpreted.
</p>
</div>
<span class="status" id="decoderStatus">0 / 2 inspected</span>
</div>
<div class="choices" aria-label="Answer choices">
<button class="choice" type="button" disabled data-answer="cache-hazard">
<span class="choice-tag">A</span>
<span class="choice-value">Supply cache</span>
<span class="choice-arrow">→</span>
<span class="choice-tag">B</span>
<span class="choice-value">Hazard</span>
</button>
<button class="choice" type="button" disabled data-answer="hazard-cache">
<span class="choice-tag">A</span>
<span class="choice-value">Hazard</span>
<span class="choice-arrow">→</span>
<span class="choice-tag">B</span>
<span class="choice-value">Supply cache</span>
</button>
<button class="choice" type="button" disabled data-answer="relay-cache">
<span class="choice-tag">A</span>
<span class="choice-value">Radio relay</span>
<span class="choice-arrow">→</span>
<span class="choice-tag">B</span>
<span class="choice-value">Supply cache</span>
</button>
<button class="choice" type="button" disabled data-answer="cache-cache">
<span class="choice-tag">A</span>
<span class="choice-value">Supply cache</span>
<span class="choice-arrow">→</span>
<span class="choice-tag">B</span>
<span class="choice-value">Supply cache</span>
</button>
</div>
<p class="feedback" id="feedback" aria-live="polite"></p>
</section>
<footer>
<span>One deterministic seed · Two identical voxel terrains · One ambiguous symbol</span>
<span>Keyboard: arrows orbit · +/− zoom · Home resets</span>
</footer>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
// Shared deterministic terrain description.
const GRID_STEP = 0.43;
const VOXEL_SIZE = 0.34;
const VOXEL_PITCH = 0.36;
const MARKER = { x: 2, z: -2 };
function hash2D(x, z) {
let n = Math.imul(x, 374761393) + Math.imul(z, 668265263);
n = n ^ (n >>> 13);
n = Math.imul(n, 1274126177);
return ((n ^ (n >>> 16)) >>> 0) / 4294967296;
}
function getTile(x, z) {
const edge = (x * x) / 21 + (z * z) / 25;
const noise = hash2D(x, z);
const isMarker = x === MARKER.x && z === MARKER.z;
let water =
edge > 1.0 ||
(edge > 0.73 && noise > 0.45);
let levels = 1;
if (!water) {
if (edge < 0.38) {
levels = 3 + (noise > 0.76 ? 1 : 0);
} else if (edge < 0.7) {
levels = 2 + (noise > 0.82 ? 1 : 0);
} else {
levels = 1 + (noise > 0.88 ? 1 : 0);
}
}
if (isMarker) {
water = false;
levels = 2;
}
const path =
isMarker ||
(Math.abs(x + z) <= 1 && noise > 0.67 && levels <= 2);
return { water, levels, path, noise };
}
function createVoxelMap(container) {
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x101916);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"role",
"img"
);
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel map with a yellow diamond at location K7. Drag or use arrow keys to orbit."
);
container.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-5, 5, 4, -4, 0.1, 100);
const target = new THREE.Vector3(0, 0.35, 0);
let yaw = 0.68;
let pitch = 0.72;
let zoom = 1;
const distance = 13;
const hemisphere = new THREE.HemisphereLight(0xd9efe7, 0x332a23, 1.9);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedc7, 2.8);
sun.position.set(5, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(1024, 1024);
sun.shadow.camera.left = -6;
sun.shadow.camera.right = 6;
sun.shadow.camera.top = 6;
sun.shadow.camera.bottom = -6;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 28;
sun.shadow.bias = -0.0008;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x78a99f, 0.7);
fill.position.set(-6, 4, -5);
scene.add(fill);
const root = new THREE.Group();
scene.add(root);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: 0x14201d,
roughness: 0.95,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.025;
ground.receiveShadow = true;
root.add(ground);
const material = (color, roughness = 0.85) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness: 0.02
});
const buckets = {
water: {
material: material(0x2d6871, 0.58),
items: []
},
waterAlt: {
material: material(0x397b82, 0.62),
items: []
},
soil: {
material: material(0x68513b),
items: []
},
soilDark: {
material: material(0x4d4032),
items: []
},
grass: {
material: material(0x74846b),
items: []
},
grassLight: {
material: material(0x8b9877),
items: []
},
stone: {
material: material(0xa59b82),
items: []
},
trunk: {
material: material(0x594333),
items: []
},
foliage: {
material: material(0x4f745d),
items: []
},
foliageLight: {
material: material(0x698969),
items: []
}
};
function addCube(bucket, x, y, z, scale = 1) {
buckets[bucket].items.push({
x,
y,
z,
scale
});
}
for (let gx = -6; gx <= 6; gx++) {
for (let gz = -6; gz <= 6; gz++) {
const tile = getTile(gx, gz);
const px = gx * GRID_STEP;
const pz = gz * GRID_STEP;
if (tile.water) {
const bucket = tile.noise > 0.53 ? "waterAlt" : "water";
addCube(bucket, px, VOXEL_SIZE / 2, pz);
continue;
}
for (let layer = 0; layer < tile.levels; layer++) {
let bucket;
if (layer < tile.levels - 1) {
bucket = tile.noise > 0.5 ? "soil" : "soilDark";
} else if (tile.path) {
bucket = "stone";
} else {
bucket = tile.noise > 0.56 ? "grassLight" : "grass";
}
addCube(
bucket,
px,
VOXEL_SIZE / 2 + layer * VOXEL_PITCH,
pz
);
}
const nearMarker =
Math.abs(gx - MARKER.x) <= 1 &&
Math.abs(gz - MARKER.z) <= 1;
if (
!nearMarker &&
tile.noise > 0.935 &&
tile.levels <= 2
) {
const surface =
VOXEL_SIZE / 2 +
tile.levels * VOXEL_PITCH -
0.01;
addCube("trunk", px, surface + 0.17, pz);
addCube(
tile.noise > 0.96 ? "foliageLight" : "foliage",
px,
surface + 0.48,
pz
);
addCube(
"foliage",
px + 0.18,
surface + 0.31,
pz - 0.1
);
}
}
}
const cubeGeometry = new THREE.BoxGeometry(
VOXEL_SIZE,
VOXEL_SIZE,
VOXEL_SIZE
);
const dummy = new THREE.Object3D();
for (const [name, bucket] of Object.entries(buckets)) {
if (!bucket.items.length) continue;
const mesh = new THREE.InstancedMesh(
cubeGeometry,
bucket.material,
bucket.items.length
);
bucket.items.forEach((item, index) => {
dummy.position.set(item.x, item.y, item.z);
dummy.scale.setScalar(item.scale);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = name !== "water" && name !== "waterAlt";
mesh.receiveShadow = true;
root.add(mesh);
}
const markerTile = getTile(MARKER.x, MARKER.z);
const markerSurface =
VOXEL_SIZE / 2 +
markerTile.levels * VOXEL_PITCH -
0.01;
const markerGroup = new THREE.Group();
markerGroup.position.set(
MARKER.x * GRID_STEP,
markerSurface + 0.015,
MARKER.z * GRID_STEP
);
root.add(markerGroup);
const markerGold = new THREE.MeshStandardMaterial({
color: 0xf0ca67,
emissive: 0x8a5700,
emissiveIntensity: 1.35,
roughness: 0.35,
metalness: 0.15
});
const diamond = new THREE.Mesh(
new THREE.OctahedronGeometry(0.28, 0),
markerGold
);
diamond.position.y = 0.72;
diamond.castShadow = true;
markerGroup.add(diamond);
const stem = new THREE.Mesh(
new THREE.CylinderGeometry(0.025, 0.025, 0.68, 8),
new THREE.MeshBasicMaterial({
color: 0xe9c96b,
transparent: true,
opacity: 0.55
})
);
stem.position.y = 0.34;
markerGroup.add(stem);
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0xe9c96b,
transparent: true,
opacity: 0.85
});
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.035, 8, 36),
ringMaterial
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.055;
markerGroup.add(ring);
const markerLight = new THREE.PointLight(0xf0c766, 0.75, 2.2);
markerLight.position.y = 0.75;
markerGroup.add(markerLight);
function updateCamera() {
const cosPitch = Math.cos(pitch);
camera.position.set(
target.x + Math.sin(yaw) * cosPitch * distance,
target.y + Math.sin(pitch) * distance,
target.z + Math.cos(yaw) * cosPitch * distance
);
camera.lookAt(target);
camera.zoom = zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = Math.max(1, Math.floor(container.clientWidth));
const height = Math.max(1, Math.floor(container.clientHeight));
const aspect = width / height;
const frustumHeight = aspect < 1 ? 9.4 : 7.4;
camera.left = (-frustumHeight * aspect) / 2;
camera.right = (frustumHeight * aspect) / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
renderer.setSize(width, height, false);
updateCamera();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(container);
resize();
// Camera controls are implemented directly without external addons.
let dragging = false;
let previousX = 0;
let previousY = 0;
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
yaw -= dx * 0.006;
pitch = THREE.MathUtils.clamp(
pitch + dy * 0.005,
0.36,
1.16
);
updateCamera();
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.7
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
yaw = 0.68;
pitch = 0.72;
zoom = 1;
updateCamera();
});
canvas.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
yaw += 0.12;
break;
case "ArrowRight":
yaw -= 0.12;
break;
case "ArrowUp":
pitch = Math.min(1.16, pitch + 0.08);
break;
case "ArrowDown":
pitch = Math.max(0.36, pitch - 0.08);
break;
case "+":
case "=":
zoom = Math.min(1.7, zoom * 1.08);
break;
case "-":
case "_":
zoom = Math.max(0.72, zoom / 1.08);
break;
case "Home":
yaw = 0.68;
pitch = 0.72;
zoom = 1;
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
return {
renderer,
scene,
camera,
diamond,
ring,
ringMaterial,
updateCamera
};
}
const views = [
createVoxelMap(document.getElementById("viewA")),
createVoxelMap(document.getElementById("viewB"))
];
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
for (const view of views) {
const pulse = reducedMotion
? 1
: 1 + Math.sin(elapsed * 2.5) * 0.07;
view.diamond.scale.setScalar(pulse);
view.ring.scale.setScalar(1 + (pulse - 1) * 0.6);
view.ringMaterial.opacity = reducedMotion
? 0.85
: 0.72 + Math.sin(elapsed * 2.5) * 0.13;
view.renderer.render(view.scene, view.camera);
}
}
animate();
// Legend inspection gates interpretation.
const inspected = {
A: false,
B: false
};
const triggers = document.querySelectorAll(".legend-trigger");
const choiceButtons = document.querySelectorAll(".choice");
const unlockText = document.getElementById("unlockText");
const decoderStatus = document.getElementById("decoderStatus");
const feedback = document.getElementById("feedback");
function updateDecoderState() {
const count = Number(inspected.A) + Number(inspected.B);
const ready = count === 2;
choiceButtons.forEach((button) => {
button.disabled = !ready;
});
decoderStatus.textContent = `${count} / 2 inspected`;
decoderStatus.classList.toggle("ready", ready);
if (!ready) {
unlockText.textContent =
count === 0
? "Both legends must be inspected before the marked location can be interpreted."
: "One legend remains sealed. The matching terrain cannot resolve the conflicting record.";
feedback.textContent = "";
feedback.removeAttribute("data-tone");
} else {
unlockText.textContent =
"Both legends inspected. Select the correct pair of declared meanings for ◆ at K7.";
}
}
triggers.forEach((trigger) => {
const key = trigger.dataset.map;
const body = document.getElementById(
trigger.getAttribute("aria-controls")
);
const title = trigger.querySelector("strong");
const status = trigger.querySelector(".legend-status");
trigger.addEventListener("click", () => {
const willOpen = body.hidden;
body.hidden = !willOpen;
trigger.setAttribute("aria-expanded", String(willOpen));
if (willOpen) {
inspected[key] = true;
trigger.classList.add("inspected");
status.textContent = "Inspected ✓";
title.textContent = "Hide legend";
} else {
title.textContent = "Show legend";
}
updateDecoderState();
});
});
choiceButtons.forEach((button) => {
button.addEventListener("click", () => {
if (button.disabled) return;
choiceButtons.forEach((choice) => {
choice.classList.remove("selected", "correct", "incorrect");
});
button.classList.add("selected");
const isCorrect = button.dataset.answer === "cache-hazard";
if (isCorrect) {
button.classList.add("correct");
feedback.dataset.tone = "correct";
feedback.textContent =
"Correct. Plate A declares ◆ as a supply cache, while Plate B declares the identical ◆ as a hazard. The terrain is the same; the archive meanings conflict.";
} else {
button.classList.add("incorrect");
feedback.dataset.tone = "wrong";
feedback.textContent =
"Not quite. Re-open the two declaration rows and compare the declared meaning of the yellow diamond.";
}
});
});
updateDecoderState();
</script>
</body>
</html>
```