Prompt specification
Build or customize the Three.js 3D scene "Boat reaching a settlement across a branching channel" 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: Boat reaching a settlement across a branching channel
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/boat-reaching-a-settlement-across-a-branching-channel-x3066
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows the Ganges–Brahmaputra delta's channels and settlements. Create a compact delta vignette with small boat, landing, and raised homes. Use a documented regional setting and keep water access connected to the settlement path. Low-poly.
Working Three.js Starter (boat-reaching-a-settlement-across-a-branching-channel-x3066):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Braided Waters — Ganges–Brahmaputra Delta</title>
<style>
:root {
--ink: #253b3c;
--muted: #62706d;
--water: #4f929d;
--land: #738e5c;
--sand: #c8ad78;
--paper: #eeeae0;
--line: rgba(37, 59, 60, 0.16);
--panel: rgba(247, 244, 236, 0.91);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, a { -webkit-tap-highlight-color: transparent; }
#stage {
position: fixed;
inset: 0;
overflow: hidden;
background:
radial-gradient(circle at 52% 44%, #f4f1e8 0%, #e9e5db 70%, #dfddd3 100%);
}
#stage canvas {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
#stage canvas.dragging { cursor: grabbing; }
.label-layer {
position: absolute;
inset: 0;
z-index: 2;
pointer-events: none;
overflow: hidden;
}
.world-label {
position: absolute;
left: 0;
top: 0;
white-space: nowrap;
transform: translate(-50%, -50%);
transition: opacity 160ms ease;
will-change: left, top;
}
.world-label.is-hidden { opacity: 0; }
.river-label {
color: #245e68;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-shadow:
0 1px 0 rgba(255, 255, 255, 0.92),
0 0 8px rgba(238, 234, 224, 0.9);
}
.feature-label {
padding: 5px 8px;
border: 1px solid rgba(37, 59, 60, 0.14);
border-radius: 999px;
background: rgba(247, 244, 236, 0.88);
box-shadow: 0 5px 18px rgba(42, 54, 50, 0.08);
color: #344d4b;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.feature-label::before {
content: "";
display: inline-block;
width: 5px;
height: 5px;
margin-right: 6px;
border-radius: 50%;
background: #bd754b;
vertical-align: 1px;
}
.ui {
position: absolute;
z-index: 5;
pointer-events: none;
}
.masthead {
top: clamp(20px, 4vw, 46px);
left: clamp(20px, 4vw, 52px);
width: min(510px, calc(100vw - 40px));
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 13px;
color: #65746e;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 29px;
height: 1px;
background: #9c7758;
}
h1 {
margin: 0;
max-width: 470px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(37px, 5.4vw, 73px);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.045em;
}
.subtitle {
max-width: 450px;
margin: 17px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.subtitle strong {
color: #405753;
font-weight: 700;
}
.notes-toggle {
position: absolute;
top: clamp(18px, 3vw, 35px);
right: clamp(18px, 3vw, 34px);
z-index: 8;
display: inline-flex;
align-items: center;
gap: 9px;
min-height: 39px;
padding: 0 14px;
border: 1px solid rgba(37, 59, 60, 0.15);
border-radius: 999px;
background: rgba(247, 244, 236, 0.86);
box-shadow: 0 7px 26px rgba(42, 54, 50, 0.08);
color: #38514f;
font: 750 10px/1 Inter, ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.13em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(12px);
}
.notes-toggle:hover { background: rgba(255, 253, 247, 0.97); }
.notes-toggle .info-dot {
display: grid;
width: 19px;
height: 19px;
place-items: center;
border-radius: 50%;
background: #3e6e6e;
color: white;
font-size: 11px;
letter-spacing: 0;
}
.notes {
top: clamp(66px, 8vw, 86px);
right: clamp(18px, 3vw, 34px);
width: min(335px, calc(100vw - 36px));
max-height: calc(100vh - 170px);
padding: 22px 22px 19px;
border: 1px solid rgba(37, 59, 60, 0.13);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 20px 70px rgba(47, 55, 48, 0.14);
opacity: 0;
visibility: hidden;
transform: translateY(-8px);
transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
overflow: auto;
pointer-events: none;
backdrop-filter: blur(18px);
}
.notes.open {
opacity: 1;
visibility: visible;
transform: translateY(0);
pointer-events: auto;
}
.notes h2 {
margin: 0 38px 13px 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 25px;
font-weight: 500;
letter-spacing: -0.025em;
}
.notes h3 {
margin: 17px 0 6px;
color: #7f624d;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.notes p {
margin: 0;
color: #586864;
font-size: 12px;
line-height: 1.62;
}
.notes .close {
position: absolute;
top: 15px;
right: 15px;
width: 28px;
height: 28px;
padding: 0;
border: 0;
border-radius: 50%;
background: rgba(37, 59, 60, 0.07);
color: #52635f;
font-size: 18px;
line-height: 28px;
cursor: pointer;
}
.sources {
display: grid;
gap: 7px;
margin-top: 10px;
}
.sources a {
display: flex;
justify-content: space-between;
gap: 10px;
padding-top: 7px;
border-top: 1px solid var(--line);
color: #365d5d;
font-size: 11px;
font-weight: 700;
line-height: 1.35;
text-decoration: none;
}
.sources a:hover { color: #a16445; }
.sources span { color: #82908b; }
.legend {
left: clamp(20px, 4vw, 52px);
bottom: clamp(20px, 3vw, 34px);
display: flex;
flex-wrap: wrap;
gap: 15px;
max-width: calc(100vw - 40px);
padding: 11px 14px;
border: 1px solid rgba(37, 59, 60, 0.12);
border-radius: 12px;
background: rgba(247, 244, 236, 0.78);
color: #53645f;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
backdrop-filter: blur(12px);
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 7px;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(37, 59, 60, 0.1);
}
.swatch.water { background: #5598a3; }
.swatch.bank { background: #aa9667; }
.swatch.path { background: #cbb083; }
.swatch.home { background: #8c5843; }
.controls {
right: clamp(18px, 3vw, 34px);
bottom: clamp(20px, 3vw, 34px);
display: flex;
align-items: center;
gap: 7px;
pointer-events: auto;
}
.control-button {
display: grid;
width: 38px;
height: 38px;
padding: 0;
place-items: center;
border: 1px solid rgba(37, 59, 60, 0.14);
border-radius: 50%;
background: rgba(247, 244, 236, 0.88);
box-shadow: 0 7px 24px rgba(42, 54, 50, 0.08);
color: #38514f;
font: 650 18px/1 Georgia, serif;
cursor: pointer;
backdrop-filter: blur(12px);
}
.control-button:hover { background: #fffdf6; }
.control-button.reset { font-size: 15px; }
.hint {
margin-left: 7px;
color: rgba(61, 80, 76, 0.67);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #e9e5db;
color: #526b68;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease, visibility 400ms;
}
.loading.hide {
opacity: 0;
visibility: hidden;
}
@media (max-width: 760px) {
.masthead {
top: 20px;
left: 20px;
}
h1 {
max-width: 310px;
font-size: clamp(38px, 12vw, 56px);
}
.subtitle {
max-width: 310px;
font-size: 11px;
}
.notes {
top: 69px;
right: 18px;
}
.legend {
bottom: 72px;
gap: 9px 12px;
}
.hint { display: none; }
}
@media (max-width: 430px) {
.legend-item:nth-child(3) { display: none; }
.subtitle { max-width: 270px; }
.notes-toggle { padding: 0 11px; }
}
</style>
</head>
<body>
<main id="stage" aria-label="Interactive low-poly model of the Ganges–Brahmaputra delta">
<div class="label-layer" aria-hidden="true">
<div class="world-label river-label" id="label-ganges">GANGES</div>
<div class="world-label river-label" id="label-brahmaputra">BRAHMAPUTRA</div>
<div class="world-label river-label" id="label-meghna">MEGHNA OUTFLOW</div>
<div class="world-label river-label" id="label-branches">DISTRIBUTARIES</div>
<div class="world-label feature-label" id="label-homes">RAISED HOMES</div>
<div class="world-label feature-label" id="label-path">SETTLEMENT PATH</div>
<div class="world-label feature-label" id="label-landing">LANDING</div>
<div class="world-label feature-label" id="label-boat">BOAT</div>
<div class="world-label feature-label" id="label-north">N</div>
</div>
<header class="ui masthead">
<div class="eyebrow">Delta vignette · Bangladesh</div>
<h1>Braided waters,<br />raised homes.</h1>
<p class="subtitle">
An interpretive low-poly reading of the
<strong>Ganges–Brahmaputra–Meghna delta</strong>, where a continuous
path links a riverbank settlement to its landing and boat.
</p>
</header>
<button class="notes-toggle" id="notes-toggle" aria-expanded="true" aria-controls="notes">
<span class="info-dot">i</span>
Regional notes
</button>
<aside class="ui notes open" id="notes" aria-label="Regional notes and references">
<button class="close" id="notes-close" aria-label="Close regional notes">×</button>
<h2>A riverine delta</h2>
<h3>Regional setting</h3>
<p>
This schematic vignette is inspired by deltaic Bangladesh within the
Ganges–Brahmaputra–Meghna drainage, roughly 22°–25° N and 88°–91° E.
The western and northeastern tributary inputs, branching distributaries,
and southern outflow are compressed into a compact model rather than a
surveyed map.
</p>
<h3>Built landscape</h3>
<p>
Pile-raised houses, shaded decks, plank jetties, and small working boats
reflect river-dependent building and transport practices. The visible
footpath runs directly from the homes to the landing, preserving an
unbroken connection between settlement and water.
</p>
<h3>References</h3>
<div class="sources">
<a href="https://en.banglapedia.org/index.php/Bangladesh_Delta" target="_blank" rel="noopener">
Banglapedia — Bangladesh Delta <span>↗</span>
</a>
<a href="https://www.britannica.com/place/Ganges-Brahmaputra-delta" target="_blank" rel="noopener">
Britannica — Ganges–Brahmaputra Delta <span>↗</span>
</a>
<a href="https://whc.unesco.org/en/list/1105" target="_blank" rel="noopener">
UNESCO — Sundarbans National Park <span>↗</span>
</a>
</div>
</aside>
<div class="ui legend" aria-label="Model legend">
<span class="legend-item"><i class="swatch water"></i>Channel</span>
<span class="legend-item"><i class="swatch bank"></i>Bank</span>
<span class="legend-item"><i class="swatch path"></i>Path</span>
<span class="legend-item"><i class="swatch home"></i>Raised home</span>
</div>
<div class="ui controls" aria-label="Camera controls">
<button class="control-button" id="zoom-in" aria-label="Zoom in">+</button>
<button class="control-button" id="zoom-out" aria-label="Zoom out">−</button>
<button class="control-button reset" id="reset-view" aria-label="Reset camera" title="Reset view">↺</button>
<span class="hint">Drag to orbit · Scroll to zoom</span>
</div>
<div class="loading" id="loading">Preparing the delta</div>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
// ------------------------------------------------------------
// Scene and renderer: Three.js core only, with direct controls.
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e5db);
scene.fog = new THREE.Fog(0xe9e5db, 34, 105);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 150);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.08;
renderer.domElement.setAttribute(
"aria-label",
"Low-poly delta landscape. Drag to orbit and scroll or pinch to zoom."
);
stage.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xf8f4e7, 0x806e58, 2.05);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffdfad, 3.15);
sun.position.set(-9, 16, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9cc8cf, 0.65);
fill.position.set(10, 8, -9);
scene.add(fill);
const palette = {
land: 0x748e5d,
earth: 0x806b4e,
bank: 0xad9869,
water: 0x5799a3,
waterBrah: 0x4f8f9b,
waterBranch: 0x68a7aa,
path: 0xc9ae78,
wood: 0x72513a,
darkWood: 0x4d392c,
roof: 0x8a4f3b,
roofDark: 0x4e5148,
wall: 0xc6b795,
wallBlue: 0x9eb1ad,
wallOchre: 0xc49a68,
leaf: 0x4e704c,
leafLight: 0x678357,
reed: 0x718b54
};
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
flatShading: true,
...options
});
}
const mats = {
land: material(palette.land),
earth: material(palette.earth),
bank: material(palette.bank),
path: material(palette.path),
wood: material(palette.wood),
darkWood: material(palette.darkWood),
roof: material(palette.roof),
roofDark: material(palette.roofDark),
wall: material(palette.wall),
wallBlue: material(palette.wallBlue),
wallOchre: material(palette.wallOchre),
leaf: material(palette.leaf),
leafLight: material(palette.leafLight),
reed: material(palette.reed),
dark: material(0x293b3a),
cream: material(0xe8ddbd)
};
function shadow(mesh, cast = true, receive = true) {
mesh.castShadow = cast;
mesh.receiveShadow = receive;
return mesh;
}
// ------------------------------------------------------------
// Irregular delta plinth and land patches.
// ------------------------------------------------------------
const ground = shadow(
new THREE.Mesh(
new THREE.PlaneGeometry(180, 180),
material(0xe4e0d6, { roughness: 1 })
),
false,
true
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.765;
scene.add(ground);
const landOutline = [
[-9.1, -7.35], [-4.3, -7.65], [8.55, -7.2], [9.15, -3.2],
[9.0, 5.45], [6.45, 7.35], [-6.8, 7.3], [-9.2, 5.55]
];
const landShape = new THREE.Shape();
landOutline.forEach(([x, z], index) => {
if (index === 0) landShape.moveTo(x, -z);
else landShape.lineTo(x, -z);
});
landShape.closePath();
const baseGeometry = new THREE.ExtrudeGeometry(landShape, {
depth: 0.72,
steps: 1,
bevelEnabled: false,
curveSegments: 1
});
baseGeometry.rotateX(-Math.PI / 2);
const base = shadow(new THREE.Mesh(baseGeometry, [mats.land, mats.earth]));
base.position.y = -0.72;
scene.add(base);
const baseEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(baseGeometry, 24),
new THREE.LineBasicMaterial({
color: 0x5b604e,
transparent: true,
opacity: 0.24
})
);
base.add(baseEdges);
function addPatch(points, color, opacity = 1) {
const vertices = [];
for (let i = 1; i < points.length - 1; i++) {
vertices.push(
points[0][0], 0, points[0][1],
points[i][0], 0, points[i][1],
points[i + 1][0], 0, points[i + 1][1]
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(vertices, 3));
geometry.computeVertexNormals();
const mesh = shadow(
new THREE.Mesh(
geometry,
material(color, { transparent: opacity < 1, opacity })
),
false,
true
);
mesh.position.y = 0.012;
scene.add(mesh);
return mesh;
}
addPatch(
[[-8.1, -2.0], [-8.3, 1.4], [-6.0, 2.4], [-4.8, -0.6]],
0x849b65
);
addPatch(
[[-7.5, 3.4], [-7.7, 6.1], [-4.5, 6.4], [-4.2, 4.3]],
0x9aa56c
);
addPatch(
[[2.5, -4.8], [4.4, -5.1], [5.0, -3.7], [2.6, -2.9]],
0x829762
);
addPatch(
[[3.5, 1.0], [4.8, 0.6], [5.3, 3.1], [3.4, 3.5]],
0x8fa168
);
addPatch(
[[-2.4, -6.4], [0.1, -6.3], [0.5, -4.5], [-1.7, -4.2]],
0x889d63
);
function addCropRows(points, rows = 4) {
const minX = Math.min(...points.map(p => p[0]));
const maxX = Math.max(...points.map(p => p[0]));
const minZ = Math.min(...points.map(p => p[1]));
const maxZ = Math.max(...points.map(p => p[1]));
const positions = [];
for (let r = 0; r < rows; r++) {
const t = (r + 0.5) / rows;
const z = minZ + (maxZ - minZ) * t;
positions.push(minX, 0.027, z, maxX, 0.027, z);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
const lines = new THREE.LineSegments(
geometry,
new THREE.LineBasicMaterial({ color: 0xb8a66f, transparent: true, opacity: 0.5 })
);
scene.add(lines);
}
addCropRows([[-8.0, -1.4], [-5.0, -0.6], [-5.8, 2.0]], 5);
addCropRows([[3.7, 1.1], [5.0, 1.0], [5.0, 3.0]], 4);
// ------------------------------------------------------------
// Connected river ribbons.
// ------------------------------------------------------------
function makeRibbonGeometry(curve, width, segments, y) {
const vertices = [];
const indices = [];
for (let i = 0; i <= segments; i++) {
const t = i / segments;
const point = curve.getPoint(t);
const tangent = curve.getTangent(t).normalize();
const side = new THREE.Vector3(tangent.z, 0, -tangent.x).normalize();
const localWidth = width * (0.86 + 0.14 * Math.sin(Math.PI * t));
const half = localWidth * 0.5;
vertices.push(
point.x + side.x * half, y, point.z + side.z * half,
point.x - side.x * half, y, point.z - side.z * half
);
if (i < segments) {
const a = i * 2;
const b = a + 1;
const c = a + 2;
const d = a + 3;
indices.push(a, b, c, b, d, c);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(vertices, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
function createRiver(points, width, waterColor, segments = 44, waterY = 0.043) {
const curve = new THREE.CatmullRomCurve3(
points.map(([x, z]) => new THREE.Vector3(x, 0, z)),
false,
"centripetal"
);
const bank = shadow(
new THREE.Mesh(
makeRibbonGeometry(curve, width + 0.38, segments, 0.018),
mats.bank
),
false,
true
);
scene.add(bank);
const waterMaterial = material(waterColor, {
roughness: 0.62,
metalness: 0.04
});
const water = shadow(
new THREE.Mesh(
makeRibbonGeometry(curve, width, segments, waterY),
waterMaterial
),
false,
true
);
scene.add(water);
return curve;
}
const ganges = createRiver(
[[-9.05, -7.28], [-7.0, -6.25], [-5.3, -4.85], [-4.1, -3.2],
[-2.6, -1.8], [-1.2, -0.45], [0, 1.25]],
1.55, palette.water, 56
);
const brahmaputra = createRiver(
[[8.75, -7.1], [6.6, -5.8], [5.1, -4.05], [3.7, -2.4],
[2.35, -0.8], [1.15, 0.35], [0, 1.25]],
1.5, palette.waterBrah, 54
);
const meghna = createRiver(
[[0, 1.25], [0.15, 2.65], [-0.35, 4.1], [-0.75, 5.7], [-0.25, 7.55]],
1.82, 0x4f8fa0, 48, 0.047
);
const westBranch = createRiver(
[[-4.1, -3.2], [-5.9, -1.8], [-6.4, 0.4], [-5.8, 2.8], [-5.4, 5.2]],
0.72, palette.waterBranch, 38, 0.040
);
const eastBranch = createRiver(
[[3.7, -2.4], [5.4, -0.4], [6.2, 2.0], [5.9, 4.6], [6.4, 6.7]],
0.78, palette.waterBranch, 40, 0.040
);
createRiver(
[[-0.35, 4.1], [-1.8, 5.2], [-3.6, 6.7]],
0.62, 0x70aaab, 28, 0.041
);
createRiver(
[[-0.35, 4.1], [1.5, 5.3], [3.2, 6.8]],
0.65, 0x70aaab, 30, 0.041
);
// Small angular highlights suggest current without obscuring the faceted style.
const rippleMaterial = new THREE.MeshBasicMaterial({
color: 0xd5e4df,
transparent: true,
opacity: 0.42,
depthWrite: false
});
function addRipples(curve, count, length = 0.65) {
for (let i = 0; i < count; i++) {
const t = 0.13 + (i / Math.max(1, count - 1)) * 0.72;
const point = curve.getPoint(t);
const tangent = curve.getTangent(t).normalize();
const ripple = new THREE.Mesh(
new THREE.BoxGeometry(length, 0.012, 0.025),
rippleMaterial
);
ripple.position.set(point.x, 0.073, point.z);
ripple.rotation.y = -Math.atan2(tangent.z, tangent.x);
scene.add(ripple);
}
}
addRipples(ganges, 4, 0.75);
addRipples(brahmaputra, 4, 0.70);
addRipples(meghna, 4, 0.82);
addRipples(westBranch, 2, 0.45);
addRipples(eastBranch, 2, 0.45);
// ------------------------------------------------------------
// Trees, reeds, and low-poly ground cover.
// ------------------------------------------------------------
function createTree(x, z, scale = 1, tint = 0) {
const group = new THREE.Group();
group.position.set(x, 0.015, z);
group.scale.setScalar(scale);
const trunk = shadow(
new THREE.Mesh(new THREE.CylinderGeometry(0.065, 0.09, 0.62, 6), mats.darkWood)
);
trunk.position.y = 0.31;
group.add(trunk);
const crown = shadow(
new THREE.Mesh(
new THREE.DodecahedronGeometry(0.46, 0),
tint ? mats.leafLight : mats.leaf
)
);
crown.position.y = 0.84;
crown.scale.set(1.05, 0.92, 0.92);
crown.rotation.y = Math.random() * Math.PI;
group.add(crown);
const crown2 = shadow(
new THREE.Mesh(
new THREE.DodecahedronGeometry(0.3, 0),
tint ? mats.leaf : mats.leafLight
)
);
crown2.position.set(0.2, 1.12, -0.08);
group.add(crown2);
scene.add(group);
}
const treePositions = [
[-7.8, -5.6, 1.0], [-6.3, -6.2, 0.8], [7.8, -5.9, 1.1],
[6.7, -6.6, 0.75], [-8.1, -2.8, 1.05], [7.9, -1.8, 0.9],
[-7.9, 3.2, 1.1], [-7.3, 5.8, 0.85], [4.5, 1.3, 0.75],
[4.1, 2.6, 0.9], [3.8, 4.2, 0.7], [1.8, 4.8, 0.75],
[0.0, -4.9, 0.85], [-2.2, -5.8, 0.95], [3.7, -5.9, 0.7],
[-1.3, -3.2, 0.8], [1.8, -2.8, 0.75]
];
treePositions.forEach((p, i) => createTree(p[0], p[1], p[2], i % 3 === 0));
function createReeds(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.02, z);
group.scale.setScalar(scale);
for (let i = 0; i < 6; i++) {
const stem = shadow(
new THREE.Mesh(new THREE.ConeGeometry(0.035, 0.48, 4), mats.reed),
false,
true
);
stem.position.set(
(Math.random() - 0.5) * 0.26,
0.24,
(Math.random() - 0.5) * 0.26
);
stem.rotation.z = (Math.random() - 0.5) * 0.28;
stem.rotation.x = (Math.random() - 0.5) * 0.2;
group.add(stem);
}
scene.add(group);
}
[
[-1.18, 1.65], [-1.25, 3.95], [-4.9, -1.35], [1.25, 3.85],
[4.8, -0.85], [-5.1, 3.2], [5.15, 3.55], [-2.8, 5.45],
[2.65, 5.7], [-7.95, 0.15], [6.95, 4.7]
].forEach((p, i) => createReeds(p[0], p[1], 0.75 + (i % 3) * 0.13));
// ------------------------------------------------------------
// Raised homes. Their doors face the shared path.
// ------------------------------------------------------------
function createHouse(x, z, rotation, scale = 1, variant = 0, ladder = true) {
const group = new THREE.Group();
group.position.set(x, 0.01, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
const wallMaterial = [mats.wall, mats.wallBlue, mats.wallOchre][variant % 3];
const roofMaterial = variant % 2 ? mats.roofDark : mats.roof;
const floor = shadow(new THREE.Mesh(new THREE.BoxGeometry(1.12, 0.12, 0.94), mats.wood));
floor.position.y = 0.62;
group.add(floor);
const crossBeam = shadow(new THREE.Mesh(new THREE.BoxGeometry(0.92, 0.08, 0.12), mats.darkWood));
crossBeam.position.set(0, 0.43, 0.28);
group.add(crossBeam);
for (const px of [-0.4, 0.4]) {
for (const pz of [-0.31, 0.31]) {
const post = shadow(
new THREE.Mesh(new THREE.CylinderGeometry(0.052, 0.069, 0.58, 6), mats.darkWood)
);
post.position.set(px, 0.29, pz);
group.add(post);
}
}
const walls = shadow(new THREE.Mesh(new THREE.BoxGeometry(1.0, 0.72, 0.84), wallMaterial));
walls.position.y = 1.04;
group.add(walls);
const roof = shadow(new THREE.Mesh(new THREE.ConeGeometry(0.76, 0.54, 4), roofMaterial));
roof.position.y = 1.67;
roof.rotation.y = Math.PI / 4;
roof.scale.z = 0.9;
group.add(roof);
const door = new THREE.Mesh(new THREE.BoxGeometry(0.25, 0.46, 0.018), mats.dark);
door.position.set(0.2, 0.91, 0.429);
group.add(door);
const windowFrame = new THREE.Mesh(new THREE.BoxGeometry(0.25, 0.21, 0.019), mats.darkWood);
windowFrame.position.set(-0.24, 1.11, 0.432);
group.add(windowFrame);
const windowPane = new THREE.Mesh(new THREE.BoxGeometry(0.17, 0.13, 0.022), mats.cream);
windowPane.position.set(-0.24, 1.11, 0.447);
group.add(windowPane);
if (ladder) {
for (const lx of [-0.16, 0.16]) {
const rail = shadow(
new THREE.Mesh(new THREE.BoxGeometry(0.035, 0.58, 0.035), mats.wood)
);
rail.position.set(lx, 0.34, 0.56);
group.add(rail);
}
for (const ly of [0.14, 0.31, 0.48]) {
const rung = new THREE.Mesh(new THREE.BoxGeometry(0.34, 0.035, 0.045), mats.wood);
rung.position.set(0, ly, 0.565);
group.add(rung);
}
}
scene.add(group);
return group;
}
createHouse(-4.3, 1.05, 1.42, 0.98, 0, true);
createHouse(-3.12, 1.18, 1.48, 0.88, 1, true);
createHouse(-4.42, 2.82, 1.38, 0.94, 2, true);
createHouse(-3.08, 3.05, 1.46, 1.0, 0, true);
createHouse(-2.35, 1.92, 1.53, 0.78, 1, false);
// A smaller hamlet across the main channel.
createHouse(2.22, 2.25, 1.22, 0.65, 2, true);
createHouse(3.28, 3.35, 1.35, 0.61, 0, true);
createHouse(2.65, 4.62, 1.40, 0.62, 1, false);
// ------------------------------------------------------------
// The visible settlement path and water landing.
// ------------------------------------------------------------
function addPathSegment(a, b, width = 0.46) {
const dx = b[0] - a[0];
const dz = b[1] - a[1];
const length = Math.hypot(dx, dz);
const mesh = shadow(
new THREE.Mesh(new THREE.BoxGeometry(length, 0.04, width), mats.path)
);
mesh.position.set((a[0] + b[0]) / 2, 0.029, (a[1] + b[1]) / 2);
mesh.rotation.y = -Math.atan2(dz, dx);
scene.add(mesh);
return mesh;
}
addPathSegment([-4.2, 2.16], [-3.08, 2.30], 0.46);
addPathSegment([-3.08, 2.30], [-1.79, 2.66], 0.48);
// Small stepping stones keep the footpath visibly continuous.
for (let i = 0; i < 9; i++) {
const t = i / 8;
const x = THREE.MathUtils.lerp(-4.05, -1.95, t);
const z = THREE.MathUtils.lerp(2.18, 2.60, t) + Math.sin(i * 1.8) * 0.07;
const stone = shadow(
new THREE.Mesh(new THREE.CylinderGeometry(0.12, 0.13, 0.045, 6), mats.path),
false,
true
);
stone.position.set(x, 0.058, z);
stone.rotation.y = i * 0.7;
scene.add(stone);
}
// Three low steps connect the land path to the raised jetty.
const steps = [
{ x: -1.68, y: 0.075, h: 0.15 },
{ x: -1.46, y: 0.165, h: 0.19 },
{ x: -1.24, y: 0.275, h: 0.23 }
];
steps.forEach((s, i) => {
const step = shadow(
new THREE.Mesh(new THREE.BoxGeometry(0.24, s.h, 0.62), i % 2 ? mats.wood : mats.darkWood)
);
step.position.set(s.x, s.y, 2.68 + i * 0.015);
step.rotation.y = -0.06;
scene.add(step);
});
// Individual boards create a low-poly landing.
const jettyStart = new THREE.Vector2(-1.20, 2.70);
const jettyEnd = new THREE.Vector2(0.46, 2.87);
const jettyDirection = jettyEnd.clone().sub(jettyStart);
const jettyLength = jettyDirection.length();
const jettyAngle = -Math.atan2(jettyDirection.y, jettyDirection.x);
const boardCount = 13;
for (let i = 0; i < boardCount; i++) {
const t = (i + 0.5) / boardCount;
const point = jettyStart.clone().lerp(jettyEnd, t);
const board = shadow(
new THREE.Mesh(
new THREE.BoxGeometry(jettyLength / boardCount - 0.012, 0.085, 0.64),
i % 3 === 0 ? mats.darkWood : mats.wood
)
);
board.position.set(point.x, 0.425, point.y);
board.rotation.y = jettyAngle;
scene.add(board);
}
// Piles support the landing above the water.
const perpendicular = new THREE.Vector2(-jettyDirection.y, jettyDirection.x).normalize();
for (const t of [0.08, 0.48, 0.88]) {
const center = jettyStart.clone().lerp(jettyEnd, t);
for (const side of [-1, 1]) {
const position = center.clone().addScaledVector(perpendicular, side * 0.24);
const pile = shadow(
new THREE.Mesh(new THREE.CylinderGeometry(0.058, 0.074, 0.58, 6), mats.darkWood)
);
pile.position.set(position.x, 0.235, position.y);
scene.add(pile);
}
}
const landing = shadow(
new THREE.Mesh(new THREE.BoxGeometry(0.48, 0.075, 0.82), mats.wood)
);
landing.position.set(-0.76, 0.47, 2.77);
landing.rotation.y = jettyAngle;
scene.add(landing);
const mooringPost = shadow(
new THREE.Mesh(new THREE.CylinderGeometry(0.055, 0.075, 0.6, 6), mats.darkWood)
);
mooringPost.position.set(0.43, 0.50, 3.03);
scene.add(mooringPost);
// ------------------------------------------------------------
// Small faceted boat, deck seats, boatman, and mooring rope.
// ------------------------------------------------------------
function createBoat() {
const boat = new THREE.Group();
boat.position.set(1.08, 0.18, 3.28);
boat.rotation.y = -0.05;
const outline = [
[-0.70, -0.27], [0.35, -0.27], [0.70, 0],
[0.35, 0.27], [-0.70, 0.27], [-0.79, 0]
];
const vertices = [];
const indices = [];
const n = outline.length;
outline.forEach(([x, z]) => vertices.push(x, 0.12, z));
outline.forEach(([x, z]) => vertices.push(x * 0.58, -0.16, z * 0.50));
vertices.push(0, -0.17, 0);
for (let i = 0; i < n; i++) {
const j = (i + 1) % n;
const topI = i;
const topJ = j;
const bottomI = n + i;
const bottomJ = n + j;
indices.push(topI, bottomI, topJ, topJ, bottomI, bottomJ);
indices.push(bottomI, 2 * n, bottomJ);
}
const hullGeometry = new THREE.BufferGeometry();
hullGeometry.setAttribute("position", new THREE.Float32BufferAttribute(vertices, 3));
hullGeometry.setIndex(indices);
hullGeometry.computeVertexNormals();
const hull = shadow(
new THREE.Mesh(hullGeometry, material(0x744235, { roughness: 0.84 }))
);
boat.add(hull);
const deckShape = new THREE.Shape();
outline.forEach(([x, z], index) => {
if (index === 0) deckShape.moveTo(x, -z);
else deckShape.lineTo(x, -z);
});
deckShape.closePath();
const deck = shadow(
new THREE.Mesh(new THREE.ShapeGeometry(deckShape), mats.wood)
);
deck.rotation.x = -Math.PI / 2;
deck.position.y = 0.135;
boat.add(deck);
for (const x of [-0.24, 0.18]) {
const seat = shadow(new THREE.Mesh(new THREE.BoxGeometry(0.12, 0.055, 0.43), mats.darkWood));
seat.position.set(x, 0.175, 0);
boat.add(seat);
}
const torso = shadow(
new THREE.Mesh(new THREE.CylinderGeometry(0.075, 0.095, 0.32, 6), mats.wallOchre)
);
torso.position.set(-0.36, 0.42, 0);
boat.add(torso);
const head = shadow(
new THREE.Mesh(new THREE.IcosahedronGeometry(0.105, 0), material(0x8e6048))
);
head.position.set(-0.36, 0.65, 0);
boat.add(head);
const hat = shadow(
new THREE.Mesh(new THREE.ConeGeometry(0.14, 0.08, 8), mats.cream)
);
hat.position.set(-0.36, 0.73, 0);
boat.add(hat);
scene.add(boat);
return boat;
}
createBoat();
function cylinderBetween(a, b, radius, mat) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = shadow(
new THREE.Mesh(new THREE.CylinderGeometry(radius, radius, length, 6), mat)
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
scene.add(mesh);
return mesh;
}
cylinderBetween(
new THREE.Vector3(0.43, 0.74, 3.03),
new THREE.Vector3(0.40, 0.43, 3.20),
0.013,
material(0x9a815b)
);
// ------------------------------------------------------------
// Schematic north arrow.
// ------------------------------------------------------------
const northArrow = new THREE.Group();
northArrow.position.set(7.65, 0.045, 5.55);
const shaft = new THREE.Mesh(new THREE.BoxGeometry(0.07, 0.025, 0.48), mats.cream);
shaft.position.z = 0.12;
northArrow.add(shaft);
const arrowHead = new THREE.Mesh(new THREE.ConeGeometry(0.15, 0.34, 3), mats.cream);
arrowHead.position.set(0, 0.012, -0.25);
arrowHead.rotation.x = -Math.PI / 2;
arrowHead.rotation.z = Math.PI / 6;
northArrow.add(arrowHead);
scene.add(northArrow);
// ------------------------------------------------------------
// Projected HTML labels.
// ------------------------------------------------------------
const labelAnchors = {
"label-ganges": ganges.getPoint(0.48).setY(0.10),
"label-brahmaputra": brahmaputra.getPoint(0.47).setY(0.10),
"label-meghna": meghna.getPoint(0.66).setY(0.10),
"label-branches": eastBranch.getPoint(0.49).setY(0.10),
"label-homes": new THREE.Vector3(-3.15, 1.62, 1.45),
"label-path": new THREE.Vector3(-2.72, 0.14, 2.39),
"label-landing": new THREE.Vector3(-0.75, 0.64, 2.77),
"label-boat": new THREE.Vector3(1.05, 0.84, 3.28),
"label-north": new THREE.Vector3(7.65, 0.10, 5.13)
};
const labelElements = {};
for (const [id, position] of Object.entries(labelAnchors)) {
labelElements[id] = {
element: document.getElementById(id),
position,
projected: new THREE.Vector3()
};
}
function updateLabels() {
const width = stage.clientWidth;
const height = stage.clientHeight;
for (const label of Object.values(labelElements)) {
label.projected.copy(label.position).project(camera);
const visible = label.projected.z > -1 && label.projected.z < 1;
label.element.classList.toggle("is-hidden", !visible);
if (visible) {
const x = (label.projected.x * 0.5 + 0.5) * width;
const y = (-label.projected.y * 0.5 + 0.5) * height;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
}
// ------------------------------------------------------------
// Direct orbit, zoom, keyboard, touch, and button controls.
// ------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 0.35, 0);
const initialYaw = 0.63;
const initialPitch = 0.90;
let yaw = initialYaw;
let yawTarget = initialYaw;
let pitch = initialPitch;
let pitchTarget = initialPitch;
let radius = 22;
let radiusTarget = 22;
let fitRadius = 22;
function updateCamera() {
const sinPitch = Math.sin(pitch);
camera.position.set(
cameraTarget.x + radius * sinPitch * Math.sin(yaw),
cameraTarget.y + radius * Math.cos(pitch),
cameraTarget.z + radius * sinPitch * Math.cos(yaw)
);
camera.lookAt(cameraTarget);
}
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
const halfFov = THREE.MathUtils.degToRad(camera.fov * 0.5);
const verticalFit = 7.1 / Math.tan(halfFov);
const horizontalFit = 9.8 / (Math.tan(halfFov) * camera.aspect);
fitRadius = Math.max(verticalFit, horizontalFit) * 1.08;
}
resize();
radius = radiusTarget = fitRadius;
window.addEventListener("resize", resize);
const canvas = renderer.domElement;
const pointers = new Map();
let dragPointer = null;
let lastX = 0;
let lastY = 0;
let pinchDistance = 0;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(values[0].x - values[1].x, values[0].y - values[1].y);
}
canvas.addEventListener("pointerdown", event => {
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
if (pointers.size === 1) {
dragPointer = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
} else if (pointers.size === 2) {
pinchDistance = pointerDistance();
dragPointer = null;
}
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size >= 2) {
const distance = pointerDistance();
if (pinchDistance > 0 && distance > 0) {
radiusTarget = THREE.MathUtils.clamp(
radiusTarget * (pinchDistance / distance),
11,
75
);
}
pinchDistance = distance;
return;
}
if (event.pointerId !== dragPointer) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
yawTarget -= dx * 0.006;
pitchTarget = THREE.MathUtils.clamp(
pitchTarget + dy * 0.005,
0.44,
1.32
);
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (dragPointer === event.pointerId) dragPointer = null;
if (pointers.size === 0) canvas.classList.remove("dragging");
pinchDistance = pointerDistance();
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("lostpointercapture", endPointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
radiusTarget = THREE.MathUtils.clamp(
radiusTarget * Math.exp(event.deltaY * 0.001),
11,
75
);
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
function resetCamera() {
yawTarget = initialYaw;
pitchTarget = initialPitch;
radiusTarget = fitRadius;
}
document.getElementById("zoom-in").addEventListener("click", () => {
radiusTarget = THREE.MathUtils.clamp(radiusTarget * 0.86, 11, 75);
});
document.getElementById("zoom-out").addEventListener("click", () => {
radiusTarget = THREE.MathUtils.clamp(radiusTarget * 1.16, 11, 75);
});
document.getElementById("reset-view").addEventListener("click", resetCamera);
window.addEventListener("keydown", event => {
if (event.key === "ArrowLeft") yawTarget += 0.12;
if (event.key === "ArrowRight") yawTarget -= 0.12;
if (event.key === "ArrowUp") pitchTarget = Math.max(0.44, pitchTarget - 0.09);
if (event.key === "ArrowDown") pitchTarget = Math.min(1.32, pitchTarget + 0.09);
if (event.key === "+" || event.key === "=") radiusTarget = Math.max(11, radiusTarget * 0.9);
if (event.key === "-") radiusTarget = Math.min(75, radiusTarget * 1.1);
if (event.key.toLowerCase() === "r") resetCamera();
});
// Regional notes.
const notes = document.getElementById("notes");
const notesToggle = document.getElementById("notes-toggle");
function setNotes(open) {
notes.classList.toggle("open", open);
notesToggle.setAttribute("aria-expanded", String(open));
}
notesToggle.addEventListener("click", () => {
setNotes(!notes.classList.contains("open"));
});
document.getElementById("notes-close").addEventListener("click", () => setNotes(false));
if (window.innerWidth <= 760) setNotes(false);
// ------------------------------------------------------------
// Render loop.
// ------------------------------------------------------------
function animate() {
requestAnimationFrame(animate);
const damping = 0.115;
yaw = THREE.MathUtils.lerp(yaw, yawTarget, damping);
pitch = THREE.MathUtils.lerp(pitch, pitchTarget, damping);
radius = THREE.MathUtils.lerp(radius, radiusTarget, damping);
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
updateCamera();
renderer.render(scene, camera);
loading.classList.add("hide");
animate();
</script>
</body>
</html>
```