Prompt specification
Build or customize the Three.js 3D scene "Hidden Tile Beneath a Liftable Cover" 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: Hidden Tile Beneath a Liftable Cover
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/hidden-tile-beneath-a-liftable-cover-x3541
Scene Description Prompt:
A stylized hidden terrain tile and remembered-state card distinguish unknown information from empty space. Use Three.js from cdnjs in one HTML file.
Working Three.js Starter (hidden-tile-beneath-a-liftable-cover-x3541):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hollow — Remembered Terrain</title>
<style>
:root {
--bg: #07141b;
--panel: #0b1d24;
--panel-soft: #10262e;
--line: rgba(177, 218, 211, 0.14);
--text: #e8f2ea;
--muted: #8da8a7;
--mint: #a9e6bd;
--unknown: #254b59;
--empty: #d7e9df;
--gold: #e8c57a;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
.app {
display: grid;
grid-template-columns: minmax(0, 1fr) 370px;
width: 100%;
height: 100%;
}
.stage {
position: relative;
min-width: 0;
overflow: hidden;
background:
radial-gradient(circle at 47% 42%, rgba(49, 103, 106, 0.2), transparent 36%),
radial-gradient(circle at 20% 90%, rgba(109, 80, 45, 0.09), transparent 32%),
linear-gradient(145deg, #081820 0%, #071218 72%);
}
.stage::before {
content: "";
position: absolute;
inset: 0;
pointer-events: none;
opacity: 0.18;
background-image:
linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
background-size: 42px 42px;
mask-image: linear-gradient(to bottom, transparent, black 35%, black);
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.topbar {
position: absolute;
z-index: 3;
top: 26px;
left: 30px;
right: 30px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
color: var(--mint);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.brand-mark {
position: relative;
width: 29px;
height: 29px;
border: 1px solid rgba(169, 230, 189, 0.65);
transform: rotate(45deg);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
inset: 6px;
border: 1px solid rgba(169, 230, 189, 0.5);
}
.brand-mark::after {
inset: 11px;
background: var(--mint);
border: 0;
}
.edition {
color: var(--muted);
font-size: 10px;
line-height: 1.5;
letter-spacing: 0.12em;
text-align: right;
text-transform: uppercase;
}
.scene-title {
position: absolute;
z-index: 3;
left: 30px;
bottom: 86px;
width: min(360px, calc(100% - 60px));
pointer-events: none;
}
.eyebrow {
margin-bottom: 9px;
color: var(--mint);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(36px, 5vw, 64px);
font-weight: 400;
line-height: 0.94;
letter-spacing: -0.045em;
}
.scene-title p {
max-width: 330px;
margin: 16px 0 0;
color: #9eb3b0;
font-size: 13px;
line-height: 1.65;
}
.scene-legend {
position: absolute;
z-index: 3;
left: 30px;
bottom: 27px;
display: flex;
flex-wrap: wrap;
gap: 9px;
pointer-events: none;
}
.legend-chip {
display: flex;
align-items: center;
gap: 8px;
min-height: 31px;
padding: 0 11px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(8, 22, 28, 0.72);
backdrop-filter: blur(10px);
color: #b9cac5;
font-size: 10px;
letter-spacing: 0.04em;
}
.legend-swatch {
width: 12px;
height: 12px;
border-radius: 2px;
}
.legend-swatch.unknown {
border: 1px solid #416775;
background:
repeating-linear-gradient(135deg, #244a58 0 3px, #1b3d49 3px 6px);
}
.legend-swatch.empty {
border: 1px dashed #c6ddd3;
background: transparent;
}
.legend-swatch.known {
background: #83b98e;
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.view-note {
position: absolute;
z-index: 3;
right: 24px;
bottom: 28px;
color: rgba(190, 211, 206, 0.55);
font-size: 10px;
letter-spacing: 0.08em;
pointer-events: none;
}
.side {
position: relative;
z-index: 5;
overflow-y: auto;
padding: 27px 25px 24px;
border-left: 1px solid var(--line);
background:
linear-gradient(180deg, rgba(14, 34, 41, 0.98), rgba(8, 24, 31, 0.98));
box-shadow: -22px 0 60px rgba(0, 0, 0, 0.18);
}
.side::-webkit-scrollbar {
width: 5px;
}
.side::-webkit-scrollbar-thumb {
border-radius: 8px;
background: rgba(169, 230, 189, 0.2);
}
.panel-kicker {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
color: var(--mint);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.panel-kicker span:last-child {
color: var(--muted);
font-weight: 600;
}
h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 29px;
font-weight: 400;
letter-spacing: -0.025em;
}
.intro {
margin: 10px 0 20px;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
}
.card {
overflow: hidden;
margin-bottom: 15px;
border: 1px solid var(--line);
border-radius: 15px;
background: rgba(16, 39, 46, 0.7);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 15px;
border-bottom: 1px solid var(--line);
}
.card-title {
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.tiny-badge {
padding: 4px 7px;
border: 1px solid rgba(169, 230, 189, 0.2);
border-radius: 999px;
background: rgba(169, 230, 189, 0.07);
color: var(--mint);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.memory-body {
padding: 15px;
}
.memory-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 7px;
padding: 9px;
border: 1px solid rgba(177, 218, 211, 0.1);
border-radius: 10px;
background: rgba(2, 12, 17, 0.38);
}
.memory-cell {
position: relative;
aspect-ratio: 1;
overflow: hidden;
padding: 0;
border-radius: 5px;
cursor: pointer;
transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.memory-cell:hover {
z-index: 2;
transform: translateY(-2px) scale(1.05);
border-color: rgba(255, 255, 255, 0.55);
box-shadow: 0 5px 13px rgba(0, 0, 0, 0.28);
}
.memory-cell:focus-visible {
outline: 2px solid var(--mint);
outline-offset: 2px;
}
.memory-cell.unknown {
border: 1px solid #416775;
background:
repeating-linear-gradient(135deg, #254b59 0 4px, #1b3d49 4px 8px);
}
.memory-cell.unknown::after {
content: "";
position: absolute;
inset: 34%;
border: 1px solid rgba(171, 216, 221, 0.5);
border-radius: 50%;
}
.memory-cell.empty {
border: 1px dashed rgba(215, 233, 223, 0.72);
background:
linear-gradient(135deg, transparent 47%, rgba(215, 233, 223, 0.18) 48% 52%, transparent 53%),
linear-gradient(45deg, transparent 47%, rgba(215, 233, 223, 0.18) 48% 52%, transparent 53%);
}
.memory-cell.known {
border: 1px solid rgba(255, 255, 255, 0.2);
background:
radial-gradient(circle at 62% 38%, rgba(255, 255, 255, 0.2), transparent 28%),
var(--cell-color, #6fa67b);
box-shadow: inset 0 -8px 12px rgba(0, 0, 0, 0.16);
}
.memory-cell.known::before {
content: "";
position: absolute;
width: 65%;
height: 45%;
left: 17%;
top: 24%;
border: 1px solid rgba(255, 255, 255, 0.23);
border-radius: 50%;
transform: rotate(-12deg);
}
.memory-cell.selected {
outline: 2px solid var(--gold);
outline-offset: 1px;
}
.memory-meta {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin-top: 13px;
}
.meta-box {
padding: 9px 8px;
border-radius: 8px;
background: rgba(2, 12, 17, 0.28);
}
.meta-value {
display: block;
margin-bottom: 3px;
font-size: 15px;
font-weight: 750;
}
.meta-label {
color: var(--muted);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.state-key {
display: grid;
gap: 10px;
padding: 0 15px 15px;
}
.key-row {
display: grid;
grid-template-columns: 27px 1fr auto;
align-items: center;
gap: 10px;
}
.key-icon {
width: 24px;
height: 24px;
border-radius: 5px;
}
.key-icon.unknown {
border: 1px solid #416775;
background: repeating-linear-gradient(135deg, #254b59 0 4px, #1b3d49 4px 8px);
}
.key-icon.empty {
border: 1px dashed #c6ddd3;
}
.key-icon.known {
background: #83b98e;
box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.13);
}
.key-name {
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.key-description {
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.key-count {
color: #91aaa7;
font-size: 10px;
font-variant-numeric: tabular-nums;
}
.cell-detail {
padding: 15px;
}
.detail-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
margin-bottom: 12px;
}
.coordinate {
color: var(--gold);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
}
.detail-state {
margin-top: 5px;
font-size: 14px;
font-weight: 750;
}
.detail-description {
min-height: 37px;
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
.detail-rule {
height: 1px;
margin: 13px 0;
background: var(--line);
}
.progress-label {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.progress-track {
height: 5px;
overflow: hidden;
border-radius: 99px;
background: rgba(255, 255, 255, 0.06);
}
.progress-fill {
width: 60%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #5f9f78, var(--mint));
transition: width 250ms ease;
}
.actions {
display: grid;
grid-template-columns: 1fr auto;
gap: 8px;
margin-top: 15px;
}
.action {
min-height: 38px;
padding: 0 14px;
border: 1px solid rgba(169, 230, 189, 0.24);
border-radius: 9px;
background: rgba(169, 230, 189, 0.08);
color: var(--mint);
cursor: pointer;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
transition: background 150ms ease, transform 150ms ease;
}
.action:hover {
background: rgba(169, 230, 189, 0.15);
transform: translateY(-1px);
}
.action.secondary {
width: 38px;
padding: 0;
border-color: var(--line);
background: rgba(255, 255, 255, 0.03);
color: var(--muted);
font-size: 16px;
}
.activity {
padding: 15px;
}
.activity-row {
display: grid;
grid-template-columns: 42px 1fr;
gap: 10px;
padding: 8px 0;
border-bottom: 1px solid rgba(177, 218, 211, 0.07);
color: var(--muted);
font-size: 9px;
line-height: 1.45;
}
.activity-row:last-child {
border-bottom: 0;
}
.activity-time {
color: #647f7e;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.panel-footer {
margin-top: 15px;
color: #607b7a;
font-size: 9px;
line-height: 1.55;
text-align: center;
}
@media (max-width: 900px) {
html,
body {
height: auto;
overflow: auto;
}
.app {
grid-template-columns: 1fr;
height: auto;
min-height: 100%;
}
.stage {
height: 68vh;
min-height: 520px;
}
.side {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.scene-title {
bottom: 80px;
}
.view-note {
display: none;
}
}
@media (max-width: 540px) {
.topbar {
top: 20px;
left: 20px;
right: 20px;
}
.edition {
display: none;
}
.scene-title {
left: 20px;
bottom: 78px;
width: calc(100% - 40px);
}
.scene-title p {
max-width: 285px;
}
.scene-legend {
left: 20px;
bottom: 22px;
}
.legend-chip {
font-size: 9px;
}
.side {
padding: 24px 18px;
}
}
</style>
</head>
<body>
<main class="app">
<section class="stage" aria-label="Interactive hidden terrain">
<div class="topbar">
<div class="brand">
<span class="brand-mark" aria-hidden="true"></span>
Hollow Field Office
</div>
<div class="edition">
Survey 07<br />
Northern shelf / Sector A-14
</div>
</div>
<div class="scene-title">
<div class="eyebrow">A cartography of remembered things</div>
<h1>Nothing here<br />is quite empty.</h1>
<p>
Solid slate marks terrain still unknown. A dashed outline records
confirmed emptiness. The field beneath remains hidden until remembered.
</p>
</div>
<div class="scene-legend">
<div class="legend-chip">
<span class="legend-swatch unknown"></span>
Unknown
</div>
<div class="legend-chip">
<span class="legend-swatch empty"></span>
Confirmed empty
</div>
<div class="legend-chip">
<span class="legend-swatch known"></span>
Remembered terrain
</div>
</div>
<div class="view-note">DRAG TO ORBIT · SCROLL TO ZOOM · CLICK TO REMEMBER</div>
</section>
<aside class="side">
<div class="panel-kicker">
<span>Cartographer’s desk</span>
<span>Field memory</span>
</div>
<h2>Remembered state</h2>
<p class="intro">
A cached impression of the terrain. Unknown cells are not blank—they
are simply waiting to be discovered.
</p>
<section class="card">
<div class="card-head">
<div class="card-title">Terrain index</div>
<div class="tiny-badge">Cached</div>
</div>
<div class="memory-body">
<div id="memoryGrid" class="memory-grid" aria-label="Remembered terrain grid"></div>
<div class="memory-meta">
<div class="meta-box">
<span id="knownCount" class="meta-value">0</span>
<span class="meta-label">Terrain</span>
</div>
<div class="meta-box">
<span id="emptyCount" class="meta-value">0</span>
<span class="meta-label">Empty</span>
</div>
<div class="meta-box">
<span id="unknownCount" class="meta-value">0</span>
<span class="meta-label">Unknown</span>
</div>
</div>
</div>
<div class="state-key">
<div class="key-row">
<span class="key-icon unknown"></span>
<div>
<div class="key-name">Unknown</div>
<div class="key-description">Information has not yet been recorded.</div>
</div>
<span id="keyUnknownCount" class="key-count">0</span>
</div>
<div class="key-row">
<span class="key-icon empty"></span>
<div>
<div class="key-name">Empty</div>
<div class="key-description">A confirmed absence of terrain.</div>
</div>
<span id="keyEmptyCount" class="key-count">0</span>
</div>
<div class="key-row">
<span class="key-icon known"></span>
<div>
<div class="key-name">Remembered</div>
<div class="key-description">Cached shape, color, and elevation.</div>
</div>
<span id="keyKnownCount" class="key-count">0</span>
</div>
</div>
</section>
<section class="card">
<div class="card-head">
<div class="card-title">Selected impression</div>
<div class="tiny-badge" id="selectedBadge">Unknown</div>
</div>
<div class="cell-detail">
<div class="detail-heading">
<div>
<div class="coordinate" id="selectedCoordinate">C3 / 03</div>
<div class="detail-state" id="selectedState">Unmapped terrain</div>
</div>
</div>
<div class="detail-description" id="selectedDescription">
No reliable impression exists for this location.
</div>
<div class="detail-rule"></div>
<div class="progress-label">
<span>Survey coverage</span>
<span id="coverageValue">15 / 25</span>
</div>
<div class="progress-track">
<div id="progressFill" class="progress-fill"></div>
</div>
<div class="actions">
<button class="action" id="cycleButton" type="button">Cycle state</button>
<button class="action secondary" id="resetButton" type="button" title="Reset all terrain">
↺
</button>
</div>
</div>
</section>
<section class="card">
<div class="card-head">
<div class="card-title">Recent impressions</div>
<div class="tiny-badge">Log</div>
</div>
<div id="activityLog" class="activity"></div>
</section>
<div class="panel-footer">
Left click cycles unknown → terrain → empty.<br />
Right click reverses the order.
</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 GRID_SIZE = 5;
const CELL_COUNT = GRID_SIZE * GRID_SIZE;
const CELL_SIZE = 1.38;
const CELL_SPACING = 1.55;
const stage = document.querySelector(".stage");
const memoryGrid = document.querySelector("#memoryGrid");
const activityLog = document.querySelector("#activityLog");
const stateNames = {
unknown: "Unknown",
known: "Terrain",
empty: "Empty"
};
const stateDescriptions = {
unknown: "No reliable impression exists for this location.",
known: "The cached survey remembers this location as raised terrain.",
empty: "The survey confirms that this location contains no terrain."
};
const terrainHeights = [
0.55, 0.75, 0.95, 0.65, 0.40,
0.85, 1.30, 1.75, 1.10, 0.60,
1.05, 1.65, 2.45, 1.50, 0.80,
0.70, 1.25, 1.85, 1.20, 0.50,
0.40, 0.85, 1.10, 0.75, 0.35
];
const cellColors = [
"#638b68", "#7f9f6d", "#9ca875", "#788f67", "#678b78",
"#6f956c", "#829d6b", "#a4a46d", "#7d966b", "#668a72",
"#75976b", "#8a9f68", "#b3a36b", "#879865", "#6d8d70",
"#698d70", "#7e9b6d", "#9e9f6b", "#82976d", "#638672",
"#648372", "#759277", "#86976f", "#738b72", "#5e7f73"
];
const states = new Array(CELL_COUNT).fill("unknown");
const initialKnown = new Set([0, 1, 5, 6, 10, 15, 20]);
const initialEmpty = new Set([2, 3, 4, 12, 13, 14, 22, 24]);
initialKnown.forEach(index => states[index] = "known");
initialEmpty.forEach(index => states[index] = "empty");
let selectedIndex = 8;
let hoveredIndex = -1;
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x07141b, 0.021);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x000000, 0);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.domElement.setAttribute("aria-label", "Orbitable hidden terrain tile");
renderer.domElement.tabIndex = 0;
stage.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-7, 7, 7, -7, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.65, 0);
let azimuth = -0.64;
let elevation = 0.91;
let orthoSize = 10.7;
function updateCamera() {
const aspect = stage.clientWidth / Math.max(stage.clientHeight, 1);
camera.left = -orthoSize * aspect / 2;
camera.right = orthoSize * aspect / 2;
camera.top = orthoSize / 2;
camera.bottom = -orthoSize / 2;
camera.updateProjectionMatrix();
const radius = 16;
const horizontal = Math.cos(elevation) * radius;
camera.position.set(
cameraTarget.x + Math.sin(azimuth) * horizontal,
cameraTarget.y + Math.sin(elevation) * radius,
cameraTarget.z + Math.cos(azimuth) * horizontal
);
camera.lookAt(cameraTarget);
}
function resize() {
renderer.setSize(stage.clientWidth, stage.clientHeight);
updateCamera();
}
window.addEventListener("resize", resize);
const hemisphere = new THREE.HemisphereLight(0xbfe4df, 0x17251f, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffe8bb, 3.2);
keyLight.position.set(-5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x6cc5c8, 1.45);
rimLight.position.set(7, 4, -6);
scene.add(rimLight);
const world = new THREE.Group();
world.rotation.y = -0.08;
scene.add(world);
const platformWidth = GRID_SIZE * CELL_SPACING + 0.52;
const platform = new THREE.Mesh(
new THREE.BoxGeometry(platformWidth, 0.46, platformWidth),
new THREE.MeshStandardMaterial({
color: 0x182c2c,
roughness: 0.92,
metalness: 0.03
})
);
platform.position.y = -0.26;
platform.receiveShadow = true;
world.add(platform);
const platformTop = new THREE.Mesh(
new THREE.BoxGeometry(platformWidth - 0.08, 0.08, platformWidth - 0.08),
new THREE.MeshStandardMaterial({
color: 0x233a36,
roughness: 1
})
);
platformTop.position.y = -0.01;
platformTop.receiveShadow = true;
world.add(platformTop);
const grid = new THREE.GridHelper(platformWidth - 0.1, GRID_SIZE, 0x7caaa0, 0x54746e);
grid.position.y = 0.045;
grid.material.transparent = true;
grid.material.opacity = 0.16;
world.add(grid);
const platformEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(platform.geometry),
new THREE.LineBasicMaterial({
color: 0x719a8f,
transparent: true,
opacity: 0.26
})
);
platformEdges.position.copy(platform.position);
world.add(platformEdges);
const shadow = new THREE.Mesh(
new THREE.CircleGeometry(6.2, 64),
new THREE.MeshBasicMaterial({
color: 0x000000,
transparent: true,
opacity: 0.27,
depthWrite: false
})
);
shadow.rotation.x = -Math.PI / 2;
shadow.position.y = -0.52;
shadow.scale.set(1, 0.72, 1);
world.add(shadow);
function makeUnknownTexture() {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#214653";
ctx.fillRect(0, 0, 128, 128);
ctx.strokeStyle = "rgba(145, 196, 201, 0.12)";
ctx.lineWidth = 2;
for (let x = -128; x < 256; x += 18) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x + 128, 128);
ctx.stroke();
}
ctx.strokeStyle = "rgba(172, 218, 218, 0.43)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(64, 64, 16, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(64, 39);
ctx.lineTo(64, 89);
ctx.stroke();
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(renderer.capabilities.getMaxAnisotropy(), 8);
return texture;
}
const unknownTexture = makeUnknownTexture();
const cells = [];
const foliageMeshes = [];
function hash(index) {
const value = Math.sin(index * 127.1 + 311.7) * 43758.5453;
return value - Math.floor(value);
}
function makeTree(scale = 1) {
const tree = new THREE.Group();
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.085, 0.42, 7),
new THREE.MeshStandardMaterial({ color: 0x5c4935, roughness: 1 })
);
trunk.position.y = 0.21;
trunk.castShadow = true;
tree.add(trunk);
const crown = new THREE.Mesh(
new THREE.ConeGeometry(0.30, 0.78, 7),
new THREE.MeshStandardMaterial({
color: 0x315b48,
roughness: 0.95,
flatShading: true
})
);
crown.position.y = 0.72;
crown.castShadow = true;
tree.add(crown);
const crownTop = new THREE.Mesh(
new THREE.ConeGeometry(0.21, 0.55, 7),
new THREE.MeshStandardMaterial({
color: 0x47735a,
roughness: 0.95,
flatShading: true
})
);
crownTop.position.y = 1.03;
crownTop.castShadow = true;
tree.add(crownTop);
tree.scale.setScalar(scale);
foliageMeshes.push(crown, crownTop);
return tree;
}
function makeRock(scale = 1) {
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.22, 0),
new THREE.MeshStandardMaterial({
color: 0x78847a,
roughness: 1,
flatShading: true
})
);
rock.scale.set(scale, scale * 0.72, scale * 0.8);
rock.rotation.set(0.2, hash(scale * 10) * Math.PI, 0.15);
rock.castShadow = true;
return rock;
}
function makeEmptyMarker() {
const marker = new THREE.Group();
const half = CELL_SIZE * 0.43;
const points = [
new THREE.Vector3(-half, 0, -half),
new THREE.Vector3(half, 0, -half),
new THREE.Vector3(half, 0, half),
new THREE.Vector3(-half, 0, half),
new THREE.Vector3(-half, 0, -half)
];
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineDashedMaterial({
color: 0xc9e3d9,
dashSize: 0.12,
gapSize: 0.09,
transparent: true,
opacity: 0.72
})
);
line.computeLineDistances();
marker.add(line);
const dot = new THREE.Mesh(
new THREE.RingGeometry(0.035, 0.065, 16),
new THREE.MeshBasicMaterial({
color: 0xd8e9df,
transparent: true,
opacity: 0.58,
side: THREE.DoubleSide
})
);
dot.rotation.x = -Math.PI / 2;
dot.position.y = 0.012;
marker.add(dot);
return marker;
}
for (let row = 0; row < GRID_SIZE; row++) {
for (let col = 0; col < GRID_SIZE; col++) {
const index = row * GRID_SIZE + col;
const height = terrainHeights[index];
const x = (col - (GRID_SIZE - 1) / 2) * CELL_SPACING;
const z = (row - (GRID_SIZE - 1) / 2) * CELL_SPACING;
const cellGroup = new THREE.Group();
cellGroup.position.set(x, 0, z);
world.add(cellGroup);
const terrainGroup = new THREE.Group();
cellGroup.add(terrainGroup);
const bodyGeometry = new THREE.BoxGeometry(CELL_SIZE, height, CELL_SIZE);
const bodyMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(cellColors[index]).multiplyScalar(0.52),
roughness: 0.98
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = height / 2;
body.castShadow = true;
body.receiveShadow = true;
terrainGroup.add(body);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(bodyGeometry),
new THREE.LineBasicMaterial({
color: 0xb9d0b7,
transparent: true,
opacity: 0.17
})
);
edges.position.y = height / 2;
terrainGroup.add(edges);
const topMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(cellColors[index]),
roughness: height < 0.65 ? 0.55 : 0.95
});
const top = new THREE.Mesh(
new THREE.PlaneGeometry(CELL_SIZE - 0.025, CELL_SIZE - 0.025),
topMaterial
);
top.rotation.x = -Math.PI / 2;
top.position.y = height + 0.012;
top.receiveShadow = true;
terrainGroup.add(top);
if (height < 0.6) {
const water = new THREE.Mesh(
new THREE.PlaneGeometry(CELL_SIZE * 0.78, CELL_SIZE * 0.78),
new THREE.MeshStandardMaterial({
color: 0x4e8990,
transparent: true,
opacity: 0.78,
roughness: 0.28,
metalness: 0.06
})
);
water.rotation.x = -Math.PI / 2;
water.position.y = height + 0.025;
terrainGroup.add(water);
}
if (hash(index + 10) > 0.45 && height > 0.7) {
const tree = makeTree(0.72 + hash(index + 50) * 0.32);
tree.position.set(
(hash(index + 11) - 0.5) * 0.36,
height + 0.02,
(hash(index + 21) - 0.5) * 0.36
);
terrainGroup.add(tree);
} else if (hash(index + 31) > 0.72) {
const rock = makeRock(0.7 + hash(index) * 0.5);
rock.position.set(
(hash(index + 12) - 0.5) * 0.35,
height + 0.08,
(hash(index + 22) - 0.5) * 0.35
);
terrainGroup.add(rock);
}
const fogMaterial = new THREE.MeshStandardMaterial({
color: 0x214653,
roughness: 0.9,
metalness: 0.03,
emissive: 0x000000
});
const fog = new THREE.Mesh(
new THREE.BoxGeometry(CELL_SIZE * 0.97, 1.35, CELL_SIZE * 0.97),
fogMaterial
);
fog.position.y = 0.69;
fog.castShadow = true;
fog.receiveShadow = true;
cellGroup.add(fog);
const fogTop = new THREE.Mesh(
new THREE.PlaneGeometry(CELL_SIZE * 0.94, CELL_SIZE * 0.94),
new THREE.MeshBasicMaterial({
map: unknownTexture,
transparent: true,
opacity: 0.95
})
);
fogTop.rotation.x = -Math.PI / 2;
fogTop.position.y = 1.372;
cellGroup.add(fogTop);
const emptyMarker = makeEmptyMarker();
emptyMarker.position.y = 0.055;
cellGroup.add(emptyMarker);
const hitbox = new THREE.Mesh(
new THREE.BoxGeometry(CELL_SIZE, 3.1, CELL_SIZE),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
})
);
hitbox.position.y = 1.45;
hitbox.userData.cellIndex = index;
cellGroup.add(hitbox);
cells.push({
terrainGroup,
fog,
fogTop,
fogMaterial,
emptyMarker,
hitbox,
x,
z,
height
});
}
}
const dustGeometry = new THREE.BufferGeometry();
const dustPositions = new Float32Array(95 * 3);
for (let i = 0; i < 95; i++) {
const radius = 4.8 + hash(i + 100) * 5;
const angle = hash(i + 200) * Math.PI * 2;
dustPositions[i * 3] = Math.cos(angle) * radius;
dustPositions[i * 3 + 1] = 0.4 + hash(i + 300) * 5.5;
dustPositions[i * 3 + 2] = Math.sin(angle) * radius;
}
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xaad7cc,
size: 0.035,
transparent: true,
opacity: 0.42,
depthWrite: false
})
);
scene.add(dust);
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function getCellFromPointer(event) {
const rect = renderer.domElement.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 hits = raycaster.intersectObjects(cells.map(cell => cell.hitbox), false);
return hits.length ? hits[0].object.userData.cellIndex : -1;
}
function setHovered(index) {
if (hoveredIndex === index) return;
if (hoveredIndex >= 0) {
cells[hoveredIndex].fogMaterial.emissive.setHex(0x000000);
cells[hoveredIndex].fogMaterial.emissiveIntensity = 1;
}
hoveredIndex = index;
if (hoveredIndex >= 0) {
const cell = cells[hoveredIndex];
if (states[hoveredIndex] === "unknown") {
cell.fogMaterial.emissive.setHex(0x234c52);
cell.fogMaterial.emissiveIntensity = 0.48;
}
renderer.domElement.style.cursor = "pointer";
} else {
renderer.domElement.style.cursor = "grab";
}
}
function cycleState(index, direction = 1) {
const order = ["unknown", "known", "empty"];
const current = order.indexOf(states[index]);
const next = (current + direction + order.length) % order.length;
states[index] = order[next];
selectedIndex = index;
updateCellVisual(index);
updateMemoryCard();
addActivity(index);
}
function updateCellVisual(index) {
const cell = cells[index];
const state = states[index];
cell.terrainGroup.visible = state === "known";
cell.fog.visible = state === "unknown";
cell.fogTop.visible = state === "unknown";
cell.emptyMarker.visible = state === "empty";
}
cells.forEach((_, index) => updateCellVisual(index));
function coordinateLabel(index) {
const row = Math.floor(index / GRID_SIZE);
const col = index % GRID_SIZE;
return `${String.fromCharCode(65 + col)}${row + 1} / ${String(index + 1).padStart(2, "0")}`;
}
function updateMemoryCard() {
memoryGrid.innerHTML = "";
const counts = { unknown: 0, known: 0, empty: 0 };
states.forEach((state, index) => {
counts[state]++;
const button = document.createElement("button");
button.type = "button";
button.className = `memory-cell ${state}`;
if (index === selectedIndex) button.classList.add("selected");
if (state === "known") {
button.style.setProperty("--cell-color", cellColors[index]);
}
button.setAttribute(
"aria-label",
`${coordinateLabel(index)}: ${stateNames[state]}. Click to cycle.`
);
button.title = `${coordinateLabel(index)} — ${stateNames[state]}`;
button.addEventListener("click", event => {
event.stopPropagation();
cycleState(index, 1);
});
memoryGrid.appendChild(button);
});
document.querySelector("#knownCount").textContent = counts.known;
document.querySelector("#emptyCount").textContent = counts.empty;
document.querySelector("#unknownCount").textContent = counts.unknown;
document.querySelector("#keyKnownCount").textContent = counts.known;
document.querySelector("#keyEmptyCount").textContent = counts.empty;
document.querySelector("#keyUnknownCount").textContent = counts.unknown;
const covered = counts.known + counts.empty;
document.querySelector("#coverageValue").textContent = `${covered} / ${CELL_COUNT}`;
document.querySelector("#progressFill").style.width = `${covered / CELL_COUNT * 100}%`;
const state = states[selectedIndex];
document.querySelector("#selectedBadge").textContent = stateNames[state];
document.querySelector("#selectedCoordinate").textContent = coordinateLabel(selectedIndex);
document.querySelector("#selectedState").textContent =
state === "unknown" ? "Unmapped terrain" :
state === "known" ? "Remembered elevation" :
"Confirmed absence";
document.querySelector("#selectedDescription").textContent =
stateDescriptions[state] +
(state === "known"
? ` Cached elevation: ${cells[selectedIndex].height.toFixed(2)} units.`
: "");
}
const activityEntries = [];
function addActivity(index) {
const now = new Date();
const time = now.toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
hour12: false
});
const state = states[index];
const verb =
state === "known" ? "terrain recalled" :
state === "empty" ? "absence confirmed" :
"impression cleared";
activityEntries.unshift({ time, text: `${coordinateLabel(index)} — ${verb}` });
activityEntries.splice(3);
activityLog.innerHTML = activityEntries.map(entry => `
<div class="activity-row">
<span class="activity-time">${entry.time}</span>
<span>${entry.text}</span>
</div>
`).join("");
}
activityEntries.push(
{ time: "08:42", text: "C3 — survey veil restored" },
{ time: "08:39", text: "D2 — absence confirmed" },
{ time: "08:31", text: "B2 — terrain recalled" }
);
addActivity = (function wrapOriginalAddActivity(original) {
return function(index) {
original(index);
};
})(addActivity);
document.querySelector("#activityLog").innerHTML = activityEntries.map(entry => `
<div class="activity-row">
<span class="activity-time">${entry.time}</span>
<span>${entry.text}</span>
</div>
`).join("");
let pointerDown = false;
let pointerButton = 0;
let pointerMoved = false;
let lastX = 0;
let lastY = 0;
let startX = 0;
let startY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
pointerDown = true;
pointerMoved = false;
pointerButton = event.button;
lastX = startX = event.clientX;
lastY = startY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", event => {
if (pointerDown) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (
Math.hypot(event.clientX - startX, event.clientY - startY) > 5 &&
pointerButton === 0
) {
pointerMoved = true;
azimuth -= dx * 0.006;
elevation = THREE.MathUtils.clamp(elevation + dy * 0.0045, 0.42, 1.34);
updateCamera();
}
lastX = event.clientX;
lastY = event.clientY;
} else {
setHovered(getCellFromPointer(event));
}
});
renderer.domElement.addEventListener("pointerup", event => {
if (pointerDown && !pointerMoved) {
const index = getCellFromPointer(event);
if (index >= 0) {
cycleState(index, event.button === 2 ? -1 : 1);
}
}
pointerDown = false;
renderer.domElement.style.cursor = hoveredIndex >= 0 ? "pointer" : "grab";
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = false;
pointerMoved = false;
});
renderer.domElement.addEventListener("pointerleave", () => {
if (!pointerDown) setHovered(-1);
});
renderer.domElement.addEventListener("contextmenu", event => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
orthoSize = THREE.MathUtils.clamp(
orthoSize + event.deltaY * 0.008,
7.6,
14
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
azimuth = -0.64;
elevation = 0.91;
orthoSize = 10.7;
updateCamera();
});
document.querySelector("#cycleButton").addEventListener("click", () => {
cycleState(selectedIndex, 1);
});
document.querySelector("#resetButton").addEventListener("click", () => {
states.fill("unknown");
cells.forEach((_, index) => updateCellVisual(index));
selectedIndex = 8;
updateMemoryCard();
activityEntries.unshift({
time: new Date().toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
hour12: false
}),
text: "Survey veil — full tile restored"
});
activityEntries.splice(3);
activityLog.innerHTML = activityEntries.map(entry => `
<div class="activity-row">
<span class="activity-time">${entry.time}</span>
<span>${entry.text}</span>
</div>
`).join("");
});
updateMemoryCard();
resize();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
dust.rotation.y = elapsed * 0.015;
dust.position.y = Math.sin(elapsed * 0.18) * 0.08;
foliageMeshes.forEach((mesh, index) => {
mesh.rotation.z = Math.sin(elapsed * 0.65 + index * 0.8) * 0.018;
});
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```