Prompt specification
Build or customize the Three.js 3D scene "Negated Instruction Navigation" 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: Negated Instruction Navigation
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/negated-instruction-navigation-x3400
Scene Description Prompt:
Use Three.js from cdnjs to create a small route puzzle with statements about forbidden tiles and required destinations. Check actual paths and explain that avoiding one area does not guarantee reaching the goal. Deliver one self-contained HTML file with visible voxel blocks.
Working Three.js Starter (negated-instruction-navigation-x3400):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Waypoint — The Long Way Round</title>
<style>
:root {
color-scheme: dark;
--bg: #07101d;
--panel: #0b1727;
--panel-2: #101f32;
--line: rgba(164, 196, 226, 0.16);
--text: #edf7ff;
--muted: #8ea6bd;
--cyan: #48e6ff;
--green: #79ffb5;
--violet: #c494ff;
--red: #ff657d;
--amber: #ffd166;
}
* {
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,
summary {
font: inherit;
}
button {
border: 0;
}
.topbar {
height: 72px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
border-bottom: 1px solid var(--line);
background:
radial-gradient(circle at 18% 0%, rgba(72, 230, 255, 0.09), transparent 30%),
#081321;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
width: 38px;
height: 38px;
display: grid;
place-items: center;
flex: 0 0 auto;
border: 1px solid rgba(72, 230, 255, 0.45);
background: rgba(72, 230, 255, 0.07);
color: var(--cyan);
font-size: 19px;
font-weight: 800;
box-shadow: inset 0 0 20px rgba(72, 230, 255, 0.06);
}
.brand-copy {
min-width: 0;
}
.eyebrow {
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 3px 0 0;
font-size: clamp(17px, 2vw, 23px);
line-height: 1.1;
letter-spacing: -0.025em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.case-pill {
flex: 0 0 auto;
padding: 8px 12px;
border: 1px solid var(--line);
border-radius: 999px;
color: var(--muted);
background: rgba(255, 255, 255, 0.025);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.app {
height: calc(100vh - 72px);
display: grid;
grid-template-columns: minmax(0, 1fr) 400px;
}
#stage {
position: relative;
min-width: 0;
min-height: 560px;
overflow: hidden;
background: #07101d;
}
#scene {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.scene-heading {
position: absolute;
top: 22px;
left: 24px;
z-index: 2;
pointer-events: none;
}
.scene-heading h2 {
margin: 4px 0 0;
font-size: 18px;
letter-spacing: -0.02em;
}
.scene-heading p {
margin: 5px 0 0;
color: var(--muted);
font-size: 12px;
}
.legend {
position: absolute;
left: 20px;
bottom: 22px;
z-index: 2;
display: flex;
flex-wrap: wrap;
gap: 8px;
max-width: calc(100% - 40px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
padding: 7px 10px;
border: 1px solid var(--line);
border-radius: 7px;
background: rgba(5, 13, 24, 0.82);
backdrop-filter: blur(10px);
color: #b8cada;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--c);
box-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent);
}
.camera-help {
position: absolute;
right: 20px;
bottom: 24px;
z-index: 2;
color: #71889f;
font-size: 10px;
pointer-events: none;
}
.route-trace {
position: absolute;
left: 50%;
bottom: 68px;
z-index: 2;
width: min(720px, calc(100% - 40px));
transform: translateX(-50%);
padding: 9px 14px;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(4, 12, 22, 0.86);
color: #a9c2d7;
font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
pointer-events: none;
backdrop-filter: blur(10px);
}
#toast {
position: absolute;
top: 22px;
left: 50%;
z-index: 5;
max-width: min(520px, calc(100% - 40px));
padding: 10px 15px;
transform: translate(-50%, -12px);
border: 1px solid rgba(255, 209, 102, 0.35);
border-radius: 8px;
background: rgba(18, 27, 37, 0.95);
color: #ffe5a6;
font-size: 12px;
opacity: 0;
pointer-events: none;
transition: 160ms ease;
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
aside {
overflow-y: auto;
padding: 24px 22px 28px;
border-left: 1px solid var(--line);
background:
linear-gradient(180deg, rgba(72, 230, 255, 0.025), transparent 180px),
var(--panel);
scrollbar-width: thin;
scrollbar-color: #29415a transparent;
}
aside h2 {
margin: 7px 0 8px;
font-size: 25px;
line-height: 1.12;
letter-spacing: -0.035em;
}
.intro {
margin: 0 0 19px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
margin: 18px 0 8px;
color: #7f96ad;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#route-length {
color: #b9cbdc;
letter-spacing: 0.04em;
}
.statements {
display: grid;
gap: 8px;
}
.statement {
display: grid;
grid-template-columns: 28px minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
padding: 11px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.025);
transition: border-color 150ms ease, background 150ms ease;
}
.statement.is-good {
border-color: rgba(121, 255, 181, 0.26);
background: rgba(121, 255, 181, 0.035);
}
.statement.is-bad {
border-color: rgba(255, 101, 125, 0.35);
background: rgba(255, 101, 125, 0.045);
}
.statement-index {
width: 28px;
height: 28px;
display: grid;
place-items: center;
border-radius: 6px;
background: rgba(255, 255, 255, 0.045);
color: #7890a8;
font: 700 10px ui-monospace, monospace;
}
.statement-copy {
min-width: 0;
}
.statement-kicker {
display: block;
margin-bottom: 2px;
color: #7890a8;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.15em;
}
.statement strong {
display: block;
font-size: 12px;
line-height: 1.25;
}
.statement small {
display: block;
margin-top: 3px;
color: #7e96ad;
font-size: 10px;
line-height: 1.35;
}
.statement-state {
align-self: start;
padding: 4px 6px;
border-radius: 4px;
background: rgba(255, 255, 255, 0.05);
color: #8299af;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.07em;
white-space: nowrap;
}
.statement-state.good {
background: rgba(121, 255, 181, 0.11);
color: var(--green);
}
.statement-state.bad {
background: rgba(255, 101, 125, 0.12);
color: var(--red);
}
.statement-state.warn {
background: rgba(255, 209, 102, 0.11);
color: var(--amber);
}
.actions {
display: grid;
grid-template-columns: 1fr auto;
gap: 8px;
margin-top: 15px;
}
.button {
min-height: 42px;
padding: 0 14px;
border: 1px solid var(--line);
border-radius: 8px;
background: #132338;
color: #c9d9e7;
cursor: pointer;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.04em;
transition: 140ms ease;
}
.button:hover {
border-color: rgba(72, 230, 255, 0.38);
color: white;
transform: translateY(-1px);
}
.button.primary {
background: var(--cyan);
color: #04131c;
box-shadow: 0 7px 22px rgba(72, 230, 255, 0.16);
}
.button.primary:hover {
background: #8aeeff;
}
.button.subtle {
min-height: 34px;
padding: 0 11px;
font-size: 10px;
}
.tool-row {
display: flex;
gap: 8px;
margin-top: 8px;
}
.result {
margin-top: 14px;
padding: 14px;
border: 1px solid rgba(72, 230, 255, 0.18);
border-radius: 10px;
background: rgba(72, 230, 255, 0.035);
}
.result.success {
border-color: rgba(121, 255, 181, 0.32);
background: rgba(121, 255, 181, 0.045);
}
.result.failure {
border-color: rgba(255, 101, 125, 0.32);
background: rgba(255, 101, 125, 0.04);
}
.result-kicker {
color: var(--cyan);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.16em;
}
.result.success .result-kicker {
color: var(--green);
}
.result.failure .result-kicker {
color: var(--red);
}
.result-title {
margin-top: 5px;
font-size: 13px;
font-weight: 800;
line-height: 1.35;
}
.result p {
margin: 7px 0 0;
color: #93a9be;
font-size: 11px;
line-height: 1.55;
}
.audit {
display: grid;
gap: 5px;
margin-top: 11px;
}
.audit-row {
display: grid;
grid-template-columns: 12px minmax(0, 1fr) auto;
align-items: center;
gap: 7px;
color: #8fa6bc;
font-size: 10px;
}
.audit-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #667b90;
}
.audit-row.good .audit-dot {
background: var(--green);
box-shadow: 0 0 8px rgba(121, 255, 181, 0.55);
}
.audit-row.bad .audit-dot {
background: var(--red);
box-shadow: 0 0 8px rgba(255, 101, 125, 0.55);
}
.audit-detail {
color: #6f879e;
font-family: ui-monospace, monospace;
font-size: 9px;
}
details {
margin-top: 13px;
border-top: 1px solid var(--line);
padding-top: 11px;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
summary {
color: #aec3d6;
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
}
details p {
margin: 9px 0 0;
}
.logic-strip {
margin-top: 15px;
padding: 11px 12px;
border-left: 2px solid var(--amber);
background: rgba(255, 209, 102, 0.045);
color: #b9aa84;
font-size: 10px;
line-height: 1.5;
}
@media (max-width: 900px) {
body {
overflow: auto;
}
.topbar {
height: 66px;
padding: 0 15px;
}
.case-pill {
display: none;
}
.app {
height: auto;
display: block;
}
#stage {
height: 66vh;
min-height: 520px;
}
aside {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.camera-help {
display: none;
}
.scene-heading {
top: 17px;
left: 17px;
}
.legend {
left: 14px;
bottom: 14px;
}
.route-trace {
bottom: 58px;
}
}
@media (max-width: 480px) {
.brand-mark {
width: 33px;
height: 33px;
}
.brand .eyebrow {
font-size: 8px;
}
h1 {
font-size: 16px;
}
.legend-item {
padding: 6px 8px;
font-size: 9px;
}
.actions {
grid-template-columns: 1fr 1fr;
}
.actions .primary {
grid-column: 1 / -1;
}
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">W</div>
<div class="brand-copy">
<div class="eyebrow">Waypoint / Route Logic</div>
<h1>The Long Way Round</h1>
</div>
</div>
<div class="case-pill">Case 03 · Voxel Transit Grid</div>
</header>
<main class="app">
<section id="stage" aria-label="Interactive voxel route grid">
<canvas id="scene" tabindex="0" aria-label="3D route grid"></canvas>
<div class="scene-heading">
<div class="eyebrow">Live route board</div>
<h2>Find a path that satisfies every statement.</h2>
<p>Click an orthogonally adjacent tile to extend the route.</p>
</div>
<div class="route-trace" id="route-trace">A1 — choose an adjacent tile</div>
<div class="legend" aria-label="Map legend">
<div class="legend-item"><span class="swatch" style="--c:#5ea7ff"></span>Start</div>
<div class="legend-item"><span class="swatch" style="--c:#48e6ff"></span>Sun Dial</div>
<div class="legend-item"><span class="swatch" style="--c:#c494ff"></span>Signal</div>
<div class="legend-item"><span class="swatch" style="--c:#ff657d"></span>Forbidden</div>
<div class="legend-item"><span class="swatch" style="--c:#79ffb5"></span>Goal</div>
</div>
<div class="camera-help">Drag: orbit · Wheel: zoom · Right-drag: pan</div>
<div id="toast" role="status" aria-live="polite"></div>
</section>
<aside>
<div class="eyebrow">Route dossier</div>
<h2>Three claims.<br>One verifiable path.</h2>
<p class="intro">
Build one continuous route from the blue Start tile. Every statement must
be true when the entire path is checked.
</p>
<div class="section-label">
<span>Statements</span>
<span id="route-length">0 steps · draft</span>
</div>
<div class="statements">
<article class="statement" id="stmt-avoid">
<div class="statement-index">01</div>
<div class="statement-copy">
<span class="statement-kicker">Must avoid</span>
<strong>Foundry district</strong>
<small>No route tile may occupy the eight red blocks.</small>
</div>
<span class="statement-state">CLEAR</span>
</article>
<article class="statement" id="stmt-sun">
<div class="statement-index">02</div>
<div class="statement-copy">
<span class="statement-kicker">Must visit</span>
<strong>Sun Dial · E2</strong>
<small>The actual path must touch the cyan destination.</small>
</div>
<span class="statement-state">NOT YET</span>
</article>
<article class="statement" id="stmt-signal">
<div class="statement-index">03</div>
<div class="statement-copy">
<span class="statement-kicker">Must visit</span>
<strong>Signal · I2</strong>
<small>The actual path must touch the violet destination.</small>
</div>
<span class="statement-state">NOT YET</span>
</article>
<article class="statement" id="stmt-goal">
<div class="statement-index">04</div>
<div class="statement-copy">
<span class="statement-kicker">Must reach</span>
<strong>Moon Gate · J10</strong>
<small>The route must finish at the green destination.</small>
</div>
<span class="statement-state">NOT YET</span>
</article>
</div>
<div class="actions">
<button class="button primary" id="check-button" type="button">
Check actual path
</button>
<button class="button" id="reset-button" type="button">Reset route</button>
</div>
<div class="tool-row">
<button class="button subtle" id="undo-button" type="button">Undo tile</button>
<button class="button subtle" id="clear-button" type="button">Clear path</button>
</div>
<div class="result" id="result" aria-live="polite"></div>
<details>
<summary>Controls and a nudge</summary>
<p>
Click a tile next to the route endpoint to extend it. Click an earlier
route tile to truncate the path there. Drag to orbit, use the wheel to
zoom, and right-drag to pan. Keyboard: Enter checks, Backspace undoes,
and R resets.
</p>
<p>
<strong>Hint:</strong> Use E2 as the first stop. G4 is the safe opening
through the G-column wall. From H4, return north to I2, then descend
the J column to J10.
</p>
</details>
<div class="logic-strip">
Avoiding one area does not guarantee reaching the goal. It proves only
that those particular tiles were not used; required stops and the actual
endpoint still need to be checked.
</div>
</aside>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (id) => document.getElementById(id);
const canvas = $("scene");
const stage = $("stage");
const N = 10;
const CELL = 1.05;
const HALF = (N - 1) / 2;
const start = { x: 0, z: 0 };
const sunDial = { x: 4, z: 1 };
const signal = { x: 8, z: 1 };
const goal = { x: 9, z: 9 };
const required = [
{ ...sunDial, name: "Sun Dial" },
{ ...signal, name: "Signal" }
];
const wallSet = new Set();
const forbiddenSet = new Set();
// Tall block walls. These are physical obstacles, separate from the red
// forbidden tiles.
for (let z = 3; z <= 8; z++) wallSet.add(key(3, z)); // D4–D9
for (let z = 0; z <= 2; z++) wallSet.add(key(6, z)); // G1–G3
for (let z = 6; z <= 9; z++) wallSet.add(key(6, z)); // G7–G10
for (let z = 2; z <= 4; z++) wallSet.add(key(8, z)); // I3–I5
for (let z = 6; z <= 8; z++) wallSet.add(key(8, z)); // I7–I9
// Irregular eight-tile forbidden district.
for (let x = 4; x <= 5; x++) {
for (let z = 4; z <= 6; z++) forbiddenSet.add(key(x, z));
}
forbiddenSet.add(key(6, 4));
forbiddenSet.add(key(6, 5));
function key(x, z) {
return `${x},${z}`;
}
function cellKey(cell) {
return key(cell.x, cell.z);
}
function coordinate(x, z) {
return `${String.fromCharCode(65 + x)}${z + 1}`;
}
function sameCell(a, b) {
return a.x === b.x && a.z === b.z;
}
function position(x, z, y = 0.1) {
return new THREE.Vector3(
(x - HALF) * CELL,
y,
(z - HALF) * CELL
);
}
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setClearColor(0x07101d, 1);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07101d);
scene.fog = new THREE.Fog(0x07101d, 21, 39);
const camera = new THREE.PerspectiveCamera(43, 1, 0.1, 100);
const hemisphere = new THREE.HemisphereLight(0xa7dcff, 0x101523, 2.0);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xd8f3ff, 3.0);
keyLight.position.set(8, 15, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0007;
scene.add(keyLight);
const rimLight = new THREE.PointLight(0x287dff, 12, 30, 2);
rimLight.position.set(-8, 5, -9);
scene.add(rimLight);
const underplate = new THREE.Mesh(
new THREE.BoxGeometry(11.4, 0.55, 11.4),
new THREE.MeshStandardMaterial({
color: 0x0d1b2b,
roughness: 0.86,
metalness: 0.12
})
);
underplate.position.y = -0.31;
underplate.receiveShadow = true;
scene.add(underplate);
const normalMaterial = new THREE.MeshStandardMaterial({
color: 0x183049,
roughness: 0.83,
metalness: 0.04
});
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0x31445d,
roughness: 0.73,
metalness: 0.12
});
const forbiddenMaterial = new THREE.MeshStandardMaterial({
color: 0x671d32,
emissive: 0x4c0718,
emissiveIntensity: 0.28,
roughness: 0.68
});
const sunMaterial = new THREE.MeshStandardMaterial({
color: 0x36dff7,
emissive: 0x0b8196,
emissiveIntensity: 0.36,
roughness: 0.38,
metalness: 0.08
});
const signalMaterial = new THREE.MeshStandardMaterial({
color: 0xb879f4,
emissive: 0x51217e,
emissiveIntensity: 0.36,
roughness: 0.4,
metalness: 0.08
});
const goalMaterial = new THREE.MeshStandardMaterial({
color: 0x68e89f,
emissive: 0x12683d,
emissiveIntensity: 0.42,
roughness: 0.38,
metalness: 0.08
});
const startMaterial = new THREE.MeshStandardMaterial({
color: 0x4b8ee7,
emissive: 0x153d75,
emissiveIntensity: 0.4,
roughness: 0.44
});
const tileGeometry = new THREE.BoxGeometry(0.96, 0.18, 0.96);
const wallBlockGeometry = new THREE.BoxGeometry(0.82, 0.7, 0.82);
const interactiveMeshes = [];
const beacons = [];
function materialFor(x, z) {
if (wallSet.has(key(x, z))) return wallMaterial;
if (forbiddenSet.has(key(x, z))) return forbiddenMaterial;
if (sameCell({ x, z }, start)) return startMaterial;
if (sameCell({ x, z }, sunDial)) return sunMaterial;
if (sameCell({ x, z }, signal)) return signalMaterial;
if (sameCell({ x, z }, goal)) return goalMaterial;
return normalMaterial;
}
for (let z = 0; z < N; z++) {
for (let x = 0; x < N; x++) {
const tile = new THREE.Mesh(tileGeometry, materialFor(x, z));
tile.position.copy(position(x, z, 0.09));
tile.castShadow = true;
tile.receiveShadow = true;
tile.userData.cell = { x, z };
scene.add(tile);
interactiveMeshes.push(tile);
if (wallSet.has(key(x, z))) {
for (let level = 0; level < 2; level++) {
const block = new THREE.Mesh(wallBlockGeometry, wallMaterial);
block.position.copy(position(x, z, 0.53 + level * 0.64));
block.castShadow = true;
block.receiveShadow = true;
block.userData.cell = { x, z };
scene.add(block);
interactiveMeshes.push(block);
}
}
}
}
function makeLabel(text, color) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 256;
labelCanvas.height = 128;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 256, 128);
ctx.fillStyle = "rgba(5, 13, 25, 0.92)";
ctx.strokeStyle = color;
ctx.lineWidth = 5;
ctx.beginPath();
ctx.roundRect(5, 5, 246, 118, 24);
ctx.fill();
ctx.stroke();
ctx.fillStyle = color;
ctx.font = "800 52px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 128, 65);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: true
})
);
sprite.scale.set(1.15, 0.575, 1);
return sprite;
}
function addBeacon(cell, color, label) {
const group = new THREE.Group();
group.position.copy(position(cell.x, cell.z, 0));
const pedestal = new THREE.Mesh(
new THREE.BoxGeometry(0.52, 0.2, 0.52),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.12,
roughness: 0.48
})
);
pedestal.position.y = 0.26;
pedestal.castShadow = true;
group.add(pedestal);
const post = new THREE.Mesh(
new THREE.BoxGeometry(0.18, 0.62, 0.18),
new THREE.MeshStandardMaterial({
color: 0xb9d7ea,
roughness: 0.36,
metalness: 0.2
})
);
post.position.y = 0.62;
post.castShadow = true;
group.add(post);
const crystal = new THREE.Mesh(
new THREE.BoxGeometry(0.36, 0.36, 0.36),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.72,
roughness: 0.28
})
);
crystal.position.y = 1.08;
crystal.castShadow = true;
group.add(crystal);
const sprite = makeLabel(label, color);
sprite.position.y = 1.72;
group.add(sprite);
group.userData.crystal = crystal;
group.userData.baseY = group.position.y;
beacons.push(group);
scene.add(group);
}
addBeacon(sunDial, "#48e6ff", "E2");
addBeacon(signal, "#c494ff", "I2");
const goalGroup = new THREE.Group();
goalGroup.position.copy(position(goal.x, goal.z, 0));
const goalPedestal = new THREE.Mesh(
new THREE.BoxGeometry(0.62, 0.2, 0.62),
goalMaterial
);
goalPedestal.position.y = 0.26;
goalPedestal.castShadow = true;
goalGroup.add(goalPedestal);
const goalRing = new THREE.Mesh(
new THREE.TorusGeometry(0.34, 0.055, 8, 28),
new THREE.MeshStandardMaterial({
color: 0x8affbd,
emissive: 0x1a9e56,
emissiveIntensity: 1.0,
roughness: 0.3
})
);
goalRing.rotation.x = Math.PI / 2;
goalRing.position.y = 0.39;
goalGroup.add(goalRing);
const goalCrystal = new THREE.Mesh(
new THREE.BoxGeometry(0.34, 0.46, 0.34),
goalMaterial
);
goalCrystal.position.y = 0.66;
goalCrystal.castShadow = true;
goalGroup.add(goalCrystal);
const goalLabel = makeLabel("J10", "#79ffb5");
goalLabel.position.y = 1.55;
goalGroup.add(goalLabel);
scene.add(goalGroup);
const startGroup = new THREE.Group();
startGroup.position.copy(position(start.x, start.z, 0));
const startCube = new THREE.Mesh(
new THREE.BoxGeometry(0.4, 0.4, 0.4),
startMaterial
);
startCube.position.y = 0.38;
startCube.castShadow = true;
startGroup.add(startCube);
const startLabel = makeLabel("A1", "#82b7ff");
startLabel.position.y = 1.12;
startGroup.add(startLabel);
scene.add(startGroup);
const routeGroup = new THREE.Group();
scene.add(routeGroup);
const routeMaterial = new THREE.MeshStandardMaterial({
color: 0x5cecff,
emissive: 0x0d7181,
emissiveIntensity: 0.85,
roughness: 0.3,
metalness: 0.08
});
const routeMarkerGeometry = new THREE.SphereGeometry(0.115, 12, 8);
const routeSegmentGeometry = new THREE.CylinderGeometry(
0.055,
0.055,
1,
10,
1,
false
);
const route = [{ ...start }];
let checked = false;
let hoverCell = null;
const hoverOutline = new THREE.LineSegments(
new THREE.EdgesGeometry(new THREE.BoxGeometry(0.985, 0.205, 0.985)),
new THREE.LineBasicMaterial({
color: 0xbfefff,
transparent: true,
opacity: 0.8
})
);
hoverOutline.visible = false;
scene.add(hoverOutline);
function rebuildRoute() {
routeGroup.clear();
for (const cell of route) {
const marker = new THREE.Mesh(routeMarkerGeometry, routeMaterial);
marker.position.copy(position(cell.x, cell.z, 0.32));
routeGroup.add(marker);
}
for (let i = 1; i < route.length; i++) {
const a = position(route[i - 1].x, route[i - 1].z, 0.31);
const b = position(route[i].x, route[i].z, 0.31);
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const segment = new THREE.Mesh(routeSegmentGeometry, routeMaterial);
segment.position.copy(a).add(b).multiplyScalar(0.5);
segment.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
segment.scale.y = length;
routeGroup.add(segment);
}
const touchedFoundry = route.some((cell) =>
forbiddenSet.has(cellKey(cell))
);
routeMaterial.color.setHex(touchedFoundry ? 0xff657d : 0x5cecff);
routeMaterial.emissive.setHex(touchedFoundry ? 0x8a1027 : 0x0d7181);
}
function inspectRoute() {
let continuous = true;
const walls = [];
for (let i = 1; i < route.length; i++) {
const dx = Math.abs(route[i].x - route[i - 1].x);
const dz = Math.abs(route[i].z - route[i - 1].z);
if (dx + dz !== 1) continuous = false;
}
for (const cell of route) {
if (wallSet.has(cellKey(cell))) walls.push(cell);
}
const foundry = route.filter((cell) =>
forbiddenSet.has(cellKey(cell))
);
const missing = required.filter(
(destination) =>
!route.some((cell) => sameCell(cell, destination))
);
const atGoal =
route.length > 1 && sameCell(route[route.length - 1], goal);
const valid =
continuous &&
walls.length === 0 &&
foundry.length === 0 &&
missing.length === 0 &&
atGoal;
return { continuous, walls, foundry, missing, atGoal, valid };
}
function setStatement(id, label, status) {
const article = $(id);
const state = article.querySelector(".statement-state");
state.textContent = label;
state.className = `statement-state ${status}`;
article.classList.remove("is-good", "is-bad");
if (status === "good") article.classList.add("is-good");
if (status === "bad") article.classList.add("is-bad");
}
function updateStatements() {
const report = inspectRoute();
if (checked) {
setStatement(
"stmt-avoid",
report.foundry.length ? "FAIL" : "PASS",
report.foundry.length ? "bad" : "good"
);
setStatement(
"stmt-sun",
report.missing.some((cell) => cell.name === "Sun Dial")
? "FAIL"
: "PASS",
report.missing.some((cell) => cell.name === "Sun Dial")
? "bad"
: "good"
);
setStatement(
"stmt-signal",
report.missing.some((cell) => cell.name === "Signal")
? "FAIL"
: "PASS",
report.missing.some((cell) => cell.name === "Signal")
? "bad"
: "good"
);
setStatement(
"stmt-goal",
report.atGoal ? "PASS" : "FAIL",
report.atGoal ? "good" : "bad"
);
} else {
setStatement(
"stmt-avoid",
report.foundry.length ? "RED HIT" : "CLEAR",
report.foundry.length ? "bad" : ""
);
setStatement(
"stmt-sun",
report.missing.some((cell) => cell.name === "Sun Dial")
? "NOT YET"
: "VISITED",
report.missing.some((cell) => cell.name === "Sun Dial") ? "" : "good"
);
setStatement(
"stmt-signal",
report.missing.some((cell) => cell.name === "Signal")
? "NOT YET"
: "VISITED",
report.missing.some((cell) => cell.name === "Signal") ? "" : "good"
);
setStatement(
"stmt-goal",
report.atGoal ? "AT GOAL" : "NOT YET",
report.atGoal ? "good" : ""
);
}
}
function auditRow(label, ok, detail) {
return `
<div class="audit-row ${ok ? "good" : "bad"}">
<span class="audit-dot"></span>
<span>${label}</span>
<span class="audit-detail">${detail}</span>
</div>
`;
}
function renderResult() {
const report = inspectRoute();
const result = $("result");
const audit = `
<div class="audit">
${auditRow(
"Continuous path",
report.continuous,
report.continuous ? "connected" : "broken"
)}
${auditRow(
"Foundry avoided",
report.foundry.length === 0,
report.foundry.length
? `${report.foundry.length} touched`
: "0 / 8 touched"
)}
${auditRow(
"Required stops",
report.missing.length === 0,
`${2 - report.missing.length} / 2 visited`
)}
${auditRow(
"Moon Gate",
report.atGoal,
report.atGoal ? "J10" : "not reached"
)}
</div>
`;
if (!checked) {
result.className = "result";
result.innerHTML = `
<div class="result-kicker">LOGIC NOTE</div>
<div class="result-title">One avoided area is not a proof.</div>
<p>
A route can avoid every Foundry tile and still be wrong: it may skip
a required destination or stop before Moon Gate. Avoidance is one
necessary clause, not evidence that the whole path is valid.
</p>
${audit}
`;
return;
}
if (report.valid) {
result.className = "result success";
result.innerHTML = `
<div class="result-kicker">ROUTE VERIFIED</div>
<div class="result-title">Every statement is satisfied.</div>
<p>
The actual path is continuous, avoids all eight Foundry tiles, visits
E2 and I2, and ends at J10. Avoiding Foundry was necessary but not
sufficient; the remaining clauses were checked independently.
</p>
${audit}
`;
return;
}
const reasons = [];
if (!report.continuous) {
reasons.push("the path contains a non-adjacent jump");
}
if (report.walls.length) {
reasons.push(
`the path enters a wall at ${report.walls
.map((cell) => coordinate(cell.x, cell.z))
.join(", ")}`
);
}
if (report.foundry.length) {
reasons.push(
`the path touches the Foundry at ${report.foundry
.map((cell) => coordinate(cell.x, cell.z))
.join(", ")}`
);
}
if (report.missing.length) {
reasons.push(
`the path skips ${report.missing
.map((cell) => `${cell.name} (${coordinate(cell.x, cell.z)})`)
.join(" and ")}`
);
}
if (!report.atGoal) {
reasons.push("the route does not finish at Moon Gate (J10)");
}
const avoided = report.foundry.length === 0;
const explanation = avoided
? "The route avoided the Foundry, but that alone did not make it valid."
: "The route did not satisfy the Foundry avoidance condition; avoiding one area never guarantees the other statements.";
result.className = "result failure";
result.innerHTML = `
<div class="result-kicker">ROUTE NOT VERIFIED</div>
<div class="result-title">${explanation}</div>
<p>
Specifically, ${reasons.join("; ")}. This is why the complete actual
path must be checked rather than inferring success from one avoided
area.
</p>
${audit}
`;
}
function updateAll() {
rebuildRoute();
updateStatements();
renderResult();
const visitedSun = route.some((cell) => sameCell(cell, sunDial));
const visitedSignal = route.some((cell) => sameCell(cell, signal));
sunMaterial.emissiveIntensity = visitedSun ? 0.95 : 0.36;
signalMaterial.emissiveIntensity = visitedSignal ? 0.95 : 0.36;
$("route-length").textContent =
`${route.length - 1} step${route.length === 2 ? "" : "s"} · ${
checked ? (inspectRoute().valid ? "verified" : "failed") : "draft"
}`;
const trace =
route.length === 1
? "A1 — choose an adjacent tile"
: route.map((cell) => coordinate(cell.x, cell.z)).join(" → ");
$("route-trace").textContent = trace;
}
let toastTimer;
function toast(message) {
const element = $("toast");
element.textContent = message;
element.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => element.classList.remove("show"), 2400);
}
function resetRoute() {
route.splice(0, route.length, { ...start });
checked = false;
updateAll();
toast("Route reset to Start (A1).");
}
function undoRoute() {
if (route.length <= 1) {
toast("The route is already at Start.");
return;
}
route.pop();
checked = false;
updateAll();
}
function handleCellClick(cell) {
if (wallSet.has(cellKey(cell))) {
toast("That tile is a physical wall. Choose a different route.");
return;
}
const existingIndex = route.findIndex((routeCell) =>
sameCell(routeCell, cell)
);
if (existingIndex !== -1) {
route.splice(existingIndex + 1);
checked = false;
updateAll();
toast(`Route truncated to ${coordinate(cell.x, cell.z)}.`);
return;
}
const last = route[route.length - 1];
const dx = Math.abs(last.x - cell.x);
const dz = Math.abs(last.z - cell.z);
if (dx + dz !== 1) {
toast("Routes move one orthogonal tile at a time. Click an adjacent tile.");
return;
}
route.push({ ...cell });
checked = false;
updateAll();
if (forbiddenSet.has(cellKey(cell))) {
toast("Foundry tile added. This route will fail the avoidance statement.");
} else if (sameCell(cell, sunDial)) {
toast("Sun Dial reached.");
} else if (sameCell(cell, signal)) {
toast("Signal reached.");
} else if (sameCell(cell, goal)) {
toast("Moon Gate reached. Check the route to verify every statement.");
}
}
$("check-button").addEventListener("click", () => {
checked = true;
updateAll();
toast(
inspectRoute().valid
? "Route verified: every statement is satisfied."
: "Route checked. One or more statements still fail."
);
});
$("reset-button").addEventListener("click", resetRoute);
$("undo-button").addEventListener("click", undoRoute);
$("clear-button").addEventListener("click", resetRoute);
document.addEventListener("keydown", (event) => {
if (event.key === "Enter") {
event.preventDefault();
$("check-button").click();
} else if (event.key === "Backspace") {
event.preventDefault();
undoRoute();
} else if (event.key.toLowerCase() === "r") {
resetRoute();
}
});
// Custom camera controls: no addons or examples are imported.
let cameraTheta = 0.68;
let cameraPhi = 0.91;
let cameraRadius = 17.2;
const cameraTarget = new THREE.Vector3(0, 0.3, 0);
function updateCamera() {
cameraPhi = THREE.MathUtils.clamp(cameraPhi, 0.38, 1.35);
cameraRadius = THREE.MathUtils.clamp(cameraRadius, 10, 29);
camera.position.set(
cameraTarget.x +
cameraRadius * Math.sin(cameraPhi) * Math.sin(cameraTheta),
cameraTarget.y + cameraRadius * Math.cos(cameraPhi),
cameraTarget.z +
cameraRadius * Math.sin(cameraPhi) * Math.cos(cameraTheta)
);
camera.lookAt(cameraTarget);
}
function panCamera(dx, dy) {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3()
.crossVectors(forward, new THREE.Vector3(0, 1, 0))
.normalize();
const up = new THREE.Vector3()
.crossVectors(right, forward)
.normalize();
const scale = cameraRadius * 0.0015;
cameraTarget.addScaledVector(right, -dx * scale);
cameraTarget.addScaledVector(up, dy * scale);
cameraTarget.x = THREE.MathUtils.clamp(cameraTarget.x, -4.5, 4.5);
cameraTarget.z = THREE.MathUtils.clamp(cameraTarget.z, -4.5, 4.5);
cameraTarget.y = THREE.MathUtils.clamp(cameraTarget.y, -1, 3);
updateCamera();
}
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const pointers = new Map();
let gesture = null;
let dragged = false;
let lastPinchDistance = 0;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
function pickCell(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(interactiveMeshes, false)[0];
return hit ? hit.object.userData.cell : null;
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
dragged = false;
gesture = {
startX: event.clientX,
startY: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
button: event.button,
shift: event.shiftKey
};
} else {
gesture = null;
dragged = true;
lastPinchDistance = pointerDistance();
}
});
canvas.addEventListener("pointermove", (event) => {
if (pointers.has(event.pointerId)) {
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
}
if (pointers.size === 1 && gesture) {
const dx = event.clientX - gesture.lastX;
const dy = event.clientY - gesture.lastY;
if (
Math.hypot(
event.clientX - gesture.startX,
event.clientY - gesture.startY
) > 4
) {
dragged = true;
}
if (dragged) {
if (gesture.button === 2 || gesture.shift) {
panCamera(dx, dy);
} else {
cameraTheta -= dx * 0.006;
cameraPhi -= dy * 0.005;
updateCamera();
}
}
gesture.lastX = event.clientX;
gesture.lastY = event.clientY;
hoverOutline.visible = false;
return;
}
if (pointers.size === 2) {
const distance = pointerDistance();
if (lastPinchDistance > 0 && distance > 0) {
cameraRadius *= lastPinchDistance / distance;
updateCamera();
}
lastPinchDistance = distance;
return;
}
const cell = pickCell(event);
if (!cell) {
hoverOutline.visible = false;
hoverCell = null;
return;
}
hoverCell = cell;
hoverOutline.position.copy(position(cell.x, cell.z, 0.12));
hoverOutline.visible = true;
});
canvas.addEventListener("pointerup", (event) => {
const wasSinglePointer = pointers.size === 1;
const shouldClick = wasSinglePointer && !dragged && event.button === 0;
pointers.delete(event.pointerId);
if (shouldClick) {
const cell = pickCell(event);
if (cell) handleCellClick(cell);
}
if (pointers.size === 0) {
gesture = null;
dragged = false;
}
});
canvas.addEventListener("pointercancel", (event) => {
pointers.delete(event.pointerId);
gesture = null;
dragged = false;
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius *= Math.exp(event.deltaY * 0.001);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(1, height);
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
resize();
updateCamera();
updateAll();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
forbiddenMaterial.emissiveIntensity =
0.25 + Math.sin(elapsed * 2.2) * 0.08;
routeMaterial.emissiveIntensity =
checked ? 1.0 : 0.72 + Math.sin(elapsed * 2.8) * 0.12;
for (const beacon of beacons) {
beacon.userData.crystal.rotation.y = elapsed * 0.7;
beacon.userData.crystal.position.y =
1.08 + Math.sin(elapsed * 1.8 + beacon.position.x) * 0.035;
}
goalRing.rotation.z = elapsed * 0.45;
goalCrystal.rotation.y = elapsed * -0.65;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```