Prompt specification
Build or customize the Three.js 3D scene "Excavated dwelling beside a reconstruction" 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: Excavated dwelling beside a reconstruction
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/excavated-dwelling-beside-a-reconstruction-x2259
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows archaeological layers and evidence-based reconstructions. Build a modest excavated foundation next to a translucent hypothetical dwelling outline. Use different visual treatment for surviving evidence and inferred roof or wall heights. Voxel style.
Working Three.js Starter (excavated-dwelling-beside-a-reconstruction-x2259):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Archaeological Layers & Evidence-Based Reconstruction</title>
<style>
:root {
color-scheme: dark;
--panel: rgba(18, 27, 24, 0.86);
--line: rgba(220, 236, 224, 0.14);
--text: #e8efe8;
--muted: #9dac9f;
--evidence: #d4ae72;
--inferred: #68d9d5;
--natural: #827158;
--deposit: #aa8053;
--occupation: #b99668;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #111a17;
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#viewport,
#viewport canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
#viewport canvas {
display: block;
touch-action: none;
cursor: grab;
outline: none;
}
#viewport canvas:active {
cursor: grabbing;
}
.panel {
position: absolute;
z-index: 10;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(14px);
}
#title-card {
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 18px 20px 17px;
border-radius: 4px;
}
.eyebrow {
margin-bottom: 8px;
color: var(--evidence);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 34px);
font-weight: 650;
letter-spacing: -0.035em;
line-height: 1.05;
}
.subtitle {
margin: 10px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.site-meta {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-top: 13px;
}
.site-meta span {
padding: 5px 7px;
border: 1px solid var(--line);
border-radius: 3px;
color: #c7d1c6;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.09em;
text-transform: uppercase;
}
#controls {
top: 24px;
right: 24px;
width: 262px;
padding: 16px;
border-radius: 4px;
}
.control-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 13px;
color: #cbd5ca;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.control-heading::after {
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--inferred);
box-shadow: 0 0 10px rgba(104, 217, 213, 0.6);
content: "";
}
.toggle {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 34px;
color: #dce5db;
font-size: 12px;
cursor: pointer;
}
.toggle span {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 2px;
background: var(--evidence);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.swatch.inferred {
background: rgba(104, 217, 213, 0.22);
border: 1px solid var(--inferred);
box-shadow: none;
}
.swatch.layer {
background: linear-gradient(
180deg,
#5f513b 0 33%,
#b39262 33% 66%,
#a27d51 66% 100%
);
}
.toggle input {
width: 30px;
height: 17px;
margin: 0;
appearance: none;
border: 1px solid rgba(220, 236, 224, 0.22);
border-radius: 20px;
background: #27322d;
cursor: pointer;
transition: background 150ms;
}
.toggle input::before {
display: block;
width: 11px;
height: 11px;
margin: 2px;
border-radius: 50%;
background: #7f8c82;
content: "";
transition: transform 150ms, background 150ms;
}
.toggle input:checked {
border-color: rgba(104, 217, 213, 0.55);
background: rgba(104, 217, 213, 0.18);
}
.toggle input:checked::before {
background: var(--inferred);
transform: translateX(13px);
}
.divider {
height: 1px;
margin: 13px 0 12px;
background: var(--line);
}
.range-label {
display: flex;
align-items: center;
justify-content: space-between;
margin: 13px 0 8px;
color: #cbd5ca;
font-size: 11px;
}
.range-label output {
color: var(--inferred);
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
height: 3px;
appearance: none;
border-radius: 4px;
background: #3a4740;
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 13px;
height: 13px;
appearance: none;
border: 2px solid #15201c;
border-radius: 50%;
background: var(--inferred);
box-shadow: 0 0 0 1px rgba(104, 217, 213, 0.6);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 2px solid #15201c;
border-radius: 50%;
background: var(--inferred);
}
#reset-view {
width: 100%;
margin-top: 17px;
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 3px;
background: rgba(255, 255, 255, 0.035);
color: #d8e1d7;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
cursor: pointer;
transition: background 150ms, border-color 150ms;
}
#reset-view:hover {
border-color: rgba(104, 217, 213, 0.42);
background: rgba(104, 217, 213, 0.08);
}
#legend {
bottom: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 15px 17px;
border-radius: 4px;
}
.legend-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 11px 16px;
}
.legend-item {
display: flex;
align-items: center;
gap: 9px;
color: #d7dfd5;
font-size: 11px;
}
.legend-note {
margin: 13px 0 0;
padding-top: 11px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.5;
}
.legend-note strong {
color: var(--inferred);
font-weight: 650;
}
#help {
right: 24px;
bottom: 24px;
padding: 9px 12px;
border-radius: 3px;
color: #aab7aa;
font-size: 10px;
letter-spacing: 0.02em;
}
#compass {
position: absolute;
z-index: 8;
right: 40px;
bottom: 78px;
width: 34px;
height: 34px;
border: 1px solid rgba(220, 236, 224, 0.18);
border-radius: 50%;
color: #cbd7ca;
background: rgba(18, 27, 24, 0.55);
pointer-events: none;
}
#compass::before {
position: absolute;
top: 5px;
left: 50%;
width: 0;
height: 0;
border-right: 4px solid transparent;
border-bottom: 9px solid var(--evidence);
border-left: 4px solid transparent;
content: "";
transform: translateX(-50%);
}
#compass span {
position: absolute;
right: 0;
bottom: -16px;
left: 0;
color: #9daa9e;
font-size: 8px;
font-weight: 800;
text-align: center;
}
#annotations {
position: absolute;
z-index: 6;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.annotation {
position: absolute;
min-width: 112px;
padding: 6px 8px;
border-left: 2px solid var(--evidence);
border-radius: 2px;
background: rgba(16, 23, 20, 0.84);
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.24);
color: #eadbc2;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.07em;
line-height: 1.35;
text-transform: uppercase;
transform: translate(-50%, -100%);
white-space: nowrap;
}
.annotation::after {
position: absolute;
bottom: -13px;
left: 8px;
width: 1px;
height: 12px;
background: var(--evidence);
content: "";
}
.annotation small {
display: block;
margin-top: 2px;
color: #9da99e;
font-size: 7px;
font-weight: 600;
letter-spacing: 0.05em;
}
.annotation.cyan {
border-left-color: var(--inferred);
color: #bdf4f1;
}
.annotation.cyan::after {
background: var(--inferred);
}
.annotation.layer {
min-width: 98px;
border-left-color: #b79667;
color: #dfc9a6;
}
.annotation.layer::after {
background: #b79667;
}
#loading {
position: absolute;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #111a17;
color: #b7c2b7;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
}
@media (max-width: 780px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
.subtitle,
.site-meta {
display: none;
}
#controls {
top: auto;
right: 12px;
bottom: 12px;
width: 224px;
padding: 12px;
}
#legend {
display: none;
}
#help,
#compass {
display: none;
}
.annotation.layer {
display: none !important;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<div id="annotations"></div>
<header id="title-card" class="panel">
<div class="eyebrow">Field 07B / Lower Terrace</div>
<h1>Layers & Reconstruction</h1>
<p class="subtitle">
A measured foundation beside a hypothetical domestic envelope.
Solid stone records surviving evidence; translucent cyan marks interpretation.
</p>
<div class="site-meta">
<span>Observed footprint 4.2 × 3.4 m</span>
<span>Hypothesis only</span>
<span>Voxel survey model</span>
</div>
</header>
<aside id="controls" class="panel">
<div class="control-heading">Interpretation Layers</div>
<label class="toggle">
<span><i class="swatch"></i>Surviving evidence</span>
<input id="toggle-evidence" type="checkbox" checked>
</label>
<label class="toggle">
<span><i class="swatch layer"></i>Archaeological strata</span>
<input id="toggle-strata" type="checkbox" checked>
</label>
<label class="toggle">
<span><i class="swatch inferred"></i>Inferred envelope</span>
<input id="toggle-inference" type="checkbox" checked>
</label>
<div class="divider"></div>
<label class="range-label" for="wall-height">
<span>Proposed wall height</span>
<output id="wall-height-value">1.8 m</output>
</label>
<input id="wall-height" type="range" min="1.4" max="2.2" step="0.1" value="1.8">
<label class="range-label" for="ghost-opacity">
<span>Hypothesis opacity</span>
<output id="opacity-value">15%</output>
</label>
<input id="ghost-opacity" type="range" min="6" max="32" step="1" value="15">
<button id="reset-view" type="button">Reset camera</button>
</aside>
<aside id="legend" class="panel">
<div class="legend-grid">
<div class="legend-item">
<i class="swatch"></i>
Surviving / observed
</div>
<div class="legend-item">
<i class="swatch inferred"></i>
Inferred / hypothetical
</div>
<div class="legend-item">
<i class="swatch layer"></i>
Stratigraphic sequence
</div>
<div class="legend-item">
<i class="swatch" style="background:#d16c43"></i>
Fired-clay alignment
</div>
</div>
<p class="legend-note">
<strong>Cyan is not preserved masonry.</strong>
Roof form and superstructure height remain testable hypotheses,
not direct observations.
</p>
</aside>
<div id="help" class="panel">
Drag to orbit · Shift + drag to pan · Wheel to zoom
</div>
<div id="compass"><span>N</span></div>
<div id="loading">Loading field model…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, lighting, and orthographic survey camera
// -------------------------------------------------------------------------
const viewport = document.querySelector("#viewport");
const loading = document.querySelector("#loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x111a17);
scene.fog = new THREE.Fog(0x111a17, 20, 43);
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.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
viewport.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-8, 8, 6, -6, 0.1, 100);
const target = new THREE.Vector3(-0.15, 0.15, 0);
const defaultCamera = {
theta: 0.68,
phi: 0.92,
zoom: 1
};
let cameraTheta = defaultCamera.theta;
let cameraPhi = defaultCamera.phi;
let cameraZoom = defaultCamera.zoom;
const hemisphere = new THREE.HemisphereLight(0xe8f4e6, 0x342719, 2.05);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe0ae, 3.2);
sun.position.set(7, 12, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -11;
sun.shadow.camera.right = 11;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 32;
sun.shadow.bias = -0.00045;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8ed9dc, 0.75);
fill.position.set(-9, 5, -4);
scene.add(fill);
// Shared low-poly geometry reinforces the voxel treatment.
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const unitEdges = new THREE.EdgesGeometry(unitBox);
const contextGroup = new THREE.Group();
const strataGroup = new THREE.Group();
const evidenceGroup = new THREE.Group();
const inferenceGroup = new THREE.Group();
scene.add(contextGroup, strataGroup, evidenceGroup, inferenceGroup);
const solidMaterialCache = new Map();
function getSolidMaterial(color) {
if (!solidMaterialCache.has(color)) {
solidMaterialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.94,
metalness: 0
})
);
}
return solidMaterialCache.get(color);
}
function addSolid(
parent,
position,
size,
color,
options = {}
) {
const mesh = new THREE.Mesh(
unitBox,
options.material || getSolidMaterial(color)
);
mesh.position.set(...position);
mesh.scale.set(...size);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
const ghostMaterial = new THREE.MeshStandardMaterial({
color: 0x68d9d5,
roughness: 0.55,
metalness: 0,
transparent: true,
opacity: 0.15,
depthWrite: false,
side: THREE.DoubleSide
});
const ghostEdgeMaterial = new THREE.LineBasicMaterial({
color: 0x8aeeea,
transparent: true,
opacity: 0.55,
depthWrite: false
});
function addGhostBlock(parent, position, size) {
const mesh = new THREE.Mesh(unitBox, ghostMaterial);
mesh.position.set(...position);
mesh.scale.set(...size);
mesh.renderOrder = 4;
parent.add(mesh);
const edges = new THREE.LineSegments(unitEdges, ghostEdgeMaterial);
edges.position.copy(mesh.position);
edges.scale.copy(mesh.scale);
edges.renderOrder = 5;
parent.add(edges);
return mesh;
}
// Deterministic randomness keeps the archaeological blocks stable on reload.
function mulberry32(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 random = mulberry32(74193);
// -------------------------------------------------------------------------
// Context: plinth, tiled terrace, and background survey floor
// -------------------------------------------------------------------------
addSolid(
contextGroup,
[0, -1.04, 0],
[14.2, 0.34, 7.7],
0x283a31
);
addSolid(
contextGroup,
[0, -1.23, 0],
[40, 0.08, 40],
0x15201b,
{ castShadow: false }
);
const grid = new THREE.GridHelper(40, 40, 0x577060, 0x34473c);
grid.position.y = -1.18;
grid.material.transparent = true;
grid.material.opacity = 0.14;
scene.add(grid);
addSolid(
contextGroup,
[-3.72, -0.72, 0],
[6.15, 0.38, 5.75],
0x5f5d43
);
const tileColors = [0x68664b, 0x716d4f, 0x5e6046, 0x777158];
for (let row = 0; row < 6; row++) {
for (let col = 0; col < 6; col++) {
const x = -3.72 + (col - 2.5) * 0.96;
const z = (row - 2.5) * 0.92;
const color = tileColors[Math.floor(random() * tileColors.length)];
addSolid(
contextGroup,
[x, -0.505, z],
[0.91, 0.05, 0.87],
color,
{ castShadow: false }
);
}
}
// Small edge markers suggest a surveyed, block-built site.
const markerMaterial = new THREE.MeshStandardMaterial({
color: 0xd8b35c,
roughness: 0.85
});
for (const [x, z] of [
[-6.45, -2.55],
[-6.45, 2.55],
[-1.0, -2.55],
[-1.0, 2.55]
]) {
addSolid(
contextGroup,
[x, -0.32, z],
[0.08, 0.36, 0.08],
0xd8b35c,
{ material: markerMaterial }
);
}
// -------------------------------------------------------------------------
// Stratigraphy: nested cut and exposed deposits
// -------------------------------------------------------------------------
const excavation = {
x: 2.4,
z: 0,
outerWidth: 5.8,
outerDepth: 5.4,
innerWidth: 4.8,
innerDepth: 4.0
};
addSolid(
strataGroup,
[2.4, -0.66, 0],
[6.2, 0.28, 5.8],
0x817057
);
addSolid(
strataGroup,
[2.4, -0.43, 0],
[6.0, 0.26, 5.6],
0xa27d51
);
addSolid(
strataGroup,
[2.4, -0.23, 0],
[5.8, 0.20, 5.4],
0xb39262
);
// The uppermost matrix survives as a rectangular frame around the cut.
const sideStripWidth =
(excavation.outerWidth - excavation.innerWidth) * 0.5;
const endStripDepth =
(excavation.outerDepth - excavation.innerDepth) * 0.5;
addSolid(
strataGroup,
[
excavation.x -
(excavation.outerWidth + excavation.innerWidth) * 0.25,
-0.07,
0
],
[sideStripWidth, 0.14, excavation.outerDepth],
0x5d513c
);
addSolid(
strataGroup,
[
excavation.x +
(excavation.outerWidth + excavation.innerWidth) * 0.25,
-0.07,
0
],
[sideStripWidth, 0.14, excavation.outerDepth],
0x5d513c
);
addSolid(
strataGroup,
[
excavation.x,
-0.07,
(excavation.outerDepth + excavation.innerDepth) * 0.25
],
[excavation.innerWidth, 0.14, endStripDepth],
0x65563e
);
addSolid(
strataGroup,
[
excavation.x,
-0.07,
-(excavation.outerDepth + excavation.innerDepth) * 0.25
],
[excavation.innerWidth, 0.14, endStripDepth],
0x65563e
);
addSolid(
strataGroup,
[excavation.x, -0.115, 0],
[excavation.innerWidth, 0.05, excavation.innerDepth],
0x6c5940
);
// Small inclusions in the exposed section make the strata legible.
const inclusionColors = [
0xc1a374,
0x6d5a41,
0xd0b48a,
0x806b4d
];
for (let i = 0; i < 30; i++) {
const layer = i % 3;
const y = [-0.66, -0.43, -0.23][layer];
const frontZ = [2.91, 2.81, 2.71][layer];
const width = 0.10 + random() * 0.18;
const height = 0.06 + random() * 0.08;
addSolid(
strataGroup,
[
-0.45 + random() * 5.7,
y + (random() - 0.5) * 0.06,
frontZ
],
[width, height, 0.055],
inclusionColors[Math.floor(random() * inclusionColors.length)],
{ castShadow: false }
);
}
// -------------------------------------------------------------------------
// Surviving foundation: irregular solid masonry blocks
// -------------------------------------------------------------------------
const foundation = {
x: 2.4,
z: 0,
width: 4.2,
depth: 3.4
};
const stoneColors = [
0xc0a77f,
0xb49b74,
0xcbb58f,
0xa89573,
0xd0ba91,
0x998a6d
];
function addFoundationStone(x, z, width, depth) {
const height = 0.27 + random() * 0.23;
const color = stoneColors[Math.floor(random() * stoneColors.length)];
return addSolid(
evidenceGroup,
[x, -0.06 + height * 0.5, z],
[width, height, depth],
color
);
}
const frontBackStep = 0.47;
const stoneCount = 9;
for (let i = 0; i < stoneCount; i++) {
const x =
foundation.x -
foundation.width * 0.5 +
frontBackStep * 0.5 +
i * frontBackStep;
if (random() > 0.07) {
addFoundationStone(x, foundation.z - foundation.depth * 0.5, 0.43, 0.44);
}
if (random() > 0.1) {
addFoundationStone(x, foundation.z + foundation.depth * 0.5, 0.43, 0.44);
}
}
const sideStep = 0.48;
const sideCount = 5;
for (let i = 0; i < sideCount; i++) {
const z =
foundation.z -
foundation.depth * 0.5 +
0.70 +
i * sideStep;
if (random() > 0.08) {
addFoundationStone(
foundation.x - foundation.width * 0.5,
z,
0.44,
0.43
);
}
if (random() > 0.1) {
addFoundationStone(
foundation.x + foundation.width * 0.5,
z,
0.44,
0.43
);
}
}
// Hearth: a dark occupation surface and a voxel ring of small stones.
const hearthX = foundation.x + 0.25;
const hearthZ = foundation.z - 0.18;
addSolid(
evidenceGroup,
[hearthX, -0.05, hearthZ],
[1.08, 0.08, 1.08],
0x302b24
);
const hearthStoneColors = [0x756b59, 0x625b4e, 0x81735d];
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const radius = 0.43;
addSolid(
evidenceGroup,
[
hearthX + Math.cos(angle) * radius,
0.015,
hearthZ + Math.sin(angle) * radius
],
[0.22, 0.17, 0.22],
hearthStoneColors[i % hearthStoneColors.length]
);
}
for (let i = 0; i < 7; i++) {
addSolid(
evidenceGroup,
[
hearthX + (random() - 0.5) * 0.42,
0.035,
hearthZ + (random() - 0.5) * 0.42
],
[0.12 + random() * 0.08, 0.07, 0.12 + random() * 0.08],
i % 3 === 0 ? 0x8a3e26 : 0x332b24
);
}
// Possible fired-clay wall alignment extending beyond the stone footing.
const alignmentMaterial = new THREE.MeshStandardMaterial({
color: 0xc15d3b,
roughness: 0.88
});
for (let i = 0; i < 4; i++) {
addSolid(
evidenceGroup,
[4.78 + i * 0.34, 0.055, 0.63],
[0.29, 0.15, 0.24],
0xc15d3b,
{ material: alignmentMaterial }
);
}
// Dark post-hole stains around the footprint.
for (const [x, z] of [
[0.52, -1.42],
[4.28, -1.42],
[0.52, 1.42],
[4.28, 1.42]
]) {
addSolid(
evidenceGroup,
[x, -0.067, z],
[0.44, 0.035, 0.44],
0x352f26,
{ castShadow: false }
);
}
// -------------------------------------------------------------------------
// Hypothetical dwelling: translucent voxel walls and stepped roof
// -------------------------------------------------------------------------
const dwelling = {
x: -3.72,
z: 0,
width: 4.4,
depth: 3.6,
baseY: -0.47,
nominalWallHeight: 1.8
};
const wallGroup = new THREE.Group();
const roofGroup = new THREE.Group();
wallGroup.position.y = dwelling.baseY;
inferenceGroup.add(wallGroup, roofGroup);
const wallStep = 0.44;
const wallLevels = 4;
const wallThickness = 0.34;
// Front and back walls, leaving a possible central doorway at the front.
for (let i = 0; i < 10; i++) {
const x = dwelling.x - dwelling.width * 0.5 + wallStep * 0.5 + i * wallStep;
const isDoor = i === 4 || i === 5;
for (let level = 0; level < wallLevels; level++) {
if (isDoor && level < 3) continue;
addGhostBlock(
wallGroup,
[x, level * 0.45 + 0.225, dwelling.z - dwelling.depth * 0.5],
[0.40, 0.43, wallThickness]
);
if (!isDoor) {
addGhostBlock(
wallGroup,
[x, level * 0.45 + 0.225, dwelling.z + dwelling.depth * 0.5],
[0.40, 0.43, wallThickness]
);
}
}
}
// Side walls.
for (let i = 0; i < 7; i++) {
const z = dwelling.z - dwelling.depth * 0.5 + wallStep * 0.5 + i * wallStep;
for (let level = 0; level < wallLevels; level++) {
addGhostBlock(
wallGroup,
[
dwelling.x - dwelling.width * 0.5,
level * 0.45 + 0.225,
z
],
[wallThickness, 0.43, 0.40]
);
addGhostBlock(
wallGroup,
[
dwelling.x + dwelling.width * 0.5,
level * 0.45 + 0.225,
z
],
[wallThickness, 0.43, 0.40]
);
}
}
// A stepped gable roof assembled from translucent voxel bands.
const roofWidth = 5.05;
const roofBand = roofWidth * 0.1;
const roofDepth = 4.15;
for (let tier = 0; tier < 5; tier++) {
const sideCenter =
roofWidth * 0.5 -
roofBand * 0.5 -
tier * roofBand;
addGhostBlock(
roofGroup,
[
dwelling.x - sideCenter,
tier * 0.20 + 0.09,
dwelling.z
],
[roofBand, 0.18, roofDepth]
);
addGhostBlock(
roofGroup,
[
dwelling.x + sideCenter,
tier * 0.20 + 0.09,
dwelling.z
],
[roofBand, 0.18, roofDepth]
);
}
// Dashed survey outline at floor level.
const outlineY = dwelling.baseY + 0.025;
const outlinePoints = [
new THREE.Vector3(
dwelling.x - dwelling.width * 0.5,
outlineY,
dwelling.z - dwelling.depth * 0.5
),
new THREE.Vector3(
dwelling.x + dwelling.width * 0.5,
outlineY,
dwelling.z - dwelling.depth * 0.5
),
new THREE.Vector3(
dwelling.x + dwelling.width * 0.5,
outlineY,
dwelling.z + dwelling.depth * 0.5
),
new THREE.Vector3(
dwelling.x - dwelling.width * 0.5,
outlineY,
dwelling.z + dwelling.depth * 0.5
),
new THREE.Vector3(
dwelling.x - dwelling.width * 0.5,
outlineY,
dwelling.z - dwelling.depth * 0.5
)
];
const outline = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(outlinePoints),
new THREE.LineDashedMaterial({
color: 0x8aeeea,
dashSize: 0.18,
gapSize: 0.11,
transparent: true,
opacity: 0.85,
depthWrite: false
})
);
outline.computeLineDistances();
outline.renderOrder = 6;
inferenceGroup.add(outline);
// Survey stakes at the hypothetical corners.
for (const [x, z] of [
[dwelling.x - dwelling.width * 0.5, dwelling.z - dwelling.depth * 0.5],
[dwelling.x + dwelling.width * 0.5, dwelling.z - dwelling.depth * 0.5],
[dwelling.x + dwelling.width * 0.5, dwelling.z + dwelling.depth * 0.5],
[dwelling.x - dwelling.width * 0.5, dwelling.z + dwelling.depth * 0.5]
]) {
addSolid(
inferenceGroup,
[x, dwelling.baseY + 0.24, z],
[0.07, 0.48, 0.07],
0xd6b35d
);
}
function updateInferenceHeight(heightMeters) {
const factor = heightMeters / dwelling.nominalWallHeight;
wallGroup.scale.y = factor;
roofGroup.position.y =
dwelling.baseY +
dwelling.nominalWallHeight * factor;
roofGroup.scale.y = factor;
}
updateInferenceHeight(1.8);
// -------------------------------------------------------------------------
// Screen-space archaeological labels
// -------------------------------------------------------------------------
const annotationContainer = document.querySelector("#annotations");
const annotationDefinitions = [
{
id: "house",
className: "cyan",
title: "Hypothetical dwelling",
subtitle: "superstructure not preserved",
position: new THREE.Vector3(-3.72, 2.55, 0),
visible: () => inferenceGroup.visible
},
{
id: "foundation",
className: "",
title: "Surviving foundation",
subtitle: "solid masonry footings",
position: new THREE.Vector3(2.4, 0.62, 1.66),
visible: () => evidenceGroup.visible
},
{
id: "hearth",
className: "",
title: "Hearth",
subtitle: "charcoal and fire-reddened stone",
position: new THREE.Vector3(2.65, 0.28, -0.18),
visible: () => evidenceGroup.visible
},
{
id: "alignment",
className: "",
title: "Possible alignment",
subtitle: "fired-clay material",
position: new THREE.Vector3(5.12, 0.27, 0.63),
visible: () => evidenceGroup.visible
},
{
id: "natural",
className: "layer",
title: "Stratum 01",
subtitle: "natural substrate",
position: new THREE.Vector3(0.55, -0.65, 2.93),
visible: () => strataGroup.visible
},
{
id: "deposit",
className: "layer",
title: "Stratum 02",
subtitle: "accumulated deposit",
position: new THREE.Vector3(1.45, -0.43, 2.83),
visible: () => strataGroup.visible
},
{
id: "occupation",
className: "layer",
title: "Stratum 03",
subtitle: "occupation horizon",
position: new THREE.Vector3(3.05, -0.22, 2.73),
visible: () => strataGroup.visible
}
];
for (const definition of annotationDefinitions) {
const element = document.createElement("div");
element.className = `annotation ${definition.className}`;
element.innerHTML = `
${definition.title}
<small>${definition.subtitle}</small>
`;
annotationContainer.appendChild(element);
definition.element = element;
}
const annotationProjection = new THREE.Vector3();
function updateAnnotations() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const definition of annotationDefinitions) {
if (!definition.visible()) {
definition.element.style.display = "none";
continue;
}
annotationProjection
.copy(definition.position)
.project(camera);
const x = (annotationProjection.x * 0.5 + 0.5) * width;
const y = (-annotationProjection.y * 0.5 + 0.5) * height;
const onScreen =
annotationProjection.z > -1 &&
annotationProjection.z < 1 &&
x > -80 &&
x < width + 80 &&
y > -40 &&
y < height + 40;
if (!onScreen) {
definition.element.style.display = "none";
continue;
}
definition.element.style.display = "block";
definition.element.style.left = `${x}px`;
definition.element.style.top = `${y}px`;
}
}
// -------------------------------------------------------------------------
// UI controls
// -------------------------------------------------------------------------
const evidenceToggle = document.querySelector("#toggle-evidence");
const strataToggle = document.querySelector("#toggle-strata");
const inferenceToggle = document.querySelector("#toggle-inference");
const wallHeightInput = document.querySelector("#wall-height");
const wallHeightValue = document.querySelector("#wall-height-value");
const opacityInput = document.querySelector("#ghost-opacity");
const opacityValue = document.querySelector("#opacity-value");
const resetButton = document.querySelector("#reset-view");
const compass = document.querySelector("#compass");
evidenceToggle.addEventListener("change", () => {
evidenceGroup.visible = evidenceToggle.checked;
});
strataToggle.addEventListener("change", () => {
strataGroup.visible = strataToggle.checked;
});
inferenceToggle.addEventListener("change", () => {
inferenceGroup.visible = inferenceToggle.checked;
});
wallHeightInput.addEventListener("input", () => {
const height = Number(wallHeightInput.value);
wallHeightValue.value = `${height.toFixed(1)} m`;
updateInferenceHeight(height);
const houseDefinition = annotationDefinitions.find(
(item) => item.id === "house"
);
houseDefinition.position.y =
dwelling.baseY +
height +
1.02;
});
opacityInput.addEventListener("input", () => {
const opacity = Number(opacityInput.value);
opacityValue.value = `${opacity}%`;
ghostMaterial.opacity = opacity / 100;
ghostEdgeMaterial.opacity = Math.min(0.82, (opacity / 100) * 3.4);
});
function resetCamera() {
cameraTheta = defaultCamera.theta;
cameraPhi = defaultCamera.phi;
cameraZoom = defaultCamera.zoom;
target.set(-0.15, 0.15, 0);
}
resetButton.addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, zoom, and keyboard alternatives
// -------------------------------------------------------------------------
const canvas = renderer.domElement;
let dragging = false;
let panning = false;
let previousX = 0;
let previousY = 0;
let activePointerId = null;
const rightVector = new THREE.Vector3();
const forwardVector = new THREE.Vector3();
canvas.addEventListener("pointerdown", (event) => {
if (activePointerId !== null) return;
activePointerId = event.pointerId;
dragging = true;
panning = event.shiftKey || event.button === 1 || event.button === 2;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointerId) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (panning) {
const worldPerPixel =
(camera.top - camera.bottom) /
camera.zoom /
window.innerHeight;
rightVector
.setFromMatrixColumn(camera.matrix, 0)
.setY(0)
.normalize();
camera.getWorldDirection(forwardVector);
forwardVector.setY(0).normalize();
target.addScaledVector(rightVector, -dx * worldPerPixel);
target.addScaledVector(forwardVector, dy * worldPerPixel);
target.x = THREE.MathUtils.clamp(target.x, -4.5, 4.5);
target.z = THREE.MathUtils.clamp(target.z, -3.5, 3.5);
} else {
cameraTheta -= dx * 0.006;
cameraPhi = THREE.MathUtils.clamp(
cameraPhi - dy * 0.005,
0.34,
1.38
);
}
});
function endPointer(event) {
if (event.pointerId !== activePointerId) return;
dragging = false;
panning = false;
activePointerId = null;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.001),
0.62,
1.85
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (
event.target instanceof HTMLInputElement ||
event.target instanceof HTMLButtonElement
) {
return;
}
switch (event.key) {
case "ArrowLeft":
cameraTheta -= 0.08;
break;
case "ArrowRight":
cameraTheta += 0.08;
break;
case "ArrowUp":
cameraPhi = THREE.MathUtils.clamp(cameraPhi - 0.06, 0.34, 1.38);
break;
case "ArrowDown":
cameraPhi = THREE.MathUtils.clamp(cameraPhi + 0.06, 0.34, 1.38);
break;
case "+":
case "=":
cameraZoom = Math.min(1.85, cameraZoom * 1.08);
break;
case "-":
cameraZoom = Math.max(0.62, cameraZoom / 1.08);
break;
case "r":
case "R":
resetCamera();
break;
}
});
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
// Preserve the entire site on narrow displays.
const viewHeight = Math.max(10.6, 14.7 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
function updateCamera() {
const sinPhi = Math.sin(cameraPhi);
const radius = 18;
camera.position.set(
target.x + radius * sinPhi * Math.sin(cameraTheta),
target.y + radius * Math.cos(cameraPhi),
target.z + radius * sinPhi * Math.cos(cameraTheta)
);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
camera.lookAt(target);
camera.updateMatrixWorld();
compass.style.transform = `rotate(${-cameraTheta * THREE.MathUtils.RAD2DEG}deg)`;
}
let firstFrame = true;
function animate() {
updateCamera();
updateAnnotations();
renderer.render(scene, camera);
if (firstFrame) {
loading.style.display = "none";
firstFrame = false;
}
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```