Prompt specification
Build or customize the Three.js 3D scene "Flood marker beside a Nile field" 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: Flood marker beside a Nile field
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/flood-marker-beside-a-nile-field-x2301
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts ancient Egyptian agriculture on the Nile floodplain. Build a riverbank step with water-height marks and a nearby field strip. Distinguish the measured river level from the field's higher planted surface. Stylized solid forms.
Working Three.js Starter (flood-marker-beside-a-nile-field-x2301):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>The Nile, Measured — Ancient Egyptian Agriculture</title>
<style>
:root {
--ink: #263b38;
--paper: #f3ead2;
--paper-soft: rgba(247, 239, 216, 0.88);
--water: #3f8e91;
--field: #b77a3f;
--ochre: #c68b45;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8cda7;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
canvas:active {
cursor: grabbing;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-card {
position: absolute;
top: 24px;
left: 24px;
width: min(360px, calc(100vw - 48px));
padding: 18px 20px 16px;
border: 1px solid rgba(55, 70, 58, 0.16);
border-radius: 4px;
background: var(--paper-soft);
box-shadow: 0 12px 35px rgba(55, 44, 28, 0.12);
backdrop-filter: blur(8px);
}
.eyebrow {
margin-bottom: 7px;
color: #9a633a;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 39px);
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.025em;
}
.subtitle {
margin: 10px 0 15px;
color: #52635d;
font-size: 13px;
line-height: 1.5;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 15px;
padding-top: 12px;
border-top: 1px solid rgba(55, 70, 58, 0.13);
font-size: 11px;
font-weight: 700;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 7px;
}
.swatch {
width: 12px;
height: 12px;
border-radius: 2px;
box-shadow: inset 0 0 0 1px rgba(30, 40, 35, 0.12);
}
.swatch.water {
background: var(--water);
}
.swatch.field {
background: var(--field);
}
.swatch.bank {
background: #d1a45f;
}
.controls {
position: absolute;
right: 22px;
bottom: 20px;
padding: 9px 12px;
border: 1px solid rgba(55, 70, 58, 0.14);
border-radius: 3px;
background: rgba(247, 239, 216, 0.76);
color: #52635d;
font-size: 11px;
letter-spacing: 0.02em;
backdrop-filter: blur(7px);
}
.scale-note {
position: absolute;
left: 24px;
bottom: 21px;
color: rgba(38, 59, 56, 0.72);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#annotations {
position: fixed;
inset: 0;
pointer-events: none;
overflow: hidden;
}
.callout {
position: absolute;
width: 0;
height: 0;
opacity: 0;
transition: opacity 120ms linear;
}
.callout.visible {
opacity: 1;
}
.callout-dot {
position: absolute;
left: -5px;
top: -5px;
width: 10px;
height: 10px;
border: 2px solid #fff8e8;
border-radius: 50%;
background: var(--ink);
box-shadow: 0 2px 8px rgba(20, 35, 30, 0.25);
}
.callout.water .callout-dot {
background: var(--water);
}
.callout.field .callout-dot {
background: var(--field);
}
.leader {
position: absolute;
left: 0;
top: -1px;
height: 2px;
transform-origin: 0 50%;
background: rgba(38, 59, 56, 0.64);
}
.callout-panel {
position: absolute;
min-width: 160px;
max-width: 220px;
padding: 9px 11px;
border-left: 3px solid var(--ink);
border-radius: 2px;
background: rgba(248, 240, 218, 0.91);
box-shadow: 0 8px 24px rgba(48, 40, 28, 0.13);
backdrop-filter: blur(7px);
}
.callout.water .callout-panel {
border-left-color: var(--water);
}
.callout.field .callout-panel {
border-left-color: var(--field);
}
.callout-title {
color: var(--ink);
font-size: 11px;
font-weight: 850;
line-height: 1.25;
letter-spacing: 0.02em;
}
.callout-detail {
margin-top: 3px;
color: #64716a;
font-size: 10px;
line-height: 1.35;
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
.subtitle {
margin: 8px 0 11px;
}
.legend {
padding-top: 9px;
}
.controls {
right: 14px;
bottom: 14px;
}
.scale-note {
display: none;
}
.callout-panel {
min-width: 132px;
max-width: 165px;
padding: 7px 8px;
}
.callout-title {
font-size: 10px;
}
.callout-detail {
font-size: 9px;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive Three.js scene of ancient Egyptian agriculture on the Nile floodplain"></main>
<div class="ui">
<section class="title-card">
<div class="eyebrow">Floodplain study · c. 1300 BCE</div>
<h1>The Nile, Measured</h1>
<p class="subtitle">
A stepped riverbank rises above the present flood stage. The nearby barley
field sits on a still higher planted terrace.
</p>
<div class="legend" aria-label="Scene legend">
<span class="legend-item">
<span class="swatch water"></span> River level
</span>
<span class="legend-item">
<span class="swatch bank"></span> Bank step
</span>
<span class="legend-item">
<span class="swatch field"></span> Planted field
</span>
</div>
</section>
<div class="scale-note">Diagrammatic elevation · not to scale</div>
<div class="controls">Drag to orbit · Scroll to zoom · R to reset</div>
</div>
<div id="annotations" aria-hidden="true">
<div class="callout water" data-offset-x="-188" data-offset-y="67">
<span class="callout-dot"></span>
<span class="leader"></span>
<div class="callout-panel">
<div class="callout-title">Measured river level</div>
<div class="callout-detail">Present flood stage · 0.00 m</div>
</div>
</div>
<div class="callout" data-offset-x="34" data-offset-y="-68">
<span class="callout-dot"></span>
<span class="leader"></span>
<div class="callout-panel">
<div class="callout-title">Cut bank step</div>
<div class="callout-detail">The exposed terrace begins above the water.</div>
</div>
</div>
<div class="callout field" data-offset-x="30" data-offset-y="-76">
<span class="callout-dot"></span>
<span class="leader"></span>
<div class="callout-panel">
<div class="callout-title">Higher planted field</div>
<div class="callout-detail">Barley terrace · +1.30 m above river level</div>
</div>
</div>
<div class="callout" data-offset-x="-205" data-offset-y="-55">
<span class="callout-dot"></span>
<span class="leader"></span>
<div class="callout-panel">
<div class="callout-title">Shaduf irrigation</div>
<div class="callout-detail">A hand-operated lift raises water to the bank.</div>
</div>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const annotationsRoot = document.getElementById("annotations");
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d8cda7");
scene.fog = new THREE.Fog("#d8cda7", 26, 48);
const camera = new THREE.PerspectiveCamera(38, innerWidth / innerHeight, 0.1, 100);
const renderer = new THREE.WebGLRenderer({
antialias: true,
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.08;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Drag to orbit the ancient Egyptian floodplain. Use arrow keys to rotate and plus or minus to zoom."
);
container.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight("#fff3ce", "#6f614c", 2.0);
scene.add(hemi);
const sunLight = new THREE.DirectionalLight("#fff0c4", 3.0);
sunLight.position.set(-9, 15, 10);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -14;
sunLight.shadow.camera.right = 14;
sunLight.shadow.camera.top = 14;
sunLight.shadow.camera.bottom = -14;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 40;
sunLight.shadow.bias = -0.00035;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight("#8fc7c3", 0.65);
fillLight.position.set(12, 8, -11);
scene.add(fillLight);
const materials = {
base: new THREE.MeshStandardMaterial({ color: "#76503a", roughness: 1 }),
baseDark: new THREE.MeshStandardMaterial({ color: "#5d4033", roughness: 1 }),
clay: new THREE.MeshStandardMaterial({ color: "#a76540", roughness: 1 }),
clayDark: new THREE.MeshStandardMaterial({ color: "#835039", roughness: 1 }),
sand: new THREE.MeshStandardMaterial({ color: "#d8c49a", roughness: 1 }),
bank: new THREE.MeshStandardMaterial({ color: "#d1a45f", roughness: 0.96 }),
bankLight: new THREE.MeshStandardMaterial({ color: "#dfb976", roughness: 0.96 }),
field: new THREE.MeshStandardMaterial({ color: "#9b6039", roughness: 1 }),
ridge: new THREE.MeshStandardMaterial({ color: "#ba7741", roughness: 1 }),
water: new THREE.MeshStandardMaterial({
color: "#3f8e91",
roughness: 0.46,
metalness: 0.03
}),
waterSide: new THREE.MeshStandardMaterial({ color: "#2c7378", roughness: 0.65 }),
wood: new THREE.MeshStandardMaterial({ color: "#6f4b2e", roughness: 1 }),
woodLight: new THREE.MeshStandardMaterial({ color: "#9a6b3e", roughness: 1 }),
rope: new THREE.MeshStandardMaterial({ color: "#c9a66d", roughness: 1 }),
ivory: new THREE.MeshStandardMaterial({ color: "#eee1bd", roughness: 0.88 }),
red: new THREE.MeshStandardMaterial({ color: "#a94f39", roughness: 0.85 }),
ink: new THREE.MeshStandardMaterial({ color: "#293d38", roughness: 0.9 }),
stem: new THREE.MeshStandardMaterial({ color: "#9c9b4b", roughness: 1 }),
grain: new THREE.MeshStandardMaterial({ color: "#d2a13c", roughness: 0.9 }),
green: new THREE.MeshStandardMaterial({ color: "#647b42", roughness: 1 }),
greenDark: new THREE.MeshStandardMaterial({ color: "#405f3b", roughness: 1 }),
skin: new THREE.MeshStandardMaterial({ color: "#70452e", roughness: 0.94 }),
linen: new THREE.MeshStandardMaterial({ color: "#e9dfc2", roughness: 1 }),
hair: new THREE.MeshStandardMaterial({ color: "#29251f", roughness: 1 })
};
function addBox(width, height, depth, material, x, y, z, cast = true, receive = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
scene.add(mesh);
return mesh;
}
function addCylinder(radiusTop, radiusBottom, height, material, x, y, z, segments = 10) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function cylinderBetween(a, b, radius, material, radialSegments = 7) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
material
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function boxBetween(a, b, width, depth, material) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, length, depth),
material
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
const WATER_LEVEL = 0.20;
const LOWER_BANK = 0.65;
const UPPER_BANK = 1.25;
const FIELD_LEVEL = 1.50;
// Ground and cutaway plinth.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(100, 100),
materials.sand
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.92;
ground.receiveShadow = true;
scene.add(ground);
addBox(16, 0.90, 10, materials.base, 0, -0.45, 0);
// Exposed sediment strata on the front and right edges.
const frontStrata = [
[-0.16, 0.10, "#9a6445"],
[-0.43, 0.12, "#67483a"],
[-0.72, 0.12, "#4f3b32"]
];
for (const [y, h, color] of frontStrata) {
const material = new THREE.MeshStandardMaterial({ color, roughness: 1 });
addBox(15.96, h, 0.035, material, 0, y, 5.018, false, true);
addBox(0.035, h, 9.96, material, 8.018, y, 0, false, true);
}
// River: an opaque, stylized solid volume.
addBox(4.80, WATER_LEVEL, 10, materials.water, -5.60, WATER_LEVEL / 2, 0);
addBox(4.82, 0.06, 10.02, materials.waterSide, -5.60, 0.03, 0);
// Two cut-bank steps leading to the elevated field.
addBox(1.40, LOWER_BANK, 10, materials.bank, -2.50, LOWER_BANK / 2, 0);
addBox(2.80, UPPER_BANK - LOWER_BANK, 10, materials.bankLight, -0.40, (UPPER_BANK + LOWER_BANK) / 2, 0);
addBox(6.80, FIELD_LEVEL - UPPER_BANK, 10, materials.field, 4.40, (FIELD_LEVEL + UPPER_BANK) / 2, 0);
// Fine bands exposed in the bank cross-section.
const lowerStrata = [
new THREE.MeshStandardMaterial({ color: "#b98551", roughness: 1 }),
new THREE.MeshStandardMaterial({ color: "#c18c55", roughness: 1 })
];
addBox(1.37, 0.075, 0.035, lowerStrata[0], -2.50, 0.22, 5.018, false);
addBox(1.37, 0.075, 0.035, lowerStrata[1], -2.50, 0.48, 5.018, false);
addBox(2.77, 0.075, 0.035, lowerStrata[0], -0.40, 0.87, 5.018, false);
addBox(2.77, 0.075, 0.035, lowerStrata[1], -0.40, 1.12, 5.018, false);
// Stylized water ripples.
const ripples = [];
let seed = 7251;
const random = () => {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
};
for (let i = 0; i < 27; i++) {
const rippleMaterial = new THREE.MeshBasicMaterial({
color: i % 3 === 0 ? "#b5d8c9" : "#80b8b0",
transparent: true,
opacity: 0.42 + random() * 0.22,
depthWrite: false
});
const ripple = new THREE.Mesh(
new THREE.BoxGeometry(0.35 + random() * 0.95, 0.012, 0.025),
rippleMaterial
);
ripple.position.set(
-7.65 + random() * 4.05,
WATER_LEVEL + 0.008,
-4.65 + random() * 9.3
);
ripple.rotation.y = (random() - 0.5) * 0.35;
ripple.userData.phase = random() * Math.PI * 2;
ripple.userData.baseLength = ripple.scale.x;
scene.add(ripple);
ripples.push(ripple);
}
// Field furrows.
const rowCount = 13;
for (let i = 0; i < rowCount; i++) {
const x = 1.48 + i * 0.49;
addBox(
0.18,
0.075,
8.85,
materials.ridge,
x,
FIELD_LEVEL + 0.035,
0
);
}
// Low-poly barley plants, rendered with instancing.
const plants = [];
for (let row = 0; row < rowCount; row++) {
for (let plant = 0; plant < 17; plant++) {
const x = 1.48 + row * 0.49 + (random() - 0.5) * 0.12;
const z = -4.05 + plant * 0.50 + (random() - 0.5) * 0.11;
const scale = 0.78 + random() * 0.40;
plants.push({ x, z, scale, color: random() });
}
}
const stemMesh = new THREE.InstancedMesh(
new THREE.CylinderGeometry(0.014, 0.022, 0.58, 5),
materials.stem,
plants.length
);
const headMesh = new THREE.InstancedMesh(
new THREE.ConeGeometry(0.070, 0.27, 5),
materials.grain,
plants.length
);
const dummy = new THREE.Object3D();
const grainColors = [
new THREE.Color("#c99332"),
new THREE.Color("#d8aa47"),
new THREE.Color("#bd812d"),
new THREE.Color("#e0b45c")
];
plants.forEach((plant, index) => {
const stemHeight = 0.58 * plant.scale;
dummy.position.set(
plant.x,
FIELD_LEVEL + 0.08 + stemHeight / 2,
plant.z
);
dummy.scale.set(plant.scale, plant.scale, plant.scale);
dummy.rotation.set(0, 0, (plant.color - 0.5) * 0.12);
dummy.updateMatrix();
stemMesh.setMatrixAt(index, dummy.matrix);
dummy.position.y = FIELD_LEVEL + 0.08 + stemHeight + 0.11 * plant.scale;
dummy.scale.set(plant.scale, plant.scale, plant.scale);
dummy.updateMatrix();
headMesh.setMatrixAt(index, dummy.matrix);
const color = grainColors[Math.floor(plant.color * grainColors.length) % grainColors.length];
headMesh.setColorAt(index, color);
});
stemMesh.instanceMatrix.needsUpdate = true;
headMesh.instanceMatrix.needsUpdate = true;
headMesh.instanceColor.needsUpdate = true;
stemMesh.castShadow = true;
headMesh.castShadow = true;
stemMesh.receiveShadow = true;
headMesh.receiveShadow = true;
scene.add(stemMesh, headMesh);
// A small graduated staff stands directly in the river.
const gaugeX = -3.28;
const gaugeZ = 3.25;
for (let i = 0; i < 8; i++) {
addBox(
0.16,
0.205,
0.16,
i % 2 === 0 ? materials.ivory : materials.red,
gaugeX,
0.11 + i * 0.21,
gaugeZ
);
}
for (let i = 0; i < 8; i++) {
addBox(
0.30,
0.025,
0.035,
materials.ink,
gaugeX,
0.20 + i * 0.20,
gaugeZ + 0.098,
false,
false
);
}
// Red marker at the measured present river level.
addBox(
0.42,
0.045,
0.055,
materials.red,
gaugeX - 0.10,
WATER_LEVEL,
gaugeZ + 0.11,
false,
false
);
const levelArrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.19, 3),
materials.red
);
levelArrow.position.set(gaugeX - 0.36, WATER_LEVEL, gaugeZ + 0.11);
levelArrow.rotation.z = Math.PI / 2;
scene.add(levelArrow);
function makeTextSprite(text, color = "#263b38", worldWidth = 0.38) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 96;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = color;
context.font = "700 52px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 128, 50);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(worldWidth, worldWidth * 0.375, 1);
scene.add(sprite);
return sprite;
}
[
["0", 0.20],
["0.5", 0.70],
["1.0", 1.20],
["1.5", 1.50]
].forEach(([label, y]) => {
const sprite = makeTextSprite(label, "#334842", 0.34);
sprite.position.set(gaugeX + 0.25, y, gaugeZ + 0.13);
});
// Comparison bracket outside the field edge.
const bracketX = 8.12;
const bracketZ = 4.20;
const bracketGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(bracketX, WATER_LEVEL, bracketZ),
new THREE.Vector3(bracketX, FIELD_LEVEL, bracketZ)
]);
const bracket = new THREE.Line(
bracketGeometry,
new THREE.LineDashedMaterial({
color: "#405a50",
dashSize: 0.10,
gapSize: 0.065
})
);
bracket.computeLineDistances();
scene.add(bracket);
addBox(0.26, 0.025, 0.025, materials.ink, bracketX, WATER_LEVEL, bracketZ, false, false);
addBox(0.26, 0.025, 0.025, materials.ink, bracketX, FIELD_LEVEL, bracketZ, false, false);
const differenceLabel = makeTextSprite("1.30 m", "#7c4a2c", 0.78);
differenceLabel.position.set(bracketX + 0.02, 0.85, bracketZ);
// A stylized shaduf used to lift water from the river toward the bank.
const shaduf = new THREE.Group();
scene.add(shaduf);
const postA = new THREE.Vector3(-0.65, UPPER_BANK, -2.55);
const postB = new THREE.Vector3(-0.65, 3.08, -2.55);
boxBetween(postA, postB, 0.14, 0.14, materials.wood);
const beamA = new THREE.Vector3(-2.85, 2.70, -2.55);
const beamB = new THREE.Vector3(0.12, 3.02, -2.55);
boxBetween(beamA, beamB, 0.13, 0.13, materials.woodLight);
boxBetween(
new THREE.Vector3(-0.65, 2.38, -2.55),
new THREE.Vector3(-1.55, 2.83, -2.55),
0.075,
0.075,
materials.wood
);
boxBetween(
new THREE.Vector3(-0.65, 2.38, -2.55),
new THREE.Vector3(0.05, 2.91, -2.55),
0.075,
0.075,
materials.wood
);
const bucketTop = new THREE.Vector3(-2.78, 1.23, -2.55);
const bucketBottom = new THREE.Vector3(-2.78, 0.93, -2.55);
cylinderBetween(bucketTop, bucketBottom, 0.025, materials.rope, 5);
const bucket = new THREE.Mesh(
new THREE.CylinderGeometry(0.22, 0.16, 0.31, 10, 1, true),
materials.woodLight
);
bucket.position.set(-2.78, 0.77, -2.55);
bucket.castShadow = true;
bucket.receiveShadow = true;
scene.add(bucket);
const bucketBottomDisc = new THREE.Mesh(
new THREE.CircleGeometry(0.16, 10),
materials.wood
);
bucketBottomDisc.rotation.x = -Math.PI / 2;
bucketBottomDisc.position.set(-2.78, 0.62, -2.55);
scene.add(bucketBottomDisc);
// Papyrus clumps on the low riverbank.
function makePapyrus(x, z, rootY) {
const group = new THREE.Group();
group.position.set(x, rootY, z);
for (let i = 0; i < 7; i++) {
const h = 0.8 + random() * 0.7;
const px = (random() - 0.5) * 0.35;
const pz = (random() - 0.5) * 0.35;
const stem = new THREE.Mesh(
new THREE.CylinderGeometry(0.018, 0.028, h, 5),
i % 2 ? materials.green : materials.greenDark
);
stem.position.set(px, h / 2, pz);
stem.rotation.z = (random() - 0.5) * 0.16;
stem.castShadow = true;
group.add(stem);
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.19, 0.18, 7),
materials.greenDark
);
head.position.set(px, h + 0.04, pz);
head.scale.z = 0.65;
head.castShadow = true;
group.add(head);
}
scene.add(group);
}
makePapyrus(-2.95, -4.15, LOWER_BANK);
makePapyrus(-7.75, 4.25, WATER_LEVEL);
makePapyrus(-7.85, -4.10, WATER_LEVEL);
// Simple farmers, solid and deliberately low-poly.
function makeWorker(x, z, rotation, carryingBasket = false) {
const worker = new THREE.Group();
worker.position.set(x, FIELD_LEVEL, z);
worker.rotation.y = rotation;
const leftLeg = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.07, 0.46, 7),
materials.skin
);
leftLeg.position.set(-0.10, 0.25, 0);
leftLeg.castShadow = true;
worker.add(leftLeg);
const rightLeg = leftLeg.clone();
rightLeg.position.x = 0.10;
worker.add(rightLeg);
const kilt = new THREE.Mesh(
new THREE.CylinderGeometry(0.17, 0.25, 0.30, 9),
materials.linen
);
kilt.position.y = 0.55;
kilt.castShadow = true;
worker.add(kilt);
const torso = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.16, 0.48, 9),
materials.skin
);
torso.position.y = 0.87;
torso.castShadow = true;
worker.add(torso);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.145, 10, 8),
materials.skin
);
head.position.y = 1.23;
head.castShadow = true;
worker.add(head);
const hair = new THREE.Mesh(
new THREE.SphereGeometry(0.15, 10, 8),
materials.hair
);
hair.position.y = 1.29;
hair.scale.set(1, 0.56, 1);
hair.castShadow = true;
worker.add(hair);
const armGeometry = new THREE.CylinderGeometry(0.045, 0.055, 0.48, 7);
const leftArm = new THREE.Mesh(armGeometry, materials.skin);
leftArm.position.set(-0.23, 0.91, 0.03);
leftArm.rotation.z = -0.28;
leftArm.castShadow = true;
worker.add(leftArm);
const rightArm = new THREE.Mesh(armGeometry, materials.skin);
rightArm.position.set(0.23, 0.91, carryingBasket ? 0.08 : 0.03);
rightArm.rotation.z = carryingBasket ? -0.95 : 0.28;
rightArm.castShadow = true;
worker.add(rightArm);
if (carryingBasket) {
const basket = new THREE.Mesh(
new THREE.CylinderGeometry(0.23, 0.18, 0.28, 10, 1, true),
materials.woodLight
);
basket.position.set(0.29, 1.16, 0.10);
basket.rotation.z = -0.15;
basket.castShadow = true;
worker.add(basket);
const basketBase = new THREE.Mesh(
new THREE.CircleGeometry(0.18, 10),
materials.wood
);
basketBase.rotation.x = -Math.PI / 2;
basketBase.position.set(0.29, 1.02, 0.10);
worker.add(basketBase);
} else {
const handleA = new THREE.Vector3(0.24, 0.78, 0.12);
const handleB = new THREE.Vector3(0.58, 0.08, 0.36);
const handle = cylinderBetween(handleA, handleB, 0.027, materials.woodLight, 6);
worker.add(handle);
const blade = new THREE.Mesh(
new THREE.BoxGeometry(0.18, 0.12, 0.055),
materials.ink
);
blade.position.set(0.58, 0.07, 0.36);
blade.rotation.y = 0.2;
blade.castShadow = true;
worker.add(blade);
}
scene.add(worker);
}
makeWorker(3.10, 2.10, -0.35, false);
makeWorker(6.15, -1.35, 2.25, true);
// Warm sun disc in the painted backdrop.
const sunCanvas = document.createElement("canvas");
sunCanvas.width = 256;
sunCanvas.height = 256;
const sunContext = sunCanvas.getContext("2d");
const sunGradient = sunContext.createRadialGradient(128, 128, 10, 128, 128, 125);
sunGradient.addColorStop(0, "rgba(255,244,187,1)");
sunGradient.addColorStop(0.55, "rgba(255,226,151,0.9)");
sunGradient.addColorStop(1, "rgba(255,226,151,0)");
sunContext.fillStyle = sunGradient;
sunContext.fillRect(0, 0, 256, 256);
const sunTexture = new THREE.CanvasTexture(sunCanvas);
sunTexture.colorSpace = THREE.SRGBColorSpace;
const sunSprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: sunTexture,
transparent: true,
depthWrite: false,
fog: false
})
);
sunSprite.position.set(-11, 8.8, -17);
sunSprite.scale.set(5.2, 5.2, 1);
scene.add(sunSprite);
// Projected HTML annotations.
const callouts = [
{
element: document.querySelector(".callout.water"),
anchor: new THREE.Vector3(-5.65, WATER_LEVEL, 3.00)
},
{
element: document.querySelectorAll(".callout")[1],
anchor: new THREE.Vector3(-0.55, UPPER_BANK, -0.45)
},
{
element: document.querySelector(".callout.field"),
anchor: new THREE.Vector3(6.25, FIELD_LEVEL, 2.70)
},
{
element: document.querySelectorAll(".callout")[3],
anchor: new THREE.Vector3(-0.65, 3.05, -2.55)
}
];
callouts.forEach((callout) => {
callout.dx = Number(callout.element.dataset.offsetX);
callout.dy = Number(callout.element.dataset.offsetY);
callout.element.style.setProperty("--dx", `${callout.dx}px`);
callout.element.style.setProperty("--dy", `${callout.dy}px`);
const length = Math.hypot(callout.dx, callout.dy);
const angle = Math.atan2(callout.dy, callout.dx);
const leader = callout.element.querySelector(".leader");
leader.style.width = `${length}px`;
leader.style.transform = `rotate(${angle}rad)`;
});
const projected = new THREE.Vector3();
function updateAnnotations() {
const width = innerWidth;
const height = innerHeight;
callouts.forEach((callout) => {
projected.copy(callout.anchor).project(camera);
const visible = projected.z > -1 && projected.z < 1;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
callout.element.style.left = `${x}px`;
callout.element.style.top = `${y}px`;
callout.element.classList.toggle("visible", visible);
});
}
// Direct camera controls: no external control addons.
const target = new THREE.Vector3(0, 0.72, 0);
let currentTheta = 0.62;
let currentPhi = 0.92;
let currentRadius = 19;
let desiredTheta = currentTheta;
let desiredPhi = currentPhi;
let desiredRadius = currentRadius;
let userAdjustedZoom = false;
let dragging = false;
let pointerId = null;
let lastX = 0;
let lastY = 0;
function updateCamera() {
const sinPhi = Math.sin(currentPhi);
camera.position.set(
target.x + currentRadius * sinPhi * Math.sin(currentTheta),
target.y + currentRadius * Math.cos(currentPhi),
target.z + currentRadius * sinPhi * Math.cos(currentTheta)
);
camera.lookAt(target);
}
function resetCamera() {
desiredTheta = 0.62;
desiredPhi = 0.92;
desiredRadius = innerWidth / innerHeight < 0.8 ? 23 : 19;
userAdjustedZoom = false;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerId = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== pointerId) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
desiredTheta -= dx * 0.006;
desiredPhi = THREE.MathUtils.clamp(desiredPhi - dy * 0.005, 0.42, 1.34);
});
function endDrag(event) {
if (event.pointerId !== pointerId) return;
dragging = false;
pointerId = null;
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
10.5,
28
);
userAdjustedZoom = true;
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "r" || event.key === "R") {
resetCamera();
} else if (event.key === "ArrowLeft") {
desiredTheta += 0.10;
} else if (event.key === "ArrowRight") {
desiredTheta -= 0.10;
} else if (event.key === "ArrowUp") {
desiredPhi = THREE.MathUtils.clamp(desiredPhi - 0.08, 0.42, 1.34);
} else if (event.key === "ArrowDown") {
desiredPhi = THREE.MathUtils.clamp(desiredPhi + 0.08, 0.42, 1.34);
} else if (event.key === "+" || event.key === "=") {
desiredRadius = Math.max(10.5, desiredRadius - 1);
userAdjustedZoom = true;
} else if (event.key === "-" || event.key === "_") {
desiredRadius = Math.min(28, desiredRadius + 1);
userAdjustedZoom = true;
}
});
function resize() {
const width = innerWidth;
const height = innerHeight;
camera.aspect = width / height;
camera.fov = camera.aspect < 0.8 ? 52 : 38;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(width, height);
if (!userAdjustedZoom) {
desiredRadius = camera.aspect < 0.8 ? 23 : 19;
currentRadius = desiredRadius;
}
}
window.addEventListener("resize", resize);
resize();
updateCamera();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
currentTheta += (desiredTheta - currentTheta) * 0.075;
currentPhi += (desiredPhi - currentPhi) * 0.075;
currentRadius += (desiredRadius - currentRadius) * 0.085;
ripples.forEach((ripple) => {
const pulse = 1 + Math.sin(elapsed * 1.2 + ripple.userData.phase) * 0.08;
ripple.scale.x = pulse;
ripple.material.opacity = 0.40 + Math.sin(elapsed * 0.8 + ripple.userData.phase) * 0.10;
});
updateCamera();
updateAnnotations();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```