Prompt specification
Build or customize the Three.js 3D scene "Ancient production settlement near resource routes" 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: Ancient production settlement near resource routes
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/ancient-production-settlement-near-resource-routes-x2283
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: Ancient production settlement near resource routes. Build a modest Meroe-inspired production area with fuel storage, work shelters, and paths to settlement. Show material movement and identify reconstructed elements separately from evidence. Return one self-contained HTML file.
Working Three.js Starter (ancient-production-settlement-near-resource-routes-x2283):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Production Settlement — Interpretive Three.js Model</title>
<style>
:root {
--ink: #25332f;
--muted: #65736d;
--paper: rgba(249, 245, 233, 0.91);
--line: rgba(52, 68, 61, 0.17);
--evidence: #87968e;
--reconstruction: #c76f3e;
--flow: #168f89;
--gold: #d9a441;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cdbb9c;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.62);
box-shadow: 0 12px 35px rgba(59, 47, 32, 0.14);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.title-panel {
top: 20px;
left: 20px;
width: min(390px, calc(100vw - 40px));
padding: 20px 21px 17px;
border-radius: 18px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
color: #68766f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--reconstruction);
box-shadow: 0 0 0 4px rgba(199, 111, 62, 0.13);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(29px, 3vw, 42px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 11px 0 15px;
max-width: 340px;
color: #5f6d67;
font-size: 13px;
line-height: 1.55;
}
.sequence {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 5px;
padding: 10px 11px;
border: 1px solid rgba(22, 143, 137, 0.15);
border-radius: 10px;
background: rgba(22, 143, 137, 0.06);
color: #376b67;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.03em;
}
.sequence span {
padding: 4px 7px;
border-radius: 5px;
background: rgba(255, 255, 255, 0.64);
}
.sequence i {
color: var(--flow);
font-style: normal;
}
.title-actions {
display: flex;
gap: 7px;
margin-top: 12px;
}
button {
border: 0;
font: inherit;
cursor: pointer;
}
.action-button,
.icon-button {
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.7);
color: var(--ink);
font-size: 11px;
font-weight: 750;
transition: background 150ms ease, transform 150ms ease, border-color 150ms ease;
}
.action-button {
padding: 9px 12px;
}
.icon-button {
width: 34px;
height: 34px;
font-size: 18px;
line-height: 1;
}
.action-button:hover,
.icon-button:hover {
border-color: rgba(37, 51, 47, 0.28);
background: white;
transform: translateY(-1px);
}
.action-button.primary {
border-color: rgba(22, 143, 137, 0.2);
background: rgba(22, 143, 137, 0.1);
color: #176e69;
}
.layer-panel {
top: 20px;
right: 20px;
width: 284px;
padding: 16px;
border-radius: 16px;
}
.panel-heading {
margin: 0 0 11px;
color: #65736d;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.layer-list {
display: grid;
gap: 7px;
}
.layer-toggle {
display: grid;
grid-template-columns: 12px 1fr auto;
align-items: center;
gap: 10px;
width: 100%;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.52);
color: var(--ink);
text-align: left;
transition: opacity 150ms ease, background 150ms ease;
}
.layer-toggle:hover { background: rgba(255,255,255,0.88); }
.layer-toggle[aria-pressed="false"] { opacity: 0.47; }
.layer-toggle .check {
width: 11px;
height: 11px;
border-radius: 3px;
background: var(--swatch);
box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.layer-toggle strong {
display: block;
font-size: 12px;
line-height: 1.2;
}
.layer-toggle small {
display: block;
margin-top: 2px;
color: #77827d;
font-size: 9px;
}
.layer-toggle .state {
color: #77827d;
font-size: 9px;
font-weight: 800;
text-transform: uppercase;
}
.note {
margin: 12px 1px 0;
padding-top: 12px;
border-top: 1px solid var(--line);
color: #66736e;
font-size: 10px;
line-height: 1.5;
}
.note strong { color: #3f4d47; }
#selectionPanel {
margin-top: 12px;
padding: 12px;
border: 1px solid rgba(217, 164, 65, 0.38);
border-radius: 11px;
background: rgba(255, 251, 232, 0.84);
}
#selectionPanel[hidden] { display: none; }
.selection-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 8px;
}
#selectionTitle {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 17px;
font-weight: 500;
}
#selectionTag {
display: inline-block;
margin-top: 5px;
color: var(--reconstruction);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
}
#selectionDetail {
margin: 7px 0 0;
color: #66736e;
font-size: 10px;
line-height: 1.5;
}
#closeSelection {
flex: 0 0 auto;
padding: 1px 5px;
background: transparent;
color: #79837f;
font-size: 18px;
line-height: 1;
}
.legend-panel {
left: 20px;
bottom: 20px;
width: min(390px, calc(100vw - 40px));
padding: 13px 15px;
border-radius: 14px;
}
.legend-items {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
}
.legend-item {
display: grid;
grid-template-columns: 13px 1fr;
gap: 7px;
align-items: start;
}
.legend-swatch {
width: 13px;
height: 13px;
margin-top: 1px;
border-radius: 3px;
}
.legend-swatch.evidence { background: var(--evidence); }
.legend-swatch.reconstruction { background: var(--reconstruction); }
.legend-swatch.flow {
background: var(--flow);
clip-path: polygon(0 30%, 60% 30%, 60% 0, 100% 50%, 60% 100%, 60% 70%, 0 70%);
}
.legend-item strong {
display: block;
font-size: 10px;
line-height: 1.25;
}
.legend-item small {
display: block;
margin-top: 2px;
color: #74807a;
font-size: 8.5px;
line-height: 1.3;
}
.hint {
position: fixed;
z-index: 8;
right: 22px;
bottom: 20px;
padding: 8px 11px;
border-radius: 9px;
background: rgba(37, 51, 47, 0.7);
color: rgba(255,255,255,0.85);
font-size: 9px;
letter-spacing: 0.02em;
backdrop-filter: blur(8px);
}
#labels {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
overflow: hidden;
}
.map-label {
position: absolute;
top: 0;
left: 0;
min-width: 120px;
padding: 7px 9px 7px 10px;
border-left: 3px solid var(--evidence);
border-radius: 5px;
background: rgba(250, 248, 238, 0.9);
box-shadow: 0 5px 18px rgba(53, 42, 28, 0.13);
color: var(--ink);
backdrop-filter: blur(5px);
will-change: transform;
}
.map-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 15px;
background: rgba(45, 60, 54, 0.45);
}
.map-label .label-title {
display: block;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.09em;
text-transform: uppercase;
white-space: nowrap;
}
.map-label .label-detail {
display: block;
margin-top: 3px;
color: #718079;
font-size: 8px;
white-space: nowrap;
}
.map-label.reconstruction { border-left-color: var(--reconstruction); }
.map-label.reconstruction .label-title { color: #a95632; }
.map-label.flow { border-left-color: var(--flow); }
.map-label.flow .label-title { color: #147873; }
.map-label.mixed {
border-left-color: var(--gold);
background: rgba(255, 250, 235, 0.93);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #cdbb9c;
color: #3c4d46;
font-size: 12px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
@media (max-width: 760px) {
.title-panel {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 14px 15px;
}
.title-panel .subtitle {
max-width: none;
margin: 8px 0 10px;
font-size: 11px;
}
.sequence { display: none; }
.layer-panel {
top: auto;
right: 10px;
bottom: 10px;
width: 220px;
padding: 11px;
}
.layer-panel .note { display: none; }
.layer-list { grid-template-columns: repeat(3, 1fr); gap: 5px; }
.layer-toggle { display: block; padding: 7px; }
.layer-toggle .check { display: inline-block; margin-bottom: 5px; }
.layer-toggle strong { font-size: 9px; }
.layer-toggle small, .layer-toggle .state { display: none; }
.legend-panel {
left: 10px;
bottom: 10px;
width: calc(100vw - 250px);
min-width: 145px;
padding: 10px;
}
.legend-items { grid-template-columns: 1fr; gap: 6px; }
.legend-item small { display: none; }
.hint { display: none; }
.map-label { transform-origin: center bottom; }
.map-label .label-detail { display: none; }
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="panel title-panel">
<div class="eyebrow">Interpretive landscape · concept model</div>
<h1>Along the<br>resource road</h1>
<p class="subtitle">
A modest Meroë-inspired production quarter: fuel storage, sheltered working
areas, a firing kiln, and routes linking the workshop to the settlement.
</p>
<div class="sequence" aria-label="Material movement sequence">
<span>Fuelwood</span><i>→</i>
<span>Charcoal</span><i>→</i>
<span>Firing</span><i>→</i>
<span>Vessels</span><i>→</i>
<span>Settlement</span>
</div>
<div class="title-actions">
<button class="action-button primary" id="pauseFlow" type="button">Pause flow</button>
<button class="action-button" id="resetView" type="button">Reset view</button>
<button class="icon-button" id="zoomIn" type="button" aria-label="Zoom in">+</button>
<button class="icon-button" id="zoomOut" type="button" aria-label="Zoom out">−</button>
</div>
</header>
<aside class="panel layer-panel" aria-label="Model layers">
<h2 class="panel-heading">Visible evidence layers</h2>
<div class="layer-list">
<button class="layer-toggle" type="button" data-layer="evidence" aria-pressed="true" style="--swatch:var(--evidence)">
<span class="check"></span>
<span><strong>Evidence</strong><small>Surviving or recorded traces</small></span>
<span class="state">On</span>
</button>
<button class="layer-toggle" type="button" data-layer="reconstruction" aria-pressed="true" style="--swatch:var(--reconstruction)">
<span class="check"></span>
<span><strong>Reconstructed</strong><small>Proposed walls and superstructure</small></span>
<span class="state">On</span>
</button>
<button class="layer-toggle" type="button" data-layer="flow" aria-pressed="true" style="--swatch:var(--flow)">
<span class="check"></span>
<span><strong>Material flow</strong><small>Interpretive movement sequence</small></span>
<span class="state">On</span>
</button>
</div>
<p class="note">
<strong>Separation of interpretation:</strong> cool gray denotes the
documented layer; ochre denotes proposed reconstruction; teal marks an
inferred logistics sequence. This is a schematic concept, not a measured
excavation plan.
</p>
<section id="selectionPanel" hidden aria-live="polite">
<div class="selection-top">
<div>
<h3 id="selectionTitle"></h3>
<span id="selectionTag"></span>
</div>
<button id="closeSelection" type="button" aria-label="Close feature information">×</button>
</div>
<p id="selectionDetail"></p>
</section>
</aside>
<aside class="panel legend-panel" aria-label="Legend">
<div class="legend-items">
<div class="legend-item">
<span class="legend-swatch evidence"></span>
<span><strong>Evidence</strong><small>Fixed recorded traces</small></span>
</div>
<div class="legend-item">
<span class="legend-swatch reconstruction"></span>
<span><strong>Reconstruction</strong><small>Interpretive form</small></span>
</div>
<div class="legend-item">
<span class="legend-swatch flow"></span>
<span><strong>Movement</strong><small>Proposed supply route</small></span>
</div>
</div>
</aside>
<div class="hint">Drag to orbit · Shift-drag to pan · Scroll to zoom · Select a feature</div>
<div id="labels" aria-hidden="true"></div>
<div id="loading">Building the production quarter…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const labelsContainer = document.getElementById("labels");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcdbb9c);
scene.fog = new THREE.Fog(0xcdbb9c, 30, 57);
const camera = new THREE.PerspectiveCamera(43, innerWidth / innerHeight, 0.1, 120);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute("aria-label", "Interactive low-poly reconstruction of an ancient production settlement");
renderer.domElement.tabIndex = 0;
container.appendChild(renderer.domElement);
const evidenceGroup = new THREE.Group();
const reconstructedGroup = new THREE.Group();
const flowGroup = new THREE.Group();
scene.add(evidenceGroup, reconstructedGroup, flowGroup);
const mats = {
terrain: new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
flatShading: true
}),
evidence: new THREE.MeshStandardMaterial({ color: 0x8d9991, roughness: 0.96, flatShading: true }),
evidenceDark: new THREE.MeshStandardMaterial({ color: 0x596762, roughness: 1, flatShading: true }),
evidenceLight: new THREE.MeshStandardMaterial({ color: 0xb6bdb3, roughness: 0.95, flatShading: true }),
clay: new THREE.MeshStandardMaterial({ color: 0xc87945, roughness: 0.9, flatShading: true }),
clayLight: new THREE.MeshStandardMaterial({ color: 0xd59a61, roughness: 0.92, flatShading: true }),
clayDark: new THREE.MeshStandardMaterial({ color: 0x9e5637, roughness: 0.95, flatShading: true }),
roof: new THREE.MeshStandardMaterial({ color: 0xd1a052, roughness: 0.94, flatShading: true }),
wood: new THREE.MeshStandardMaterial({ color: 0x715039, roughness: 1, flatShading: true }),
woodLight: new THREE.MeshStandardMaterial({ color: 0x987046, roughness: 1, flatShading: true }),
charcoal: new THREE.MeshStandardMaterial({ color: 0x343a35, roughness: 1, flatShading: true }),
path: new THREE.MeshStandardMaterial({ color: 0xb59a6d, roughness: 1, flatShading: true }),
pathEdge: new THREE.MeshStandardMaterial({ color: 0x9b815b, roughness: 1, flatShading: true }),
river: new THREE.MeshStandardMaterial({
color: 0x4e8e92,
roughness: 0.28,
metalness: 0.08,
transparent: true,
opacity: 0.88,
flatShading: true
}),
leaf: new THREE.MeshStandardMaterial({ color: 0x66784a, roughness: 1, flatShading: true }),
leafDark: new THREE.MeshStandardMaterial({ color: 0x4e633b, roughness: 1, flatShading: true }),
rock: new THREE.MeshStandardMaterial({ color: 0x8c8067, roughness: 1, flatShading: true }),
rockLight: new THREE.MeshStandardMaterial({ color: 0xa79778, roughness: 1, flatShading: true }),
flow: new THREE.MeshStandardMaterial({
color: 0x168f89,
emissive: 0x0b4d4a,
emissiveIntensity: 0.22,
roughness: 0.55,
transparent: true,
opacity: 0.84,
side: THREE.DoubleSide
})
};
const hemi = new THREE.HemisphereLight(0xf7e9c7, 0x675e4d, 2.1);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe4b0, 3.25);
sun.position.set(-9, 19, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.0006;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9fc3c0, 0.65);
fill.position.set(12, 8, -12);
scene.add(fill);
let seed = 84721;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function groundHeight(x, z) {
const undulation = 0.13 + Math.sin(x * 0.48) * 0.045 + Math.cos(z * 0.72) * 0.035;
const riverDepression = Math.exp(-Math.pow((z + 8.1) / 1.35, 2)) * 0.115;
return Math.max(0.018, undulation - riverDepression);
}
function addMesh(geometry, material, parent, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(w, h, d, material, parent, x = 0, y = 0, z = 0) {
return addMesh(new THREE.BoxGeometry(w, h, d), material, parent, x, y, z);
}
function addCylinder(rt, rb, h, segments, material, parent, x = 0, y = 0, z = 0) {
return addMesh(new THREE.CylinderGeometry(rt, rb, h, segments), material, parent, x, y, z);
}
function makeFeature(parent, title, detail, kind) {
const group = new THREE.Group();
group.userData.info = { title, detail, kind };
parent.add(group);
return group;
}
function addGableRoof(parent, width, depth, rise, y = 0) {
const roof = new THREE.Group();
roof.position.y = y;
parent.add(roof);
const slopeLength = Math.sqrt((width / 2) ** 2 + rise ** 2);
const angle = Math.atan2(rise, width / 2);
const left = addBox(slopeLength, 0.16, depth, mats.roof, roof, -width / 4, rise / 2, 0);
left.rotation.z = angle;
const right = addBox(slopeLength, 0.16, depth, mats.roof, roof, width / 4, rise / 2, 0);
right.rotation.z = -angle;
addBox(0.17, 0.18, depth + 0.12, mats.woodLight, roof, 0, rise + 0.02, 0);
return roof;
}
function addJar(parent, x, y, z, scale = 1, material = mats.clay) {
const profile = [
new THREE.Vector2(0.00, 0.00),
new THREE.Vector2(0.24, 0.00),
new THREE.Vector2(0.34, 0.12),
new THREE.Vector2(0.38, 0.30),
new THREE.Vector2(0.31, 0.55),
new THREE.Vector2(0.17, 0.68),
new THREE.Vector2(0.17, 0.78),
new THREE.Vector2(0.23, 0.82)
];
const jar = addMesh(new THREE.LatheGeometry(profile, 9), material, parent, x, y, z);
jar.scale.setScalar(scale);
const rim = addMesh(new THREE.TorusGeometry(0.21 * scale, 0.035 * scale, 4, 9), material, parent, x, y + 0.81 * scale, z);
rim.rotation.x = Math.PI / 2;
const opening = addCylinder(0.16 * scale, 0.16 * scale, 0.018, 8, mats.charcoal, parent, x, y + 0.82 * scale, z);
return jar;
}
// Terrain: faceted, low-poly desert surface.
let terrainGeometry = new THREE.PlaneGeometry(36, 24, 42, 28);
terrainGeometry.rotateX(-Math.PI / 2);
terrainGeometry = terrainGeometry.toNonIndexed();
const terrainPositions = terrainGeometry.attributes.position;
const terrainColors = [];
for (let i = 0; i < terrainPositions.count; i += 3) {
const x = (terrainPositions.getX(i) + terrainPositions.getX(i + 1) + terrainPositions.getX(i + 2)) / 3;
const z = (terrainPositions.getZ(i) + terrainPositions.getZ(i + 1) + terrainPositions.getZ(i + 2)) / 3;
const y = groundHeight(x, z);
for (let j = 0; j < 3; j++) {
terrainPositions.setY(i + j, y);
}
const color = new THREE.Color();
color.setHSL(0.105 + random() * 0.018, 0.31 + random() * 0.08, 0.51 + random() * 0.055);
for (let j = 0; j < 3; j++) terrainColors.push(color.r, color.g, color.b);
}
terrainGeometry.setAttribute("color", new THREE.Float32BufferAttribute(terrainColors, 3));
terrainGeometry.computeVertexNormals();
const terrain = addMesh(terrainGeometry, mats.terrain, scene);
terrain.castShadow = false;
// A subdued river edge places the production area within a broader route landscape.
const riverCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-17, 0, -7.5),
new THREE.Vector3(-10, 0, -8.0),
new THREE.Vector3(-3, 0, -8.25),
new THREE.Vector3(4, 0, -7.85),
new THREE.Vector3(11, 0, -8.25),
new THREE.Vector3(17, 0, -8.0)
]);
function ribbonGeometry(curve, width, segments = 70, yOffset = 0, flatY = null) {
const positions = [];
const indices = [];
for (let i = 0; i <= segments; i++) {
const t = i / segments;
const point = curve.getPointAt(t);
const tangent = curve.getTangentAt(t).normalize();
const side = new THREE.Vector3(-tangent.z, 0, tangent.x).normalize().multiplyScalar(width / 2);
for (const sign of [-1, 1]) {
const x = point.x + side.x * sign;
const z = point.z + side.z * sign;
const y = flatY === null ? groundHeight(x, z) + yOffset : flatY;
positions.push(x, y, z);
}
if (i < segments) {
const a = i * 2;
indices.push(a, a + 2, a + 1, a + 1, a + 2, a + 3);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
addMesh(ribbonGeometry(riverCurve, 1.65, 90, 0, 0.072), mats.river, scene).castShadow = false;
// Routes are shown as part of the schematic recorded layer.
const resourceCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-14.2, 0, -5.2),
new THREE.Vector3(-10.2, 0, -4.3),
new THREE.Vector3(-7.2, 0, -2.7),
new THREE.Vector3(-5.3, 0, -0.8),
new THREE.Vector3(-4.4, 0, 0.45),
new THREE.Vector3(-2.0, 0, 1.35)
]);
const settlementCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.5, 0, 1.45),
new THREE.Vector3(1.0, 0, 2.25),
new THREE.Vector3(4.0, 0, 2.0),
new THREE.Vector3(6.6, 0, 1.1),
new THREE.Vector3(8.8, 0, 0.8)
]);
const workSpur = new THREE.CatmullRomCurve3([
new THREE.Vector3(-4.35, 0, 0.45),
new THREE.Vector3(-2.2, 0, -0.7),
new THREE.Vector3(0.0, 0, -0.8)
]);
const routeEvidence = makeFeature(
evidenceGroup,
"Route corridor",
"The pale route surfaces show the schematic alignment used by this concept. Their recorded status is diagrammatic; actual use, load, and direction remain interpretive.",
"evidence"
);
addMesh(ribbonGeometry(resourceCurve, 0.82), mats.path, routeEvidence);
addMesh(ribbonGeometry(settlementCurve, 0.78), mats.path, routeEvidence);
addMesh(ribbonGeometry(workSpur, 0.58), mats.path, routeEvidence);
// Low rocks and scrub provide scale without competing with the production area.
for (let i = 0; i < 42; i++) {
const x = -16 + random() * 32;
const z = -6 + random() * 16;
if (z < -6.7 || (x > -7 && x < 12 && z > -2 && z < 5)) continue;
if (Math.abs(z + 8.1) < 1.2) continue;
const rock = addMesh(
new THREE.DodecahedronGeometry(0.25 + random() * 0.7, 0),
random() > 0.45 ? mats.rock : mats.rockLight,
scene,
x,
groundHeight(x, z) + 0.13,
z
);
rock.scale.set(1 + random(), 0.55 + random() * 0.55, 0.8 + random());
rock.rotation.set(random(), random() * Math.PI, random());
}
for (let i = 0; i < 20; i++) {
const x = -15 + random() * 29;
const z = -5.5 + random() * 14;
if ((x > -7 && x < 12 && z > -2 && z < 5) || Math.abs(z + 8.1) < 1.3) continue;
const shrub = addMesh(
new THREE.ConeGeometry(0.25 + random() * 0.2, 0.55 + random() * 0.3, 5),
random() > 0.5 ? mats.leaf : mats.leafDark,
scene,
x,
groundHeight(x, z) + 0.22,
z
);
shrub.rotation.y = random() * Math.PI;
}
// Fuel storage: gray footings remain visible when the reconstruction is hidden.
const fuelEvidence = makeFeature(
evidenceGroup,
"Fuel-store footings",
"These cool-gray corner and wall-base blocks stand for the fixed evidence layer. Roof pitch, wall height, and the arrangement of fuel are reconstructed interpretations.",
"evidence"
);
fuelEvidence.position.set(-4.5, 0, 0.45);
[-2.15, 2.15].forEach(x => {
[-1.35, 1.35].forEach(z => addBox(0.48, 0.28, 0.48, mats.evidence, fuelEvidence, x, 0.15, z));
});
addBox(4.7, 0.23, 0.34, mats.evidenceLight, fuelEvidence, 0, 0.13, -1.45);
const fuelRec = makeFeature(
reconstructedGroup,
"Fuel store",
"A proposed open-sided shelter protects stacked timber and charcoal. The ochre roof and mud-brick supports are reconstructed forms, not surviving evidence.",
"reconstruction"
);
fuelRec.position.set(-4.5, 0, 0.45);
addBox(4.65, 0.14, 3.0, mats.clayLight, fuelRec, 0, 0.08, 0);
addBox(4.65, 0.72, 0.25, mats.clay, fuelRec, 0, 0.48, -1.42);
addBox(0.25, 0.72, 2.8, mats.clay, fuelRec, -2.18, 0.48, 0);
[-2.12, 2.12].forEach(x => {
[-1.32, 1.32].forEach(z => addBox(0.22, 2.55, 0.22, mats.woodLight, fuelRec, x, 1.42, z));
});
addGableRoof(fuelRec, 5.1, 3.55, 0.92, 2.67);
for (let row = 0; row < 3; row++) {
for (let column = 0; column < 4; column++) {
const log = addCylinder(0.14, 0.16, 1.55, 7, row % 2 ? mats.wood : mats.woodLight, fuelRec, -1.05 + column * 0.31, 0.3 + row * 0.27, 0.95);
log.rotation.x = Math.PI / 2;
log.rotation.z = (random() - 0.5) * 0.04;
}
}
const basket = addCylinder(0.53, 0.38, 0.58, 9, mats.woodLight, fuelRec, 0.85, 0.39, 0.62);
basket.rotation.y = 0.2;
addCylinder(0.43, 0.43, 0.035, 9, mats.charcoal, fuelRec, 0.85, 0.69, 0.62);
// Work shelter and its recorded postholes.
const workEvidence = makeFeature(
evidenceGroup,
"Work-shelter postholes",
"Small gray blocks indicate the recorded footprint of a sheltered work area. Canopy form, benches, and tools are interpretive additions.",
"evidence"
);
workEvidence.position.set(0.15, 0, -0.85);
[-2.25, 2.25].forEach(x => {
[-1.45, 1.45].forEach(z => addBox(0.42, 0.25, 0.42, mats.evidence, workEvidence, x, 0.14, z));
});
addBox(4.8, 0.2, 0.3, mats.evidenceLight, workEvidence, 0, 0.12, -1.6);
const workRec = makeFeature(
reconstructedGroup,
"Work shelter",
"A proposed timber-and-thatch shelter covers grinding stones, benches, and drying vessels. It suggests a shaded production area rather than a fully enclosed building.",
"reconstruction"
);
workRec.position.set(0.15, 0, -0.85);
addBox(4.85, 0.13, 3.2, mats.clayLight, workRec, 0, 0.08, 0);
[-2.22, 2.22].forEach(x => {
[-1.42, 1.42].forEach(z => addBox(0.2, 2.45, 0.2, mats.woodLight, workRec, x, 1.35, z));
});
addGableRoof(workRec, 5.45, 3.85, 0.78, 2.55);
addBox(2.5, 0.16, 0.78, mats.wood, workRec, -0.5, 0.93, -0.7);
[-1.45, 0.45].forEach(x => addBox(0.17, 0.78, 0.58, mats.woodLight, workRec, x, 0.47, -0.7));
const grindingStone = addCylinder(0.56, 0.61, 0.22, 10, mats.evidenceLight, workRec, -0.55, 1.11, -0.7);
grindingStone.rotation.y = 0.3;
addCylinder(0.12, 0.14, 0.18, 8, mats.evidence, workRec, -0.54, 1.29, -0.7);
addJar(workRec, 0.78, 1.02, -0.55, 0.75);
addJar(workRec, 1.35, 1.02, -0.2, 0.56, mats.clayLight);
// Kiln: stone base is evidence, ochre shell is reconstructed.
const kilnEvidence = makeFeature(
evidenceGroup,
"Firing-kiln base",
"The gray ring and dark hearth define the recorded kiln base. The dome, chimney, and operating front are reconstructed interpretations.",
"evidence"
);
kilnEvidence.position.set(-1.65, 0, 1.45);
for (let i = 0; i < 13; i++) {
const angle = (i / 13) * Math.PI * 2;
const stone = addBox(0.42, 0.3, 0.34, i % 3 ? mats.evidence : mats.evidenceLight, kilnEvidence, Math.cos(angle) * 0.92, 0.17, Math.sin(angle) * 0.92);
stone.rotation.y = -angle;
}
addCylinder(0.75, 0.75, 0.055, 12, mats.charcoal, kilnEvidence, 0, 0.08, 0);
const kilnRec = makeFeature(
reconstructedGroup,
"Firing kiln",
"A proposed clay dome is reconstructed over the recorded stone base. Its color and mass are intentionally distinct so the interpretive shell can be isolated.",
"reconstruction"
);
kilnRec.position.set(-1.65, 0, 1.45);
const kilnDome = addMesh(new THREE.SphereGeometry(1.02, 12, 6, 0, Math.PI * 2, 0, Math.PI / 2), mats.clay, kilnRec, 0, 0.22, 0);
kilnDome.scale.y = 1.05;
addCylinder(0.24, 0.3, 0.55, 8, mats.clayDark, kilnRec, 0, 1.35, 0);
const kilnMouth = addMesh(new THREE.CircleGeometry(0.27, 10), mats.charcoal, kilnRec, 0, 0.52, 0.99);
kilnMouth.rotation.x = -0.08;
addCylinder(0.32, 0.37, 0.12, 10, mats.clayLight, kilnRec, 0, 0.3, 1.01).rotation.x = Math.PI / 2;
// Additional production fixtures.
const fixtureEvidence = makeFeature(
evidenceGroup,
"Working surfaces",
"Low gray slabs and circular settings stand for recorded working surfaces. Their precise use remains an interpretation.",
"evidence"
);
fixtureEvidence.position.set(2.1, 0, -1.5);
addBox(1.5, 0.18, 0.85, mats.evidenceLight, fixtureEvidence, 0, 0.1, 0);
addCylinder(0.48, 0.54, 0.16, 9, mats.evidence, fixtureEvidence, 1.35, 0.1, 0.15);
const fixtureRec = makeFeature(
reconstructedGroup,
"Vessel-drying area",
"A reconstructed rack and pottery indicate the handling of newly made vessels before distribution to the settlement.",
"reconstruction"
);
fixtureRec.position.set(2.1, 0, -1.5);
[-0.5, 0.5].forEach(x => addBox(0.12, 1.0, 0.12, mats.wood, fixtureRec, x, 0.55, 0));
addBox(1.35, 0.12, 0.75, mats.woodLight, fixtureRec, 0, 1.04, 0);
addJar(fixtureRec, -0.3, 1.12, 0, 0.68);
addJar(fixtureRec, 0.3, 1.12, 0, 0.72, mats.clayLight);
// Settlement: footings are separated from reconstructed mud-brick architecture.
const houseSpecs = [
{ x: 7.2, z: 0.7, w: 2.8, d: 2.8, h: 2.25 },
{ x: 9.7, z: -0.65, w: 3.0, d: 2.65, h: 2.5 },
{ x: 8.05, z: 3.25, w: 2.45, d: 2.55, h: 2.05 }
];
const settlementEvidence = makeFeature(
evidenceGroup,
"Settlement wall footings",
"Gray base courses indicate the recorded settlement edge and house alignments. Building height, flat roofs, openings, and parapets are reconstructed.",
"evidence"
);
const settlementRec = makeFeature(
reconstructedGroup,
"Settlement edge",
"Compact ochre mud-brick houses are a proposed reconstruction over recorded wall lines. Their arrangement suggests a small production-linked residential quarter.",
"reconstruction"
);
houseSpecs.forEach((spec, index) => {
addBox(spec.w + 0.15, 0.22, 0.28, mats.evidenceLight, settlementEvidence, spec.x, 0.13, spec.z - spec.d / 2);
addBox(spec.w + 0.15, 0.22, 0.28, mats.evidenceLight, settlementEvidence, spec.x, 0.13, spec.z + spec.d / 2);
addBox(0.28, 0.22, spec.d, mats.evidence, settlementEvidence, spec.x - spec.w / 2, 0.13, spec.z);
addBox(0.28, 0.22, spec.d, mats.evidence, settlementEvidence, spec.x + spec.w / 2, 0.13, spec.z);
const house = new THREE.Group();
house.position.set(spec.x, 0, spec.z);
settlementRec.add(house);
addBox(spec.w, spec.h, spec.d, index === 1 ? mats.clayLight : mats.clay, house, 0, 0.24 + spec.h / 2, 0);
addBox(spec.w + 0.22, 0.22, spec.d + 0.22, mats.roof, house, 0, spec.h + 0.31, 0);
addBox(spec.w + 0.18, 0.36, 0.18, mats.clayLight, house, 0, spec.h + 0.55, spec.d / 2);
addBox(spec.w + 0.18, 0.36, 0.18, mats.clayLight, house, 0, spec.h + 0.55, -spec.d / 2);
addBox(0.18, 0.36, spec.d, mats.clayLight, house, spec.w / 2, spec.h + 0.55, 0);
addBox(0.18, 0.36, spec.d, mats.clayLight, house, -spec.w / 2, spec.h + 0.55, 0);
addBox(0.62, 1.18, 0.07, mats.charcoal, house, 0.12, 0.84, spec.d / 2 + 0.04);
addBox(0.32, 0.35, 0.065, mats.evidenceDark, house, -spec.w * 0.27, 1.45, spec.d / 2 + 0.045);
for (let row = 1; row < 4; row++) {
addBox(spec.w * 0.88, 0.025, 0.025, mats.clayDark, house, 0, 0.5 + row * 0.48, spec.d / 2 + 0.02);
}
[-1, 1].forEach(side => {
addBox(0.36, spec.h * 0.82, 0.42, mats.clayLight, house, side * (spec.w / 2 - 0.13), 0.25 + spec.h * 0.41, spec.d / 2 - 0.25);
});
});
// A low reconstructed settlement wall.
addBox(0.3, 0.9, 6.8, mats.clay, settlementRec, 5.9, 0.55, 0.8);
addBox(5.2, 0.9, 0.3, mats.clay, settlementRec, 8.35, 0.55, 4.05);
// Resource-side timber cache.
const cacheRec = makeFeature(
reconstructedGroup,
"Fuelwood cache",
"This roadside cache is interpretive, suggesting where cut fuel could be sorted before entering the sheltered store.",
"reconstruction"
);
cacheRec.position.set(-9.6, 0, -3.55);
for (let row = 0; row < 3; row++) {
for (let column = 0; column < 4; column++) {
const log = addCylinder(0.14, 0.16, 1.8, 7, row % 2 ? mats.wood : mats.woodLight, cacheRec, -0.48 + column * 0.32, 0.18 + row * 0.27, 0);
log.rotation.x = Math.PI / 2;
}
}
// Palms and a small river boat are reconstructed landscape elements.
function makePalm(parent, x, z, scale = 1) {
const palm = new THREE.Group();
palm.position.set(x, groundHeight(x, z), z);
palm.scale.setScalar(scale);
parent.add(palm);
for (let i = 0; i < 5; i++) {
const segment = addCylinder(0.13 - i * 0.012, 0.16 - i * 0.012, 0.75, 7, mats.wood, palm, i * 0.035, 0.38 + i * 0.68, 0);
segment.rotation.z = -0.045;
}
for (let i = 0; i < 7; i++) {
const leaf = addMesh(new THREE.ConeGeometry(0.32, 1.8, 4), i % 2 ? mats.leaf : mats.leafDark, palm, 0, 3.65, 0);
leaf.rotation.z = Math.PI / 2;
leaf.rotation.y = (i / 7) * Math.PI * 2;
leaf.position.x = Math.cos((i / 7) * Math.PI * 2) * 0.72;
leaf.position.z = Math.sin((i / 7) * Math.PI * 2) * 0.72;
}
addCylinder(0.18, 0.22, 0.32, 7, mats.woodLight, palm, 0, 3.62, 0);
return palm;
}
makePalm(reconstructedGroup, 5.35, -4.7, 0.92);
makePalm(reconstructedGroup, 6.2, -4.2, 0.72);
makePalm(reconstructedGroup, 11.5, 3.9, 0.83);
makePalm(reconstructedGroup, -12.5, -6.25, 0.7);
const boat = makeFeature(
reconstructedGroup,
"River-route landing",
"A small boat and landing cargo are reconstructed to suggest the wider river corridor beyond the immediate production paths.",
"reconstruction"
);
boat.position.set(1.7, 0.08, -8.05);
const hull = addMesh(new THREE.CylinderGeometry(0.36, 0.52, 2.7, 6), mats.wood, boat, 0, 0.05, 0);
hull.rotation.x = Math.PI / 2;
hull.scale.y = 0.75;
addBox(0.75, 0.38, 0.65, mats.clayLight, boat, 0.2, 0.35, 0.3);
const pole = addCylinder(0.035, 0.045, 2.6, 6, mats.woodLight, boat, -0.25, 1.0, 0);
pole.rotation.z = -0.42;
// Teal moving arrows communicate the proposed logistics sequence.
function makeArrowGeometry() {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute([
-0.17, 0, -0.17,
0.17, 0, -0.17,
0.00, 0, 0.30
], 3));
geometry.computeVertexNormals();
return geometry;
}
const arrowGeometry = makeArrowGeometry();
const flowArrows = [];
function addFlowArrows(curve, count, phase = 0) {
for (let i = 0; i < count; i++) {
const arrow = addMesh(arrowGeometry, mats.flow, flowGroup);
arrow.castShadow = false;
arrow.receiveShadow = false;
flowArrows.push({ arrow, curve, phase: phase + i / count });
}
}
addFlowArrows(resourceCurve, 8, 0.02);
addFlowArrows(settlementCurve, 7, 0.48);
function makeCart(load = "wood") {
const cart = new THREE.Group();
flowGroup.add(cart);
addBox(0.95, 0.16, 1.25, mats.woodLight, cart, 0, 0.42, 0);
addBox(0.08, 0.55, 1.2, mats.wood, cart, -0.48, 0.69, 0);
addBox(0.08, 0.55, 1.2, mats.wood, cart, 0.48, 0.69, 0);
[-0.55, 0.55].forEach(x => {
[-0.43, 0.43].forEach(z => {
const wheel = addCylinder(0.24, 0.24, 0.12, 10, mats.charcoal, cart, x, 0.27, z);
wheel.rotation.z = Math.PI / 2;
const hub = addCylinder(0.08, 0.08, 0.14, 8, mats.woodLight, cart, x, 0.27, z);
hub.rotation.z = Math.PI / 2;
});
});
const shaft = addBox(0.08, 0.08, 1.2, mats.wood, cart, 0, 0.43, 1.15);
shaft.rotation.x = -0.12;
if (load === "wood") {
for (let row = 0; row < 2; row++) {
for (let column = 0; column < 3; column++) {
const log = addCylinder(0.11, 0.13, 0.95, 6, row % 2 ? mats.wood : mats.woodLight, cart, -0.27 + column * 0.27, 0.58 + row * 0.23, -0.05);
log.rotation.x = Math.PI / 2;
}
}
} else {
addJar(cart, -0.2, 0.52, 0.05, 0.65);
addJar(cart, 0.22, 0.52, -0.13, 0.58, mats.clayLight);
}
return cart;
}
const fuelCart = makeCart("wood");
const vesselCart = makeCart("vessels");
function makeWorker(color) {
const worker = new THREE.Group();
flowGroup.add(worker);
const cloth = new THREE.MeshStandardMaterial({ color, roughness: 1, flatShading: true });
addCylinder(0.14, 0.18, 0.48, 7, cloth, worker, 0, 0.75, 0);
addMesh(new THREE.DodecahedronGeometry(0.14, 0), mats.evidenceDark, worker, 0, 1.12, 0);
addBox(0.11, 0.45, 0.13, cloth, worker, -0.1, 0.32, 0);
addBox(0.11, 0.45, 0.13, cloth, worker, 0.1, 0.32, 0);
addBox(0.1, 0.4, 0.12, cloth, worker, -0.23, 0.74, 0);
addBox(0.1, 0.4, 0.12, cloth, worker, 0.23, 0.74, 0);
return worker;
}
const workerCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-4.3, 0, 1.55),
new THREE.Vector3(-3.1, 0, 2.0),
new THREE.Vector3(-1.9, 0, 1.5),
new THREE.Vector3(-0.5, 0, 0.65)
]);
const workerA = makeWorker(0xb65e3f);
const workerB = makeWorker(0x6d7d68);
// Projected HTML labels.
const labels = [];
function addLabel(type, title, detail, x, y, z) {
const element = document.createElement("div");
element.className = `map-label ${type}`;
const titleElement = document.createElement("span");
titleElement.className = "label-title";
titleElement.textContent = title;
const detailElement = document.createElement("span");
detailElement.className = "label-detail";
detailElement.textContent = detail;
element.append(titleElement, detailElement);
labelsContainer.appendChild(element);
labels.push({ element, type, anchor: new THREE.Vector3(x, y, z) });
}
addLabel("reconstruction", "01 · Fuel store", "reconstructed shelter and fuel stock", -4.5, 4.0, 0.45);
addLabel("mixed", "02 · Firing kiln", "recorded base · reconstructed dome", -1.65, 2.55, 1.45);
addLabel("reconstruction", "03 · Work shelter", "reconstructed canopy and production area", 0.15, 3.8, -0.85);
addLabel("reconstruction", "Settlement edge", "reconstructed over recorded wall lines", 8.3, 4.35, 0.9);
addLabel("evidence", "Route corridor", "schematic recorded alignment", -8.3, 0.8, -3.45);
addLabel("flow", "Material movement", "interpretive direction and loads", 3.7, 0.95, 2.0);
// Manual camera controls; no external controls addon is used.
const controls = {
target: new THREE.Vector3(0, 0, 0),
radius: 27,
theta: 0.43,
phi: 0.87
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
function resetCamera() {
controls.target.set(0, 0, 0);
controls.radius = 27;
controls.theta = 0.43;
controls.phi = 0.87;
updateCamera();
}
let pointerDown = false;
let pointerMoved = 0;
let pointerStart = { x: 0, y: 0 };
let panMode = false;
let previous = { x: 0, y: 0 };
renderer.domElement.addEventListener("pointerdown", event => {
pointerDown = true;
pointerMoved = 0;
pointerStart = { x: event.clientX, y: event.clientY };
previous = { x: event.clientX, y: event.clientY };
panMode = event.shiftKey || event.button === 2;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointerDown) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointerMoved += Math.abs(dx) + Math.abs(dy);
previous = { x: event.clientX, y: event.clientY };
if (panMode) {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3().crossVectors(forward, camera.up).normalize();
const scale = controls.radius * 0.0014;
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(forward, dy * scale);
} else {
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(controls.phi - dy * 0.005, 0.28, 1.35);
}
updateCamera();
});
renderer.domElement.addEventListener("pointerup", event => {
pointerDown = false;
if (pointerMoved < 6 && event.button === 0) selectAt(event.clientX, event.clientY);
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => pointerDown = false);
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(controls.radius * Math.exp(event.deltaY * 0.001), 10, 43);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
// Picking and selection details.
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let selectedGroup = null;
let selectionHelper = null;
const selectionPanel = document.getElementById("selectionPanel");
const selectionTitle = document.getElementById("selectionTitle");
const selectionTag = document.getElementById("selectionTag");
const selectionDetail = document.getElementById("selectionDetail");
function actuallyVisible(object) {
let current = object;
while (current) {
if (!current.visible) return false;
current = current.parent;
}
return true;
}
function findFeature(object) {
let current = object;
while (current) {
if (current.userData.info) return current;
current = current.parent;
}
return null;
}
function clearSelection() {
selectedGroup = null;
if (selectionHelper) {
scene.remove(selectionHelper);
selectionHelper.geometry.dispose();
selectionHelper.material.dispose();
selectionHelper = null;
}
selectionPanel.hidden = true;
}
function selectAt(clientX, clientY) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects([evidenceGroup, reconstructedGroup], true);
const hit = intersections.find(item => actuallyVisible(item.object) && findFeature(item.object));
if (!hit) {
clearSelection();
return;
}
const feature = findFeature(hit.object);
selectedGroup = feature;
const info = feature.userData.info;
selectionTitle.textContent = info.title;
selectionTag.textContent = info.kind === "evidence" ? "Evidence layer" : "Reconstructed layer";
selectionTag.style.color = info.kind === "evidence" ? "#65776f" : "#b55c32";
selectionDetail.textContent = info.detail;
selectionPanel.hidden = false;
if (selectionHelper) {
scene.remove(selectionHelper);
selectionHelper.geometry.dispose();
selectionHelper.material.dispose();
}
selectionHelper = new THREE.BoxHelper(feature, 0xf2c85b);
selectionHelper.material.depthTest = false;
selectionHelper.material.transparent = true;
selectionHelper.material.opacity = 0.85;
selectionHelper.renderOrder = 10;
scene.add(selectionHelper);
}
document.getElementById("closeSelection").addEventListener("click", clearSelection);
// Layer switches.
let evidenceVisible = true;
let reconstructionVisible = true;
let flowVisible = true;
let flowPlaying = true;
const layerButtons = [...document.querySelectorAll(".layer-toggle")];
function setLayerVisibility() {
evidenceGroup.visible = evidenceVisible;
reconstructedGroup.visible = reconstructionVisible;
flowGroup.visible = flowVisible;
layerButtons.forEach(button => {
const layer = button.dataset.layer;
const visible = layer === "evidence" ? evidenceVisible : layer === "reconstruction" ? reconstructionVisible : flowVisible;
button.setAttribute("aria-pressed", String(visible));
button.querySelector(".state").textContent = visible ? "On" : "Off";
});
if (!evidenceVisible && selectedGroup?.userData.info?.kind === "evidence") clearSelection();
if (!reconstructionVisible && selectedGroup?.userData.info?.kind === "reconstruction") clearSelection();
}
layerButtons.forEach(button => {
button.addEventListener("click", () => {
const layer = button.dataset.layer;
if (layer === "evidence") evidenceVisible = !evidenceVisible;
if (layer === "reconstruction") reconstructionVisible = !reconstructionVisible;
if (layer === "flow") flowVisible = !flowVisible;
setLayerVisibility();
});
});
const pauseButton = document.getElementById("pauseFlow");
pauseButton.addEventListener("click", () => {
flowPlaying = !flowPlaying;
pauseButton.textContent = flowPlaying ? "Pause flow" : "Resume flow";
});
document.getElementById("resetView").addEventListener("click", resetCamera);
document.getElementById("zoomIn").addEventListener("click", () => {
controls.radius = Math.max(10, controls.radius * 0.84);
updateCamera();
});
document.getElementById("zoomOut").addEventListener("click", () => {
controls.radius = Math.min(43, controls.radius * 1.16);
updateCamera();
});
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetCamera();
if (event.code === "Space" && event.target === document.body) {
event.preventDefault();
pauseButton.click();
}
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
const clock = new THREE.Clock();
let elapsed = 0;
function orientAlong(object, curve, t, heightOffset = 0) {
const point = curve.getPointAt(THREE.MathUtils.euclideanModulo(t, 1));
const tangent = curve.getTangentAt(THREE.MathUtils.euclideanModulo(t, 1));
object.position.set(point.x, groundHeight(point.x, point.z) + heightOffset, point.z);
object.rotation.y = Math.atan2(tangent.x, tangent.z);
}
function updateLabels() {
labels.forEach(label => {
let visible = true;
if (label.type === "evidence") visible = evidenceVisible;
if (label.type === "reconstruction") visible = reconstructionVisible;
if (label.type === "flow") visible = flowVisible;
if (label.type === "mixed") visible = evidenceVisible || reconstructionVisible;
const projected = label.anchor.clone().project(camera);
const onScreen = projected.z > -1 && projected.z < 1 && Math.abs(projected.x) < 1.2 && Math.abs(projected.y) < 1.2;
visible = visible && onScreen;
label.element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
label.element.style.transform = `translate3d(${x}px, ${y}px, 0) translate(-50%, -100%)`;
});
}
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (flowPlaying && flowVisible) elapsed += delta;
flowArrows.forEach(({ arrow, curve, phase }) => {
const t = THREE.MathUtils.euclideanModulo(elapsed * 0.075 + phase, 1);
const point = curve.getPointAt(t);
const tangent = curve.getTangentAt(t);
arrow.position.set(point.x, groundHeight(point.x, point.z) + 0.11, point.z);
arrow.rotation.y = Math.atan2(tangent.x, tangent.z);
const pulse = 0.82 + Math.sin(elapsed * 4 + phase * 10) * 0.12;
arrow.scale.setScalar(pulse);
});
orientAlong(fuelCart, resourceCurve, elapsed * 0.027, 0.08);
orientAlong(vesselCart, settlementCurve, 1 - elapsed * 0.024, 0.08);
orientAlong(workerA, workerCurve, elapsed * 0.055, 0.02);
orientAlong(workerB, workerCurve, 0.5 - elapsed * 0.046, 0.02);
if (selectionHelper && selectedGroup) selectionHelper.update();
updateLabels();
renderer.render(scene, camera);
}
updateCamera();
animate();
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```