Prompt specification
Build or customize the Three.js 3D scene "Two occupation layers and a later pit" 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: Two occupation layers and a later pit
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-occupation-layers-and-a-later-pit-x2258
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows archaeological layers and evidence-based reconstructions. Create a cutaway trench with two layers interrupted by a later pit. Make the cutting relationship visible and separate observed geometry from inferred chronological order. Low-poly.
Working Three.js Starter (two-occupation-layers-and-a-later-pit-x2258):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Archaeological Trench — Observed Geometry & Inferred Sequence</title>
<style>
:root {
--paper: #eee8d8;
--ink: #322d27;
--muted: #766c5e;
--rule: rgba(58, 49, 39, 0.22);
--observed: #b35f2d;
--observed-dark: #63452f;
--inferred: #8d654d;
--accent: #e1a347;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d6cebc;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button { font: inherit; }
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
#scene canvas:active { cursor: grabbing; }
#leaders {
position: fixed;
inset: 0;
z-index: 2;
width: 100%;
height: 100%;
pointer-events: none;
overflow: visible;
}
.leader-line {
stroke: rgba(67, 53, 40, 0.82);
stroke-width: 1.25;
}
.leader-line.cut {
stroke: #c67827;
stroke-width: 1.6;
}
.leader-dot {
fill: #f7f2e7;
stroke: #624a36;
stroke-width: 1.5;
}
.leader-dot.cut {
stroke: #d57a22;
}
#labels {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
.callout {
position: absolute;
width: 158px;
padding: 9px 11px 10px;
background: rgba(248, 244, 234, 0.93);
border: 1px solid rgba(63, 49, 36, 0.28);
border-left: 4px solid var(--observed);
box-shadow: 0 8px 22px rgba(46, 37, 27, 0.13);
backdrop-filter: blur(7px);
-webkit-backdrop-filter: blur(7px);
}
.callout[data-kind="cut"] {
border-left-color: #d98627;
}
.callout-kicker {
display: block;
margin-bottom: 3px;
color: var(--observed-dark);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.callout strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: 17px;
line-height: 1.05;
}
.callout small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 10px;
line-height: 1.3;
}
.masthead {
position: fixed;
z-index: 4;
top: 25px;
left: 28px;
width: min(520px, calc(100vw - 390px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: #5f5142;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 24px;
height: 2px;
background: var(--observed);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3.1vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 450px;
margin: 10px 0 0;
color: #625748;
font-size: 12px;
line-height: 1.45;
}
.observed-chip {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 13px;
padding: 6px 9px;
border: 1px solid rgba(74, 58, 42, 0.28);
background: rgba(246, 241, 228, 0.78);
color: #594838;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.observed-chip i {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--observed);
}
.controls {
position: fixed;
z-index: 6;
top: 24px;
right: 24px;
display: flex;
gap: 7px;
}
.controls button {
padding: 8px 11px;
border: 1px solid rgba(65, 52, 40, 0.3);
background: rgba(246, 242, 231, 0.9);
color: #4e4033;
cursor: pointer;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
box-shadow: 0 5px 16px rgba(54, 42, 30, 0.08);
}
.controls button:hover {
background: #fffaf0;
border-color: rgba(65, 52, 40, 0.55);
}
#sequencePanel {
position: fixed;
z-index: 5;
top: 73px;
right: 24px;
bottom: 24px;
width: 310px;
padding: 21px 20px 19px;
overflow: auto;
background:
linear-gradient(rgba(248, 244, 234, 0.96), rgba(244, 238, 224, 0.96)),
repeating-linear-gradient(
0deg,
rgba(80, 60, 40, 0.025) 0,
rgba(80, 60, 40, 0.025) 1px,
transparent 1px,
transparent 5px
);
border: 1px solid rgba(66, 52, 39, 0.28);
box-shadow: 0 16px 45px rgba(57, 44, 31, 0.16);
transition: opacity 180ms ease, transform 180ms ease;
}
body.hide-inference #sequencePanel {
opacity: 0;
transform: translateX(15px);
pointer-events: none;
}
.panel-heading {
padding-bottom: 15px;
border-bottom: 1px solid var(--rule);
}
.panel-heading .eyebrow {
margin-bottom: 7px;
color: #775944;
}
.panel-heading .eyebrow::before {
background: transparent;
border-top: 2px dashed var(--inferred);
height: 0;
}
.panel-heading h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 23px;
font-weight: 500;
letter-spacing: -0.02em;
}
.panel-heading p {
margin: 8px 0 0;
color: #716657;
font-size: 11px;
line-height: 1.45;
}
.sequence-list {
position: relative;
margin: 20px 0 19px;
padding: 0;
list-style: none;
}
.sequence-list::before {
content: "";
position: absolute;
top: 12px;
bottom: 19px;
left: 7px;
border-left: 2px dashed rgba(126, 86, 58, 0.65);
}
.sequence-list li {
position: relative;
margin-bottom: 16px;
padding-left: 23px;
}
.sequence-list li:last-child {
margin-bottom: 0;
}
.sequence-node {
position: absolute;
top: 2px;
left: 0;
width: 15px;
height: 15px;
border: 2px solid #8b6248;
border-radius: 50%;
background: #f4eddf;
box-shadow: 0 0 0 3px rgba(244, 237, 223, 0.9);
}
.sequence-node::after {
content: "";
position: absolute;
inset: 3px;
border-radius: 50%;
background: #8b6248;
}
.sequence-list strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: 16px;
font-weight: 500;
}
.sequence-list small {
display: block;
margin-top: 2px;
color: #786d5f;
font-size: 10px;
line-height: 1.35;
}
.relation {
display: inline-block;
margin-top: 6px;
padding: 3px 6px;
border: 1px dashed rgba(126, 86, 58, 0.55);
color: #805c43;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.evidence {
padding: 14px;
border: 1px dashed rgba(126, 86, 58, 0.55);
background: rgba(229, 216, 195, 0.4);
}
.evidence h3 {
margin: 0 0 7px;
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.evidence p {
margin: 0;
color: #625749;
font-size: 10.5px;
line-height: 1.5;
}
.confidence {
margin-top: 11px;
color: #7b563d;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.1em;
line-height: 1.4;
text-transform: uppercase;
}
.legend {
position: fixed;
z-index: 4;
left: 28px;
bottom: 24px;
display: flex;
align-items: center;
gap: 20px;
padding: 10px 13px;
border: 1px solid rgba(67, 53, 40, 0.22);
background: rgba(246, 241, 228, 0.84);
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
color: #5e5144;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.legend-line {
width: 27px;
border-top: 2px solid #6b4b32;
}
.legend-line.dashed {
border-top-style: dashed;
border-top-color: #8b6248;
}
.navigation-hint {
color: #776b5d;
font-size: 9px;
letter-spacing: 0.03em;
}
.scale {
position: fixed;
z-index: 4;
left: 360px;
bottom: 27px;
display: flex;
align-items: flex-end;
gap: 7px;
color: #67594b;
font-size: 9px;
font-weight: 700;
pointer-events: none;
}
.scale-bar {
position: relative;
width: 88px;
height: 7px;
border: 1px solid #5f5143;
border-top: 0;
background:
linear-gradient(90deg,
#5f5143 0 25%,
transparent 25% 50%,
#5f5143 50% 75%,
transparent 75% 100%);
}
@media (max-width: 900px) {
.masthead {
width: calc(100vw - 340px);
}
#sequencePanel {
width: 280px;
}
.callout {
width: 140px;
}
.scale { display: none; }
.navigation-hint { display: none; }
}
@media (max-width: 700px) {
.masthead {
top: 14px;
left: 14px;
width: calc(100vw - 130px);
}
h1 { font-size: 25px; }
.subtitle { display: none; }
.observed-chip { margin-top: 8px; font-size: 8px; }
.controls {
top: 13px;
right: 12px;
flex-direction: column;
}
.controls button {
padding: 7px 8px;
font-size: 8px;
}
#sequencePanel {
top: auto;
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
max-height: 42vh;
padding: 15px;
}
.panel-heading h2 { font-size: 19px; }
.panel-heading p { display: none; }
.sequence-list {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px 14px;
margin: 13px 0;
}
.sequence-list::before { display: none; }
.sequence-list li { margin: 0; padding-left: 18px; }
.sequence-list small { font-size: 9px; }
.sequence-list strong { font-size: 13px; }
.relation { display: none; }
.evidence { display: none; }
.legend { display: none; }
.callout { display: none; }
}
</style>
</head>
<body>
<div id="scene"></div>
<svg id="leaders" aria-hidden="true"></svg>
<div id="labels" aria-hidden="true">
<div class="callout" data-kind="layer2" data-x="-4.1" data-y="2.35" data-z="4.05" data-dx="-168" data-dy="-52">
<span class="callout-kicker">01 · Observed</span>
<strong>Layer 2</strong>
<small>Upper occupation deposit</small>
</div>
<div class="callout" data-kind="layer1" data-x="-4.0" data-y="0.78" data-z="4.05" data-dx="-142" data-dy="34">
<span class="callout-kicker">02 · Observed</span>
<strong>Layer 1</strong>
<small>Basal natural deposit</small>
</div>
<div class="callout" data-kind="pit" data-x="2.45" data-y="1.78" data-z="3.96" data-dx="55" data-dy="28">
<span class="callout-kicker">03 · Observed</span>
<strong>Pit fill</strong>
<small>Dark deposit within the cut</small>
</div>
<div class="callout" data-kind="cut" data-x="3.70" data-y="2.72" data-z="4.02" data-dx="74" data-dy="-64">
<span class="callout-kicker">04 · Observed</span>
<strong>Cut interface</strong>
<small>Earlier layers terminate here</small>
</div>
</div>
<header class="masthead">
<div class="eyebrow">Field reconstruction · Trench A–A′</div>
<h1>The cut & the fill</h1>
<p class="subtitle">
A low-poly section through two deposits. Solid geometry records visible relationships;
the separate dashed sequence presents the inferred order of formation.
</p>
<div class="observed-chip"><i></i> Observed geometry</div>
</header>
<div class="controls">
<button id="resetView" type="button" title="Reset camera">Reset view</button>
<button id="toggleInference" type="button" aria-pressed="true">Hide inference</button>
</div>
<aside id="sequencePanel" aria-label="Inferred depositional sequence">
<div class="panel-heading">
<div class="eyebrow">Interpretive overlay</div>
<h2>Inferred sequence</h2>
<p>
Temporal order reconstructed from superposition and cut–fill relationships.
This panel is interpretive; the trench model itself remains observational.
</p>
</div>
<ol class="sequence-list">
<li>
<span class="sequence-node"></span>
<strong>Layer 1</strong>
<small>Basal natural deposit</small>
<span class="relation">Earlier deposit</span>
</li>
<li>
<span class="sequence-node"></span>
<strong>Layer 2</strong>
<small>Occupation soil overlying Layer 1</small>
<span class="relation">Seals Layer 1</span>
</li>
<li>
<span class="sequence-node"></span>
<strong>Pit cut</strong>
<small>Removes both earlier layers</small>
<span class="relation">Truncates L1 + L2</span>
</li>
<li>
<span class="sequence-node"></span>
<strong>Pit fill</strong>
<small>Dark sediment accumulated in the cut</small>
<span class="relation">Postdates the cut</span>
</li>
</ol>
<div class="evidence">
<h3>Evidence for the order</h3>
<p>
Layer 2 lies directly above Layer 1. The pit interface cuts across both,
and its fill lies inside that cut. The cut must therefore postdate the
layers, while the fill must postdate the cut.
</p>
<div class="confidence">Relation: stratigraphic superposition · Confidence: high</div>
</div>
</aside>
<div class="legend">
<div class="legend-item"><span class="legend-line"></span> Observed interface</div>
<div class="legend-item"><span class="legend-line dashed"></span> Inferred temporal relation</div>
<div class="navigation-hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
</div>
<div class="scale">
<span>0</span>
<span class="scale-bar"></span>
<span>2 m</span>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const leaderSvg = document.getElementById("leaders");
const labelsRoot = document.getElementById("labels");
const sequencePanel = document.getElementById("sequencePanel");
const toggleInferenceButton = document.getElementById("toggleInference");
const resetViewButton = document.getElementById("resetView");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd6cebc);
scene.fog = new THREE.Fog(0xd6cebc, 25, 55);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute("aria-label", "Interactive three-dimensional archaeological trench section");
sceneHost.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 6, -6, 0.1, 100);
const cameraTarget = new THREE.Vector3(-0.65, 1.25, 0);
const orbit = {
theta: 0.69,
phi: 0.91,
zoom: 1.0,
radius: 19
};
function applyCamera() {
const horizontal = Math.sin(orbit.phi) * orbit.radius;
camera.position.set(
cameraTarget.x + horizontal * Math.sin(orbit.theta),
cameraTarget.y + Math.cos(orbit.phi) * orbit.radius,
cameraTarget.z + horizontal * Math.cos(orbit.theta)
);
camera.lookAt(cameraTarget);
camera.zoom = orbit.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = width < 700 ? 13.2 : 10.5;
camera.left = -viewHeight * aspect * 0.5;
camera.right = viewHeight * aspect * 0.5;
camera.top = viewHeight * 0.5;
camera.bottom = -viewHeight * 0.5;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
applyCamera();
const hemisphere = new THREE.HemisphereLight(0xf8efd9, 0x65584d, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d2, 3.2);
sun.position.set(8, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 14;
sun.shadow.camera.bottom = -14;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 38;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fillLight = new THREE.DirectionalLight(0xbfd0d5, 0.8);
fillLight.position.set(-10, 6, -7);
scene.add(fillLight);
const materials = {
layer1: new THREE.MeshStandardMaterial({
color: 0xb58d64,
roughness: 0.96,
metalness: 0,
flatShading: true
}),
layer2: new THREE.MeshStandardMaterial({
color: 0x68584b,
roughness: 1,
metalness: 0,
flatShading: true
}),
pit: new THREE.MeshStandardMaterial({
color: 0x3b302c,
roughness: 1,
metalness: 0,
flatShading: true
}),
plinth: new THREE.MeshStandardMaterial({
color: 0x8e806d,
roughness: 1,
flatShading: true
}),
ground: new THREE.MeshStandardMaterial({
color: 0xcfc5af,
roughness: 1,
flatShading: true
})
};
function addBox(width, height, depth, x, y, z, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function addLine(points, color = 0x604b36, opacity = 1, dashed = false) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map(p => new THREE.Vector3(p[0], p[1], p[2]))
);
const material = dashed
? new THREE.LineDashedMaterial({
color,
transparent: opacity < 1,
opacity,
dashSize: 0.18,
gapSize: 0.12,
depthTest: true
})
: new THREE.LineBasicMaterial({
color,
transparent: opacity < 1,
opacity
});
const line = new THREE.Line(geometry, material);
if (dashed) line.computeLineDistances();
scene.add(line);
return line;
}
function hashNoise(x, z, seed) {
const value = Math.sin(x * 12.9898 + z * 78.233 + seed * 37.719) * 43758.5453;
return value - Math.floor(value);
}
function addTriangulatedSurface(x0, x1, z0, z1, y, baseColor, seed) {
const width = x1 - x0;
const depth = z1 - z0;
const segmentsX = Math.max(2, Math.ceil(width / 1.45));
const segmentsZ = Math.max(2, Math.ceil(depth / 1.45));
let geometry = new THREE.PlaneGeometry(width, depth, segmentsX, segmentsZ);
geometry.rotateX(-Math.PI / 2);
geometry.translate((x0 + x1) * 0.5, y, (z0 + z1) * 0.5);
geometry = geometry.toNonIndexed();
const positions = geometry.attributes.position;
const colors = new Float32Array(positions.count * 3);
const base = new THREE.Color(baseColor);
for (let i = 0; i < positions.count; i += 3) {
for (let j = 0; j < 3; j++) {
const index = i + j;
const x = positions.getX(index);
const z = positions.getZ(index);
const noise = hashNoise(x, z, seed);
positions.setY(index, y + noise * 0.038);
const color = base.clone();
color.offsetHSL((noise - 0.5) * 0.012, (noise - 0.5) * 0.035, (noise - 0.5) * 0.075);
color.toArray(colors, index * 3);
}
}
geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
metalness: 0,
flatShading: true,
side: THREE.FrontSide
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// Ground and trench footing.
const ground = new THREE.Mesh(new THREE.PlaneGeometry(90, 90), materials.ground);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.33;
ground.receiveShadow = true;
scene.add(ground);
addBox(12.35, 0.3, 8.35, 0, -0.16, 0, materials.plinth);
// Layer 1: rear block plus a front section with a true negative pit notch.
addBox(12, 1.6, 4.2, 0, 0.8, -1.9, materials.layer1);
const lowerShape = new THREE.Shape();
const lowerProfile = [
[-6, 0],
[6, 0],
[6, 1.6],
[3.7, 1.6],
[3.7, 0.85],
[1.2, 0.85],
[1.2, 1.6],
[-6, 1.6]
];
lowerShape.moveTo(lowerProfile[0][0], lowerProfile[0][1]);
for (let i = 1; i < lowerProfile.length; i++) {
lowerShape.lineTo(lowerProfile[i][0], lowerProfile[i][1]);
}
lowerShape.closePath();
const lowerFront = new THREE.Mesh(
new THREE.ExtrudeGeometry(lowerShape, {
depth: 3.8,
bevelEnabled: false,
steps: 1,
curveSegments: 1
}),
materials.layer1
);
lowerFront.position.z = 0.2;
lowerFront.castShadow = true;
lowerFront.receiveShadow = true;
scene.add(lowerFront);
// Layer 2: rear block and separated front blocks create the visible cut.
addBox(12, 1.6, 4.2, 0, 2.4, -1.9, materials.layer2);
addBox(7.2, 1.6, 3.8, -2.4, 2.4, 2.1, materials.layer2);
addBox(2.3, 1.6, 3.8, 4.85, 2.4, 2.1, materials.layer2);
// Faceted upper surfaces.
addTriangulatedSurface(-6, 1.2, 0.2, 4, 3.214, 0x705f50, 11);
addTriangulatedSurface(3.7, 6, 0.2, 4, 3.214, 0x705f50, 19);
addTriangulatedSurface(-6, 6, -4, 0.2, 3.214, 0x705f50, 29);
// Low-poly pit fill, deliberately recessed below the surrounding ground.
const pitGeometry = new THREE.BufferGeometry();
const pitVertices = new Float32Array([
1.28, 0.90, 0.25,
3.62, 0.90, 0.25,
3.62, 0.90, 3.94,
1.28, 0.90, 3.94,
1.34, 2.78, 0.32,
3.57, 2.90, 0.36,
3.56, 2.78, 3.88,
1.35, 2.88, 3.84
]);
const pitIndices = [
0, 4, 5, 0, 5, 1,
3, 2, 6, 3, 6, 7,
0, 3, 7, 0, 7, 4,
1, 5, 6, 1, 6, 2,
4, 7, 6, 4, 6, 5,
0, 1, 2, 0, 2, 3
];
pitGeometry.setAttribute("position", new THREE.BufferAttribute(pitVertices, 3));
pitGeometry.setIndex(pitIndices);
pitGeometry.computeVertexNormals();
const pitFill = new THREE.Mesh(pitGeometry, materials.pit);
pitFill.castShadow = true;
pitFill.receiveShadow = true;
scene.add(pitFill);
// Observed outer section edges.
addLine([[-6, 3.225, -4], [6, 3.225, -4]], 0x574a3c, 0.9);
addLine([[-6, 3.225, -4], [-6, 3.225, 4]], 0x574a3c, 0.9);
addLine([[6, 3.225, -4], [6, 3.225, 4]], 0x574a3c, 0.9);
addLine([[-6, 3.225, 4], [1.2, 3.225, 4]], 0x574a3c, 0.9);
addLine([[3.7, 3.225, 4], [6, 3.225, 4]], 0x574a3c, 0.9);
addLine([[-6, 0.02, 4], [-6, 3.225, 4]], 0x574a3c, 0.65);
addLine([[6, 0.02, 4], [6, 3.225, 4]], 0x574a3c, 0.65);
addLine([[-6, 0.02, 4], [6, 0.02, 4]], 0x574a3c, 0.7);
// Layer boundary: solid, observed, and visibly interrupted by the pit.
addLine([[-6, 1.6, 4.012], [1.2, 1.6, 4.012]], 0xd2b78e, 0.95);
addLine([[3.7, 1.6, 4.012], [6, 1.6, 4.012]], 0xd2b78e, 0.95);
// Cut interface: solid amber traces emphasize truncation of both layers.
addLine([[1.2, 0.85, 4.02], [1.2, 3.225, 4.02]], 0xdd8b28, 1);
addLine([[3.7, 0.85, 4.02], [3.7, 3.225, 4.02]], 0xdd8b28, 1);
addLine([[1.2, 0.85, 4.02], [3.7, 0.85, 4.02]], 0xdd8b28, 1);
// Opening around the pit at the modern surface.
addLine([[1.2, 3.225, 0.2], [1.2, 3.225, 4]], 0xdd8b28, 0.95);
addLine([[3.7, 3.225, 0.2], [3.7, 3.225, 4]], 0xdd8b28, 0.95);
addLine([[1.2, 3.225, 0.2], [3.7, 3.225, 0.2]], 0xdd8b28, 0.95);
// Small low-poly inclusions embedded in the exposed section.
const pebbleGeometry = new THREE.DodecahedronGeometry(1, 0);
const pebbleMaterials = [
new THREE.MeshStandardMaterial({ color: 0x4c4540, roughness: 1, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0x8f7253, roughness: 1, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0xc09a67, roughness: 1, flatShading: true })
];
function addPebble(x, y, z, scale, materialIndex, rotation = 0) {
const pebble = new THREE.Mesh(pebbleGeometry, pebbleMaterials[materialIndex]);
pebble.position.set(x, y, z);
pebble.scale.set(scale * 1.25, scale * 0.7, scale * 0.55);
pebble.rotation.set(0.15, rotation, rotation * 0.4);
pebble.castShadow = true;
scene.add(pebble);
}
addPebble(-4.75, 2.43, 4.03, 0.19, 0, 0.4);
addPebble(-3.32, 2.10, 4.04, 0.15, 1, 1.1);
addPebble(-0.45, 2.54, 4.03, 0.13, 2, 0.2);
addPebble(-4.50, 0.57, 4.03, 0.17, 2, 0.8);
addPebble(-2.92, 0.98, 4.04, 0.21, 1, 1.5);
addPebble(-0.72, 0.48, 4.03, 0.13, 0, 0.3);
addPebble(2.10, 1.33, 3.98, 0.12, 2, 0.5);
addPebble(2.72, 1.96, 3.98, 0.10, 1, 1.0);
// Angular ceramic sherd visible in Layer 1.
const sherd = new THREE.Mesh(
new THREE.CircleGeometry(0.22, 5),
new THREE.MeshStandardMaterial({
color: 0xa85d3c,
roughness: 1,
flatShading: true,
side: THREE.DoubleSide
})
);
sherd.position.set(-1.42, 1.14, 4.025);
sherd.scale.set(1.35, 0.72, 1);
sherd.rotation.z = 0.35;
sherd.castShadow = true;
scene.add(sherd);
// A few stones on the current ground surface.
addPebble(-4.3, 3.36, -1.25, 0.21, 1, 0.6);
addPebble(-2.7, 3.35, 1.05, 0.15, 0, 1.4);
addPebble(4.85, 3.37, -1.4, 0.18, 2, 0.4);
// SVG leaders and projected HTML callouts.
const callouts = [...document.querySelectorAll(".callout")].map(element => {
const line = document.createElementNS("http://www.w3.org/2000/svg", "line");
line.setAttribute("class", "leader-line");
if (element.dataset.kind === "cut") line.classList.add("cut");
const dot = document.createElementNS("http://www.w3.org/2000/svg", "circle");
dot.setAttribute("class", "leader-dot");
dot.setAttribute("r", "3.5");
if (element.dataset.kind === "cut") dot.classList.add("cut");
leaderSvg.appendChild(line);
leaderSvg.appendChild(dot);
return {
element,
line,
dot,
anchor: new THREE.Vector3(
Number(element.dataset.x),
Number(element.dataset.y),
Number(element.dataset.z)
),
dx: Number(element.dataset.dx),
dy: Number(element.dataset.dy)
};
});
function updateCallouts() {
const width = window.innerWidth;
const height = window.innerHeight;
const panelVisible = !document.body.classList.contains("hide-inference");
const panelLeft = sequencePanel.getBoundingClientRect().left;
const availableRight = panelVisible && width > 900 ? panelLeft - 12 : width - 12;
for (const item of callouts) {
const projected = item.anchor.clone().project(camera);
const anchorX = (projected.x * 0.5 + 0.5) * width;
const anchorY = (-projected.y * 0.5 + 0.5) * height;
const labelWidth = item.element.offsetWidth;
const labelHeight = item.element.offsetHeight;
const labelX = THREE.MathUtils.clamp(
anchorX + item.dx,
12,
Math.max(12, availableRight - labelWidth)
);
const labelY = THREE.MathUtils.clamp(
anchorY + item.dy,
12,
height - labelHeight - 12
);
item.element.style.left = `${labelX}px`;
item.element.style.top = `${labelY}px`;
const centerX = labelX + labelWidth * 0.5;
const endX = centerX > anchorX ? labelX : labelX + labelWidth;
const endY = labelY + labelHeight * 0.5;
item.line.setAttribute("x1", anchorX);
item.line.setAttribute("y1", anchorY);
item.line.setAttribute("x2", endX);
item.line.setAttribute("y2", endY);
item.dot.setAttribute("cx", anchorX);
item.dot.setAttribute("cy", anchorY);
}
}
// Direct orbit controls; no external camera-control addons are used.
const pointers = new Map();
let previousPinchDistance = 0;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].clientX - values[1].clientX,
values[0].clientY - values[1].clientY
);
}
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
previousPinchDistance = pointerDistance();
});
renderer.domElement.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 === 1) {
orbit.theta -= dx * 0.007;
orbit.phi = THREE.MathUtils.clamp(orbit.phi + dy * 0.006, 0.38, 1.43);
} else {
const distance = pointerDistance();
if (previousPinchDistance > 0 && distance > 0) {
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * (distance / previousPinchDistance),
0.68,
2.25
);
}
previousPinchDistance = distance;
}
applyCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = pointerDistance();
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.001),
0.68,
2.25
);
applyCamera();
}, { passive: false });
function resetView() {
orbit.theta = 0.69;
orbit.phi = 0.91;
orbit.zoom = 1;
applyCamera();
}
renderer.domElement.addEventListener("dblclick", resetView);
resetViewButton.addEventListener("click", resetView);
renderer.domElement.addEventListener("keydown", event => {
const step = 0.08;
if (event.key === "ArrowLeft") orbit.theta += step;
else if (event.key === "ArrowRight") orbit.theta -= step;
else if (event.key === "ArrowUp") orbit.phi = Math.max(0.38, orbit.phi - step);
else if (event.key === "ArrowDown") orbit.phi = Math.min(1.43, orbit.phi + step);
else if (event.key === "+" || event.key === "=") orbit.zoom = Math.min(2.25, orbit.zoom * 1.08);
else if (event.key === "-") orbit.zoom = Math.max(0.68, orbit.zoom / 1.08);
else if (event.key.toLowerCase() === "r") resetView();
else return;
event.preventDefault();
applyCamera();
});
toggleInferenceButton.addEventListener("click", () => {
const hidden = document.body.classList.toggle("hide-inference");
toggleInferenceButton.textContent = hidden ? "Show inference" : "Hide inference";
toggleInferenceButton.setAttribute("aria-pressed", String(!hidden));
});
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
updateCallouts();
}
animate();
</script>
</body>
</html>
```