Prompt specification
Build or customize the Three.js 3D scene "Stone-working area beside a stela base" 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: Stone-working area beside a stela base
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/stone-working-area-beside-a-stela-base-x2266
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts ancient Aksum's monuments and trade. Create a compact stone-working vignette with an unfinished block, measuring cord, and completed base. Label uncertain tool arrangements as illustrative rather than archaeological reconstruction. Voxel style.
Working Three.js Starter (stone-working-area-beside-a-stela-base-x2266):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ancient Aksum — Monuments, Stonework and Trade</title>
<style>
:root {
--ink: #342f29;
--paper: #f4ead5;
--paper-deep: #e5d5b5;
--gold: #bd8d32;
--rust: #984b35;
--line: rgba(78, 60, 40, 0.35);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8ddc5;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
z-index: 10;
top: 24px;
left: 26px;
width: min(360px, calc(100vw - 52px));
padding: 19px 21px 17px;
border: 1px solid rgba(69, 53, 37, 0.28);
border-left: 5px solid var(--rust);
background:
linear-gradient(135deg, rgba(255, 251, 239, 0.94), rgba(239, 224, 194, 0.88));
box-shadow: 0 13px 36px rgba(73, 55, 34, 0.13);
pointer-events: none;
}
.kicker {
margin-bottom: 7px;
color: #86602f;
font: 700 10px/1.3 Arial, sans-serif;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(30px, 4vw, 45px);
font-weight: 500;
line-height: 0.96;
letter-spacing: -0.035em;
}
.subtitle {
margin: 11px 0 14px;
color: #655747;
font-size: 15px;
line-height: 1.35;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.chip {
padding: 5px 7px 4px;
border: 1px solid rgba(88, 66, 42, 0.24);
background: rgba(255, 255, 255, 0.34);
color: #67543f;
font: 700 9px/1 Arial, sans-serif;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#leaders {
position: fixed;
z-index: 3;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
#leaders path {
fill: none;
stroke: rgba(70, 52, 34, 0.58);
stroke-width: 1.15;
stroke-dasharray: 3 4;
}
#leaders circle {
fill: #f5e8ca;
stroke: rgba(70, 52, 34, 0.75);
stroke-width: 1.4;
}
#annotations {
position: fixed;
z-index: 5;
inset: 0;
pointer-events: none;
}
.annotation {
position: absolute;
width: 178px;
padding: 9px 11px 9px 13px;
border: 1px solid rgba(72, 55, 37, 0.32);
background: rgba(248, 239, 218, 0.91);
box-shadow: 0 6px 18px rgba(68, 52, 35, 0.11);
backdrop-filter: blur(4px);
}
.annotation::before {
position: absolute;
top: -1px;
bottom: -1px;
left: -1px;
width: 4px;
background: var(--gold);
content: "";
}
.annotation strong {
display: block;
color: #45392d;
font: 800 10px/1.2 Arial, sans-serif;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.annotation span {
display: block;
margin-top: 4px;
color: #786651;
font-size: 11px;
line-height: 1.25;
}
.annotation.trade::before {
background: var(--rust);
}
.annotation.caution {
border-style: dashed;
}
.annotation.caution::before {
background: #9c5339;
}
.notice {
position: fixed;
z-index: 10;
left: 26px;
bottom: 24px;
width: min(570px, calc(100vw - 52px));
padding: 12px 15px;
border: 1px solid rgba(77, 59, 40, 0.25);
background: rgba(246, 236, 213, 0.9);
color: #675746;
font: 12px/1.45 Arial, sans-serif;
box-shadow: 0 8px 24px rgba(75, 55, 34, 0.1);
pointer-events: none;
}
.notice strong {
color: #4d3d2c;
}
.controls {
position: fixed;
z-index: 10;
right: 25px;
bottom: 25px;
padding: 8px 11px;
border: 1px solid rgba(77, 59, 40, 0.23);
background: rgba(246, 236, 213, 0.82);
color: #6d5b46;
font: 10px/1 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
#loading {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
background: #e8ddc5;
color: #67513a;
font: 12px/1 Arial, sans-serif;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity 0.4s;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 800px) {
.title-card {
top: 14px;
left: 14px;
width: 270px;
padding: 14px 15px;
}
.subtitle {
margin: 8px 0 10px;
font-size: 13px;
}
.annotation {
width: 142px;
padding: 7px 8px 7px 11px;
}
.annotation span {
display: none;
}
.notice {
left: 14px;
bottom: 14px;
width: calc(100vw - 28px);
padding: 9px 11px;
font-size: 10px;
}
.controls {
display: none;
}
}
@media (max-width: 520px) {
.title-card {
width: calc(100vw - 28px);
}
.title-card .subtitle,
.title-card .chips {
display: none;
}
#ann-base,
#ann-tools {
display: none;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive voxel scene of ancient Aksumite stonework and exchange motifs"></div>
<header class="title-card">
<div class="kicker">Horn of Africa · 1st–7th centuries CE</div>
<h1>Ancient Aksum</h1>
<p class="subtitle">Monuments, measured stone and the routes of exchange.</p>
<div class="chips">
<span class="chip">Voxel vignette</span>
<span class="chip">Interpretive scene</span>
<span class="chip">Aksumite highlands</span>
</div>
</header>
<svg id="leaders" aria-hidden="true"></svg>
<div id="annotations" aria-hidden="true"></div>
<div class="notice">
<strong>Interpretive vignette:</strong>
Monument forms and trade goods are stylized.
The measuring sequence, cord placement and tool arrangement are
<strong>illustrative—not an archaeological reconstruction.</strong>
</div>
<div class="controls">Drag to orbit · scroll to zoom</div>
<div id="loading">Building the stone court…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Scene setup
// ---------------------------------------------------------------------
const sceneHost = document.getElementById("scene");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8ddc5);
scene.fog = new THREE.Fog(0xe8ddc5, 42, 78);
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;
renderer.domElement.setAttribute(
"aria-label",
"Voxel-style ancient Aksumite stone-working court"
);
sceneHost.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-20, 20, 13, -13, 0.1, 120);
const cameraTarget = new THREE.Vector3(0, 2.4, 0);
const orbit = {
theta: 0.72,
phi: 0.90,
radius: 37,
zoom: 1
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
cameraTarget.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
cameraTarget.y + orbit.radius * Math.cos(orbit.phi),
cameraTarget.z + orbit.radius * sinPhi * 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 = aspect < 1 ? 31 / aspect : 26;
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();
updateCamera();
// ---------------------------------------------------------------------
// Direct camera controls; no Three.js add-ons are used.
// ---------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - dy * 0.005,
0.48,
1.30
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.0009),
0.70,
1.65
);
updateCamera();
},
{ passive: false }
);
// ---------------------------------------------------------------------
// Materials and voxel helpers
// ---------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.95,
metalness: options.metalness ?? 0,
flatShading: true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
});
const M = {
ground: material(0xcbb489),
groundEdge: material(0xa98c62),
paving: material(0xd9c59b),
pavingAlt: material(0xcbb68a),
granite: material(0x8d7d6c),
graniteDark: material(0x685c50),
graniteLight: material(0xa9957e),
graniteBlue: material(0x777269),
recess: material(0x49423b),
wood: material(0x765039),
woodLight: material(0x9a7048),
cord: material(0xd4a944, { roughness: 0.8 }),
iron: material(0x4b4945, { metalness: 0.22, roughness: 0.72 }),
rust: material(0x9d5138),
rustDark: material(0x713b2d),
gold: material(0xd0a033, { metalness: 0.25, roughness: 0.6 }),
ivory: material(0xe6d8b7),
mat: material(0x7d6247),
teal: material(0x53756d),
skin: material(0x9a6745),
skinDark: material(0x70462f),
hair: material(0x302823),
robe: material(0x6d7d5e),
robeDark: material(0x4f6149),
cream: material(0xd9c7a4)
};
let seed = 7341;
function rand() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
const stoneVariants = [
M.granite,
M.graniteLight,
M.graniteBlue
];
function pickStone() {
return stoneVariants[Math.floor(rand() * stoneVariants.length)];
}
function box(parent, w, h, d, x, y, z, mat) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = h > 0.18;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beamBetween(parent, a, b, thickness, mat) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(thickness, length, thickness),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
const hemi = new THREE.HemisphereLight(0xfff3d6, 0x766552, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0cf, 3.1);
sun.position.set(-14, 24, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 24;
sun.shadow.camera.bottom = -24;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xadc4c2, 0.55);
fill.position.set(15, 10, -16);
scene.add(fill);
// ---------------------------------------------------------------------
// Diorama ground and paving
// ---------------------------------------------------------------------
const GROUND = 0.35;
box(scene, 30, 1.1, 20, 0, -0.55, 0, M.groundEdge);
box(scene, 29.6, 0.35, 19.6, 0, 0.175, 0, M.ground);
// Irregular square paving around the working court.
for (let x = -13; x <= 13; x += 2) {
for (let z = -8; z <= 8; z += 2) {
if (rand() < 0.22) continue;
if (Math.abs(x - 6) < 6 && Math.abs(z - 4) < 5) continue;
const tileMat = rand() > 0.5 ? M.paving : M.pavingAlt;
box(
scene,
1.86,
0.09,
1.86,
x + (rand() - 0.5) * 0.08,
GROUND + 0.045,
z + (rand() - 0.5) * 0.08,
tileMat
);
}
}
// Low rear masonry wall.
for (let i = 0; i < 10; i++) {
const x = -13.2 + i * 2.05;
const h = 0.8 + (i % 3) * 0.18;
box(scene, 1.9, h, 0.8, x, GROUND + h / 2, -8.45, pickStone());
}
// ---------------------------------------------------------------------
// Aksumite stelae
// ---------------------------------------------------------------------
function addStela(x, z, height, width, depth, detailed = true) {
const group = new THREE.Group();
group.position.set(x, GROUND, z);
scene.add(group);
const baseWidth = width + 2.2;
const baseDepth = depth + 1.65;
box(group, baseWidth, 0.55, baseDepth, 0, 0.275, 0, M.graniteDark);
box(group, baseWidth - 0.65, 0.52, baseDepth - 0.55, 0, 0.81, 0, pickStone());
const shaftHeight = height * 0.78;
const shaftY = 1.07 + shaftHeight / 2;
box(group, width, shaftHeight, depth, 0, shaftY, 0, M.granite);
// Stepped crown.
box(
group,
width * 0.83,
height * 0.09,
depth * 0.9,
0,
1.07 + shaftHeight + height * 0.045,
0,
M.graniteLight
);
box(
group,
width * 0.64,
height * 0.13,
depth * 0.76,
0,
1.07 + shaftHeight + height * 0.155,
0,
M.graniteBlue
);
if (detailed) {
// A stylized false door and upper window motif.
const doorWidth = Math.min(1.45, width * 0.43);
const doorHeight = Math.min(4.6, height * 0.43);
const doorY = 1.25 + shaftHeight * 0.45;
const frontZ = depth / 2 + 0.035;
box(
group,
doorWidth,
doorHeight,
0.07,
0,
doorY,
frontZ,
M.recess
);
box(
group,
0.13,
doorHeight + 0.22,
0.11,
-doorWidth / 2 - 0.06,
doorY,
frontZ + 0.07,
M.graniteLight
);
box(
group,
0.13,
doorHeight + 0.22,
0.11,
doorWidth / 2 + 0.06,
doorY,
frontZ + 0.07,
M.graniteLight
);
box(
group,
doorWidth + 0.24,
0.14,
0.12,
0,
doorY + doorHeight / 2 + 0.06,
frontZ + 0.07,
M.graniteLight
);
const windowY = 1.2 + shaftHeight * 0.78;
box(
group,
width * 0.28,
0.65,
0.08,
0,
windowY,
frontZ + 0.03,
M.recess
);
box(
group,
width * 0.34,
0.11,
0.12,
0,
windowY,
frontZ + 0.08,
M.graniteLight
);
box(
group,
0.10,
0.66,
0.12,
0,
windowY,
frontZ + 0.08,
M.graniteLight
);
}
return group;
}
// Distant monumental group.
addStela(-11.5, -5.0, 6.5, 2.15, 1.25, false);
addStela(-8.9, -5.8, 4.8, 1.85, 1.15, false);
addStela(-5.7, -6.1, 3.3, 1.35, 0.95, false);
// Main foreground stela.
addStela(-3.2, -1.25, 10.3, 3.35, 1.85, true);
// ---------------------------------------------------------------------
// Completed stepped base
// ---------------------------------------------------------------------
const completedBase = new THREE.Group();
completedBase.position.set(-7.3, GROUND, 4.65);
scene.add(completedBase);
box(completedBase, 7.0, 0.78, 5.0, 0, 0.39, 0, M.graniteDark);
box(completedBase, 6.25, 0.66, 4.45, 0, 1.11, 0, M.graniteLight);
box(completedBase, 5.45, 0.52, 3.78, 0, 1.70, 0, M.granite);
// Clean corner joints and a small central socket.
box(completedBase, 0.10, 0.54, 3.78, -2.68, 1.70, 0, M.graniteLight);
box(completedBase, 0.10, 0.54, 3.78, 2.68, 1.70, 0, M.graniteLight);
box(completedBase, 0.74, 0.10, 0.74, 0, 2.00, 0, M.recess);
box(completedBase, 0.24, 0.34, 0.24, 0, 2.18, 0, M.graniteDark);
// ---------------------------------------------------------------------
// Unfinished block, measuring cord and tools
// ---------------------------------------------------------------------
const work = new THREE.Group();
work.position.set(6.0, GROUND, 3.35);
scene.add(work);
box(work, 4.8, 4.05, 4.45, 0, 2.025, 0, M.granite);
// Rough, incompletely dressed top and irregular edge blocks.
for (let i = 0; i < 15; i++) {
const w = 0.45 + rand() * 0.85;
const d = 0.45 + rand() * 0.75;
const h = 0.18 + rand() * 0.35;
box(
work,
w,
h,
d,
-2.05 + rand() * 4.1,
4.08 + h / 2,
-1.85 + rand() * 3.7,
rand() > 0.45 ? M.graniteLight : M.graniteBlue
);
}
box(work, 0.65, 0.45, 3.95, -2.46, 2.35, 0, M.graniteLight);
box(work, 0.55, 1.1, 1.0, 2.35, 3.25, 0.55, M.graniteBlue);
// Cord wrapped around the block.
const cordY = 1.62;
const cordFront = 2.36;
const cordBack = -2.36;
const cordLeft = -2.52;
const cordRight = 2.52;
box(work, 5.13, 0.085, 0.085, 0, cordY, cordFront, M.cord);
box(work, 5.13, 0.085, 0.085, 0, cordY, cordBack, M.cord);
box(work, 0.085, 0.085, 4.78, cordLeft, cordY, 0, M.cord);
box(work, 0.085, 0.085, 4.78, cordRight, cordY, 0, M.cord);
// Knots at the corners.
for (const x of [cordLeft, cordRight]) {
for (const z of [cordBack, cordFront]) {
box(work, 0.18, 0.18, 0.18, x, cordY, z, M.cord);
}
}
// Graduated marks along the visible front cord.
for (let x = -2.1; x <= 2.1; x += 0.45) {
box(work, 0.045, 0.23, 0.09, x, cordY, cordFront + 0.07, M.graniteDark);
}
// Loose cord running to an upright measuring stake.
beamBetween(
work,
[cordRight, cordY, cordFront],
[4.10, 0.35, 3.00],
0.075,
M.cord
);
beamBetween(
work,
[4.10, 0.35, 3.00],
[4.82, 2.35, 3.00],
0.075,
M.cord
);
box(work, 0.16, 2.55, 0.16, 4.82, 1.275, 3.00, M.wood);
for (let y = 0.3; y < 2.5; y += 0.45) {
box(work, 0.21, 0.12, 0.21, 4.82, y, 3.00, M.cream);
}
// Illustrative mallet, chisel and wedges.
beamBetween(
work,
[2.80, 0.32, 3.10],
[4.40, 0.32, 2.35],
0.16,
M.woodLight
);
box(work, 0.72, 0.55, 0.62, 4.48, 0.42, 2.28, M.wood);
beamBetween(
work,
[-2.70, 0.35, 3.10],
[-0.50, 0.35, 2.78],
0.11,
M.iron
);
box(work, 0.35, 0.16, 0.30, -0.48, 0.35, 2.77, M.wood);
box(work, 0.55, 0.22, 0.30, 0.65, 0.27, 3.45, M.woodLight);
box(work, 0.42, 0.18, 0.28, 1.12, 0.25, 3.55, M.woodLight);
// ---------------------------------------------------------------------
// Exchange area: amphora, ivory-like pieces, gold and a small chest
// ---------------------------------------------------------------------
const trade = new THREE.Group();
trade.position.set(9.0, GROUND, -3.65);
scene.add(trade);
box(trade, 7.0, 0.18, 4.8, 0, 0.09, 0, M.mat);
box(trade, 7.25, 0.08, 0.18, 0, 0.19, -2.20, M.rustDark);
box(trade, 7.25, 0.08, 0.18, 0, 0.19, 2.20, M.rustDark);
// Stepped amphora.
box(trade, 0.72, 0.32, 0.72, -2.05, 0.34, -0.45, M.rustDark);
box(trade, 1.40, 1.05, 1.40, -2.05, 1.02, -0.45, M.rust);
box(trade, 1.02, 0.45, 1.02, -2.05, 1.77, -0.45, M.rust);
box(trade, 0.48, 0.72, 0.48, -2.05, 2.35, -0.45, M.rustDark);
box(trade, 0.76, 0.16, 0.76, -2.05, 2.77, -0.45, M.rust);
// Small woven sack.
box(trade, 1.25, 1.10, 1.15, 0.05, 0.73, -1.28, M.cream);
box(trade, 0.82, 0.28, 0.80, 0.05, 1.40, -1.28, M.woodLight);
box(trade, 0.30, 0.30, 0.35, 0.05, 1.65, -1.28, M.cream);
// Stylized ivory/tusk pieces.
box(trade, 1.55, 0.34, 0.38, 1.30, 0.36, -1.30, M.ivory);
box(trade, 1.12, 0.34, 0.36, 1.83, 0.60, -1.32, M.ivory);
box(trade, 0.72, 0.32, 0.34, 2.26, 0.79, -1.34, M.ivory);
box(trade, 0.38, 0.28, 0.30, 2.58, 0.92, -1.35, M.ivory);
// Gold as small square ingots/beads.
for (let i = 0; i < 6; i++) {
box(
trade,
0.34,
0.18,
0.34,
0.55 + (i % 3) * 0.46,
0.31 + Math.floor(i / 3) * 0.20,
0.20 + (i % 2) * 0.42,
M.gold
);
}
// Small chest.
box(trade, 1.55, 0.82, 1.05, 2.40, 0.60, 1.25, M.wood);
box(trade, 1.62, 0.16, 1.12, 2.40, 1.08, 1.25, M.woodLight);
box(trade, 0.15, 0.85, 0.13, 2.40, 0.62, 1.81, M.gold);
// ---------------------------------------------------------------------
// Blocky figures
// ---------------------------------------------------------------------
function addPerson(x, z, robeMat, rotation = 0, pose = "idle") {
const person = new THREE.Group();
person.position.set(x, GROUND, z);
person.rotation.y = rotation;
scene.add(person);
box(person, 0.76, 1.02, 0.48, 0, 1.30, 0, robeMat);
box(person, 0.94, 0.42, 0.62, 0, 0.69, 0, robeMat);
box(person, 0.24, 0.60, 0.30, -0.24, 0.28, 0, M.skinDark);
box(person, 0.24, 0.60, 0.30, 0.24, 0.28, 0, M.skinDark);
box(person, 0.52, 0.58, 0.50, 0, 2.10, 0, M.skin);
box(person, 0.57, 0.18, 0.54, 0, 2.43, 0, M.hair);
box(person, 0.08, 0.08, 0.04, -0.11, 2.15, 0.26, M.hair);
box(person, 0.08, 0.08, 0.04, 0.11, 2.15, 0.26, M.hair);
if (pose === "work") {
beamBetween(person, [-0.40, 1.62, 0], [-0.68, 1.14, 0.38], 0.22, robeMat);
beamBetween(person, [0.40, 1.62, 0], [0.78, 1.90, 0.34], 0.22, robeMat);
box(person, 0.28, 0.24, 0.28, 0.80, 1.96, 0.36, M.skin);
} else {
beamBetween(person, [-0.40, 1.60, 0], [-0.60, 0.95, 0.12], 0.22, robeMat);
beamBetween(person, [0.40, 1.60, 0], [0.62, 1.02, 0.30], 0.22, robeMat);
box(person, 0.27, 0.23, 0.27, 0.64, 0.93, 0.31, M.skin);
}
return person;
}
const worker = addPerson(3.15, 4.75, M.robe, 0.72, "work");
addPerson(11.7, -1.35, M.rust, -1.30, "offer");
addPerson(8.0, -1.35, M.teal, 1.25, "idle");
// A few extra crates imply the exchange court without depicting a
// specific historical transaction.
box(scene, 1.45, 1.0, 1.25, 12.7, GROUND + 0.5, -0.55, M.wood);
box(scene, 1.52, 0.14, 1.32, 12.7, GROUND + 1.06, -0.55, M.woodLight);
// ---------------------------------------------------------------------
// Screen-space annotations
// ---------------------------------------------------------------------
const annotationDefs = [
{
id: "stela",
title: "Granite stela",
sub: "False-door motif is stylized",
anchor: new THREE.Vector3(-3.2, 8.8, -1.2),
left: "7%",
top: "35%"
},
{
id: "base",
title: "Completed base",
sub: "Clean, stepped dressed stone",
anchor: new THREE.Vector3(-7.3, 2.0, 4.65),
left: "8%",
top: "68%"
},
{
id: "block",
title: "Unfinished block",
sub: "Rough mass awaiting dressing",
anchor: new THREE.Vector3(6.0, 3.5, 3.35),
left: "73%",
top: "56%"
},
{
id: "cord",
title: "Measuring cord",
sub: "Illustrative measuring sequence",
anchor: new THREE.Vector3(8.8, 2.0, 5.65),
left: "68%",
top: "36%"
},
{
id: "tools",
title: "Illustrative tool set",
sub: "Placement is not archaeologically reconstructed",
anchor: new THREE.Vector3(7.0, 0.85, 6.0),
left: "74%",
top: "74%",
caution: true
},
{
id: "trade",
title: "Exchange motifs",
sub: "Amphora · ivory-like pieces · gold",
anchor: new THREE.Vector3(9.0, 2.5, -3.65),
left: "75%",
top: "17%",
trade: true
}
];
const annotationLayer = document.getElementById("annotations");
const leaderSvg = document.getElementById("leaders");
const svgNS = "http://www.w3.org/2000/svg";
for (const def of annotationDefs) {
const card = document.createElement("article");
card.className = "annotation";
card.id = `ann-${def.id}`;
if (def.caution) card.classList.add("caution");
if (def.trade) card.classList.add("trade");
card.style.left = def.left;
card.style.top = def.top;
card.innerHTML = `
<strong>${def.title}</strong>
<span>${def.sub}</span>
`;
annotationLayer.appendChild(card);
const path = document.createElementNS(svgNS, "path");
const circle = document.createElementNS(svgNS, "circle");
circle.setAttribute("r", "3.2");
leaderSvg.append(path, circle);
def.card = card;
def.path = path;
def.circle = circle;
}
const projected = new THREE.Vector3();
function updateAnnotations() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const def of annotationDefs) {
projected.copy(def.anchor).project(camera);
const anchorX = (projected.x * 0.5 + 0.5) * width;
const anchorY = (-projected.y * 0.5 + 0.5) * height;
const rect = def.card.getBoundingClientRect();
const endX = THREE.MathUtils.clamp(anchorX, rect.left, rect.right);
const endY = THREE.MathUtils.clamp(anchorY, rect.top, rect.bottom);
const elbowX = anchorX + (endX - anchorX) * 0.52;
def.path.setAttribute(
"d",
`M ${anchorX.toFixed(1)} ${anchorY.toFixed(1)}
L ${elbowX.toFixed(1)} ${anchorY.toFixed(1)}
L ${endX.toFixed(1)} ${endY.toFixed(1)}`
);
def.circle.setAttribute("cx", anchorX.toFixed(1));
def.circle.setAttribute("cy", anchorY.toFixed(1));
const visible =
projected.z > -1 &&
projected.z < 1 &&
anchorX > -30 &&
anchorX < width + 30 &&
anchorY > -30 &&
anchorY < height + 30;
def.path.style.opacity = visible ? "1" : "0";
def.circle.style.opacity = visible ? "1" : "0";
}
}
// ---------------------------------------------------------------------
// Render loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
// Very restrained motion keeps the scene readable and diorama-like.
worker.position.y = GROUND + Math.sin(time * 1.8) * 0.025;
worker.rotation.z = Math.sin(time * 1.8) * 0.008;
updateAnnotations();
renderer.render(scene, camera);
}
renderer.render(scene, camera);
updateAnnotations();
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 500);
animate();
</script>
</body>
</html>
```