Prompt specification
Build or customize the Three.js 3D scene "Storehouse tally table at Uruk" 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: Storehouse tally table at Uruk
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/storehouse-tally-table-at-uruk-x2298
Scene Description Prompt:
Make a cutaway Three.js scene in a self-contained HTML file using cdnjs: Storehouse tally table at Uruk. Create a stylized Uruk accounting table with tokens, a clay envelope, and grain containers. Show one recorded delivery without inventing readable ancient text.
Working Three.js Starter (storehouse-tally-table-at-uruk-x2298):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Uruk Storehouse — Accounting Cutaway</title>
<style>
:root {
color-scheme: dark;
--ink: #f4e6c9;
--muted: #cdbb98;
--panel: rgba(35, 25, 18, 0.82);
--line: rgba(244, 230, 201, 0.2);
--accent: #d99458;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b89c73;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#app, canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
canvas {
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
color: var(--ink);
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
header {
position: absolute;
top: clamp(18px, 3vw, 34px);
left: clamp(18px, 3vw, 38px);
max-width: 520px;
}
.eyebrow {
margin-bottom: 7px;
color: #f4c38f;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 54px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.025em;
}
header p {
margin: 12px 0 0;
max-width: 460px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.record {
position: absolute;
top: clamp(18px, 3vw, 34px);
right: clamp(18px, 3vw, 38px);
width: min(270px, calc(100vw - 36px));
padding: 17px 18px;
border: 1px solid var(--line);
border-radius: 4px;
background: var(--panel);
backdrop-filter: blur(12px);
box-shadow: 0 16px 50px rgba(0, 0, 0, 0.2);
}
.record-title {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 12px;
color: #f4c38f;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.record-title::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(217, 148, 88, 0.15);
}
.record strong {
display: block;
margin-bottom: 6px;
font-family: Georgia, "Times New Roman", serif;
font-size: 21px;
font-weight: 500;
}
.record p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.record small {
display: block;
margin-top: 12px;
padding-top: 11px;
border-top: 1px solid var(--line);
color: #bca986;
font-size: 10px;
line-height: 1.45;
}
footer {
position: absolute;
left: clamp(18px, 3vw, 38px);
right: clamp(18px, 3vw, 38px);
bottom: clamp(16px, 2.6vw, 30px);
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 20px;
}
.caption {
max-width: 570px;
padding: 13px 16px;
border-left: 2px solid rgba(244, 195, 143, 0.85);
background: linear-gradient(90deg, rgba(35, 25, 18, 0.8), rgba(35, 25, 18, 0.08));
color: #ead9b8;
font-size: 12px;
line-height: 1.5;
}
.caption b {
color: #fff1d3;
}
.views {
pointer-events: auto;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 7px;
}
button {
appearance: none;
border: 1px solid rgba(255, 237, 204, 0.24);
border-radius: 3px;
padding: 9px 12px;
background: rgba(35, 25, 18, 0.78);
color: #ead9b8;
cursor: pointer;
font: 600 10px/1.1 Inter, ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
backdrop-filter: blur(8px);
transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
button:hover,
button:focus-visible {
border-color: rgba(255, 237, 204, 0.6);
background: rgba(69, 45, 28, 0.92);
color: #fff1d3;
outline: none;
}
button.active {
border-color: #d99458;
color: #ffd6a7;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #b89c73;
color: #493322;
font: 600 11px/1 Inter, sans-serif;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
header p { display: none; }
.record { top: auto; bottom: 84px; width: 220px; }
.record p, .record small { display: none; }
.caption { display: none; }
footer { justify-content: flex-end; }
.views { width: 100%; }
button { flex: 1; }
}
</style>
</head>
<body>
<div id="app"></div>
<div class="hud">
<header>
<div class="eyebrow">Stylized reconstruction · Southern Mesopotamia</div>
<h1>Storehouse Tally<br />at Uruk</h1>
<p>
A cutaway view of a single delivery being counted with clay tokens
and preserved as one abstract clay record.
</p>
</header>
<aside class="record" aria-label="Scene interpretation">
<div class="record-title">One recorded delivery</div>
<strong>Three grouped tokens</strong>
<p>One grouped set of tokens and one corresponding clay entry.</p>
<small>
Modern annotation only. The clay marks are deliberately abstract
and do not imitate or invent readable ancient script.
</small>
</aside>
<footer>
<div class="caption">
<b>Drag</b> to orbit · <b>Scroll</b> to zoom · <b>Double-click</b> to reset.
The room is cut away at the front and right; grain jars remain in the storeroom.
</div>
<nav class="views" aria-label="Camera views">
<button data-view="overview" class="active">Overview</button>
<button data-view="ledger">Ledger</button>
<button data-view="grain">Grain Store</button>
</nav>
</footer>
</div>
<div id="loading">Preparing the storehouse…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const loading = document.getElementById("loading");
// ---------------------------------------------------------------------
// Renderer, scene, camera
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb89c73);
scene.fog = new THREE.Fog(0xb89c73, 13, 24);
const camera = new THREE.PerspectiveCamera(
39,
innerWidth / innerHeight,
0.1,
60
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
app.appendChild(renderer.domElement);
// ---------------------------------------------------------------------
// Deterministic procedural textures — no external assets
// ---------------------------------------------------------------------
function seededRandom(seed) {
let value = seed >>> 0;
return () => {
value = (value * 1664525 + 1013904223) >>> 0;
return value / 4294967296;
};
}
function canvasTexture(size, draw, repeatX = 1, repeatY = 1) {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = size;
const ctx = canvas.getContext("2d");
draw(ctx, size);
const texture = new THREE.CanvasTexture(canvas);
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(repeatX, repeatY);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
const brickTexture = canvasTexture(512, (ctx, s) => {
const random = seededRandom(117);
ctx.fillStyle = "#775039";
ctx.fillRect(0, 0, s, s);
const rowHeight = 64;
for (let row = 0; row < s / rowHeight; row++) {
const offset = row % 2 ? -80 : 0;
for (let x = offset; x < s; x += 160) {
const shade = 145 + Math.floor(random() * 35);
const r = Math.floor(shade * 1.25);
const g = Math.floor(shade * 0.72);
const b = Math.floor(shade * 0.43);
ctx.fillStyle = `rgb(${r},${g},${b})`;
ctx.fillRect(x + 5, row * rowHeight + 5, 150, rowHeight - 10);
}
}
for (let i = 0; i < 5500; i++) {
ctx.fillStyle = random() > 0.5
? "rgba(255,220,165,0.055)"
: "rgba(54,28,16,0.07)";
const size2 = random() * 3 + 0.5;
ctx.fillRect(random() * s, random() * s, size2, size2);
}
const gradient = ctx.createLinearGradient(0, 0, 0, s);
gradient.addColorStop(0, "rgba(255,255,255,0.07)");
gradient.addColorStop(1, "rgba(30,15,8,0.12)");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, s, s);
}, 4, 2.4);
const clayTexture = canvasTexture(256, (ctx, s) => {
const random = seededRandom(913);
ctx.fillStyle = "#b66e43";
ctx.fillRect(0, 0, s, s);
for (let i = 0; i < 2600; i++) {
const light = random() > 0.5;
ctx.fillStyle = light
? "rgba(255,205,145,0.08)"
: "rgba(68,31,18,0.08)";
const r = random() * 2.6 + 0.4;
ctx.beginPath();
ctx.arc(random() * s, random() * s, r, 0, Math.PI * 2);
ctx.fill();
}
}, 2, 2);
const paleClayTexture = canvasTexture(256, (ctx, s) => {
const random = seededRandom(403);
ctx.fillStyle = "#c9905d";
ctx.fillRect(0, 0, s, s);
for (let i = 0; i < 3000; i++) {
ctx.fillStyle = random() > 0.5
? "rgba(255,225,180,0.10)"
: "rgba(77,37,21,0.08)";
const r = random() * 2.5 + 0.4;
ctx.fillRect(random() * s, random() * s, r, r);
}
}, 2, 2);
const woodTexture = canvasTexture(256, (ctx, s) => {
const random = seededRandom(71);
ctx.fillStyle = "#745034";
ctx.fillRect(0, 0, s, s);
for (let i = 0; i < 180; i++) {
const y = random() * s;
ctx.strokeStyle = random() > 0.5
? "rgba(35,20,12,0.22)"
: "rgba(220,170,100,0.12)";
ctx.lineWidth = random() * 2 + 0.5;
ctx.beginPath();
ctx.moveTo(0, y);
ctx.bezierCurveTo(s * 0.3, y + random() * 9, s * 0.7, y - random() * 9, s, y + random() * 4);
ctx.stroke();
}
for (let i = 0; i < 6; i++) {
const x = random() * s;
const y = random() * s;
ctx.strokeStyle = "rgba(44,24,14,0.22)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.ellipse(x, y, 14 + random() * 18, 5 + random() * 7, random(), 0, Math.PI * 2);
ctx.stroke();
}
}, 2, 2);
const floorTexture = canvasTexture(512, (ctx, s) => {
const random = seededRandom(22);
ctx.fillStyle = "#987754";
ctx.fillRect(0, 0, s, s);
for (let i = 0; i < 7000; i++) {
ctx.fillStyle = random() > 0.5
? "rgba(239,209,157,0.09)"
: "rgba(44,29,18,0.09)";
const r = random() * 3 + 0.5;
ctx.fillRect(random() * s, random() * s, r, r);
}
ctx.strokeStyle = "rgba(54,37,22,0.13)";
ctx.lineWidth = 2;
for (let y = 0; y <= s; y += 128) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(s, y);
ctx.stroke();
const offset = (y / 128) % 2 ? 64 : 0;
for (let x = offset; x <= s; x += 128) {
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x, y + 128);
ctx.stroke();
}
}
}, 5, 4);
const matTexture = canvasTexture(256, (ctx, s) => {
ctx.fillStyle = "#b99a68";
ctx.fillRect(0, 0, s, s);
for (let y = 0; y < s; y += 8) {
ctx.fillStyle = y % 16 === 0 ? "rgba(66,42,23,0.16)" : "rgba(255,226,170,0.12)";
ctx.fillRect(0, y, s, 3);
}
for (let x = 0; x < s; x += 8) {
ctx.fillStyle = x % 16 === 0 ? "rgba(255,232,184,0.10)" : "rgba(63,38,20,0.12)";
ctx.fillRect(x, 0, 2, s);
}
}, 3, 2);
const sackTexture = canvasTexture(256, (ctx, s) => {
const random = seededRandom(801);
ctx.fillStyle = "#b69b6a";
ctx.fillRect(0, 0, s, s);
for (let i = 0; i < 2200; i++) {
ctx.fillStyle = random() > 0.5
? "rgba(255,232,184,0.10)"
: "rgba(76,52,26,0.10)";
ctx.fillRect(random() * s, random() * s, 2, 1);
}
}, 2, 2);
// ---------------------------------------------------------------------
// Materials and geometry helpers
// ---------------------------------------------------------------------
const wallMaterial = new THREE.MeshStandardMaterial({
map: brickTexture,
bumpMap: brickTexture,
bumpScale: 0.035,
roughness: 0.96
});
const floorMaterial = new THREE.MeshStandardMaterial({
map: floorTexture,
roughness: 0.93
});
const woodMaterial = new THREE.MeshStandardMaterial({
map: woodTexture,
roughness: 0.78
});
const darkWoodMaterial = new THREE.MeshStandardMaterial({
color: 0x49301f,
map: woodTexture,
roughness: 0.88
});
const clayMaterial = new THREE.MeshStandardMaterial({
map: clayTexture,
bumpMap: clayTexture,
bumpScale: 0.025,
roughness: 0.9
});
const paleClayMaterial = new THREE.MeshStandardMaterial({
map: paleClayTexture,
bumpMap: paleClayTexture,
bumpScale: 0.018,
roughness: 0.88
});
const darkClayMaterial = new THREE.MeshStandardMaterial({
color: 0x875036,
roughness: 0.92
});
const sackMaterial = new THREE.MeshStandardMaterial({
map: sackTexture,
roughness: 1
});
const grainMaterial = new THREE.MeshStandardMaterial({
color: 0xd9b965,
roughness: 0.78
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x3e2a20,
roughness: 0.9
});
function addMesh(parent, geometry, material, position, rotation = null) {
const mesh = new THREE.Mesh(geometry, material);
if (position) mesh.position.set(...position);
if (rotation) mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedSlab(width, depth, height, radius = 0.08) {
const w = width / 2;
const d = depth / 2;
const r = Math.min(radius, w, d);
const shape = new THREE.Shape();
shape.moveTo(-w + r, -d);
shape.lineTo(w - r, -d);
shape.quadraticCurveTo(w, -d, w, -d + r);
shape.lineTo(w, d - r);
shape.quadraticCurveTo(w, d, w - r, d);
shape.lineTo(-w + r, d);
shape.quadraticCurveTo(-w, d, -w, d - r);
shape.lineTo(-w, -d + r);
shape.quadraticCurveTo(-w, -d, -w + r, -d);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: height,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: Math.min(0.018, height * 0.22),
bevelThickness: Math.min(0.018, height * 0.22),
curveSegments: 10
});
geometry.translate(0, 0, -height / 2);
geometry.rotateX(-Math.PI / 2);
geometry.computeVertexNormals();
return geometry;
}
// ---------------------------------------------------------------------
// Architecture: the front and right sides are intentionally cut away
// ---------------------------------------------------------------------
const architecture = new THREE.Group();
scene.add(architecture);
addMesh(
architecture,
new THREE.BoxGeometry(10.3, 0.38, 8.3),
floorMaterial,
[0, -0.24, 0]
);
addMesh(
architecture,
new THREE.BoxGeometry(10.2, 5.35, 0.36),
wallMaterial,
[0, 2.48, -4.02]
);
addMesh(
architecture,
new THREE.BoxGeometry(0.36, 4.3, 8.1),
wallMaterial,
[-5.02, 1.93, 0]
);
// Cut edges emphasize that this is an architectural section.
const cutEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0xc18b58,
roughness: 0.9
});
addMesh(
architecture,
new THREE.BoxGeometry(0.39, 4.32, 0.11),
cutEdgeMaterial,
[-5.02, 1.93, 4.08]
);
addMesh(
architecture,
new THREE.BoxGeometry(0.12, 5.38, 0.39),
cutEdgeMaterial,
[5.08, 2.48, -4.02]
);
// Timber roof remnants.
addMesh(
architecture,
new THREE.BoxGeometry(10.45, 0.25, 0.43),
darkWoodMaterial,
[0, 5.05, -3.82]
);
addMesh(
architecture,
new THREE.BoxGeometry(0.28, 0.28, 2.3),
darkWoodMaterial,
[-3.7, 4.88, -2.85],
[0.16, 0, 0]
);
// A shallow wall shelf for additional stores.
addMesh(
architecture,
new THREE.BoxGeometry(4.4, 0.13, 0.72),
woodMaterial,
[0.8, 2.5, -3.55]
);
for (const x of [-0.8, 2.2]) {
addMesh(
architecture,
new THREE.BoxGeometry(0.13, 1.25, 0.16),
darkWoodMaterial,
[x, 1.87, -3.66]
);
}
// ---------------------------------------------------------------------
// Pottery helpers
// ---------------------------------------------------------------------
function makeJar({
scale = 1,
open = false,
bandColor = 0x5d4030,
handles = true
} = {}) {
const group = new THREE.Group();
const profile = [
new THREE.Vector2(0.22, 0.00),
new THREE.Vector2(0.43, 0.07),
new THREE.Vector2(0.56, 0.42),
new THREE.Vector2(0.53, 0.88),
new THREE.Vector2(0.36, 1.21),
new THREE.Vector2(0.28, 1.34),
new THREE.Vector2(0.31, 1.42),
new THREE.Vector2(0.25, 1.45),
new THREE.Vector2(0.23, 1.37),
new THREE.Vector2(0.27, 1.31),
new THREE.Vector2(0.43, 0.91),
new THREE.Vector2(0.47, 0.47),
new THREE.Vector2(0.34, 0.16),
new THREE.Vector2(0.20, 0.08)
];
addMesh(group, new THREE.LatheGeometry(profile, 36), clayMaterial);
const bandMaterial = new THREE.MeshStandardMaterial({
color: bandColor,
roughness: 0.86
});
const band = addMesh(
group,
new THREE.TorusGeometry(0.535, 0.035, 8, 36),
bandMaterial,
[0, 0.83, 0],
[Math.PI / 2, 0, 0]
);
band.scale.y = 1.015;
if (handles) {
for (const side of [-1, 1]) {
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(side * 0.45, 1.08, 0),
new THREE.Vector3(side * 0.67, 0.98, 0),
new THREE.Vector3(side * 0.64, 0.72, 0),
new THREE.Vector3(side * 0.48, 0.59, 0)
]);
addMesh(
group,
new THREE.TubeGeometry(curve, 16, 0.047, 8, false),
clayMaterial
);
}
}
if (open) {
const grain = addMesh(
group,
new THREE.SphereGeometry(0.37, 24, 12),
grainMaterial,
[0, 1.28, 0]
);
grain.scale.set(1, 0.16, 1);
} else {
const lid = addMesh(
group,
new THREE.CylinderGeometry(0.285, 0.31, 0.085, 28),
darkClayMaterial,
[0, 1.45, 0]
);
lid.castShadow = true;
}
group.scale.setScalar(scale);
return group;
}
function makeSack(scale = 1, rotation = 0) {
const group = new THREE.Group();
const body = addMesh(
group,
new THREE.SphereGeometry(0.6, 24, 18),
sackMaterial,
[0, 0.58, 0]
);
body.scale.set(0.92, 1.25, 0.82);
const gathered = addMesh(
group,
new THREE.CylinderGeometry(0.19, 0.31, 0.34, 18),
sackMaterial,
[0, 1.27, 0]
);
gathered.scale.z = 0.85;
addMesh(
group,
new THREE.TorusGeometry(0.23, 0.035, 8, 24),
darkWoodMaterial,
[0, 1.18, 0],
[Math.PI / 2, 0, 0]
);
group.scale.setScalar(scale);
group.rotation.y = rotation;
return group;
}
// Shelf storage.
const shelfJarA = makeJar({ scale: 0.52, open: false, handles: false });
shelfJarA.position.set(-0.55, 2.57, -3.45);
scene.add(shelfJarA);
const shelfJarB = makeJar({ scale: 0.47, open: true, handles: false });
shelfJarB.position.set(0.45, 2.57, -3.47);
scene.add(shelfJarB);
const shelfSack = makeSack(0.48, -0.15);
shelfSack.position.set(1.55, 2.55, -3.48);
scene.add(shelfSack);
// ---------------------------------------------------------------------
// Grain storage at floor level
// ---------------------------------------------------------------------
const largeGrainJar = makeJar({
scale: 1.34,
open: true,
bandColor: 0x60412f
});
largeGrainJar.position.set(3.25, 0.02, 0.05);
largeGrainJar.rotation.y = -0.18;
scene.add(largeGrainJar);
const closedJar = makeJar({
scale: 0.93,
open: false,
bandColor: 0x704831
});
closedJar.position.set(4.05, 0.02, -1.75);
closedJar.rotation.y = 0.24;
scene.add(closedJar);
const smallJar = makeJar({
scale: 0.62,
open: false,
bandColor: 0x65402d,
handles: false
});
smallJar.position.set(2.15, 0.02, -2.25);
smallJar.rotation.y = -0.12;
scene.add(smallJar);
const grainSack = makeSack(0.95, 0.35);
grainSack.position.set(2.35, 0.02, 1.7);
scene.add(grainSack);
const secondSack = makeSack(0.72, -0.32);
secondSack.position.set(4.08, 0.02, 1.55);
scene.add(secondSack);
// A low woven basket near the sacks.
const basket = new THREE.Group();
const basketProfile = [
new THREE.Vector2(0.34, 0),
new THREE.Vector2(0.46, 0.08),
new THREE.Vector2(0.54, 0.42),
new THREE.Vector2(0.51, 0.46),
new THREE.Vector2(0.43, 0.15),
new THREE.Vector2(0.31, 0.08)
];
addMesh(basket, new THREE.LatheGeometry(basketProfile, 28), woodMaterial);
basket.position.set(1.25, 0.02, 2.65);
basket.rotation.y = 0.1;
scene.add(basket);
// Loose grain kernels, instanced for low overhead.
const kernelGeometry = new THREE.SphereGeometry(0.034, 6, 4);
const kernels = new THREE.InstancedMesh(kernelGeometry, grainMaterial, 90);
const dummy = new THREE.Object3D();
const random = seededRandom(300);
for (let i = 0; i < 90; i++) {
const angle = random() * Math.PI * 2;
const radius = 0.3 + random() * 0.8;
dummy.position.set(
3.05 + Math.cos(angle) * radius,
0.01 + random() * 0.025,
0.85 + Math.sin(angle) * radius * 0.72
);
dummy.rotation.set(random() * Math.PI, random() * Math.PI, random() * Math.PI);
dummy.scale.set(1 + random(), 0.55 + random() * 0.35, 0.7 + random() * 0.5);
dummy.updateMatrix();
kernels.setMatrixAt(i, dummy.matrix);
}
kernels.castShadow = true;
kernels.receiveShadow = true;
scene.add(kernels);
// ---------------------------------------------------------------------
// Accounting table
// ---------------------------------------------------------------------
const table = new THREE.Group();
table.position.set(-0.85, 0, 0.15);
table.rotation.y = -0.025;
scene.add(table);
// Legs and bracing.
for (const x of [-1.45, 1.45]) {
for (const z of [-0.61, 0.61]) {
addMesh(
table,
new THREE.BoxGeometry(0.16, 1.55, 0.16),
darkWoodMaterial,
[x, 0.76, z]
);
}
}
addMesh(
table,
new THREE.BoxGeometry(3.05, 0.12, 0.12),
darkWoodMaterial,
[0, 0.5, -0.61]
);
addMesh(
table,
new THREE.BoxGeometry(3.05, 0.12, 0.12),
darkWoodMaterial,
[0, 0.5, 0.61]
);
addMesh(
table,
new THREE.BoxGeometry(0.12, 0.12, 1.18),
darkWoodMaterial,
[-1.45, 0.5, 0]
);
addMesh(
table,
new THREE.BoxGeometry(0.12, 0.12, 1.18),
darkWoodMaterial,
[1.45, 0.5, 0]
);
// Thick wooden top and woven work surface.
addMesh(
table,
roundedSlab(3.55, 1.78, 0.18, 0.08),
woodMaterial,
[0, 1.66, 0]
);
const tableMatMaterial = new THREE.MeshStandardMaterial({
map: matTexture,
roughness: 0.96
});
addMesh(
table,
roundedSlab(2.72, 1.28, 0.035, 0.055),
tableMatMaterial,
[-0.05, 1.765, -0.03]
);
// ---------------------------------------------------------------------
// One abstract clay record: a clay tablet with non-linguistic impressions
// ---------------------------------------------------------------------
const tablet = new THREE.Group();
tablet.position.set(-0.55, 1.82, -0.26);
tablet.rotation.y = -0.055;
table.add(tablet);
addMesh(
tablet,
roundedSlab(1.30, 0.76, 0.075, 0.11),
paleClayMaterial
);
// Three deliberately abstract, non-textual impressions form one group.
const impressionMaterial = new THREE.MeshBasicMaterial({
color: 0x6d402a
});
for (const x of [-0.18, 0, 0.18]) {
addMesh(
tablet,
new THREE.CircleGeometry(0.052, 22),
impressionMaterial,
[x, 0.043, 0.02],
[-Math.PI / 2, 0, 0]
);
}
// A shallow impressed ring distinguishes this as a single grouped entry.
const entryRing = addMesh(
tablet,
new THREE.RingGeometry(0.052, 0.071, 24),
impressionMaterial,
[0, 0.044, 0.02],
[-Math.PI / 2, 0, 0]
);
entryRing.material = impressionMaterial;
// ---------------------------------------------------------------------
// Clay envelope beside the tablet
// ---------------------------------------------------------------------
const envelope = new THREE.Group();
envelope.position.set(0.83, 1.82, 0.28);
envelope.rotation.y = 0.18;
table.add(envelope);
addMesh(
envelope,
roundedSlab(0.78, 0.50, 0.075, 0.15),
clayMaterial
);
// Overlapping flap and a narrow shadow beneath it suggest an opened shell.
addMesh(
envelope,
new THREE.BoxGeometry(0.59, 0.018, 0.025),
darkClayMaterial,
[0, 0.046, 0.13]
);
addMesh(
envelope,
roundedSlab(0.67, 0.23, 0.038, 0.08),
paleClayMaterial,
[0.015, 0.075, 0.16],
[0, 0, 0]
);
// ---------------------------------------------------------------------
// Three grouped tokens representing the single delivery
// ---------------------------------------------------------------------
const tokenTray = new THREE.Group();
tokenTray.position.set(-0.64, 1.79, 0.51);
table.add(tokenTray);
addMesh(
tokenTray,
roundedSlab(1.55, 0.46, 0.05, 0.055),
darkWoodMaterial
);
addMesh(
tokenTray,
new THREE.BoxGeometry(1.55, 0.075, 0.045),
woodMaterial,
[0, 0.035, -0.21]
);
addMesh(
tokenTray,
new THREE.BoxGeometry(1.55, 0.075, 0.045),
woodMaterial,
[0, 0.035, 0.21]
);
addMesh(
tokenTray,
new THREE.BoxGeometry(0.045, 0.075, 0.42),
woodMaterial,
[-0.75, 0.035, 0]
);
addMesh(
tokenTray,
new THREE.BoxGeometry(0.045, 0.075, 0.42),
woodMaterial,
[0.75, 0.035, 0]
);
const tokenMaterials = [
new THREE.MeshStandardMaterial({ color: 0xb86943, roughness: 0.88 }),
new THREE.MeshStandardMaterial({ color: 0xd09a65, roughness: 0.9 }),
new THREE.MeshStandardMaterial({ color: 0x8e5135, roughness: 0.88 })
];
const token1 = addMesh(
tokenTray,
new THREE.CylinderGeometry(0.12, 0.12, 0.075, 24),
tokenMaterials[0],
[-0.35, 0.07, 0]
);
token1.rotation.y = 0.2;
const token2 = addMesh(
tokenTray,
new THREE.SphereGeometry(0.13, 20, 12),
tokenMaterials[1],
[0, 0.075, 0]
);
token2.scale.set(1, 0.48, 1);
const token3 = addMesh(
tokenTray,
new THREE.ConeGeometry(0.13, 0.17, 24),
tokenMaterials[2],
[0.35, 0.11, 0]
);
token3.rotation.y = 0.15;
// ---------------------------------------------------------------------
// Extra token bowl beside the table
// ---------------------------------------------------------------------
const stool = new THREE.Group();
stool.position.set(-3.05, 0, 0.85);
scene.add(stool);
addMesh(
stool,
new THREE.CylinderGeometry(0.62, 0.66, 0.13, 28),
woodMaterial,
[0, 0.86, 0]
);
for (let i = 0; i < 3; i++) {
const angle = (i / 3) * Math.PI * 2;
addMesh(
stool,
new THREE.CylinderGeometry(0.08, 0.11, 0.82, 12),
darkWoodMaterial,
[Math.cos(angle) * 0.42, 0.42, Math.sin(angle) * 0.42]
);
}
const bowlProfile = [
new THREE.Vector2(0.22, 0),
new THREE.Vector2(0.38, 0.06),
new THREE.Vector2(0.51, 0.30),
new THREE.Vector2(0.49, 0.35),
new THREE.Vector2(0.43, 0.32),
new THREE.Vector2(0.31, 0.12),
new THREE.Vector2(0.20, 0.07)
];
addMesh(
stool,
new THREE.LatheGeometry(bowlProfile, 30),
clayMaterial,
[0, 0.94, 0]
);
const looseTokenPositions = [
[-0.13, 1.13, -0.03],
[0.08, 1.12, 0.08],
[0.18, 1.12, -0.10],
[-0.05, 1.16, 0.15],
[0.26, 1.11, 0.02]
];
looseTokenPositions.forEach((position, index) => {
const geometry = index % 2
? new THREE.SphereGeometry(0.105, 16, 10)
: new THREE.CylinderGeometry(0.105, 0.105, 0.07, 18);
const token = addMesh(
stool,
geometry,
tokenMaterials[index % tokenMaterials.length],
position
);
token.scale.y = geometry.type === "SphereGeometry" ? 0.55 : 1;
token.rotation.y = index * 0.8;
});
// ---------------------------------------------------------------------
// Lighting and soft architectural accents
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xe8e1c8, 0x65442b, 1.75);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe0a7, 3.2);
sun.position.set(5.5, 9.5, 6.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -8;
sun.shadow.camera.right = 8;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -8;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 25;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const doorwayLight = new THREE.PointLight(0xffc985, 38, 11, 2);
doorwayLight.position.set(-1.8, 3.6, 0.4);
scene.add(doorwayLight);
const fillLight = new THREE.PointLight(0xb9d0cf, 20, 12, 2);
fillLight.position.set(4.0, 4.5, 3.0);
scene.add(fillLight);
// A few simple floor stones and storage details.
const floorRandom = seededRandom(89);
for (let i = 0; i < 12; i++) {
const stone = addMesh(
scene,
new THREE.DodecahedronGeometry(0.07 + floorRandom() * 0.045, 0),
floorMaterial,
[
-4.2 + floorRandom() * 8.4,
0.01,
-3.5 + floorRandom() * 7.1
]
);
stone.scale.set(1.4, 0.45, 1);
stone.rotation.set(floorRandom(), floorRandom(), floorRandom());
}
// ---------------------------------------------------------------------
// Custom camera controls — implemented directly without addons
// ---------------------------------------------------------------------
const defaultView = {
radius: 10.9,
phi: 1.03,
theta: 0.72,
target: new THREE.Vector3(0, 1.35, 0)
};
const currentTarget = defaultView.target.clone();
const desiredTarget = defaultView.target.clone();
const currentSpherical = new THREE.Spherical(
defaultView.radius,
defaultView.phi,
defaultView.theta
);
const desiredSpherical = currentSpherical.clone();
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
let pointerId = null;
function setCameraFromSpherical(spherical, target) {
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerId = event.pointerId;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== pointerId) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
desiredSpherical.theta -= dx * 0.006;
desiredSpherical.phi -= dy * 0.005;
desiredSpherical.phi = THREE.MathUtils.clamp(
desiredSpherical.phi,
0.35,
1.38
);
});
function endDrag(event) {
if (pointerId !== null && event.pointerId !== pointerId) return;
dragging = false;
pointerId = null;
renderer.domElement.style.cursor = "grab";
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
desiredSpherical.radius *= Math.exp(event.deltaY * 0.001);
desiredSpherical.radius = THREE.MathUtils.clamp(
desiredSpherical.radius,
3.2,
16
);
}, { passive: false });
renderer.domElement.style.cursor = "grab";
const views = {
overview: {
radius: 10.9,
phi: 1.03,
theta: 0.72,
target: new THREE.Vector3(0, 1.35, 0)
},
ledger: {
radius: 5.0,
phi: 0.78,
theta: 0.56,
target: new THREE.Vector3(-0.85, 1.65, 0.25)
},
grain: {
radius: 7.8,
phi: 1.02,
theta: 1.08,
target: new THREE.Vector3(2.2, 1.15, -0.2)
}
};
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => {
const view = views[button.dataset.view];
desiredSpherical.radius = view.radius;
desiredSpherical.phi = view.phi;
desiredSpherical.theta = view.theta;
desiredTarget.copy(view.target);
document.querySelectorAll("[data-view]").forEach((other) => {
other.classList.toggle("active", other === button);
});
});
});
renderer.domElement.addEventListener("dblclick", () => {
desiredSpherical.set(
defaultView.radius,
defaultView.phi,
defaultView.theta
);
desiredTarget.copy(defaultView.target);
document.querySelectorAll("[data-view]").forEach((button) => {
button.classList.toggle("active", button.dataset.view === "overview");
});
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const damping = 1 - Math.exp(-delta * 8.5);
currentSpherical.radius = THREE.MathUtils.lerp(
currentSpherical.radius,
desiredSpherical.radius,
damping
);
currentSpherical.phi = THREE.MathUtils.lerp(
currentSpherical.phi,
desiredSpherical.phi,
damping
);
currentSpherical.theta = THREE.MathUtils.lerp(
currentSpherical.theta,
desiredSpherical.theta,
damping
);
currentTarget.lerp(desiredTarget, damping);
setCameraFromSpherical(currentSpherical, currentTarget);
renderer.render(scene, camera);
}
setCameraFromSpherical(currentSpherical, currentTarget);
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```