Prompt specification
Build or customize the Three.js 3D scene "Early modern town lane emergency scene" 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: Early modern town lane emergency scene
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/early-modern-town-lane-emergency-scene-x2359
Scene Description Prompt:
Make a low-poly Three.js scene in a self-contained HTML file using cdnjs: Early modern town lane emergency scene. Build a compact timber-and-masonry street with a water source, access gaps, and coordinated helpers. Keep the fire schematic and focus on route organization rather than destruction.
Working Three.js Starter (early-modern-town-lane-emergency-scene-x2359):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Water Lane — Emergency Route Plan</title>
<style>
:root {
--ink: #222b2a;
--muted: #66706c;
--paper: rgba(248, 246, 235, 0.93);
--line: rgba(42, 55, 51, 0.17);
--water: #168c8b;
--water-dark: #0d6668;
--bucket: #d39a36;
--access: #619b69;
--fire: #dc6242;
--shadow: 0 12px 34px rgba(35, 43, 40, 0.16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d7d1bd;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 5;
border: 1px solid var(--line);
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#title-card {
top: 18px;
left: 18px;
width: min(390px, calc(100vw - 36px));
padding: 17px 18px 15px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 19px;
height: 3px;
background: var(--fire);
}
h1 {
margin: 8px 0 3px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 3vw, 35px);
font-weight: 600;
letter-spacing: -0.035em;
line-height: 1;
}
#title-card p {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
#incident-card {
top: 18px;
right: 18px;
width: 230px;
padding: 14px 15px;
}
.panel-heading {
margin-bottom: 10px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.step {
display: grid;
grid-template-columns: 29px 1fr;
gap: 9px;
align-items: start;
padding: 8px 0;
border-top: 1px solid var(--line);
}
.step:first-of-type { border-top: 0; }
.step b {
display: grid;
place-items: center;
width: 26px;
height: 26px;
border: 1px solid var(--line);
border-radius: 50%;
color: var(--water-dark);
font-size: 9px;
}
.step strong {
display: block;
font-size: 11px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.step span {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
#controls {
right: 18px;
bottom: 18px;
display: flex;
gap: 6px;
padding: 7px;
}
button {
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.58);
color: var(--ink);
padding: 9px 11px;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
cursor: pointer;
}
button:hover {
border-color: rgba(22, 140, 139, 0.55);
background: #fff;
}
button.active {
border-color: var(--water);
background: var(--water);
color: white;
}
#legend {
left: 18px;
bottom: 18px;
padding: 12px 14px;
pointer-events: none;
}
#legend .panel-heading { margin-bottom: 8px; }
.legend-row {
display: flex;
align-items: center;
gap: 8px;
margin-top: 6px;
color: var(--muted);
font-size: 10px;
}
.swatch {
width: 22px;
height: 3px;
background: var(--water);
}
.swatch.bucket { background: var(--bucket); }
.swatch.access { background: var(--access); }
.swatch.fire { background: var(--fire); }
#hint {
position: fixed;
z-index: 4;
left: 50%;
bottom: 20px;
transform: translateX(-50%);
padding: 8px 12px;
border-radius: 2px;
background: rgba(31, 40, 38, 0.78);
color: rgba(255, 255, 255, 0.85);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
white-space: nowrap;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #d7d1bd;
color: #33403d;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity 0.35s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
#title-card {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 13px 14px;
}
#title-card p { display: none; }
#incident-card {
display: none;
}
#legend {
left: 10px;
bottom: 62px;
padding: 9px 11px;
}
#controls {
right: 10px;
bottom: 10px;
}
button { padding: 8px; }
#hint { display: none; }
}
</style>
</head>
<body>
<div id="scene"></div>
<section id="title-card" class="panel">
<div class="eyebrow">Early modern town · incident plan</div>
<h1>Water Lane</h1>
<p>
A coordinated response schematic for a compact timber-and-masonry lane.
Routes, access gaps, staging, and the water source remain legible;
structures are intentionally intact.
</p>
</section>
<section id="incident-card" class="panel">
<div class="panel-heading">Response sequence</div>
<div class="step">
<b>01</b>
<div>
<strong>Draw water</strong>
<span>Cistern and hand pump form the primary source.</span>
</div>
</div>
<div class="step">
<b>02</b>
<div>
<strong>Relay</strong>
<span>Bucket line advances toward the staging area.</span>
</div>
</div>
<div class="step">
<b>03</b>
<div>
<strong>Attack</strong>
<span>Hose uses the eastern gap without blocking the lane.</span>
</div>
</div>
</section>
<section id="legend" class="panel">
<div class="panel-heading">Operational overlay</div>
<div class="legend-row"><span class="swatch"></span> Hose route</div>
<div class="legend-row"><span class="swatch bucket"></span> Bucket relay</div>
<div class="legend-row"><span class="swatch access"></span> Access gap</div>
<div class="legend-row"><span class="swatch fire"></span> Attack point</div>
</section>
<nav id="controls" class="panel" aria-label="Scene controls">
<button id="reset-view" type="button">Reset</button>
<button id="top-view" type="button">Plan</button>
<button id="toggle-overlay" class="active" type="button">Overlay On</button>
</nav>
<div id="hint">Drag: orbit · Shift/right-drag: pan · Wheel: zoom</div>
<div id="loading">Preparing the incident plan…</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, and camera
// -------------------------------------------------------------------------
const host = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd7d1bd);
scene.fog = new THREE.Fog(0xd7d1bd, 43, 78);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
host.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-16, 16, 12, -12, 0.1, 120);
const cameraTarget = new THREE.Vector3(0, 1.7, 0.4);
let cameraYaw = -0.68;
let cameraPitch = 0.78;
let cameraZoom = 1;
const cameraRadius = 38;
function updateCamera() {
const horizontal = Math.cos(cameraPitch) * cameraRadius;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontal,
cameraTarget.y + Math.sin(cameraPitch) * cameraRadius,
cameraTarget.z + Math.cos(cameraYaw) * horizontal
);
camera.lookAt(cameraTarget);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const halfHeight = 12.5;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// -------------------------------------------------------------------------
// Lighting and materials
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xf8f1d8, 0x66776c, 2.1));
const sun = new THREE.DirectionalLight(0xffe3ad, 3.2);
sun.position.set(-15, 25, 14);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -23;
sun.shadow.camera.right = 23;
sun.shadow.camera.top = 23;
sun.shadow.camera.bottom = -23;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.0003;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9dc7c6, 0.7);
fill.position.set(12, 9, -15);
scene.add(fill);
function standard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
flatShading: true,
...options
});
}
const mat = {
earth: standard(0x827f69),
road: standard(0x777467),
grass: standard(0x6f7953),
stone: standard(0x77796e),
stoneLight: standard(0x98998a),
stoneDark: standard(0x555a54),
timber: standard(0x3b3026),
timberLight: standard(0x6d5036),
roofRed: standard(0x8b4937),
roofBrown: standard(0x695044),
roofSlate: standard(0x50575a),
plasterCream: standard(0xd9cda9),
plasterOchre: standard(0xc7ae79),
plasterRose: standard(0xc5a68e),
plasterPale: standard(0xcbd0b8),
wood: standard(0x805638),
darkWood: standard(0x493525),
iron: standard(0x343a38, { metalness: 0.35, roughness: 0.62 }),
window: standard(0x30494b, { metalness: 0.12, roughness: 0.38 }),
water: standard(0x4b9e9d, {
transparent: true,
opacity: 0.8,
metalness: 0.12,
roughness: 0.25
}),
leather: standard(0x4a3528),
skin: standard(0xb98761),
tunicWater: standard(0x287f7d),
tunicAttack: standard(0xb65b39),
tunicNeutral: standard(0xa99a72),
trousers: standard(0x41494a),
flameOrange: new THREE.MeshBasicMaterial({
color: 0xf18a3c,
transparent: true,
opacity: 0.86,
depthWrite: false
}),
flameYellow: new THREE.MeshBasicMaterial({
color: 0xffd46a,
transparent: true,
opacity: 0.92,
depthWrite: false
})
};
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function addBox(parent, w, h, d, material, x = 0, y = 0, z = 0, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
rTop,
rBottom,
height,
material,
x = 0,
y = 0,
z = 0,
segments = 8,
cast = true
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rTop, rBottom, height, segments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function seededRandom(seed) {
let value = seed >>> 0;
return function () {
value += 0x6D2B79F5;
let t = value;
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 = seededRandom(1729);
// -------------------------------------------------------------------------
// Terrain and cobbled lane
// -------------------------------------------------------------------------
const town = new THREE.Group();
scene.add(town);
addBox(town, 28, 0.65, 35, mat.earth, 0, -0.42, 0, false);
addBox(town, 9.5, 0.10, 31.5, mat.road, 0, -0.05, 0, false);
const cobbleGeometry = new THREE.BoxGeometry(0.72, 0.13, 0.61);
const cobbleMaterial = standard(0xffffff);
const columns = 12;
const rows = 43;
const cobbles = new THREE.InstancedMesh(
cobbleGeometry,
cobbleMaterial,
columns * rows
);
cobbles.receiveShadow = true;
const dummy = new THREE.Object3D();
const cobbleColor = new THREE.Color();
let cobbleIndex = 0;
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
const jitterX = (random() - 0.5) * 0.13;
const jitterZ = (random() - 0.5) * 0.12;
dummy.position.set(
-4.4 + column * 0.8 + jitterX,
0.055 + random() * 0.025,
-15 + row * 0.7 + jitterZ
);
dummy.rotation.set(
(random() - 0.5) * 0.025,
(random() - 0.5) * 0.09,
(random() - 0.5) * 0.02
);
dummy.scale.set(
0.88 + random() * 0.12,
0.85 + random() * 0.18,
0.88 + random() * 0.12
);
dummy.updateMatrix();
cobbles.setMatrixAt(cobbleIndex, dummy.matrix);
const tone = 0.47 + random() * 0.12;
cobbleColor.setHSL(0.105, 0.07, tone);
cobbles.setColorAt(cobbleIndex, cobbleColor);
cobbleIndex++;
}
}
cobbles.instanceMatrix.needsUpdate = true;
if (cobbles.instanceColor) cobbles.instanceColor.needsUpdate = true;
town.add(cobbles);
// Narrow drainage edges help define the operational street.
addBox(town, 0.26, 0.11, 31, mat.stoneDark, -4.72, 0.02, 0, false);
addBox(town, 0.26, 0.11, 31, mat.stoneDark, 4.72, 0.02, 0, false);
// -------------------------------------------------------------------------
// Half-timbered buildings
// -------------------------------------------------------------------------
function createRoof(width, depth, eaveY, ridgeY, material) {
const e = width * 0.5;
const zFront = depth * 0.5;
const zBack = -depth * 0.5;
const vertices = new Float32Array([
-e, eaveY, zFront,
e, eaveY, zFront,
0, ridgeY, zFront,
-e, eaveY, zBack,
e, eaveY, zBack,
0, ridgeY, zBack
]);
const indices = [
0, 1, 2,
3, 5, 4,
0, 2, 5,
0, 5, 3,
1, 4, 5,
1, 5, 2,
0, 3, 4,
0, 4, 1
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
const roofMaterial = material.clone();
roofMaterial.side = THREE.DoubleSide;
const roof = new THREE.Mesh(geometry, roofMaterial);
roof.castShadow = true;
roof.receiveShadow = true;
return roof;
}
function addWindow(parent, x, y, z, width = 0.92, height = 1.12) {
const windowGroup = new THREE.Group();
windowGroup.position.set(x, y, z);
parent.add(windowGroup);
addBox(windowGroup, width, height, 0.09, mat.window, 0, 0, 0, false);
addBox(windowGroup, width + 0.18, 0.11, 0.14, mat.timber, 0, height * 0.5, 0.04);
addBox(windowGroup, width + 0.18, 0.11, 0.14, mat.timber, 0, -height * 0.5, 0.04);
addBox(windowGroup, 0.11, height, 0.14, mat.timber, -width * 0.5, 0, 0.04);
addBox(windowGroup, 0.11, height, 0.14, mat.timber, width * 0.5, 0, 0.04);
addBox(windowGroup, 0.065, height, 0.16, mat.timberLight, 0, 0, 0.08);
addBox(windowGroup, width, 0.065, 0.16, mat.timberLight, 0, 0.04, 0.08);
addBox(windowGroup, width + 0.26, 0.10, 0.25, mat.stoneLight, 0, -height * 0.5 - 0.08, 0.06);
}
function addDoor(parent, x, z) {
addBox(parent, 1.05, 2.15, 0.12, mat.darkWood, x, 1.08, z);
addBox(parent, 0.09, 1.85, 0.08, mat.timberLight, x - 0.2, 1.05, z + 0.08);
addBox(parent, 0.09, 1.85, 0.08, mat.timberLight, x + 0.2, 1.05, z + 0.08);
addBox(parent, 0.08, 0.08, 0.09, mat.iron, x + 0.29, 1.1, z + 0.1);
addBox(parent, 1.45, 0.17, 0.42, mat.stoneLight, x, 2.23, z + 0.12);
}
function createHouse({
x,
z,
width,
depth,
rotation,
plaster,
roof,
fireHouse = false
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
town.add(group);
// Masonry ground floor.
addBox(group, width, 2.65, depth, mat.stone, 0, 1.325, 0);
addBox(group, width + 0.12, 0.20, depth + 0.12, mat.stoneLight, 0, 2.63, 0);
// A few larger facade stones break up the lower wall.
for (let i = 0; i < 5; i++) {
const block = addBox(
group,
0.74,
0.30,
0.08,
i % 2 ? mat.stoneDark : mat.stoneLight,
-width * 0.37 + i * (width * 0.185),
0.65 + (i % 2) * 0.54,
depth * 0.5 + 0.045,
false
);
block.scale.x = 0.78 + random() * 0.18;
}
// Plastered timber-framed upper floor.
addBox(group, width - 0.12, 2.77, depth - 0.12, plaster, 0, 4.0, 0);
const frontZ = depth * 0.5 + 0.08;
const beamXs = [
-width * 0.5 + 0.08,
-width / 6,
width / 6,
width * 0.5 - 0.08
];
beamXs.forEach((beamX) => {
addBox(group, 0.17, 2.78, 0.15, mat.timber, beamX, 4.0, frontZ);
});
[2.72, 4.0, 5.29].forEach((beamY) => {
addBox(group, width, 0.17, 0.15, mat.timber, 0, beamY, frontZ);
});
// Exposed corner and side framing.
[-1, 1].forEach((side) => {
addBox(
group,
0.17,
2.78,
0.15,
mat.timber,
side * (width * 0.5 - 0.07),
4.0,
-depth * 0.5 + 0.08
);
addBox(
group,
0.15,
0.17,
depth,
mat.timber,
side * (width * 0.5 + 0.015),
4.0,
0
);
});
addDoor(group, -width * 0.23, frontZ + 0.03);
addWindow(group, width * 0.24, 4.05, frontZ + 0.08);
if (fireHouse) {
addWindow(group, width * 0.235, 4.05, frontZ + 0.09, 1.04, 1.3);
}
// Small lower windows.
addBox(group, 0.72, 0.82, 0.09, mat.window, width * 0.25, 1.52, frontZ, false);
addBox(group, 0.09, 0.93, 0.13, mat.timber, width * 0.25, 1.52, frontZ + 0.03);
addBox(group, 0.83, 0.09, 0.13, mat.timber, width * 0.25, 1.52, frontZ + 0.03);
// Deep gabled roof.
const roofMesh = createRoof(width + 0.72, depth + 0.72, 5.37, 7.02, roof);
group.add(roofMesh);
addBox(group, width + 0.74, 0.16, 0.18, mat.timber, 0, 5.37, depth * 0.5 + 0.31);
addBox(group, width + 0.74, 0.16, 0.18, mat.timber, 0, 5.37, -depth * 0.5 - 0.31);
addBox(group, 0.18, 0.18, depth + 0.74, mat.timber, 0, 7.02, 0);
// Chimney.
addBox(group, 0.65, 2.0, 0.72, mat.stoneDark, -width * 0.28, 6.25, -depth * 0.19);
addBox(group, 0.82, 0.18, 0.88, mat.stoneLight, -width * 0.28, 7.28, -depth * 0.19);
// Hanging trade sign.
if (!fireHouse) {
const sign = addBox(group, 1.1, 0.52, 0.12, mat.wood, width * 0.27, 2.3, frontZ + 0.22);
sign.rotation.z = -0.04;
addBox(group, 0.07, 0.4, 0.07, mat.iron, width * 0.27 - 0.4, 2.65, frontZ + 0.22);
addBox(group, 0.07, 0.4, 0.07, mat.iron, width * 0.27 + 0.4, 2.65, frontZ + 0.22);
}
return group;
}
const houseSpecs = [
{
x: -7.8, z: -7.5, width: 5.6, depth: 6.2, rotation: Math.PI / 2,
plaster: mat.plasterCream, roof: mat.roofRed
},
{
x: -8.2, z: 0.5, width: 5.8, depth: 6.4, rotation: Math.PI / 2,
plaster: mat.plasterOchre, roof: mat.roofSlate
},
{
x: -7.9, z: 8.6, width: 5.7, depth: 6.1, rotation: Math.PI / 2,
plaster: mat.plasterRose, roof: mat.roofBrown
},
{
x: 7.8, z: -7.5, width: 5.4, depth: 6.2, rotation: -Math.PI / 2,
plaster: mat.plasterOchre, roof: mat.roofSlate
},
{
x: 8.1, z: 0.4, width: 5.8, depth: 6.4, rotation: -Math.PI / 2,
plaster: mat.plasterPale, roof: mat.roofBrown
},
{
x: 7.9, z: 8.8, width: 5.8, depth: 6.2, rotation: -Math.PI / 2,
plaster: mat.plasterCream, roof: mat.roofRed, fireHouse: true
}
];
houseSpecs.forEach((spec) => createHouse(spec));
// -------------------------------------------------------------------------
// Water cistern and hand pump
// -------------------------------------------------------------------------
const cistern = new THREE.Group();
cistern.position.set(-4.65, 0, -13.05);
town.add(cistern);
// Octagonal stone basin assembled from individual blocks.
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const block = addBox(
cistern,
0.75,
0.95,
0.42,
i % 2 ? mat.stone : mat.stoneLight,
Math.sin(angle) * 1.45,
0.48,
Math.cos(angle) * 1.45
);
block.rotation.y = angle;
}
addCylinder(cistern, 1.2, 1.2, 0.08, mat.stoneDark, 0, 0.08, 0, 8, false);
const cisternWater = addCylinder(
cistern,
1.22,
1.22,
0.035,
mat.water,
0,
0.52,
0,
16,
false
);
const pump = new THREE.Group();
pump.position.set(-2.65, 0, -12.35);
town.add(pump);
addBox(pump, 1.05, 0.20, 0.95, mat.stone, 0, 0.12, 0);
addCylinder(pump, 0.19, 0.24, 1.25, mat.iron, 0, 0.82, 0, 8);
addCylinder(pump, 0.10, 0.10, 0.85, mat.iron, 0, 1.63, 0, 8);
const spoutCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(0, 0.63, 0.05),
new THREE.Vector3(0, 0.95, 0.15),
new THREE.Vector3(0, 0.97, 0.55),
new THREE.Vector3(0, 0.76, 0.78)
]);
const spout = new THREE.Mesh(
new THREE.TubeGeometry(spoutCurve, 14, 0.085, 7, false),
mat.iron
);
spout.castShadow = true;
pump.add(spout);
const pumpHandle = addBox(pump, 0.95, 0.12, 0.13, mat.iron, 0.27, 1.82, 0);
pumpHandle.rotation.z = -0.2;
// -------------------------------------------------------------------------
// Operational route geometry
// -------------------------------------------------------------------------
const overlay = new THREE.Group();
scene.add(overlay);
const hoseRoute = [
new THREE.Vector3(-2.65, 0.18, -12.35),
new THREE.Vector3(-2.45, 0.18, -10.4),
new THREE.Vector3(-2.15, 0.18, -7.7),
new THREE.Vector3(-0.9, 0.18, -4.2),
new THREE.Vector3(0.35, 0.18, -1.0),
new THREE.Vector3(1.45, 0.18, 2.7),
new THREE.Vector3(2.15, 0.18, 5.0),
new THREE.Vector3(3.55, 0.18, 7.1),
new THREE.Vector3(4.20, 0.72, 8.8),
new THREE.Vector3(4.42, 2.65, 10.15)
];
const bucketRoute = [
new THREE.Vector3(-4.45, 0.18, -12.65),
new THREE.Vector3(-3.65, 0.18, -11.75),
new THREE.Vector3(-3.15, 0.18, -9.65),
new THREE.Vector3(-2.45, 0.18, -7.15),
new THREE.Vector3(-1.55, 0.18, -4.65),
new THREE.Vector3(-0.7, 0.18, -2.15),
new THREE.Vector3(0.15, 0.18, 0.45),
new THREE.Vector3(0.95, 0.18, 2.95),
new THREE.Vector3(1.35, 0.18, 4.65)
];
// The physical leather hose follows the operational line.
const hoseCurve = new THREE.CatmullRomCurve3(hoseRoute, false, "centripetal");
const hose = new THREE.Mesh(
new THREE.TubeGeometry(hoseCurve, 110, 0.105, 7, false),
mat.leather
);
hose.castShadow = true;
hose.receiveShadow = true;
town.add(hose);
function addRouteLine(points, color, dashSize, gapSize, opacity = 0.9) {
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineDashedMaterial({
color,
dashSize,
gapSize,
transparent: true,
opacity,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
line.renderOrder = 4;
overlay.add(line);
return line;
}
addRouteLine(hoseRoute, 0x168c8b, 0.42, 0.24);
addRouteLine(bucketRoute, 0xd39a36, 0.23, 0.20, 0.88);
function addGroundArrow(position, direction, color, scale = 1) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
0, 0, 0.42,
-0.24, 0, -0.28,
0.24, 0, -0.28
], 3)
);
geometry.computeVertexNormals();
const arrow = new THREE.Mesh(
geometry,
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.94,
side: THREE.DoubleSide,
depthWrite: false
})
);
arrow.position.copy(position);
arrow.rotation.y = Math.atan2(direction.x, direction.z);
arrow.scale.setScalar(scale);
arrow.renderOrder = 5;
overlay.add(arrow);
}
addGroundArrow(new THREE.Vector3(-2.3, 0.21, -9.0), new THREE.Vector3(0.2, 0, 3.5), 0x168c8b);
addGroundArrow(new THREE.Vector3(0.0, 0.21, -2.2), new THREE.Vector3(1.4, 0, 3.5), 0x168c8b);
addGroundArrow(new THREE.Vector3(1.55, 0.21, 2.0), new THREE.Vector3(0.6, 0, 3.0), 0x168c8b);
addGroundArrow(new THREE.Vector3(2.65, 0.21, 5.8), new THREE.Vector3(1.3, 0, 2.4), 0x168c8b);
addGroundArrow(new THREE.Vector3(-3.0, 0.21, -8.4), new THREE.Vector3(0.7, 0, 2.6), 0xd39a36, 0.8);
addGroundArrow(new THREE.Vector3(-0.7, 0.21, -1.3), new THREE.Vector3(0.8, 0, 2.7), 0xd39a36, 0.8);
function addAccessMarker(x, z, width, depth) {
const fill = new THREE.Mesh(
new THREE.PlaneGeometry(width, depth),
new THREE.MeshBasicMaterial({
color: 0x619b69,
transparent: true,
opacity: 0.22,
side: THREE.DoubleSide,
depthWrite: false
})
);
fill.rotation.x = -Math.PI / 2;
fill.position.set(x, 0.17, z);
fill.renderOrder = 3;
overlay.add(fill);
const points = [
new THREE.Vector3(x - width / 2, 0.19, z - depth / 2),
new THREE.Vector3(x + width / 2, 0.19, z - depth / 2),
new THREE.Vector3(x + width / 2, 0.19, z + depth / 2),
new THREE.Vector3(x - width / 2, 0.19, z + depth / 2),
new THREE.Vector3(x - width / 2, 0.19, z - depth / 2)
];
const border = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color: 0x619b69,
transparent: true,
opacity: 0.9
})
);
border.renderOrder = 4;
overlay.add(border);
}
// Two gaps are marked; the eastern gap is the hose approach.
addAccessMarker(4.75, 5.0, 3.6, 2.45);
addAccessMarker(-4.8, -3.55, 3.5, 2.1);
const stagingRing = new THREE.Mesh(
new THREE.RingGeometry(1.02, 1.13, 32),
new THREE.MeshBasicMaterial({
color: 0xd39a36,
transparent: true,
opacity: 0.9,
side: THREE.DoubleSide,
depthWrite: false
})
);
stagingRing.rotation.x = -Math.PI / 2;
stagingRing.position.set(1.35, 0.2, 4.65);
stagingRing.renderOrder = 5;
overlay.add(stagingRing);
const targetRing = new THREE.Mesh(
new THREE.RingGeometry(1.02, 1.12, 32),
new THREE.MeshBasicMaterial({
color: 0xdc6242,
transparent: true,
opacity: 0.95,
side: THREE.DoubleSide,
depthWrite: false
})
);
targetRing.rotation.y = Math.PI / 2;
targetRing.position.set(4.38, 3.9, 10.15);
targetRing.renderOrder = 5;
overlay.add(targetRing);
// -------------------------------------------------------------------------
// World-space labels drawn with canvas textures
// -------------------------------------------------------------------------
function makeLabel(text, position, accent = "#168c8b") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 128;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
const x = 8;
const y = 20;
const width = 624;
const height = 86;
const radius = 12;
context.beginPath();
context.moveTo(x + radius, y);
context.lineTo(x + width - radius, y);
context.quadraticCurveTo(x + width, y, x + width, y + radius);
context.lineTo(x + width, y + height - radius);
context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
context.lineTo(x + radius, y + height);
context.quadraticCurveTo(x, y + height, x, y + height - radius);
context.lineTo(x, y + radius);
context.quadraticCurveTo(x, y, x + radius, y);
context.closePath();
context.fillStyle = "rgba(248,246,235,0.94)";
context.fill();
context.strokeStyle = "rgba(42,55,51,0.24)";
context.lineWidth = 3;
context.stroke();
context.fillStyle = accent;
context.fillRect(x + 18, y + 18, 9, 50);
context.fillStyle = "#273330";
context.font = "700 31px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, x + width / 2 + 9, y + height / 2 + 1);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
const labelWidth = Math.max(2.6, text.length * 0.095);
sprite.scale.set(labelWidth, labelWidth * 0.2, 1);
sprite.position.copy(position);
sprite.renderOrder = 20;
overlay.add(sprite);
return sprite;
}
makeLabel("WATER CISTERN", new THREE.Vector3(-4.65, 2.05, -13.05), "#168c8b");
makeLabel("BUCKET RELAY", new THREE.Vector3(-1.9, 2.2, -6.0), "#d39a36");
makeLabel("STAGING", new THREE.Vector3(1.35, 1.15, 4.65), "#d39a36");
makeLabel("ACCESS GAP", new THREE.Vector3(5.2, 1.45, 5.0), "#619b69");
makeLabel("ATTACK POINT", new THREE.Vector3(4.4, 5.25, 10.15), "#dc6242");
// -------------------------------------------------------------------------
// Coordinated helpers
// -------------------------------------------------------------------------
const animatedHelpers = [];
function createHelper({
x,
z,
rotation = 0,
tunic = mat.tunicWater,
bucket = false,
nozzle = false,
phase = 0
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
town.add(group);
const leftLeg = addBox(group, 0.23, 0.72, 0.25, mat.trousers, -0.17, 0.4, 0);
const rightLeg = addBox(group, 0.23, 0.72, 0.25, mat.trousers, 0.17, 0.4, 0);
leftLeg.rotation.z = 0.06;
rightLeg.rotation.z = -0.06;
addCylinder(group, 0.31, 0.4, 0.72, tunic, 0, 1.08, 0, 7);
addBox(group, 0.78, 0.11, 0.43, tunic, 0, 1.22, 0.015);
const head = new THREE.Mesh(new THREE.SphereGeometry(0.235, 8, 6), mat.skin);
head.position.set(0, 1.64, 0);
head.castShadow = true;
group.add(head);
addCylinder(group, 0.29, 0.32, 0.10, mat.timberLight, 0, 1.82, 0, 8);
addCylinder(group, 0.19, 0.23, 0.25, mat.timberLight, 0, 1.94, 0, 8);
const leftArm = addBox(group, 0.13, 0.67, 0.16, tunic, -0.38, 1.08, 0.03);
const rightArm = addBox(group, 0.13, 0.67, 0.16, tunic, 0.38, 1.08, 0.03);
leftArm.rotation.z = -0.16;
rightArm.rotation.z = 0.16;
let bucketObject = null;
if (bucket) {
bucketObject = new THREE.Group();
bucketObject.position.set(0.48, 0.76, 0.1);
group.add(bucketObject);
addCylinder(bucketObject, 0.2, 0.14, 0.28, mat.wood, 0, 0, 0, 8);
const handle = new THREE.Mesh(
new THREE.TorusGeometry(0.17, 0.018, 4, 10, Math.PI),
mat.iron
);
handle.position.y = 0.12;
bucketObject.add(handle);
}
if (nozzle) {
const pole = addCylinder(group, 0.045, 0.055, 1.35, mat.iron, 0.43, 1.0, 0.18, 6);
pole.rotation.x = Math.PI / 2.3;
pole.rotation.z = -0.25;
}
const helper = {
group,
leftLeg,
rightLeg,
leftArm,
rightArm,
bucket: bucketObject,
phase
};
animatedHelpers.push(helper);
return helper;
}
// Source crew.
createHelper({
x: -3.7, z: -11.65, rotation: -1.2,
tunic: mat.tunicWater, bucket: true, phase: 0.1
});
createHelper({
x: -5.25, z: -12.35, rotation: 0.45,
tunic: mat.tunicWater, bucket: true, phase: 1.8
});
// Bucket relay, oriented along the route.
const relayPositions = [
[-3.12, -9.65],
[-2.43, -7.15],
[-1.53, -4.63],
[-0.68, -2.15],
[0.16, 0.45],
[0.94, 2.92]
];
relayPositions.forEach(([x, z], index) => {
const next = relayPositions[Math.min(index + 1, relayPositions.length - 1)];
const previous = relayPositions[Math.max(index - 1, 0)];
const direction = new THREE.Vector2(
next[0] - previous[0],
next[1] - previous[1]
);
createHelper({
x,
z,
rotation: Math.atan2(direction.x, direction.y),
tunic: index % 2 ? mat.tunicNeutral : mat.tunicWater,
bucket: true,
phase: index * 0.85
});
});
// Hose crew in the access gap.
createHelper({
x: 2.7, z: 6.0, rotation: -0.75,
tunic: mat.tunicAttack, nozzle: true, phase: 2.6
});
createHelper({
x: 3.75, z: 7.85, rotation: -0.55,
tunic: mat.tunicAttack, nozzle: true, phase: 3.9
});
// -------------------------------------------------------------------------
// Schematic fire: contained, graphic, and non-destructive
// -------------------------------------------------------------------------
const fire = new THREE.Group();
fire.position.set(4.43, 3.75, 10.15);
town.add(fire);
const flameParts = [];
function addFlame(x, z, scale, phase) {
const flame = new THREE.Mesh(
new THREE.ConeGeometry(0.48 * scale, 1.55 * scale, 5),
mat.flameOrange
);
flame.position.set(x, 0.12 * scale, z);
flame.rotation.y = phase;
flame.renderOrder = 6;
fire.add(flame);
flameParts.push({ mesh: flame, phase, base: flame.scale.y });
const core = new THREE.Mesh(
new THREE.ConeGeometry(0.25 * scale, 1.08 * scale, 5),
mat.flameYellow
);
core.position.set(x + 0.02, -0.08 * scale, z + 0.02);
core.rotation.y = phase + 0.4;
core.renderOrder = 7;
fire.add(core);
flameParts.push({ mesh: core, phase: phase + 1.3, base: core.scale.y });
}
addFlame(-0.42, 0.05, 0.95, 0.2);
addFlame(0.32, -0.12, 1.15, 1.7);
addFlame(0.0, 0.28, 0.72, 3.1);
const fireLight = new THREE.PointLight(0xff8a3d, 2.1, 7, 2);
fireLight.position.set(4.1, 4.0, 10.15);
town.add(fireLight);
// -------------------------------------------------------------------------
// Street furniture and settlement details
// -------------------------------------------------------------------------
function addBarrel(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
town.add(group);
addCylinder(group, 0.42, 0.34, 1.05, mat.wood, 0, 0.53, 0, 9);
[0.22, 0.81].forEach((y) => {
const band = new THREE.Mesh(
new THREE.TorusGeometry(0.40, 0.035, 4, 9),
mat.iron
);
band.rotation.x = Math.PI / 2;
band.position.y = y;
band.scale.z = 0.88;
group.add(band);
});
}
function addCrate(x, z, rotation = 0, size = 0.7) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
town.add(group);
addBox(group, size, size, size, mat.wood, 0, size / 2, 0);
addBox(group, size + 0.04, 0.08, size + 0.04, mat.timberLight, 0, size * 0.55, 0);
addBox(group, 0.08, size, size + 0.04, mat.timberLight, 0, size / 2, 0);
}
function addLantern(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
town.add(group);
addCylinder(group, 0.055, 0.085, 2.8, mat.iron, 0, 1.4, 0, 7);
addBox(group, 0.34, 0.42, 0.34, mat.iron, 0, 2.95, 0);
addBox(
group,
0.23,
0.28,
0.23,
standard(0xffd77d, {
emissive: 0xe7a94d,
emissiveIntensity: 0.6,
roughness: 0.5
}),
0,
2.95,
0,
false
);
addBox(group, 0.45, 0.09, 0.45, mat.iron, 0, 3.22, 0);
}
function addTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
town.add(group);
addCylinder(group, 0.18, 0.28, 2.2, mat.wood, 0, 1.1, 0, 7);
const crownMaterial = standard(0x66784d);
const crown1 = new THREE.Mesh(new THREE.IcosahedronGeometry(1.45, 0), crownMaterial);
crown1.position.set(-0.3, 2.65, 0.1);
crown1.scale.set(1, 1.1, 0.9);
crown1.castShadow = true;
group.add(crown1);
const crown2 = new THREE.Mesh(new THREE.IcosahedronGeometry(1.12, 0), standard(0x7c8958));
crown2.position.set(0.65, 2.85, -0.15);
crown2.castShadow = true;
group.add(crown2);
}
addBarrel(4.05, -10.1, 0.1);
addBarrel(4.55, -9.65, -0.25);
addCrate(5.0, -11.1, 0.08, 0.72);
addCrate(5.15, -11.05, 0.3, 0.56);
addBarrel(-5.0, 4.0, -0.15);
addCrate(-5.2, 4.55, 0.2, 0.65);
addLantern(-4.35, -3.4);
addLantern(4.3, 5.7);
addLantern(-4.25, 7.8);
addTree(-11.5, -12.4, 1.08);
addTree(11.5, -12.2, 0.96);
addTree(-11.7, 11.8, 1.12);
addTree(11.6, 12.3, 1.0);
// Rear gateway gives the compact settlement a terminating vista.
addBox(town, 5.4, 3.1, 0.65, mat.stone, -7.4, 1.55, 15.6);
addBox(town, 5.4, 3.1, 0.65, mat.stone, 7.4, 1.55, 15.6);
addBox(town, 9.5, 0.6, 0.65, mat.stone, 0, 3.35, 15.6);
addBox(town, 0.75, 3.4, 0.8, mat.stoneDark, -2.25, 1.7, 15.6);
addBox(town, 0.75, 3.4, 0.8, mat.stoneDark, 2.25, 1.7, 15.6);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, and zoom
// -------------------------------------------------------------------------
const canvas = renderer.domElement;
let pointerDown = false;
let dragMode = "orbit";
let lastPointerX = 0;
let lastPointerY = 0;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
pointerDown = true;
dragMode = event.shiftKey || event.button === 2 ? "pan" : "orbit";
lastPointerX = event.clientX;
lastPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!pointerDown) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
if (dragMode === "orbit") {
cameraYaw -= dx * 0.005;
cameraPitch = THREE.MathUtils.clamp(cameraPitch + dy * 0.0035, 0.32, 1.38);
} else {
const panScale = 0.022 / cameraZoom;
const right = new THREE.Vector3(Math.cos(cameraYaw), 0, -Math.sin(cameraYaw));
const forward = new THREE.Vector3(Math.sin(cameraYaw), 0, Math.cos(cameraYaw));
cameraTarget.addScaledVector(right, -dx * panScale);
cameraTarget.addScaledVector(forward, -dy * panScale);
cameraTarget.x = THREE.MathUtils.clamp(cameraTarget.x, -10, 10);
cameraTarget.z = THREE.MathUtils.clamp(cameraTarget.z, -10, 12);
}
updateCamera();
});
function endPointer(event) {
pointerDown = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.001),
0.62,
1.75
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.key === "r" || event.key === "R") resetView();
if (event.key === "ArrowLeft") cameraYaw -= 0.08;
if (event.key === "ArrowRight") cameraYaw += 0.08;
if (event.key === "ArrowUp") cameraPitch = Math.min(1.38, cameraPitch + 0.05);
if (event.key === "ArrowDown") cameraPitch = Math.max(0.32, cameraPitch - 0.05);
if (event.key === "+" || event.key === "=") cameraZoom = Math.min(1.75, cameraZoom + 0.08);
if (event.key === "-") cameraZoom = Math.max(0.62, cameraZoom - 0.08);
updateCamera();
});
function resetView() {
cameraYaw = -0.68;
cameraPitch = 0.78;
cameraZoom = 1;
cameraTarget.set(0, 1.7, 0.4);
updateCamera();
}
document.getElementById("reset-view").addEventListener("click", resetView);
document.getElementById("top-view").addEventListener("click", () => {
cameraYaw = 0;
cameraPitch = 1.38;
cameraZoom = 0.96;
cameraTarget.set(0, 0.7, 0.3);
updateCamera();
});
const overlayButton = document.getElementById("toggle-overlay");
overlayButton.addEventListener("click", () => {
overlay.visible = !overlay.visible;
overlayButton.classList.toggle("active", overlay.visible);
overlayButton.textContent = overlay.visible ? "Overlay On" : "Overlay Off";
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
flameParts.forEach((part, index) => {
const pulse = 1 + Math.sin(elapsed * 5.2 + part.phase) * 0.12;
part.mesh.scale.y = part.base * pulse;
part.mesh.rotation.z = Math.sin(elapsed * 3.1 + part.phase) * 0.055;
part.mesh.position.x +=
Math.sin(elapsed * 2.3 + index) * 0.00045;
});
animatedHelpers.forEach((helper, index) => {
const step = Math.sin(elapsed * 3.2 + helper.phase);
helper.group.position.y = Math.abs(step) * 0.018;
helper.leftLeg.rotation.x = step * 0.10;
helper.rightLeg.rotation.x = -step * 0.10;
helper.leftArm.rotation.x = -step * 0.12;
helper.rightArm.rotation.x = step * 0.12;
if (helper.bucket) {
helper.bucket.position.y = 0.76 + Math.sin(elapsed * 3.2 + helper.phase) * 0.025;
helper.bucket.rotation.z = Math.sin(elapsed * 2.6 + helper.phase + index) * 0.025;
}
});
pumpHandle.rotation.z = -0.2 + Math.sin(elapsed * 2.8) * 0.16;
cisternWater.material.opacity = 0.76 + Math.sin(elapsed * 1.5) * 0.035;
fireLight.intensity = 1.85 + Math.sin(elapsed * 5.5) * 0.24;
renderer.render(scene, camera);
}
updateCamera();
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```