Prompt specification
Build or customize the Three.js 3D scene "Compare evidence and alternative enclosure uses" 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: Compare evidence and alternative enclosure uses
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/compare-evidence-and-alternative-enclosure-uses-x2352
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows the dry-stone enclosures of Great Zimbabwe. Let users switch labeled interpretive overlays on the same stone enclosure geometry. Separate documented surviving features from competing functional interpretations instead of presenting one reconstruction as certain. Low-poly.
Working Three.js Starter (compare-evidence-and-alternative-enclosure-uses-x2352):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#26332f">
<title>Great Zimbabwe — Reading the Enclosures</title>
<style>
:root {
--ink: #26332f;
--muted: #65706a;
--paper: rgba(248, 246, 237, 0.94);
--paper-solid: #f7f4e9;
--line: rgba(38, 51, 47, 0.16);
--cyan: #48b9d1;
--coral: #e66e51;
--teal: #2aa6a0;
--violet: #b45bd1;
--green: #72994e;
--stone: #8d8270;
--shadow: 0 12px 36px rgba(32, 40, 35, 0.15);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background: #d6d8ca;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input,
select {
font: inherit;
}
button {
color: inherit;
}
#app,
#scene,
#labels {
position: fixed;
inset: 0;
}
#scene {
z-index: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas.dragging {
cursor: grabbing;
}
#labels {
z-index: 3;
pointer-events: none;
overflow: hidden;
}
.masthead {
position: fixed;
z-index: 5;
top: 20px;
left: 22px;
max-width: 430px;
pointer-events: none;
text-shadow: 0 1px 10px rgba(247, 244, 233, 0.55);
}
.eyebrow {
margin: 0 0 5px;
color: #516259;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.masthead h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 3vw, 46px);
font-weight: 500;
letter-spacing: 0.045em;
line-height: 0.98;
}
.masthead .subtitle {
margin: 8px 0 0;
color: #4d5b55;
font-size: 12px;
letter-spacing: 0.04em;
}
.model-badge {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 11px;
padding: 6px 9px;
border: 1px solid rgba(38, 51, 47, 0.19);
border-radius: 999px;
background: rgba(248, 246, 237, 0.72);
color: #4b5a54;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
backdrop-filter: blur(9px);
}
.model-badge::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: #d49345;
content: "";
}
.views {
position: fixed;
z-index: 7;
top: 20px;
right: 20px;
display: flex;
gap: 4px;
padding: 5px;
border: 1px solid rgba(38, 51, 47, 0.13);
border-radius: 12px;
background: rgba(248, 246, 237, 0.89);
box-shadow: var(--shadow);
backdrop-filter: blur(15px);
}
.view-button {
padding: 8px 10px;
border: 0;
border-radius: 8px;
background: transparent;
color: #59665f;
cursor: pointer;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
}
.view-button:hover {
background: rgba(38, 51, 47, 0.06);
}
.view-button.active {
background: var(--ink);
color: #fffdf4;
}
.panel {
position: fixed;
z-index: 6;
top: 94px;
left: 18px;
width: 318px;
max-height: calc(100vh - 116px);
overflow: auto;
border: 1px solid rgba(38, 51, 47, 0.14);
border-radius: 16px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
scrollbar-width: thin;
scrollbar-color: rgba(38, 51, 47, 0.25) transparent;
}
.panel-intro {
padding: 16px 17px 13px;
border-bottom: 1px solid var(--line);
}
.panel-intro h2 {
margin: 0 0 5px;
font-family: Georgia, "Times New Roman", serif;
font-size: 20px;
font-weight: 500;
}
.panel-intro p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
padding: 13px 16px 7px;
color: #68726c;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.section-label span {
color: #929990;
font-size: 8px;
letter-spacing: 0.11em;
}
.section-label.hypothesis {
margin-top: 4px;
border-top: 1px solid var(--line);
background: rgba(38, 51, 47, 0.025);
}
.layers {
padding: 0 8px 9px;
}
.layer {
display: grid;
grid-template-columns: 13px 1fr auto;
gap: 9px;
align-items: center;
width: 100%;
padding: 8px;
border: 1px solid transparent;
border-radius: 9px;
background: transparent;
text-align: left;
cursor: pointer;
transition:
background 140ms ease,
border-color 140ms ease,
transform 140ms ease;
}
.layer:hover {
background: rgba(38, 51, 47, 0.045);
}
.layer:focus-visible,
.view-button:focus-visible,
.map-label:focus-visible,
.text-button:focus-visible {
outline: 2px solid #3b8ca1;
outline-offset: 2px;
}
.layer.selected {
border-color: rgba(38, 51, 47, 0.13);
background: rgba(38, 51, 47, 0.055);
}
.swatch {
width: 9px;
height: 9px;
margin-left: 2px;
border-radius: 50%;
background: var(--swatch);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--swatch) 15%, transparent);
opacity: 0.5;
}
.layer.active .swatch {
opacity: 1;
}
.layer-copy {
min-width: 0;
}
.layer-title {
display: block;
font-size: 11px;
font-weight: 750;
line-height: 1.25;
}
.layer-subtitle {
display: block;
margin-top: 2px;
color: #7b837d;
font-size: 9px;
line-height: 1.25;
}
.switch {
position: relative;
width: 28px;
height: 16px;
border-radius: 999px;
background: #c8ccc5;
transition: background 150ms ease;
}
.switch::after {
position: absolute;
top: 3px;
left: 3px;
width: 10px;
height: 10px;
border-radius: 50%;
background: white;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
content: "";
transition: transform 150ms ease;
}
.layer.active .switch {
background: var(--swatch);
}
.layer.active .switch::after {
transform: translateX(12px);
}
.panel-footer {
padding: 11px 16px 14px;
border-top: 1px solid var(--line);
color: #707973;
font-size: 9px;
line-height: 1.45;
}
.panel-footer strong {
color: #4b5b54;
}
.inspector {
position: fixed;
z-index: 6;
top: 94px;
right: 20px;
width: 300px;
padding: 16px;
border: 1px solid rgba(38, 51, 47, 0.14);
border-radius: 16px;
background: rgba(248, 246, 237, 0.91);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.inspector-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.inspector .eyebrow {
margin-bottom: 6px;
font-size: 8px;
}
.inspector h3 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 20px;
font-weight: 500;
line-height: 1.12;
}
.status-chip {
flex: none;
padding: 5px 7px;
border: 1px solid rgba(38, 51, 47, 0.15);
border-radius: 999px;
color: #5e6963;
background: rgba(255, 255, 255, 0.42);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.inspector-body {
margin: 11px 0 0;
color: #59665f;
font-size: 10.5px;
line-height: 1.55;
}
.inspector-divider {
height: 1px;
margin: 13px 0;
background: var(--line);
}
.detail-row {
display: grid;
grid-template-columns: 65px 1fr;
gap: 8px;
margin-top: 9px;
font-size: 9.5px;
line-height: 1.5;
}
.detail-row strong {
color: #3e5048;
font-size: 8px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.detail-row span {
color: #68736d;
}
.text-button {
margin-top: 13px;
padding: 0;
border: 0;
border-bottom: 1px solid #829087;
background: transparent;
color: #53665d;
cursor: pointer;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.04em;
}
.map-label {
position: absolute;
display: flex;
align-items: center;
gap: 6px;
padding: 5px 8px;
border: 1px solid rgba(38, 51, 47, 0.18);
border-radius: 999px;
background: rgba(248, 246, 237, 0.87);
box-shadow: 0 4px 12px rgba(30, 38, 33, 0.11);
color: #3c4c45;
cursor: pointer;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
transform: translate(-50%, -50%);
white-space: nowrap;
backdrop-filter: blur(8px);
}
.map-label::before {
width: 5px;
height: 5px;
border-radius: 50%;
background: #52675d;
content: "";
}
.map-label.secondary {
padding: 4px 7px;
font-size: 7px;
opacity: 0.92;
}
.map-label.hidden {
display: none;
}
.bottom-bar {
position: fixed;
z-index: 5;
bottom: 18px;
left: 50%;
display: flex;
align-items: center;
gap: 13px;
padding: 7px 12px;
border: 1px solid rgba(38, 51, 47, 0.12);
border-radius: 999px;
background: rgba(248, 246, 237, 0.83);
color: #657069;
box-shadow: 0 5px 18px rgba(30, 38, 33, 0.09);
font-size: 8px;
letter-spacing: 0.04em;
transform: translateX(-50%);
backdrop-filter: blur(12px);
pointer-events: none;
}
.bottom-bar b {
color: #43554c;
font-weight: 800;
}
.compass {
position: fixed;
z-index: 5;
right: 26px;
bottom: 22px;
display: grid;
place-items: center;
width: 46px;
height: 46px;
border: 1px solid rgba(38, 51, 47, 0.17);
border-radius: 50%;
background: rgba(248, 246, 237, 0.74);
color: #42564c;
font-size: 8px;
font-weight: 900;
backdrop-filter: blur(10px);
pointer-events: none;
}
.compass-arrow {
position: absolute;
top: 6px;
width: 0;
height: 0;
border-right: 4px solid transparent;
border-bottom: 13px solid #53685e;
border-left: 4px solid transparent;
transform-origin: 50% 16px;
}
.compass span {
margin-top: 13px;
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #d6d8ca;
transition: opacity 500ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
.loading-inner {
text-align: center;
}
.loading-mark {
width: 40px;
height: 40px;
margin: 0 auto 14px;
border: 2px solid rgba(38, 51, 47, 0.15);
border-top-color: #40584d;
border-radius: 50%;
animation: spin 1.2s linear infinite;
}
.loading strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: 20px;
font-weight: 500;
}
.loading small {
color: #69736e;
font-size: 9px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
dialog {
width: min(720px, calc(100vw - 32px));
max-height: calc(100vh - 40px);
padding: 0;
border: 0;
border-radius: 18px;
background: var(--paper-solid);
color: var(--ink);
box-shadow: 0 25px 90px rgba(20, 28, 24, 0.3);
}
dialog::backdrop {
background: rgba(28, 37, 32, 0.5);
backdrop-filter: blur(4px);
}
.dialog-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
padding: 24px 26px 18px;
border-bottom: 1px solid var(--line);
}
.dialog-head h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 28px;
font-weight: 500;
}
.dialog-head p {
max-width: 530px;
margin: 7px 0 0;
color: #69736d;
font-size: 11px;
line-height: 1.55;
}
.close-button {
width: 31px;
height: 31px;
border: 1px solid var(--line);
border-radius: 50%;
background: transparent;
color: #53625b;
cursor: pointer;
font-size: 17px;
line-height: 1;
}
.dialog-body {
padding: 20px 26px 25px;
}
.method-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.method-card {
padding: 14px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.35);
}
.method-card strong {
display: block;
margin-bottom: 5px;
font-size: 11px;
}
.method-card p {
margin: 0;
color: #69736d;
font-size: 10px;
line-height: 1.5;
}
.source-list {
margin: 18px 0 0;
padding-left: 18px;
color: #65716a;
font-size: 10px;
line-height: 1.6;
}
.source-list a {
color: #3f6e78;
}
.caveat {
margin-top: 18px;
padding: 13px;
border-left: 3px solid #c4904d;
background: rgba(196, 144, 77, 0.09);
color: #5e675f;
font-size: 10px;
line-height: 1.55;
}
@media (max-width: 980px) {
.inspector {
display: none;
}
.masthead {
max-width: 330px;
}
.views {
top: 16px;
right: 14px;
}
.view-button {
padding: 7px 8px;
}
}
@media (max-width: 700px) {
.masthead {
top: 14px;
left: 14px;
}
.masthead h1 {
font-size: 29px;
}
.masthead .subtitle {
max-width: 240px;
font-size: 10px;
}
.model-badge {
display: none;
}
.views {
top: auto;
right: 10px;
bottom: 10px;
flex-direction: column;
}
.view-button {
min-width: 70px;
padding: 6px 8px;
font-size: 9px;
}
.panel {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 40vh;
border-radius: 13px;
}
.panel-intro {
padding: 12px 14px 10px;
}
.panel-intro p {
display: none;
}
.section-label {
padding-top: 9px;
}
.layer {
padding: 7px 6px;
}
.bottom-bar {
display: none;
}
.compass {
top: 112px;
right: 14px;
bottom: auto;
}
.method-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<main id="app">
<div id="scene" aria-label="Interactive low-poly model of the Great Zimbabwe enclosures"></div>
<div id="labels"></div>
<header class="masthead">
<p class="eyebrow">Zimbabwe · c. 11th–15th centuries CE</p>
<h1>Great Zimbabwe</h1>
<p class="subtitle">Reading the dry-stone enclosures</p>
<div class="model-badge">Schematic interpretation · not a survey</div>
</header>
<nav class="views" aria-label="Camera views">
<button class="view-button active" data-view="all">All</button>
<button class="view-button" data-view="great">Great Enclosure</button>
<button class="view-button" data-view="hill">Hill Complex</button>
<button class="view-button" data-view="valley">Valley Ruins</button>
</nav>
<aside class="panel" aria-label="Visible features and interpretations">
<div class="panel-intro">
<h2>Build the reading</h2>
<p>Switch hypotheses on the same surviving enclosure geometry. Colors indicate interpretations, not certainty.</p>
</div>
<div class="section-label">
Surviving form
<span>Documented</span>
</div>
<div class="layers" id="survivingLayers"></div>
<div class="section-label">
Documentary trace
<span>Observed</span>
</div>
<div class="layers" id="documentaryLayers"></div>
<div class="section-label hypothesis">
Competing readings
<span>Hypotheses</span>
</div>
<div class="layers" id="interpretiveLayers"></div>
<div class="panel-footer">
<strong id="readingCount">0 interpretations active.</strong>
Readings may overlap and are not mutually exclusive.
</div>
</aside>
<aside class="inspector" aria-live="polite">
<div class="inspector-head">
<div>
<p class="eyebrow" id="inspectEyebrow">Documentary layer</p>
<h3 id="inspectTitle">Wall circuits and access</h3>
</div>
<span class="status-chip" id="inspectStatus">Observed</span>
</div>
<p class="inspector-body" id="inspectBody"></p>
<div class="inspector-divider"></div>
<div class="detail-row">
<strong id="detailLabelOne">Observed</strong>
<span id="detailOne"></span>
</div>
<div class="detail-row">
<strong id="detailLabelTwo">Model note</strong>
<span id="detailTwo"></span>
</div>
<button class="text-button" id="openMethod">Method, sources & limitations ↗</button>
</aside>
<div class="bottom-bar">
<span><b>Drag</b> orbit</span>
<span><b>Scroll / pinch</b> zoom</span>
<span><b>Shift + drag</b> pan</span>
</div>
<div class="compass" aria-hidden="true">
<div class="compass-arrow" id="compassArrow"></div>
<span>N</span>
</div>
<div class="loading" id="loading">
<div class="loading-inner">
<div class="loading-mark"></div>
<strong>Assembling the stone</strong>
<small>Schematic landscape model</small>
</div>
</div>
</main>
<dialog id="methodDialog">
<div class="dialog-head">
<div>
<p class="eyebrow">How to read this model</p>
<h2>Evidence first; interpretation second.</h2>
<p>
The model separates surviving architecture from arguments about what that
architecture meant. It does not present a single reconstructed past.
</p>
</div>
<button class="close-button" id="closeMethod" aria-label="Close">×</button>
</div>
<div class="dialog-body">
<div class="method-grid">
<article class="method-card">
<strong>Stone-grey massing</strong>
<p>
Curving walls, the conical tower, narrow access passage, Hill Complex
and Valley Ruins. These are simplified forms based on the commonly
documented layout, not measured individual stones.
</p>
</article>
<article class="method-card">
<strong>Cyan survey trace</strong>
<p>
A documentary layer marking wall circuits and access features. The
trace makes relationships easier to see but does not imply that every
point has been surveyed in this model.
</p>
</article>
<article class="method-card">
<strong>Coral · defence / control</strong>
<p>
One possible reading: walls, restricted access and elevated positions
could support surveillance or controlled movement. A primarily military
function for the Great Enclosure is not established.
</p>
</article>
<article class="method-card">
<strong>Teal · elite residence</strong>
<p>
One possible reading: dense compounds, specialized spaces and the tower
may have supported elite households, administration or a court. This does
not identify a particular ruler or household.
</p>
</article>
<article class="method-card">
<strong>Violet · ceremonial center</strong>
<p>
One possible reading: the tower, passage and open courts may have
structured gatherings, ceremonies or ancestral relationships. The
original ceremonial program cannot be reconstructed with certainty.
</p>
</article>
<article class="method-card">
<strong>Green · pastoral landscape</strong>
<p>
One possible reading: enclosures and open ground belonged to a mixed
agricultural and pastoral society. The green overlay does not classify
the Great Enclosure itself as a cattle pen.
</p>
</article>
</div>
<div class="caveat">
<strong>Model limitation.</strong> Wall heights, spacing, terrain and the
positions of open courts are diagrammatic. The landscape is not a measured
digital twin, individual stones are procedurally generated, and the colored
interpretations are explanatory overlays anchored to the same surviving
footprint. They should not be read as excavation plans.
</div>
<ol class="source-list">
<li>
UNESCO World Heritage Centre,
<a href="https://whc.unesco.org/en/list/364/" target="_blank" rel="noreferrer">
“Great Zimbabwe National Monument”
</a>.
</li>
<li>
Paul MacKenzie, <em>Great Zimbabwe: The Origins of an African City</em>
(2012).
</li>
<li>
Robert Soper, “The UNESCO General History of Africa”, discussions of
Great Zimbabwe and the wider Shona monumental tradition.
</li>
<li>
Names such as Great Enclosure, Hill Complex and Valley Ruins follow the
site’s commonly used interpretive nomenclature.
</li>
</ol>
</div>
</dialog>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Utilities and scene
// ------------------------------------------------------------
const $ = (selector) => document.querySelector(selector);
const clamp = THREE.MathUtils.clamp;
const lerp = THREE.MathUtils.lerp;
function seededRandom(seed) {
return function () {
let t = seed += 0x6D2B79F5;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd6d8ca);
scene.fog = new THREE.Fog(0xd6d8ca, 105, 235);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
$("#scene").appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
350
);
const hemisphere = new THREE.HemisphereLight(0xf5f0dd, 0x59645a, 2.05);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1cf, 3.2);
sun.position.set(-48, 78, 36);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -95;
sun.shadow.camera.right = 95;
sun.shadow.camera.top = 85;
sun.shadow.camera.bottom = -85;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 210;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d4dc, 0.8);
fill.position.set(60, 28, -40);
scene.add(fill);
const terrainHeight = (x, z) => {
const mainHill = Math.hypot((x + 42) / 20, (z + 12) / 16);
const westernRise = Math.hypot((x + 57) / 32, (z - 17) / 15);
const southernRise = Math.hypot((x - 48) / 36, (z - 54) / 15);
const distantRidge = Math.hypot((x + 72) / 25, (z + 64) / 17);
let h = 0;
h += 13.0 * Math.max(0, 1 - mainHill * mainHill);
h += 2.4 * Math.max(0, 1 - westernRise * westernRise);
h += 1.8 * Math.max(0, 1 - southernRise * southernRise);
h += 2.7 * Math.max(0, 1 - distantRidge * distantRidge);
h += 0.28 * Math.sin(x * 0.09) * Math.cos(z * 0.11);
return h;
};
function createTerrain() {
const segments = 92;
const size = 180;
const count = (segments + 1) * (segments + 1);
const positions = new Float32Array(count * 3);
const colors = new Float32Array(count * 3);
const indices = [];
const low = new THREE.Color(0xa69a72);
const mid = new THREE.Color(0x858765);
const high = new THREE.Color(0x5d694f);
const color = new THREE.Color();
let p = 0;
for (let iz = 0; iz <= segments; iz++) {
const z = -size / 2 + (iz / segments) * size;
for (let ix = 0; ix <= segments; ix++) {
const x = -size / 2 + (ix / segments) * size;
const y = terrainHeight(x, z);
positions[p * 3] = x;
positions[p * 3 + 1] = y;
positions[p * 3 + 2] = z;
const grain = 0.5 + 0.5 * Math.sin(x * 0.33 + Math.cos(z * 0.21));
color.copy(low).lerp(mid, clamp(y / 8 + grain * 0.12, 0, 1));
if (y > 7) color.lerp(high, clamp((y - 7) / 12, 0, 1));
color.offsetHSL(0, 0, (grain - 0.5) * 0.055);
colors[p * 3] = color.r;
colors[p * 3 + 1] = color.g;
colors[p * 3 + 2] = color.b;
p++;
}
}
for (let iz = 0; iz < segments; iz++) {
for (let ix = 0; ix < segments; ix++) {
const a = iz * (segments + 1) + ix;
const b = a + segments + 1;
const c = b + 1;
const d = a + 1;
if ((ix + iz) % 2 === 0) {
indices.push(a, b, d, b, c, d);
} else {
indices.push(a, b, c, a, c, d);
}
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
metalness: 0,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.receiveShadow = true;
scene.add(mesh);
}
createTerrain();
// ------------------------------------------------------------
// Procedural masonry
// ------------------------------------------------------------
const stoneMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1,
metalness: 0
});
const stonePalette = [
0x776f61,
0x8e8370,
0x9a8e78,
0x69645b,
0xa89b82,
0x817b6b
];
function ellipsePoints(cx, cz, rx, rz, count = 120, irregularity = 0, phase = 0) {
const points = [];
for (let i = 0; i < count; i++) {
const angle = (i / count) * Math.PI * 2;
const variation =
1 +
irregularity * Math.sin(angle * 3 + phase) +
irregularity * 0.45 * Math.sin(angle * 7 - phase * 0.7);
points.push({
x: cx + Math.cos(angle) * rx * variation,
z: cz + Math.sin(angle) * rz * variation,
angle
});
}
return points;
}
function resamplePath(points, spacing = 1.2, closed = false) {
const source = points.map((p) => new THREE.Vector2(p.x, p.z));
const lengths = [];
let total = 0;
const segmentCount = closed ? source.length : source.length - 1;
for (let i = 0; i < segmentCount; i++) {
const a = source[i];
const b = source[(i + 1) % source.length];
const length = a.distanceTo(b);
lengths.push(length);
total += length;
}
const count = Math.max(2, Math.ceil(total / spacing));
const output = [];
let segment = 0;
let traversed = 0;
for (let i = 0; i < count; i++) {
const distance = closed
? (i / count) * total
: (i / (count - 1)) * total;
while (
segment < lengths.length - 1 &&
traversed + lengths[segment] < distance
) {
traversed += lengths[segment];
segment++;
}
const local = clamp((distance - traversed) / lengths[segment], 0, 1);
const a = source[segment];
const b = source[(segment + 1) % source.length];
const x = lerp(a.x, b.x, local);
const z = lerp(a.y, b.y, local);
const tx = b.x - a.x;
const tz = b.y - a.y;
const length = Math.hypot(tx, tz) || 1;
output.push({
x,
z,
tx: tx / length,
tz: tz / length,
nx: tz / length,
nz: -tx / length
});
}
return output;
}
function buildWall(
points,
{
height = 5,
thickness = 3,
closed = false,
seed = 1,
spacing = 1.22,
heightFunction = null
} = {}
) {
const path = resamplePath(points, spacing, closed);
const random = seededRandom(seed);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
let instanceCount = 0;
for (let i = 0; i < path.length; i++) {
const h = heightFunction ? heightFunction(path[i], i, path.length) : height;
instanceCount += Math.max(2, Math.round(h / 0.92)) *
Math.max(1, Math.round(thickness / 1.05));
}
const geometry = new THREE.BoxGeometry(1, 1, 1);
const mesh = new THREE.InstancedMesh(geometry, stoneMaterial, instanceCount);
mesh.castShadow = true;
mesh.receiveShadow = true;
let instance = 0;
for (let i = 0; i < path.length; i++) {
const point = path[i];
const wallHeight = heightFunction
? heightFunction(point, i, path.length)
: height;
const courses = Math.max(2, Math.round(wallHeight / 0.92));
const columns = Math.max(1, Math.round(thickness / 1.05));
for (let course = 0; course < courses; course++) {
const taper = 1 - 0.11 * (course / Math.max(1, courses - 1));
for (let column = 0; column < columns; column++) {
const offset = (column - (columns - 1) / 2) * 1.04 * taper;
const jitter = (random() - 0.5) * 0.14;
const x = point.x + point.nx * offset + jitter;
const z = point.z + point.nz * offset + (random() - 0.5) * 0.12;
const y = terrainHeight(x, z) + course * 0.92 + 0.46 +
(random() - 0.5) * 0.08;
dummy.position.set(x, y, z);
dummy.rotation.set(
(random() - 0.5) * 0.035,
-Math.atan2(point.tz, point.tx),
(random() - 0.5) * 0.025
);
dummy.scale.set(
spacing * (0.88 + random() * 0.15),
0.88 + random() * 0.1,
(thickness / columns) * 1.02 * taper * (0.94 + random() * 0.1)
);
dummy.updateMatrix();
mesh.setMatrixAt(instance, dummy.matrix);
color.setHex(stonePalette[Math.floor(random() * stonePalette.length)]);
color.offsetHSL(0, 0, (random() - 0.5) * 0.035);
mesh.setColorAt(instance, color);
instance++;
}
}
}
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
return mesh;
}
function buildTower(cx, cz, seed = 91) {
const random = seededRandom(seed);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
const courses = 9;
let count = 0;
for (let c = 0; c < courses; c++) {
const radius = 2.9 - c * 0.17;
count += Math.max(8, Math.round((Math.PI * 2 * radius) / 0.92));
}
const mesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(1, 1, 1),
stoneMaterial,
count
);
mesh.castShadow = true;
mesh.receiveShadow = true;
let instance = 0;
const ground = terrainHeight(cx, cz);
for (let course = 0; course < courses; course++) {
const radius = 2.9 - course * 0.17;
const blocks = Math.max(8, Math.round((Math.PI * 2 * radius) / 0.92));
const arcLength = (Math.PI * 2 * radius) / blocks;
for (let i = 0; i < blocks; i++) {
const angle = (i / blocks) * Math.PI * 2 + course * 0.035;
const x = cx + Math.sin(angle) * radius;
const z = cz + Math.cos(angle) * radius;
const y = ground + course * 0.91 + 0.45;
dummy.position.set(x, y, z);
dummy.rotation.set(0, angle, 0);
dummy.scale.set(
arcLength * 0.9,
0.88 + random() * 0.08,
0.94 + random() * 0.08
);
dummy.updateMatrix();
mesh.setMatrixAt(instance, dummy.matrix);
color.setHex(stonePalette[Math.floor(random() * stonePalette.length)]);
mesh.setColorAt(instance, color);
instance++;
}
}
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
return mesh;
}
// Great Enclosure: incomplete ellipse with a southeastern access opening.
const greatEntryAngle = 0.58;
const greatGap = 0.072;
const greatFullPath = ellipsePoints(0, 0, 24, 17.5, 190, 0.022, 0.8);
const greatPath = greatFullPath.filter((point) => {
let difference = Math.abs(point.angle - greatEntryAngle);
difference = Math.min(difference, Math.PI * 2 - difference);
return difference > greatGap;
});
const greatHeight = (point) =>
5.1 +
3.1 * clamp((point.x + 24) / 48, 0, 1) +
1.05 * Math.sin(point.x * 0.31);
const greatGroup = new THREE.Group();
const greatWall = buildWall(greatPath, {
heightFunction: greatHeight,
thickness: 4.6,
seed: 42,
spacing: 1.18
});
greatGroup.add(greatWall);
scene.add(greatGroup);
// Narrow passage and tower.
const featureGroup = new THREE.Group();
const passageLeft = [
{ x: 23.7, z: 8.5 },
{ x: 20.1, z: 8.0 },
{ x: 16.2, z: 6.7 },
{ x: 12.0, z: 5.6 },
{ x: 8.3, z: 5.0 }
];
const passageRight = [
{ x: 23.7, z: 10.8 },
{ x: 20.1, z: 10.3 },
{ x: 16.2, z: 9.0 },
{ x: 12.0, z: 7.9 },
{ x: 8.3, z: 7.1 }
];
featureGroup.add(buildWall(passageLeft, {
height: 4.1,
thickness: 1.35,
seed: 51,
spacing: 1.0
}));
featureGroup.add(buildWall(passageRight, {
height: 3.7,
thickness: 1.35,
seed: 52,
spacing: 1.0
}));
const towerX = 7.0;
const towerZ = 5.5;
featureGroup.add(buildTower(towerX, towerZ));
const doorway = new THREE.Mesh(
new THREE.BoxGeometry(0.22, 1.75, 0.76),
new THREE.MeshBasicMaterial({ color: 0x262722 })
);
doorway.position.set(
towerX + 2.78,
terrainHeight(towerX, towerZ) + 0.92,
towerZ + 0.05
);
doorway.castShadow = true;
featureGroup.add(doorway);
// Small domestic-looking foundation, kept separate from any interpretation.
const hutPath = ellipsePoints(-8.5, 2.4, 2.4, 1.8, 38, 0.06, 1.2);
featureGroup.add(buildWall(hutPath, {
closed: true,
height: 1.6,
thickness: 0.8,
seed: 57,
spacing: 0.82
}));
scene.add(featureGroup);
// Hill Complex.
const hillGroup = new THREE.Group();
const hillOuterPath = ellipsePoints(-42, -12, 18.5, 13.5, 145, 0.075, 0.2);
const hillInnerPath = ellipsePoints(-42.8, -12.2, 10.8, 7.4, 100, 0.055, 1.4);
hillGroup.add(buildWall(hillOuterPath, {
closed: true,
height: 3.7,
thickness: 2.35,
seed: 71,
spacing: 1.13
}));
hillGroup.add(buildWall(hillInnerPath, {
closed: true,
height: 3.1,
thickness: 1.8,
seed: 72,
spacing: 1.02
}));
scene.add(hillGroup);
// Valley Ruins.
const valleyGroup = new THREE.Group();
const valleyA = ellipsePoints(28, 23, 7.4, 6.2, 76, 0.045, 0.5);
const valleyB = ellipsePoints(38.5, 29.2, 5.4, 4.5, 58, 0.06, 1.3);
valleyGroup.add(buildWall(valleyA, {
closed: true,
height: 3.2,
thickness: 1.75,
seed: 81,
spacing: 1.02
}));
valleyGroup.add(buildWall(valleyB, {
closed: true,
height: 2.4,
thickness: 1.55,
seed: 82,
spacing: 0.95
}));
valleyGroup.add(buildWall([
{ x: 33.4, z: 25.0 },
{ x: 36.0, z: 26.3 },
{ x: 39.0, z: 27.2 }
], {
height: 2.0,
thickness: 1.25,
seed: 83,
spacing: 1.0
}));
scene.add(valleyGroup);
// ------------------------------------------------------------
// Sparse low-poly landscape details
// ------------------------------------------------------------
function insideEllipse(x, z, cx, cz, rx, rz) {
return ((x - cx) / rx) ** 2 + ((z - cz) / rz) ** 2 < 1.08;
}
const landscapeGroup = new THREE.Group();
const landscapeRandom = seededRandom(310);
const shrubCount = 72;
const shrubMesh = new THREE.InstancedMesh(
new THREE.IcosahedronGeometry(1, 0),
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1,
flatShading: true
}),
shrubCount
);
const shrubDummy = new THREE.Object3D();
const shrubColor = new THREE.Color();
let shrubIndex = 0;
while (shrubIndex < shrubCount) {
const x = -83 + landscapeRandom() * 166;
const z = -80 + landscapeRandom() * 155;
if (
insideEllipse(x, z, 0, 0, 28, 21) ||
insideEllipse(x, z, -42, -12, 22, 17) ||
insideEllipse(x, z, 28, 23, 9, 8) ||
insideEllipse(x, z, 38.5, 29.2, 7, 6)
) continue;
const scale = 0.45 + landscapeRandom() * 1.2;
shrubDummy.position.set(x, terrainHeight(x, z) + scale * 0.45, z);
shrubDummy.rotation.set(
landscapeRandom() * 0.4,
landscapeRandom() * Math.PI,
landscapeRandom() * 0.2
);
shrubDummy.scale.set(
scale * (0.8 + landscapeRandom() * 0.35),
scale * (0.65 + landscapeRandom() * 0.5),
scale * (0.8 + landscapeRandom() * 0.35)
);
shrubDummy.updateMatrix();
shrubMesh.setMatrixAt(shrubIndex, shrubDummy.matrix);
shrubColor.setHex(
landscapeRandom() > 0.55 ? 0x5f6f4d : 0x78805a
);
shrubMesh.setColorAt(shrubIndex, shrubColor);
shrubIndex++;
}
shrubMesh.instanceMatrix.needsUpdate = true;
if (shrubMesh.instanceColor) shrubMesh.instanceColor.needsUpdate = true;
shrubMesh.castShadow = true;
shrubMesh.receiveShadow = true;
landscapeGroup.add(shrubMesh);
const rockCount = 42;
const rockMesh = new THREE.InstancedMesh(
new THREE.DodecahedronGeometry(0.5, 0),
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1,
flatShading: true
}),
rockCount
);
const rockDummy = new THREE.Object3D();
const rockColor = new THREE.Color();
for (let i = 0; i < rockCount; i++) {
const angle = landscapeRandom() * Math.PI * 2;
const radius = 36 + landscapeRandom() * 48;
const x = Math.cos(angle) * radius;
const z = Math.sin(angle) * radius - 4;
const scale = 0.3 + landscapeRandom() * 0.75;
rockDummy.position.set(x, terrainHeight(x, z) + scale * 0.25, z);
rockDummy.rotation.set(
landscapeRandom(),
landscapeRandom() * Math.PI,
landscapeRandom()
);
rockDummy.scale.set(scale * 1.4, scale * 0.8, scale);
rockDummy.updateMatrix();
rockMesh.setMatrixAt(i, rockDummy.matrix);
rockColor.setHex(landscapeRandom() > 0.5 ? 0x8a806c : 0x746d60);
rockMesh.setColorAt(i, rockColor);
}
rockMesh.instanceMatrix.needsUpdate = true;
if (rockMesh.instanceColor) rockMesh.instanceColor.needsUpdate = true;
rockMesh.castShadow = true;
rockMesh.receiveShadow = true;
landscapeGroup.add(rockMesh);
scene.add(landscapeGroup);
// ------------------------------------------------------------
// Documentary and interpretive overlays
// ------------------------------------------------------------
function addTube(
group,
points,
color,
{
closed = false,
radius = 0.1,
opacity = 0.95,
dashed = false,
dashSize = 1.8,
gapSize = 1.2
} = {}
) {
if (!points.length) return;
if (dashed) {
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineDashedMaterial({
color,
transparent: true,
opacity,
dashSize,
gapSize,
depthTest: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
line.renderOrder = 30;
group.add(line);
return;
}
const curve = new THREE.CatmullRomCurve3(points, closed, "catmullrom", 0.12);
const geometry = new THREE.TubeGeometry(
curve,
Math.min(420, Math.max(32, points.length * 2)),
radius,
5,
closed
);
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity,
depthTest: false,
depthWrite: false
});
const mesh = new THREE.Mesh(geometry, material);
mesh.renderOrder = 30;
group.add(mesh);
}
function groundPoints(points, lift = 0.3) {
return points.map((point) => {
const y = terrainHeight(point.x, point.z) + lift;
return new THREE.Vector3(point.x, y, point.z);
});
}
function addMarker(group, x, z, color, height = 1.3, size = 0.55) {
const marker = new THREE.Mesh(
new THREE.OctahedronGeometry(size, 0),
new THREE.MeshBasicMaterial({
color,
depthTest: false,
transparent: true,
opacity: 0.95
})
);
marker.position.set(x, terrainHeight(x, z) + height, z);
marker.renderOrder = 40;
group.add(marker);
return marker;
}
const surveyGroup = new THREE.Group();
addTube(
surveyGroup,
greatPath.map((point) => new THREE.Vector3(
point.x,
terrainHeight(point.x, point.z) + greatHeight(point) + 0.18,
point.z
)),
0x48b9d1,
{ radius: 0.095 }
);
addTube(surveyGroup, groundPoints(passageLeft, 4.3), 0x48b9d1, { radius: 0.08 });
addTube(surveyGroup, groundPoints(passageRight, 3.9), 0x48b9d1, { radius: 0.08 });
addTube(
surveyGroup,
groundPoints(hillOuterPath, 3.9),
0x48b9d1,
{ closed: true, radius: 0.09 }
);
addTube(
surveyGroup,
groundPoints(hillInnerPath, 3.3),
0x48b9d1,
{ closed: true, radius: 0.08 }
);
addTube(
surveyGroup,
groundPoints(valleyA, 3.4),
0x48b9d1,
{ closed: true, radius: 0.08 }
);
addTube(
surveyGroup,
groundPoints(valleyB, 2.6),
0x48b9d1,
{ closed: true, radius: 0.08 }
);
addMarker(surveyGroup, 23.0, 9.6, 0x48b9d1, 1.5, 0.7);
addMarker(surveyGroup, towerX, towerZ, 0x48b9d1, 9.5, 0.8);
addMarker(surveyGroup, -42.8, -12.2, 0x48b9d1, 4.8, 0.65);
scene.add(surveyGroup);
// 1. Defence / controlled access.
const defenseGroup = new THREE.Group();
const defenseColor = 0xe66e51;
addTube(
defenseGroup,
groundPoints(ellipsePoints(0, 0, 25.7, 19.1, 130, 0.02), 0.42),
defenseColor,
{
closed: true,
radius: 0.105,
opacity: 0.9,
dashed: true,
dashSize: 2.1,
gapSize: 1.35
}
);
addTube(
defenseGroup,
groundPoints(passageLeft, 4.6),
defenseColor,
{ radius: 0.12, dashed: true, dashSize: 1.1, gapSize: 0.7 }
);
addTube(
defenseGroup,
groundPoints(passageRight, 4.2),
defenseColor,
{ radius: 0.12, dashed: true, dashSize: 1.1, gapSize: 0.7 }
);
addTube(
defenseGroup,
groundPoints(ellipsePoints(-42, -12, 19.7, 14.5, 100), 0.45),
defenseColor,
{
closed: true,
radius: 0.1,
dashed: true,
dashSize: 1.6,
gapSize: 1
}
);
addMarker(defenseGroup, 22.4, 9.7, defenseColor, 1.5, 0.7);
addMarker(defenseGroup, -52, -17, defenseColor, 4.0, 0.65);
scene.add(defenseGroup);
// 2. Elite residence and court.
const eliteGroup = new THREE.Group();
const eliteColor = 0x2aa6a0;
addTube(
eliteGroup,
groundPoints(ellipsePoints(-42.8, -12.2, 7.4, 5.0, 90), 0.38),
eliteColor,
{ closed: true, radius: 0.12, opacity: 0.92 }
);
addTube(
eliteGroup,
groundPoints(ellipsePoints(towerX, towerZ, 4.8, 4.4, 80), 0.38),
eliteColor,
{ closed: true, radius: 0.1, opacity: 0.92 }
);
addTube(
eliteGroup,
groundPoints([
{ x: -34.5, z: -13.5 },
{ x: -30.2, z: -11.0 },
{ x: -26.5, z: -8.5 }
], 0.4),
eliteColor,
{ radius: 0.09, dashed: true, dashSize: 1.4, gapSize: 0.9 }
);
addMarker(eliteGroup, -42.8, -12.2, eliteColor, 5.2, 0.75);
addMarker(eliteGroup, towerX, towerZ, eliteColor, 10.0, 0.65);
scene.add(eliteGroup);
// 3. Ceremonial or ancestral center.
const ritualGroup = new THREE.Group();
const ritualColor = 0xb45bd1;
addTube(
ritualGroup,
groundPoints(ellipsePoints(towerX, towerZ, 5.5, 4.8, 90), 0.42),
ritualColor,
{ closed: true, radius: 0.12, opacity: 0.95 }
);
addTube(
ritualGroup,
groundPoints(ellipsePoints(-5.5, -0.7, 10.5, 7.4, 110), 0.35),
ritualColor,
{
closed: true,
radius: 0.09,
opacity: 0.85,
dashed: true,
dashSize: 1.8,
gapSize: 1.1
}
);
addTube(
ritualGroup,
groundPoints([
{ x: 8.0, z: 5.5 },
{ x: 13.0, z: 7.0 },
{ x: 18.5, z: 8.8 },
{ x: 23.0, z: 9.6 },
{ x: 17.0, z: 2.0 },
{ x: 10.0, z: -3.0 },
{ x: -0.5, z: -5.0 },
{ x: -18.0, z: -8.0 },
{ x: -31.0, z: -10.0 },
{ x: -42.0, z: -12.0 }
], 0.45),
ritualColor,
{ radius: 0.1, dashed: true, dashSize: 1.25, gapSize: 1.05 }
);
addMarker(ritualGroup, towerX, towerZ, ritualColor, 10.4, 0.8);
scene.add(ritualGroup);
// 4. Pastoral / productive landscape.
const pastoralGroup = new THREE.Group();
const pastoralColor = 0x72994e;
addTube(
pastoralGroup,
groundPoints(ellipsePoints(31.5, 25, 11.5, 9.0, 110, 0.035), 0.34),
pastoralColor,
{
closed: true,
radius: 0.09,
dashed: true,
dashSize: 2,
gapSize: 1.4
}
);
const fieldLines = [
[
{ x: 12, z: -18 },
{ x: 24, z: -19 },
{ x: 32, z: -16 }
],
[
{ x: 12, z: -18 },
{ x: 15, z: -8 },
{ x: 18, z: 3 }
],
[
{ x: 24, z: -19 },
{ x: 28, z: -9 },
{ x: 30, z: 2 }
],
[
{ x: 32, z: -16 },
{ x: 37, z: -8 },
{ x: 40, z: 4 }
],
[
{ x: 16, z: -7 },
{ x: 25, z: -8 },
{ x: 29, z: -1 }
]
];
fieldLines.forEach((line) => {
addTube(pastoralGroup, groundPoints(line, 0.28), pastoralColor, {
radius: 0.07,
opacity: 0.75,
dashed: true,
dashSize: 1.5,
gapSize: 1.2
});
});
scene.add(pastoralGroup);
// ------------------------------------------------------------
// Layer definitions and interface
// ------------------------------------------------------------
const layerDefinitions = {
great: {
group: greatGroup,
container: "#survivingLayers",
type: "surviving",
color: "#8d8270",
title: "Great Enclosure",
subtitle: "Curving coursed wall",
status: "Surviving form",
body: "The largest enclosure is represented by a thick, curving dry-stone wall with a narrow access opening. The wall massing is simplified, but the broad oval footprint and changing wall height are recognizable features of the monument.",
labelOne: "Observed",
textOne: "A large curving enclosure wall, broad gateways and passages, and substantial masonry survive in the archaeological record.",
labelTwo: "Model note",
textTwo: "Stone courses and individual blocks are procedural. Wall height and exact curvature are diagrammatic rather than survey-derived."
},
hill: {
group: hillGroup,
container: "#survivingLayers",
type: "surviving",
color: "#8d8270",
title: "Hill Complex",
subtitle: "Terraced enclosures on the granite hill",
status: "Surviving form",
body: "The elevated complex is shown as connected outer and inner enclosures. Its steep setting and dense masonry make it visually distinct from the open enclosures on the plain.",
labelOne: "Observed",
textOne: "Multiple dry-stone enclosures, platforms and walls occupy the hill above the central complex.",
labelTwo: "Model note",
textTwo: "The terrain expresses the prominent landscape position; individual terraces and buildings are not reconstructed."
},
valley: {
group: valleyGroup,
container: "#survivingLayers",
type: "surviving",
color: "#8d8270",
title: "Valley Ruins",
subtitle: "Smaller enclosures beyond the main complex",
status: "Surviving form",
body: "Smaller circular or oval enclosures and connecting walls form the group conventionally called the Valley Ruins. Their arrangement broadens the settlement beyond the monumental center.",
labelOne: "Observed",
textOne: "Several smaller enclosures, wall segments and structures survive in the valley portion of the site.",
labelTwo: "Model note",
textTwo: "The relative positions are diagrammatic and are not intended as a measured site plan."
},
features: {
group: featureGroup,
container: "#survivingLayers",
type: "surviving",
color: "#8d8270",
title: "Tower, passage & platforms",
subtitle: "Access and specialized structures",
status: "Surviving form",
body: "The conical tower and the constricted passage between parallel walls are highlighted because they are among the most discussed surviving architectural features at Great Zimbabwe.",
labelOne: "Observed",
textOne: "The distinctive tapering tower, narrow passage system and smaller stone platforms are extant features.",
labelTwo: "Model note",
textTwo: "The tower is assembled from stylized courses. The passage route is schematic, and the small platform is not assigned a definite use."
},
survey: {
group: surveyGroup,
container: "#documentaryLayers",
type: "documentary",
color: "#48b9d1",
title: "Wall circuits & access",
subtitle: "Documentary highlight layer",
status: "Observed",
body: "This cyan layer traces the principal enclosure circuits, access route and tower location. It makes the surviving spatial relationships easier to compare with the interpretive readings.",
labelOne: "Function",
textOne: "A visual index of documented architectural relationships, not an archaeological measurement.",
labelTwo: "Limitation",
textTwo: "A continuous line simplifies gaps, changes in construction and the much more complicated excavated wall fabric."
},
defense: {
group: defenseGroup,
container: "#interpretiveLayers",
type: "interpretation",
color: "#e66e51",
title: "Defence / controlled access",
subtitle: "One possible functional reading",
status: "Hypothesis",
body: "The walls, constricted entrance and elevated Hill Complex can be read as a system for surveillance, controlled movement or the display of authority. This overlay marks those relationships rather than claiming that the monument was a conventional fortress.",
labelOne: "Plausible from",
textOne: "Restricted circulation, wall mass, elevated sightlines and the presence of access points that can be regulated.",
labelTwo: "Caution",
textTwo: "There is no clear evidence for sustained siege warfare, and a primarily military function for the Great Enclosure is not established."
},
elite: {
group: eliteGroup,
container: "#interpretiveLayers",
type: "interpretation",
color: "#2aa6a0",
title: "Elite residence & court",
subtitle: "One possible functional reading",
status: "Hypothesis",
body: "The concentration of structures on the Hill Complex, specialized internal spaces and the conical tower have supported readings involving elite households, administration or a courtly center.",
labelOne: "Plausible from",
textOne: "Denser and more specialized architecture, prominent internal structures and unequal access to prominent spaces.",
labelTwo: "Caution",
textTwo: "The overlay cannot identify a particular family, ruler or political institution, and residence and assembly functions could overlap."
},
ritual: {
group: ritualGroup,
container: "#interpretiveLayers",
type: "interpretation",
color: "#b45bd1",
title: "Ceremonial & ancestral center",
subtitle: "One possible functional reading",
status: "Hypothesis",
body: "The tower, narrow passage, open court-like spaces and a processional route through the complex may have structured gatherings, ceremony or relationships with ancestors and sacred landscapes.",
labelOne: "Plausible from",
textOne: "Monumentality, restricted movement, open assembly space and the continuing sacred importance of the site for Shona communities.",
labelTwo: "Caution",
textTwo: "The original ritual program cannot be recovered with certainty, and the suggested route is an explanatory overlay rather than a documented path."
},
pastoral: {
group: pastoralGroup,
container: "#interpretiveLayers",
type: "interpretation",
color: "#72994e",
title: "Pastoral & productive landscape",
subtitle: "One possible functional reading",
status: "Hypothesis",
body: "The monument sat within a wider agricultural and pastoral economy. The Valley Ruins, open common areas and surrounding productive landscape can be read as part of a settlement system rather than isolated architecture.",
labelOne: "Plausible from",
textOne: "Smaller enclosures, open land, varied construction and evidence for an agricultural-pastoral society around the monumental core.",
labelTwo: "Caution",
textTwo: "The green zone is conceptual. It does not identify specific crops, pastures or livestock routes and does not label the Great Enclosure as a cattle pen."
}
};
const layerButtons = new Map();
const layerState = {};
for (const [key, definition] of Object.entries(layerDefinitions)) {
const defaultOn = ["great", "hill", "valley", "features", "survey"].includes(key);
layerState[key] = defaultOn;
definition.group.visible = defaultOn;
const button = document.createElement("button");
button.className = `layer${defaultOn ? " active" : ""}`;
button.dataset.layer = key;
button.setAttribute("aria-pressed", String(defaultOn));
button.style.setProperty("--swatch", definition.color);
button.innerHTML = `
<span class="swatch" aria-hidden="true"></span>
<span class="layer-copy">
<span class="layer-title">${definition.title}</span>
<span class="layer-subtitle">${definition.subtitle}</span>
</span>
<span class="switch" aria-hidden="true"></span>
`;
button.addEventListener("click", () => {
layerState[key] = !layerState[key];
definition.group.visible = layerState[key];
button.classList.toggle("active", layerState[key]);
button.setAttribute("aria-pressed", String(layerState[key]));
selectLayer(key);
updateReadingCount();
});
$(definition.container).appendChild(button);
layerButtons.set(key, button);
}
function updateReadingCount() {
const count = ["defense", "elite", "ritual", "pastoral"]
.filter((key) => layerState[key]).length;
$("#readingCount").textContent =
`${count} interpretation${count === 1 ? "" : "s"} active.`;
}
function selectLayer(key) {
const definition = layerDefinitions[key];
if (!definition) return;
for (const [buttonKey, button] of layerButtons) {
button.classList.toggle("selected", buttonKey === key);
}
$("#inspectEyebrow").textContent =
definition.type === "surviving"
? "Documented · surviving form"
: definition.type === "documentary"
? "Documentary layer"
: "Competing interpretation";
$("#inspectTitle").textContent = definition.title;
$("#inspectStatus").textContent = definition.status;
$("#inspectBody").textContent = definition.body;
$("#detailLabelOne").textContent = definition.labelOne;
$("#detailOne").textContent = definition.textOne;
$("#detailLabelTwo").textContent = definition.labelTwo;
$("#detailTwo").textContent = definition.textTwo;
}
updateReadingCount();
selectLayer("survey");
// ------------------------------------------------------------
// Map labels
// ------------------------------------------------------------
const labelDefinitions = [
{
text: "Great Enclosure",
position: new THREE.Vector3(-1, 8.4, -5),
view: "great",
secondary: false
},
{
text: "Conical Tower",
position: new THREE.Vector3(towerX, 10.8, towerZ),
view: "tower",
secondary: true
},
{
text: "Narrow Passage",
position: new THREE.Vector3(17.3, 6.0, 7.9),
view: "tower",
secondary: true
},
{
text: "Hill Complex",
position: new THREE.Vector3(-42, 18.2, -12),
view: "hill",
secondary: false
},
{
text: "Valley Ruins",
position: new THREE.Vector3(31, 5.4, 25),
view: "valley",
secondary: false
},
{
text: "Common Area",
position: new THREE.Vector3(-24, 3.5, -8),
view: "great",
secondary: true
}
];
const projectedLabels = [];
labelDefinitions.forEach((definition) => {
const element = document.createElement("button");
element.className = `map-label${definition.secondary ? " secondary" : ""}`;
element.textContent = definition.text;
element.addEventListener("click", () => setView(definition.view));
$("#labels").appendChild(element);
projectedLabels.push({ element, position: definition.position });
});
// ------------------------------------------------------------
// Custom camera controls
// ------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(-2, 3, 0),
radius: 113,
theta: 0.78,
phi: 0.78
};
const cameraGoal = {
target: cameraState.target.clone(),
radius: cameraState.radius,
theta: cameraState.theta,
phi: cameraState.phi
};
function applyCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
const viewPresets = {
all: {
target: new THREE.Vector3(-2, 3, 0),
radius: 113,
theta: 0.78,
phi: 0.78
},
great: {
target: new THREE.Vector3(0, 3.5, 0),
radius: 67,
theta: 0.63,
phi: 0.69
},
hill: {
target: new THREE.Vector3(-42, 9.5, -12),
radius: 48,
theta: 0.72,
phi: 0.76
},
valley: {
target: new THREE.Vector3(30, 1.5, 25),
radius: 42,
theta: 0.72,
phi: 0.84
},
tower: {
target: new THREE.Vector3(10, 3, 6),
radius: 38,
theta: 0.52,
phi: 0.70
}
};
function setView(name) {
const preset = viewPresets[name] || viewPresets.all;
cameraGoal.target.copy(preset.target);
cameraGoal.radius = preset.radius;
cameraGoal.theta = preset.theta;
cameraGoal.phi = preset.phi;
document.querySelectorAll(".view-button").forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
document.querySelectorAll(".view-button").forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
const canvas = renderer.domElement;
const pointers = new Map();
let dragMode = "orbit";
let pinchDistance = 0;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
dragMode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
canvas.classList.add("dragging");
if (pointers.size === 2) {
const values = [...pointers.values()];
pinchDistance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size >= 2) {
const values = [...pointers.values()];
const distance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
if (pinchDistance > 0 && distance > 0) {
cameraGoal.radius = clamp(
cameraGoal.radius * (pinchDistance / distance),
25,
180
);
}
pinchDistance = distance;
return;
}
if (dragMode === "pan" || event.shiftKey) {
const right = new THREE.Vector3()
.setFromMatrixColumn(camera.matrixWorld, 0);
right.y = 0;
right.normalize();
const forward = new THREE.Vector3()
.setFromMatrixColumn(camera.matrixWorld, 2);
forward.y = 0;
forward.normalize().negate();
const scale = cameraGoal.radius * 0.00135;
cameraGoal.target.addScaledVector(right, -dx * scale);
cameraGoal.target.addScaledVector(forward, -dy * scale);
} else {
cameraGoal.theta -= dx * 0.006;
cameraGoal.phi = clamp(cameraGoal.phi - dy * 0.005, 0.25, 1.35);
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) pinchDistance = 0;
if (pointers.size === 0) canvas.classList.remove("dragging");
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraGoal.radius = clamp(
cameraGoal.radius * Math.exp(event.deltaY * 0.001),
25,
180
);
}, { passive: false });
// ------------------------------------------------------------
// Dialog and animation
// ------------------------------------------------------------
const methodDialog = $("#methodDialog");
$("#openMethod").addEventListener("click", () => methodDialog.showModal());
$("#closeMethod").addEventListener("click", () => methodDialog.close());
methodDialog.addEventListener("click", (event) => {
const rect = methodDialog.getBoundingClientRect();
const outside =
event.clientX < rect.left ||
event.clientX > rect.right ||
event.clientY < rect.top ||
event.clientY > rect.bottom;
if (outside) methodDialog.close();
});
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
const projected = new THREE.Vector3();
function updateLabels() {
camera.updateMatrixWorld();
projectedLabels.forEach(({ element, position }) => {
projected.copy(position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.08 &&
projected.x < 1.08 &&
projected.y > -1.08 &&
projected.y < 1.08;
element.classList.toggle("hidden", !visible);
if (visible) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
});
$("#compassArrow").style.transform =
`rotate(${-cameraState.theta * 180 / Math.PI}deg)`;
}
function animate() {
requestAnimationFrame(animate);
const smoothing = 0.105;
cameraState.target.lerp(cameraGoal.target, smoothing);
cameraState.radius = lerp(cameraState.radius, cameraGoal.radius, smoothing);
cameraState.theta = lerp(cameraState.theta, cameraGoal.theta, smoothing);
cameraState.phi = lerp(cameraState.phi, cameraGoal.phi, smoothing);
applyCamera();
updateLabels();
renderer.render(scene, camera);
}
applyCamera();
animate();
requestAnimationFrame(() => {
$("#loading").classList.add("hidden");
setTimeout(() => $("#loading").remove(), 600);
});
</script>
</body>
</html>
```