Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(society): the island grows into a landscape - 16x16 fields, biomes at ten heights, graded roads, the hub on its podium, shore-driven water

rubenluetke10-beep3fc6a3e8d5bf
diff --git a/docs/agent-society/world-art-direction.md b/docs/agent-society/world-art-direction.md
index 83c2e1aa6d..f046d94ce8 100644
--- a/docs/agent-society/world-art-direction.md
+++ b/docs/agent-society/world-art-direction.md
@@ -21,12 +21,12 @@ places of the society. Seen steeply from above, lightly pixelated, never dark, n
|---|---|---|---|
| 1 | Look | **Colourful pixel island** (cosy-farming-game softness in 3D) | matches "bright, beautiful, lightly pixelated"; a block diorama or clean low-poly would lose the warmth |
| 2 | Camera | **Steep bird's-eye: 50° below the horizon, 45° dimetric yaw**, orthographic | reads as "from above" yet keeps house fronts and figure silhouettes; 30–35° gives more façade but less overview |
-| 3 | Size | **10 × 10 fields; the central 4 × 4 fields are the market district** | the maintainer wants a big island that is not seen in one screen; one field = one screen at the closest zoom |
-| 4 | Landscape | **A village / small town** on a green island: meadows, beach, a bay, one rocky highland | free-text decision: "a village, ultramodern, future-oriented" |
+| 3 | Size | **16 × 16 fields (512 m); the central 4 × 4 fields are the market district** | the maintainer wants a big island that is not seen in one screen — grown from 10 × 10 on 2026-09-02 ("at least 50 % bigger"); one field = one screen at the closest zoom |
+| 4 | Landscape | **A village / small town** on an island of **biomes at different heights**: a snow-capped mountain, terraced hills, alpine meadows, a rocky cape, a tropical cove with a lagoon, the harbor bay, orchards, a dark forest | free-text decisions: "a village, ultramodern, future-oriented" (2026-09-01) and "not flat — biomes, heights, spectacular, never overloaded" (2026-09-02) |
| 5 | Architecture | **Solarpunk village** — white + glass + solar + gardens + wood, lots of green between | colourful AND futuristic; pure factory grey or neon-cyber contradicts the bright island |
| 6 | Centre | **Comic-village ring structure, modernised**: houses around the open square, the big tree with the long table in the middle, the lead's hub at the head (north) | the maintainer's own image ("Asterix-style village structure, only modern") |
| 7 | Pixel grain | **Fine — 2 screen pixels per rendered pixel** (a 1280-px stage renders at 640 px) | figures and signs stay readable; 320×180 would be too coarse for a big island |
-| 8 | Navigation | **Drag + arrow keys/WASD, three fixed zoom steps (32 / 64 / 128 m), minimap** | 100 fields need zoom to find an agent; fixed steps keep pixels crisp |
+| 8 | Navigation | **Drag + arrow keys/WASD, five fixed zoom steps (32 / 64 / 128 / 256 / 512 m), minimap with relief** | 256 fields need zoom to find an agent; fixed steps keep pixels crisp; the widest step is the postcard of the island |
Decided by the build, open to the maintainer: fixed warm-afternoon light in V1 (a real-clock
day/night cycle is a later flavour); animated pixel water; the hub carries the pulsing beacon
@@ -34,47 +34,70 @@ that will map onto the voice orb.
## 3. Layout
-Units: 1 world unit = 1 m; one tile = 2 m; the island is 160 × 160 tiles (320 m). World origin
-is the island centre; +x east, +z south.
+Units: 1 world unit = 1 m; one tile = 2 m; the island is 256 × 256 tiles (512 m). World origin
+is the island centre; +x east, +z south. The camera looks toward the north-west, so the tall
+things stand at the back (north-west) and the low, bright things in the foreground (south-east).
```
- N (archive tower)
- |
- solar | rock highland
- field |
-W (workshop)—[ MARKET DISTRICT ]—(lighthouse cape) E
- |
- gardens |
- greenhouses|
- S (harbor gate + dock in the bay)
+ MOUNTAIN (snow cap) N archive HILL ALPINE meadows, flower fields
+ solar terrace |
+ |
+W dark FOREST (workshop)—[ MARKET PLATEAU ]—(lighthouse on the rocky CAPE) E · islets
+ |
+ ORCHARD meadows | tropical COVE: lagoon, sandbar, palms, gardens
+ S harbor BAY, dock, breakwater
```
-**Market district (64 × 64 tiles, one flat plateau):**
+**Terrain:** a continuous height field (`islandLayout.heightAt`) — a radial fall-off plus one
+designed bump or dip per biome (`REGIONS`) plus a little noise — quantised into ten levels
+(`LEVEL_Y`, 0.35 m at the beach to 12.6 m at the peak). Every slope becomes a terrace, every
+steep place a cliff. The tile kind follows level and region: sand → grass / meadow → forest (west)
+→ alpine (high, north-east and the mountain) → rock → snow (level 8+). Flower fields are drifts of
+`garden` tiles over the meadows. Offshore: four rock islets with a green crown, the breakwater in
+the bay's mouth, the lagoon (sea level, enclosed by a sandbar, a channel to the sea, a jetty).
+
+**Roads are graded:** each spoke is walked outward from the square and clamped to ±1 level per
+tile, shoulders included, so a walker can climb to the archive hill or the cape; cliffs of two
+steps or more are real barriers (`findPath` refuses them). Every place's plot is flattened to its
+own terrace level (`PLOT_LEVEL`): the archive on the hill at 5, the lighthouse knob at 6, the
+harbor and the gardens low at 2, the solar field on the mountain's foot terrace at 4.
+
+**Market district (a round plateau of radius 39 tiles, level 3):**
- open square, radius 13 tiles, paved; garden beds alternate around its rim;
- the big tree in the exact centre, a ring bench around it, the long table on the south side —
this is the `meeting` checkpoint (MASTERPLAN §2.7);
-- 12 houses on a ring at radius 19 tiles, doors facing the square; the four cardinal directions
- stay open as gates; three variants cycle: solar-barrel roof, garden roof, glass loft;
-- the **hub** (lead agent) at the head of the square, north, radius 20: the largest building,
- glass band, dome, beacon mast;
-- ring road at radius 25, hedge ring with four gates at radius 29, lamps along the spokes;
+- the house ring at radius 19 tiles, doors facing the square; the four cardinal directions stay
+ open as gates; the Plugin Docks take two north-west slots, the hub's podium the two slots
+ flanking the north gate — eight houses remain, three variants cycling: solar-barrel roof,
+ garden roof, glass loft;
+- the **hub** (lead agent) at the head of the square, north, on a **podium one level up**
+ (18 × 10 tiles): a 24 × 12 m hall with a glass band and garden roofs, a set-back upper floor,
+ the glass atrium under the dome, the beacon spire with its halo, two solar-roofed wings, a
+ colonnade over the entrance, the grand stair down to the square, the reflecting pool and two
+ flag masts at its foot;
+- ring road at radius 25 (it climbs the podium's back terrace instead of vanishing under it),
+ hedge ring with four gates at radius 29, lamps along the spokes;
- four spokes (width 3 tiles) from the square to the quarters.
**Quarters and checkpoints** (backend place → island place, `Walkers.tsx`):
| checkpoint | place | building |
|---|---|---|
-| `desk` | workshop (west) | long hall, sawtooth skylights, wide door toward the village |
+| `desk` | workshop (west, a clearing in the forest) | long hall, sawtooth skylights, wide door toward the village |
| `meeting` | market square | the table under the big tree |
-| `archive` | archive (north) | round tower, two glass bands, blue dome |
-| `gate` | harbor gate (south) | gate pillars over the dock into the bay, kiosk, moored boat |
-| — | lighthouse (east cape) | striped tower with rotating lamp, keeper's hut |
-| — | gardens (south-east) | six glass greenhouses on garden tiles |
-| — | solar field (north-west) | 35 tilted panels on posts |
+| `archive` | archive (north, on the terraced hill) | round tower, two glass bands, blue dome |
+| `gate` | harbor gate (south, the bay) | gate pillars over the dock into the bay, kiosk, two moored boats, buoys, breakwater |
+| — | lighthouse (east cape, on the rock) | striped tower with rotating lamp, keeper's hut |
+| — | gardens (south-east, the cove's low terrace) | six glass greenhouses on garden tiles |
+| — | solar field (north-west, the mountain's foot terrace) | 35 tilted panels on posts |
Idle agents (`idle`) wander inside the square with the rest-biased model (`wander.ts`);
paused agents stand still.
+**Vegetation per biome** (`treeChoice`): round trees on grass and meadow (dense and taller in the
+forest), pines on the alpine meadows and the high slopes, palms on the cove's sand — thickest
+around the lagoon; boulders on the high ground, at the foot of cliffs and on the beaches.
+
## 4. Palette
Everything inside the viewport comes from `worldPalette.ts`. Never a theme token, never Ink &
@@ -84,9 +107,10 @@ tile-art flicker under the pixel pass.
| Role | Colours |
|---|---|
| sky / clear | `#a5dbff` |
-| sea | surface `#44a0dd`, deep `#2f7fc4`, ripple `#8fd0f4`, foam `#d9f2ff` |
+| sea | shallow `#72d3e2`, surface `#44a0dd`, deep `#2f7fc4`, abyss `#1e5c9a`, ripple `#9fdcf6`, foam `#e4f6ff` |
| sand | `#f3e2ad` / `#ead597` |
| grass | `#7ccb5c` / `#6fbe51`; meadow (high ground) `#97d46c` / `#8ac860` |
+| forest floor | `#4f9e47` / `#47923f`; alpine `#bcd97c` / `#aecf6f`; snow `#f6f9fc` / `#e9eff6` |
| rock | `#a8a7b3` / `#9a99a6`, faces `#6f6e7c` |
| square / paths | `#ece1cf` / `#e2d5c0`; paths `#dcc9a5` / `#d0bd97` |
| cliff faces under grass | `#8e6a44` |
@@ -95,7 +119,7 @@ tile-art flicker under the pixel pass.
| solar | `#26375a`, seams `#3e5f95` |
| wood | `#b57f45` / `#8c5e2f`, doors `#e0893b` |
| lead accent | `#2f6f8f` (the Jarvis palette of the roster), beacon `#ffe08a` |
-| trees | trunk `#7a5230`, canopies `#4faf49` / `#6cc35e` / `#93da7c` |
+| trees | trunk `#7a5230`, canopies `#4faf49` / `#6cc35e` / `#93da7c`; pines `#2f7f45` / `#3b9452` / `#5aae64`; palms `#4fb254` / `#7ccf6c`; boulders `#a19fab` / `#7e7c8a` |
| in-world type | Pixelify Sans (OFL, bundled via fontsource), ink `#1f2a3a` on cream chips |
Light: hemisphere sky `#d6ecff` / ground `#7f9c5a`, one warm directional sun `#fff1d6` from the
@@ -108,8 +132,9 @@ lamps and beacons — never PBR.
- Orthographic camera, `RenderPixelatedPass` (normal edge 0.18, depth edge 0.28) +
`OutputPass`, `dpr = 1`, antialias off. Pixel size is an integer (2); zoom never scales the
pixel grid.
-- Terrain is ONE merged vertex-coloured mesh; trees, hedges, lamps, panels and greenhouses are
- instanced; buildings are shared unit geometries scaled per use, sharing ~25 materials through
+- Terrain is ONE merged vertex-coloured mesh (high ground tinted lighter, wet sand darker); trees,
+ pines, palms, boulders, hedges, lamps, panels and greenhouses are instanced; the sea is one
+ plane whose shader reads a shore-distance texture (depth tint, crests rolling in, foam line); buildings are shared unit geometries scaled per use, sharing ~25 materials through
`WorldKit`.
- Every canvas mounts through `useWebglSurface`; the loop pauses via IntersectionObserver;
reduced motion → demand-driven frames, no wander, no water drift; no WebGL → fallback to the
diff --git a/jarvis/ui/web/frontend/src/components/society/world/Landmarks.tsx b/jarvis/ui/web/frontend/src/components/society/world/Landmarks.tsx
index 2735fe254b..7e31f09f2a 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/Landmarks.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/Landmarks.tsx
@@ -6,7 +6,7 @@
*/
import { useMemo, useRef } from "react";
import { useFrame } from "@react-three/fiber";
-import { InstancedMesh, Mesh, Object3D } from "three";
+import { Group, InstancedMesh, Mesh, Object3D } from "three";
import { buildIsland, groundY, tileToWorld, type PlaceId, type Post } from "./islandLayout";
import { KIT_PLACEMENTS, KitBuilding } from "./KitBuilding";
@@ -67,11 +67,24 @@ function Archive({ kit }: { kit: Kit }) {
function Harbor({ kit, paused }: { kit: Kit; paused: boolean }) {
const [x, y, z] = placeWorld("harbor");
const boat = useRef<Mesh>(null);
+ const boat2 = useRef<Mesh>(null);
+ const buoys = useRef<Group>(null);
useFrame(({ clock }) => {
- if (!boat.current || paused) return;
+ if (paused) return;
const t = clock.getElapsedTime();
- boat.current.position.y = 0.15 + Math.sin(t * 1.1) * 0.08;
- boat.current.rotation.z = Math.sin(t * 0.8) * 0.03;
+ if (boat.current) {
+ boat.current.position.y = 0.15 + Math.sin(t * 1.1) * 0.08;
+ boat.current.rotation.z = Math.sin(t * 0.8) * 0.03;
+ }
+ if (boat2.current) {
+ boat2.current.position.y = 0.15 + Math.sin(t * 0.9 + 1.7) * 0.09;
+ boat2.current.rotation.z = Math.sin(t * 0.7 + 0.4) * 0.035;
+ }
+ if (buoys.current) {
+ buoys.current.children.forEach((b, i) => {
+ b.position.y = 0.25 + Math.sin(t * 1.3 + i * 2.1) * 0.12;
+ });
+ }
});
return (
<group position={[x, y, z]}>
@@ -86,13 +99,27 @@ function Harbor({ kit, paused }: { kit: Kit; paused: boolean }) {
<Block kit={kit} at={[-7, 1.4, 2]} size={[4, 2.8, 3.5]} color={PAL.wallShade} />
<Block kit={kit} at={[-7, 2.95, 2]} size={[4.6, 0.3, 4.1]} color={PAL.solar} />
<Block kit={kit} at={[-7, 1.6, 3.8]} size={[2.4, 1.0, 0.12]} color={PAL.glass} glow />
- {/* a boat moored beside the dock */}
- <group position={[6.5, -y, 24]}>
+ {/* boats moored beside the dock, and the buoys marking the fairway */}
+ <group position={[6.5, -y, 26]}>
<mesh ref={boat} geometry={kit.g.box} material={kit.m.lit(PAL.wood)} position={[0, 0.15, 0]} scale={[2.2, 1.0, 6]}>
<mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.woodDark)} position={[0, 2.4, 0.1]} scale={[0.08, 4.4, 0.04]} />
<mesh geometry={kit.g.box} material={kit.m.lit(PAL.wall)} position={[0.45, 2.6, 0.1]} scale={[0.75, 2.6, 0.03]} />
</mesh>
</group>
+ <group position={[-7, -y, 32]} rotation={[0, 0.35, 0]}>
+ <mesh ref={boat2} geometry={kit.g.box} material={kit.m.lit(PAL.hubAccent)} position={[0, 0.15, 0]} scale={[2.6, 1.0, 7]}>
+ <mesh geometry={kit.g.box} material={kit.m.lit(PAL.wall)} position={[0, 0.9, -0.1]} scale={[0.7, 0.9, 0.36]} />
+ </mesh>
+ </group>
+ <group ref={buoys} position={[0, -y, 0]}>
+ {[
+ [16, 44],
+ [-14, 48],
+ [4, 58],
+ ].map(([bx, bz]) => (
+ <mesh key={`${bx},${bz}`} geometry={kit.g.sphere} material={kit.m.lit(PAL.buoy)} position={[bx, 0.25, bz]} scale={[1.1, 1.3, 1.1]} />
+ ))}
+ </group>
</group>
);
}
@@ -105,7 +132,7 @@ function Lighthouse({ kit, paused }: { kit: Kit; paused: boolean }) {
lamp.current.rotation.y = clock.getElapsedTime() * 1.4;
});
return (
- <group position={[x, y, z]}>
+ <group position={[x, y, z]} scale={[1.3, 1.3, 1.3]}>
<mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.trim)} position={[0, 0.25, 0]} scale={[5.5, 0.5, 5.5]} />
<mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.wall)} position={[0, 5.5, 0]} scale={[3.4, 11, 3.4]} />
<mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.lighthouseStripe)} position={[0, 3.2, 0]} scale={[3.45, 1.5, 3.45]} />
diff --git a/jarvis/ui/web/frontend/src/components/society/world/Minimap.tsx b/jarvis/ui/web/frontend/src/components/society/world/Minimap.tsx
index 7559cc8cb0..2d48bd7832 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/Minimap.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/Minimap.tsx
@@ -1,16 +1,17 @@
/**
- * The island at a glance: a 2D canvas painted once from the tile map, with the
- * viewport rectangle and the walkers' pins redrawn a few times a second.
- * Clicking it moves the camera there.
+ * The island at a glance: a 2D canvas painted once from the tile map — every
+ * kind in its colour, the high ground lighter and the low ground deeper so the
+ * relief reads — with the viewport rectangle and the walkers' pins redrawn a
+ * few times a second. Clicking it moves the camera there.
*/
import { useEffect, useMemo, useRef } from "react";
import { useT } from "@/i18n";
import { useCameraStore } from "./cameraStore";
-import { ISLAND_HALF_M, TILE_M, buildIsland, type TileKind } from "./islandLayout";
+import { ISLAND_HALF_M, PLATEAU_LEVEL, TILE_M, TileKind, buildIsland } from "./islandLayout";
import { walkerPins } from "./walkerRegistry";
import { ZOOM_WIDTHS_M, visibleGroundCorners } from "./worldCamera";
-import { LABEL, minimapColor } from "./worldPalette";
+import { LABEL, WATER, minimapColor, shadeHex } from "./worldPalette";
const SIZE_PX = 168;
const REDRAW_MS = 120;
@@ -25,7 +26,13 @@ function paintBase(): HTMLCanvasElement | null {
if (!ctx) return null;
for (let tz = 0; tz < map.size; tz++) {
for (let tx = 0; tx < map.size; tx++) {
- ctx.fillStyle = minimapColor(map.kind[tz * map.size + tx] as TileKind);
+ const i = tz * map.size + tx;
+ const kind = map.kind[i] as TileKind;
+ if (kind === TileKind.water) {
+ ctx.fillStyle = WATER.deep;
+ } else {
+ ctx.fillStyle = shadeHex(minimapColor(kind), 1 + (map.level[i] - PLATEAU_LEVEL) * 0.06);
+ }
ctx.fillRect(tx, tz, 1, 1);
}
}
diff --git a/jarvis/ui/web/frontend/src/components/society/world/PlaceLabels.tsx b/jarvis/ui/web/frontend/src/components/society/world/PlaceLabels.tsx
index 57c8bfbefe..921faf01b0 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/PlaceLabels.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/PlaceLabels.tsx
@@ -11,11 +11,11 @@ import { buildIsland, groundY, tileToWorld, type PlaceId } from "./islandLayout"
/** Label anchor height above the ground per place (roughly the roofline). */
const LABEL_Y: Record<PlaceId, number> = {
market: 12.5,
- hub: 13,
+ hub: 26,
workshop: 9,
archive: 15,
harbor: 8,
- lighthouse: 16,
+ lighthouse: 20,
gardens: 6,
solar: 5,
plugins: 13,
diff --git a/jarvis/ui/web/frontend/src/components/society/world/README.md b/jarvis/ui/web/frontend/src/components/society/world/README.md
index 25daa0e0d6..260c3d6777 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/README.md
+++ b/jarvis/ui/web/frontend/src/components/society/world/README.md
@@ -8,7 +8,7 @@ Binding design: `docs/agent-society/world-masterplan-v2.md` (look, kit, market,
| File | Role |
|---|---|
-| `islandLayout.ts` | THE model: grid constants, deterministic terrain, village ring, places, trees, A\* pathfinding. Pure, tested. |
+| `islandLayout.ts` | THE model: grid constants, the height field and its biomes, graded roads, village ring, places, trees, boulders, A\* pathfinding. Pure, tested. |
| `worldCamera.ts` | Pitch/yaw/zoom steps and screen↔ground math. Pure, tested. |
| `walkerKinematics.ts` | character-pipeline.md §6 as functions (heading, turning, arrival). Pure, tested. The figure pipeline's F3 step plugs its GLB `<Figure>` in here without changing these. |
| `wander.ts` | Rest-biased idle model (zero tokens). Pure, tested. |
@@ -17,7 +17,7 @@ Binding design: `docs/agent-society/world-masterplan-v2.md` (look, kit, market,
| `cameraStore.ts` · `useWorldControls.ts` · `WorldCameraRig.tsx` | Target/zoom store, DOM navigation, the R3F camera driver. |
| `WorldComposer.tsx` · `worldSettings.ts` | Scaled render + bloom (smooth default) or `RenderPixelatedPass` (grain option / cheap-GPU mode). |
| `SunRig.tsx` · `Clouds.tsx` · `Shadowed.tsx` | The sun with a view-following shadow camera, shadow-casting clouds, the cast/receive marker. |
-| `Terrain.tsx` · `Village.tsx` · `Landmarks.tsx` · `Trees.tsx` | The scene, all primitives, shared through `WorldKit.tsx`. |
+| `Terrain.tsx` · `Village.tsx` · `Landmarks.tsx` · `Trees.tsx` | The scene: the terrain mesh and the shore-driven water shader, the village with the hub on its podium, the landmarks, every tree, palm, pine and boulder — all primitives, shared through `WorldKit.tsx`. |
| `Walkers.tsx` · `WalkerFigure.tsx` · `walkerRegistry.ts` | Agents on foot: state machine, stand-in figure, minimap pins. |
| `PlaceLabels.tsx` · `WorldHud.tsx` · `Minimap.tsx` · `world.css` | DOM over the canvas in the world's type. |
| `WorldStage.tsx` | The composition; mounted by `views/JarvisAgentsView.tsx` behind the World / Ledger switch. |
diff --git a/jarvis/ui/web/frontend/src/components/society/world/Terrain.tsx b/jarvis/ui/web/frontend/src/components/society/world/Terrain.tsx
index 31da662856..503a9ee5eb 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/Terrain.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/Terrain.tsx
@@ -1,8 +1,10 @@
/**
* The ground and the sea. The terrain is one merged, vertex-coloured mesh
* (`terrainGeometry.ts`) that receives the sun's shadows. The sea is a single
- * plane with a small shader: depth tint toward the coast, an animated foam
- * line along the shore, sparkle — world-masterplan-v2.md §3.6.
+ * plane with a shader driven by a shore-distance texture baked from the tile
+ * map: turquoise shallows deepening to the open sea, long swells, caustic
+ * shimmer in the shallows, wave crests rolling toward every coast and
+ * breaking into a foam line, sparkle further out — world-masterplan-v2.md §3.6.
*/
import { useEffect, useMemo } from "react";
import { useFrame } from "@react-three/fiber";
@@ -18,7 +20,7 @@ import {
ShaderMaterial,
} from "three";
-import { ISLAND_HALF_M, TileKind, buildIsland, type IslandMap } from "./islandLayout";
+import { ISLAND_HALF_M, TILE_M, TileKind, buildIsland, type IslandMap } from "./islandLayout";
import { buildTerrainGeometry } from "./terrainGeometry";
import { WATER } from "./worldPalette";
@@ -39,13 +41,16 @@ export function Terrain() {
}
/** The sea plane — far larger than the island so its edge is never in view. */
-const SEA_SIZE_M = 1600;
-/** How many tiles out from the coast the foam and the shallow tint reach. */
-const SHORE_REACH_TILES = 4;
+const SEA_SIZE_M = 2400;
+/** How many tiles out from the coast the shore texture measures distance. */
+export const SHORE_REACH_TILES = 16;
+/** The same reach in metres — the shader's distance scale. */
+const SHORE_REACH_M = SHORE_REACH_TILES * TILE_M;
/**
- * Shore proximity per tile, 1 at the coast fading to 0 four tiles out: a
- * multi-source breadth-first walk from every land tile over the water.
+ * Shore distance per tile: 1 on land and at the coast, fading to 0 sixteen
+ * tiles out — a multi-source breadth-first walk from every land tile over the
+ * water. Linear filtering turns the per-tile values into a smooth field.
*/
export function buildShoreTexture(map: IslandMap): DataTexture {
const n = map.size * map.size;
@@ -86,7 +91,7 @@ export function buildShoreTexture(map: IslandMap): DataTexture {
continue;
}
const d = dist[i];
- data[i] = d < 0 ? 0 : Math.round(255 * (1 - (d - 0.5) / SHORE_REACH_TILES));
+ data[i] = d < 0 ? 0 : Math.max(0, Math.round(255 * (1 - (d - 0.5) / SHORE_REACH_TILES)));
}
const tex = new DataTexture(data, map.size, map.size, RedFormat);
tex.minFilter = LinearFilter;
@@ -110,26 +115,71 @@ const WATER_FRAGMENT = /* glsl */ `
uniform sampler2D shoreTex;
uniform float time;
uniform float halfSize;
+ uniform float reachM;
+ uniform vec3 abyss;
uniform vec3 deep;
uniform vec3 surface;
+ uniform vec3 shallow;
uniform vec3 ripple;
uniform vec3 foam;
varying vec3 vWorld;
+ float hashn(vec2 p) {
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
+ }
+ float noise(vec2 p) {
+ vec2 i = floor(p);
+ vec2 f = fract(p);
+ f = f * f * (3.0 - 2.0 * f);
+ float a = hashn(i);
+ float b = hashn(i + vec2(1.0, 0.0));
+ float c = hashn(i + vec2(0.0, 1.0));
+ float d = hashn(i + vec2(1.0, 1.0));
+ return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
+ }
+
void main() {
vec2 uv = vWorld.xz / (2.0 * halfSize) + 0.5;
float shore = texture2D(shoreTex, uv).r;
- // Two slow wave fields; their product gives moving glints.
- float w1 = sin(vWorld.x * 0.42 + vWorld.z * 0.18 + time * 0.9);
- float w2 = sin(vWorld.z * 0.37 - vWorld.x * 0.21 - time * 0.7);
- float glint = smoothstep(0.86, 1.0, w1 * w2);
- vec3 col = mix(deep, surface, clamp(shore * 1.3, 0.0, 1.0));
- col = mix(col, ripple, glint * 0.5);
- // Foam: a band hugging the coast that breathes with the waves.
- float breathe = 0.06 * sin(time * 1.6 + vWorld.x * 0.8 + vWorld.z * 0.6);
- float band = smoothstep(0.62 + breathe, 0.9 + breathe, shore);
- float lace = smoothstep(0.2, 0.8, sin(vWorld.x * 0.9 + time * 0.9) * sin(vWorld.z * 0.8 - time * 0.7) * 0.5 + 0.5);
- col = mix(col, foam, band * (0.7 + 0.3 * lace));
+ // Metres from the nearest coast, 0 at the shore, reachM on the open sea.
+ float dist = (1.0 - shore) * reachM;
+
+ // Depth: turquoise over the sand, the surface blue, then deep, then the abyss.
+ vec3 col = mix(shallow, surface, smoothstep(0.0, 9.0, dist));
+ col = mix(col, deep, smoothstep(8.0, 22.0, dist));
+ col = mix(col, abyss, smoothstep(24.0, reachM, dist));
+
+ // Long swells: two slow bands crossing the whole sea.
+ float swell = sin(dot(vWorld.xz, vec2(0.045, 0.028)) - time * 0.55) * 0.5 + 0.5;
+ float swell2 = sin(dot(vWorld.xz, vec2(-0.03, 0.05)) + time * 0.4) * 0.5 + 0.5;
+ col *= 0.94 + 0.05 * swell + 0.04 * swell2;
+
+ // Caustic shimmer where the bottom is close.
+ float n1 = noise(vWorld.xz * 0.8 + vec2(time * 0.35, -time * 0.22));
+ float n2 = noise(vWorld.xz * 1.15 - vec2(time * 0.28, time * 0.31));
+ float caustic = smoothstep(0.66, 0.92, n1 * 0.5 + n2 * 0.5) * (1.0 - smoothstep(2.0, 12.0, dist));
+ col = mix(col, ripple, caustic * 0.32);
+
+ // Breakers: crests rolling in toward the coast, wavelength ~9 m, bent by noise.
+ float wobble = noise(vWorld.xz * 0.12 + vec2(3.7, 1.3)) * 2.5;
+ float crest = sin(dist * 0.7 - time * 1.35 + wobble);
+ float crestMask = (1.0 - smoothstep(3.0, 16.0, dist)) * smoothstep(0.6, 3.0, dist);
+ float lace = noise(vWorld.xz * 0.9 + vec2(-time * 0.6, time * 0.45));
+ float waves = smoothstep(0.84, 0.97, crest) * crestMask * smoothstep(0.25, 0.75, lace);
+
+ // The foam line hugging the coast, breathing with the waves.
+ float breathe = 0.35 * sin(time * 1.35 + wobble);
+ float band = 1.0 - smoothstep(1.0 + breathe, 2.8 + breathe, dist);
+ float foamAmt = max(band * (0.7 + 0.3 * lace), waves * 0.9);
+ col = mix(col, foam, foamAmt);
+
+ // Sparkle on the open water.
+ float g1 = sin(vWorld.x * 0.42 + vWorld.z * 0.18 + time * 0.9);
+ float g2 = sin(vWorld.z * 0.37 - vWorld.x * 0.21 - time * 0.7);
+ float patch = smoothstep(0.42, 0.72, noise(vWorld.xz * 0.06 + vec2(time * 0.05, -time * 0.03)));
+ float glint = smoothstep(0.9, 1.0, g1 * g2) * smoothstep(4.0, 12.0, dist) * patch;
+ col = mix(col, ripple, glint * 0.45);
+
gl_FragColor = vec4(col, 1.0);
#include <colorspace_fragment>
}
@@ -145,8 +195,11 @@ export function Water({ paused }: { paused: boolean }) {
shoreTex: { value: shore },
time: { value: 0 },
halfSize: { value: ISLAND_HALF_M },
+ reachM: { value: SHORE_REACH_M },
+ abyss: { value: new Color(WATER.abyss) },
deep: { value: new Color(WATER.deep) },
surface: { value: new Color(WATER.surface) },
+ shallow: { value: new Color(WATER.shallow) },
ripple: { value: new Color(WATER.ripple) },
foam: { value: new Color(WATER.foam) },
},
diff --git a/jarvis/ui/web/frontend/src/components/society/world/Trees.tsx b/jarvis/ui/web/frontend/src/components/society/world/Trees.tsx
index c334a9d3e0..670065352f 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/Trees.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/Trees.tsx
@@ -1,27 +1,30 @@
/**
- * Every tree on the island in three draw calls: instanced trunks, instanced
- * lower canopies, instanced upper canopies. Size and shade come from the
- * layout's deterministic spots, so the forest is the same in every window.
+ * Everything that grows or lies on the island, in a handful of draw calls:
+ * round trees (instanced trunks + two canopy layers), pines (trunk + a merged
+ * two-cone crown), palms (a leaning trunk + a merged frond crown) and the
+ * boulders. Kind, size and shade come from the layout's deterministic spots,
+ * so the landscape is the same in every window.
*/
import { useMemo } from "react";
import { Color, InstancedMesh, Object3D } from "three";
-import { buildIsland } from "./islandLayout";
+import { buildIsland, type Boulder, type TreeSpot } from "./islandLayout";
import { NATURE } from "./worldPalette";
import { useKit } from "./WorldKit";
-export function Trees() {
+type Setup = (mesh: InstancedMesh | null) => void;
+
+function RoundTrees({ spots }: { spots: TreeSpot[] }) {
const { g, m } = useKit();
- const { trees } = buildIsland().content;
const dummy = useMemo(() => new Object3D(), []);
const colors = useMemo(
() => ({ a: new Color(NATURE.canopyA), b: new Color(NATURE.canopyB), light: new Color(NATURE.canopyLight) }),
[],
);
- const trunks = (mesh: InstancedMesh | null) => {
+ const trunks: Setup = (mesh) => {
if (!mesh) return;
- trees.forEach((t, i) => {
+ spots.forEach((t, i) => {
const h = 1.1 + t.size * 0.9;
dummy.position.set(t.x, t.y + h / 2, t.z);
dummy.rotation.set(0, 0, 0);
@@ -34,7 +37,7 @@ export function Trees() {
const canopies = (mesh: InstancedMesh | null, upper: boolean) => {
if (!mesh) return;
- trees.forEach((t, i) => {
+ spots.forEach((t, i) => {
const h = 1.1 + t.size * 0.9;
const r = upper ? 1.6 + t.size * 1.2 : 2.4 + t.size * 1.8;
const dy = upper ? h + r * 0.55 + 0.9 : h + r * 0.35;
@@ -50,11 +53,165 @@ export function Trees() {
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
};
+ if (spots.length === 0) return null;
+ return (
+ <group>
+ <instancedMesh ref={trunks} args={[g.cylinder, m.lit(NATURE.trunk), spots.length]} />
+ <instancedMesh ref={(mesh) => canopies(mesh, false)} args={[g.blob, m.lit("#ffffff"), spots.length]} />
+ <instancedMesh ref={(mesh) => canopies(mesh, true)} args={[g.blob, m.lit("#ffffff"), spots.length]} />
+ </group>
+ );
+}
+
+function Pines({ spots }: { spots: TreeSpot[] }) {
+ const { g, m } = useKit();
+ const dummy = useMemo(() => new Object3D(), []);
+ const colors = useMemo(
+ () => ({ a: new Color(NATURE.pineA), b: new Color(NATURE.pineB), light: new Color(NATURE.pineLight) }),
+ [],
+ );
+
+ const trunks: Setup = (mesh) => {
+ if (!mesh) return;
+ spots.forEach((t, i) => {
+ const h = 1.0 + t.size * 0.8;
+ dummy.position.set(t.x, t.y + h / 2, t.z);
+ dummy.rotation.set(0, 0, 0);
+ dummy.scale.set(0.34, h, 0.34);
+ dummy.updateMatrix();
+ mesh.setMatrixAt(i, dummy.matrix);
+ });
+ mesh.instanceMatrix.needsUpdate = true;
+ };
+
+ const crowns: Setup = (mesh) => {
+ if (!mesh) return;
+ spots.forEach((t, i) => {
+ const h = 1.0 + t.size * 0.8;
+ const s = 4.6 + t.size * 3.2; // crown height in metres
+ const r = 2.0 + t.size * 1.4;
+ dummy.position.set(t.x, t.y + h - 0.3, t.z);
+ dummy.rotation.set(0, t.shade * Math.PI * 2, 0);
+ dummy.scale.set(r * 2, s, r * 2);
+ dummy.updateMatrix();
+ mesh.setMatrixAt(i, dummy.matrix);
+ mesh.setColorAt(i, t.shade < 0.33 ? colors.a : t.shade < 0.66 ? colors.b : colors.light);
+ });
+ mesh.instanceMatrix.needsUpdate = true;
+ if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
+ };
+
+ if (spots.length === 0) return null;
+ return (
+ <group>
+ <instancedMesh ref={trunks} args={[g.cylinder, m.lit(NATURE.trunk), spots.length]} />
+ <instancedMesh ref={crowns} args={[g.pine, m.lit("#ffffff"), spots.length]} />
+ </group>
+ );
+}
+
+function Palms({ spots }: { spots: TreeSpot[] }) {
+ const { g, m } = useKit();
+ const dummy = useMemo(() => new Object3D(), []);
+ const colors = useMemo(() => ({ a: new Color(NATURE.palmLeaf), b: new Color(NATURE.palmLeafLight) }), []);
+
+ /** Where the trunk top ends up: the trunk leans by up to ~12°. */
+ const top = (t: TreeSpot): { x: number; y: number; z: number; lean: number; dir: number } => {
+ const h = 4.2 + t.size * 2.4;
+ const lean = 0.08 + t.shade * 0.14;
+ const dir = t.shade * Math.PI * 2;
+ return {
+ x: t.x + Math.sin(lean) * h * Math.cos(dir),
+ y: t.y + Math.cos(lean) * h,
+ z: t.z + Math.sin(lean) * h * Math.sin(dir),
+ lean,
+ dir,
+ };
+ };
+
+ const trunks: Setup = (mesh) => {
+ if (!mesh) return;
+ spots.forEach((t, i) => {
+ const h = 4.2 + t.size * 2.4;
+ const { lean, dir } = top(t);
+ dummy.position.set(t.x, t.y, t.z);
+ // Tilt about the axis perpendicular to the lean direction, then stand it up.
+ dummy.rotation.set(0, 0, 0);
+ dummy.rotateY(-dir);
+ dummy.rotateZ(-lean);
+ dummy.scale.set(0.34, h, 0.34);
+ dummy.translateY(h / 2); // the unit cylinder is centred: lift it onto its foot
+ dummy.updateMatrix();
+ mesh.setMatrixAt(i, dummy.matrix);
+ });
+ mesh.instanceMatrix.needsUpdate = true;
+ };
+
+ const crowns: Setup = (mesh) => {
+ if (!mesh) return;
+ spots.forEach((t, i) => {
+ const { x, y, z } = top(t);
+ const r = 2.6 + t.size * 1.4;
+ dummy.position.set(x, y, z);
+ dummy.rotation.set(0, t.shade * 7, 0);
+ dummy.scale.set(r, r * 0.9, r);
+ dummy.updateMatrix();
+ mesh.setMatrixAt(i, dummy.matrix);
+ mesh.setColorAt(i, t.shade > 0.5 ? colors.b : colors.a);
+ });
+ mesh.instanceMatrix.needsUpdate = true;
+ if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
+ };
+
+ if (spots.length === 0) return null;
+ return (
+ <group>
+ <instancedMesh ref={trunks} args={[g.cylinder, m.lit(NATURE.palmTrunk), spots.length]} />
+ <instancedMesh ref={crowns} args={[g.palmCrown, m.lit("#ffffff"), spots.length]} />
+ </group>
+ );
+}
+
+function Boulders({ rocks }: { rocks: Boulder[] }) {
+ const { g, m } = useKit();
+ const dummy = useMemo(() => new Object3D(), []);
+ const colors = useMemo(() => ({ a: new Color(NATURE.boulderA), b: new Color(NATURE.boulderB) }), []);
+
+ const setup: Setup = (mesh) => {
+ if (!mesh) return;
+ rocks.forEach((r, i) => {
+ const s = 0.9 + r.size * 2.6;
+ dummy.position.set(r.x, r.y + s * 0.28, r.z);
+ dummy.rotation.set(r.seed * 0.6, r.seed * Math.PI * 2, r.size * 0.5);
+ dummy.scale.set(s, s * 0.7, s * (0.8 + r.seed * 0.4));
+ dummy.updateMatrix();
+ mesh.setMatrixAt(i, dummy.matrix);
+ mesh.setColorAt(i, r.seed > 0.5 ? colors.a : colors.b);
+ });
+ mesh.instanceMatrix.needsUpdate = true;
+ if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
+ };
+
+ if (rocks.length === 0) return null;
+ return <instancedMesh ref={setup} args={[g.blob, m.lit("#ffffff"), rocks.length]} />;
+}
+
+export function Trees() {
+ const { trees, boulders } = buildIsland().content;
+ const byKind = useMemo(
+ () => ({
+ round: trees.filter((t) => t.kind === "round"),
+ pine: trees.filter((t) => t.kind === "pine"),
+ palm: trees.filter((t) => t.kind === "palm"),
+ }),
+ [trees],
+ );
return (
<group>
- <instancedMesh ref={trunks} args={[g.cylinder, m.lit(NATURE.trunk), trees.length]} />
- <instancedMesh ref={(mesh) => canopies(mesh, false)} args={[g.blob, m.lit("#ffffff"), trees.length]} />
- <instancedMesh ref={(mesh) => canopies(mesh, true)} args={[g.blob, m.lit("#ffffff"), trees.length]} />
+ <RoundTrees spots={byKind.round} />
+ <Pines spots={byKind.pine} />
+ <Palms spots={byKind.palm} />
+ <Boulders rocks={boulders} />
</group>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/society/world/Village.tsx b/jarvis/ui/web/frontend/src/components/society/world/Village.tsx
index 34840fc15f..1a5ab7ab37 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/Village.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/Village.tsx
@@ -1,7 +1,7 @@
/**
- * The market district: twelve solarpunk houses in a ring around the open
- * square, the lead agent's hub at its head, the Quest Board monument with the
- * long table in the middle, the hedge ring with its four gates, and the lamps.
+ * The market district: the solarpunk houses in a ring around the open square,
+ * the lead agent's hub on its podium at the head, the Quest Board monument with
+ * the long table in the middle, the hedge ring with its four gates, and the lamps.
*
* Everything is primitives from `worldMaterials.ts` — no asset files. The
* building language (docs/agent-society/world-art-direction.md §4): white
@@ -11,7 +11,7 @@ import { useMemo, useRef } from "react";
import { useFrame } from "@react-three/fiber";
import { Color, InstancedMesh, Mesh, Object3D } from "three";
-import { buildIsland, groundY, type HousePlot, type Post } from "./islandLayout";
+import { LEVEL_Y, PLATEAU_LEVEL, buildIsland, groundY, type HousePlot, type Post } from "./islandLayout";
import { QuestMonument } from "./QuestMonument";
import { Block, useKit, type Kit } from "./WorldKit";
import { PAL } from "./worldMaterials";
@@ -73,37 +73,110 @@ function House({ kit, plot }: { kit: Kit; plot: HousePlot }) {
);
}
-/** The lead agent's hub — the largest house, at the head of the square, with a beacon. */
+/**
+ * The lead agent's hub — the landmark at the head of the square, on its own
+ * podium one step above the village: a wide hall with a glass band and garden
+ * roofs, a set-back upper floor, a glass atrium tower under the dome, the
+ * beacon spire, two solar-roofed wings, a colonnade over the entrance, the
+ * grand stair down to the square and the reflecting pool at its foot.
+ * Local +z is the front (south, toward the square).
+ */
function Hub({ kit, paused }: { kit: Kit; paused: boolean }) {
const { map, content } = buildIsland();
const [tx, tz] = content.places.hub.tile;
const x = (tx + 0.5 - map.size / 2) * 2;
const z = (tz + 0.5 - map.size / 2) * 2;
const y = groundY(map, x, z);
+ const plazaDrop = LEVEL_Y[PLATEAU_LEVEL] - y; // negative: the square lies below the podium
const beacon = useRef<Mesh>(null);
+ const halo = useRef<Mesh>(null);
useFrame(({ clock }) => {
- if (!beacon.current || paused) return;
+ if (paused) return;
const t = clock.getElapsedTime();
- const s = 1 + Math.sin(t * 2.2) * 0.12;
- beacon.current.scale.setScalar(s * 1.3);
+ if (beacon.current) beacon.current.scale.setScalar((1 + Math.sin(t * 2.2) * 0.12) * 1.6);
+ if (halo.current) {
+ halo.current.rotation.z = t * 0.6;
+ const s = 1 + Math.sin(t * 2.2 + 1.2) * 0.06;
+ halo.current.scale.set(2.6 * s, 2.6 * s, 2.6);
+ }
});
+ const towerZ = -0.5;
return (
<group position={[x, y, z]}>
- <Block kit={kit} at={[0, 0.2, 0]} size={[15, 0.4, 11]} color={PAL.trim} />
- <Block kit={kit} at={[0, 2.4, 0]} size={[14, 4.4, 10]} color={PAL.wall} />
- {/* glass band all around */}
- <Block kit={kit} at={[0, 2.6, 0]} size={[14.1, 1.2, 10.1]} color={PAL.hubGlass} glow />
- {/* accent trim in the lead's colour */}
- <Block kit={kit} at={[0, 4.7, 0]} size={[14.6, 0.3, 10.6]} color={PAL.hubAccent} />
- {/* entrance: wide door, two steps, facing the square (south, +z) */}
- <Block kit={kit} at={[0, 1.4, 5.1]} size={[3.2, 2.8, 0.2]} color={PAL.door} />
- <Block kit={kit} at={[0, 0.5, 6.2]} size={[5, 0.2, 1.6]} color={PAL.trim} />
- <Block kit={kit} at={[0, 0.3, 7.4]} size={[6, 0.2, 1.4]} color={PAL.trim} />
- {/* dome */}
- <mesh geometry={kit.g.dome} material={kit.m.lit(PAL.hubGlass)} position={[0, 4.85, 0]} scale={[9, 7, 9]} />
- {/* beacon mast and light */}
- <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.metal)} position={[0, 9.2, 0]} scale={[0.35, 2.4, 0.35]} />
- <mesh ref={beacon} geometry={kit.g.sphere} material={kit.m.glow(PAL.beacon)} position={[0, 10.9, 0]} scale={1.3} />
+ {/* plinth and the main hall */}
+ <Block kit={kit} at={[0, 0.15, 0]} size={[25, 0.3, 13]} color={PAL.trim} />
+ <Block kit={kit} at={[0, 2.6, 0]} size={[24, 5.2, 12]} color={PAL.wall} />
+ <Block kit={kit} at={[0, 2.7, 0]} size={[24.1, 1.3, 12.1]} color={PAL.hubGlass} glow />
+ <Block kit={kit} at={[0, 5.35, 0]} size={[24.6, 0.3, 12.6]} color={PAL.hubAccent} />
+ {/* garden roofs on both ends of the hall */}
+ {[-8.6, 8.6].map((ox) => (
+ <group key={ox} position={[ox, 5.5, 0]}>
+ <Block kit={kit} at={[0, 0.2, 0]} size={[6.2, 0.4, 11.4]} color={PAL.trim} />
+ <Block kit={kit} at={[0, 0.5, 0]} size={[5.6, 0.25, 10.8]} color={PAL.gardenRoof} />
+ <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.gardenRoofBush)} position={[0.6, 1.0, -2.4]} scale={1.3} />
+ <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.gardenRoofBush)} position={[-0.9, 0.95, 2.2]} scale={1.1} />
+ <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.flower)} position={[1.1, 0.85, 1.4]} scale={0.6} />
+ </group>
+ ))}
+ {/* the upper floor, set back */}
+ <Block kit={kit} at={[0, 7.4, towerZ]} size={[15, 4.2, 9]} color={PAL.wall} />
+ <Block kit={kit} at={[0, 7.6, towerZ]} size={[15.1, 1.2, 9.1]} color={PAL.hubGlass} glow />
+ <Block kit={kit} at={[0, 9.55, towerZ]} size={[15.6, 0.3, 9.6]} color={PAL.hubAccent} />
+ {/* the glass atrium under the dome */}
+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.trim)} position={[0, 9.85, towerZ]} scale={[8.6, 0.3, 8.6]} />
+ <mesh geometry={kit.g.cylinder} material={kit.m.glow(PAL.hubGlass)} position={[0, 12.3, towerZ]} scale={[8, 4.8, 8]} />
+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.hubAccent)} position={[0, 14.75, towerZ]} scale={[8.6, 0.3, 8.6]} />
+ <mesh geometry={kit.g.dome} material={kit.m.lit(PAL.hubGlass)} position={[0, 14.9, towerZ]} scale={[9, 6.6, 9]} />
+ {/* the spire: mast, halo ring and the pulsing beacon */}
+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.metal)} position={[0, 20.6, towerZ]} scale={[0.45, 5.4, 0.45]} />
+ <mesh ref={halo} geometry={kit.g.ring} material={kit.m.glow(PAL.beacon)} position={[0, 22.6, towerZ]} rotation={[Math.PI / 2, 0, 0]} scale={[2.6, 2.6, 2.6]} />
+ <mesh ref={beacon} geometry={kit.g.sphere} material={kit.m.glow(PAL.beaconCore)} position={[0, 23.8, towerZ]} scale={1.6} />
+ {/* two wings with solar barrel roofs */}
+ {[-15.5, 15.5].map((ox) => (
+ <group key={ox} position={[ox, 0, 1]}>
+ <Block kit={kit} at={[0, 0.15, 0]} size={[7.6, 0.3, 8.6]} color={PAL.trim} />
+ <Block kit={kit} at={[0, 1.9, 0]} size={[7, 3.8, 8]} color={PAL.wallShade} />
+ <Block kit={kit} at={[0, 1.9, 4.05]} size={[4.4, 1.2, 0.12]} color={PAL.glass} glow />
+ <mesh geometry={kit.g.halfCylinder} material={kit.m.lit(PAL.solar)} position={[0, 3.8, 0]} rotation={[0, 0, Math.PI / 2]} scale={[3.2, 7.4, 8.6]} />
+ <Block kit={kit} at={[0, 5.42, 0]} size={[7.5, 0.1, 0.5]} color={PAL.solarLine} />
+ </group>
+ ))}
+ {/* the colonnade over the entrance */}
+ {[-10, -6, -2, 2, 6, 10].map((px) => (
+ <mesh key={px} geometry={kit.g.cylinder} material={kit.m.lit(PAL.wall)} position={[px, 2.6, 7.4]} scale={[0.7, 5.2, 0.7]} />
+ ))}
+ <Block kit={kit} at={[0, 5.4, 7.5]} size={[23, 0.3, 3.2]} color={PAL.trim} />
+ <Block kit={kit} at={[0, 5.62, 7.5]} size={[22, 0.12, 2.8]} color={PAL.glass} glow />
+ {/* entrance: the wide door with glass to both sides */}
+ <Block kit={kit} at={[0, 1.8, 6.1]} size={[4.2, 3.6, 0.2]} color={PAL.door} />
+ <Block kit={kit} at={[-4.6, 1.9, 6.08]} size={[3.2, 2.6, 0.14]} color={PAL.glass} glow />
+ <Block kit={kit} at={[4.6, 1.9, 6.08]} size={[3.2, 2.6, 0.14]} color={PAL.glass} glow />
+ {/* planters on the podium's front corners */}
+ {[-13, 13].map((px) => (
+ <group key={px} position={[px, 0, 7.5]}>
+ <Block kit={kit} at={[0, 0.35, 0]} size={[2.4, 0.7, 2.4]} color={PAL.trim} />
+ <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.gardenRoofBush)} position={[0, 1.2, 0]} scale={1.8} />
+ </group>
+ ))}
+ {/* the grand stair down to the square: three broad steps */}
+ {[0, 1, 2].map((k) => (
+ <Block
+ key={k}
+ kit={kit}
+ at={[0, plazaDrop * ((k + 1) / 3) + 0.17, 9.6 + k * 1.0]}
+ size={[11, 0.34, 1.0]}
+ color={PAL.trim}
+ />
+ ))}
+ {/* the reflecting pool and two flag masts at the foot of the stair */}
+ <Block kit={kit} at={[0, plazaDrop + 0.12, 13.2]} size={[8.4, 0.24, 2.2]} color={PAL.trim} />
+ <Block kit={kit} at={[0, plazaDrop + 0.2, 13.2]} size={[8, 0.12, 1.8]} color={PAL.pool} glow />
+ {[-6.2, 6.2].map((px) => (
+ <group key={px} position={[px, plazaDrop, 13.2]}>
+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.metal)} position={[0, 3.2, 0]} scale={[0.2, 6.4, 0.2]} />
+ <Block kit={kit} at={[0.8, 5.8, 0]} size={[1.5, 0.9, 0.08]} color={PAL.hubAccent} />
+ </group>
+ ))}
</group>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/society/world/cameraStore.ts b/jarvis/ui/web/frontend/src/components/society/world/cameraStore.ts
index 6f8c95463c..0f64655646 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/cameraStore.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/cameraStore.ts
@@ -6,7 +6,7 @@
*/
import { create } from "zustand";
-import { DEFAULT_ZOOM, clampTarget, stepZoom, type ZoomLevel } from "./worldCamera";
+import { DEFAULT_ZOOM, MAX_ZOOM, clampTarget, stepZoom, type ZoomLevel } from "./worldCamera";
export interface CameraState {
/** Ground point the camera looks at, world metres. */
@@ -30,7 +30,7 @@ export interface CameraState {
/**
* `?world=x,z[,zoom]` deep-links a spot on the island (metres from the centre,
- * zoom step 0–2) — for "show me the harbor" from voice or a shared link, and
+ * zoom step 0–4) — for "show me the harbor" from voice or a shared link, and
* for screenshots. Anything malformed falls back to the square.
*/
export function focusFromSearch(search: string): { target: [number, number]; zoom: ZoomLevel } | null {
@@ -39,7 +39,10 @@ export function focusFromSearch(search: string): { target: [number, number]; zoo
const parts = raw.split(",").map((v) => Number(v));
if (parts.length < 2 || !parts.slice(0, 2).every(Number.isFinite)) return null;
const target = clampTarget(parts[0], parts[1]);
- const z = parts.length > 2 && Number.isInteger(parts[2]) && parts[2] >= 0 && parts[2] <= 2 ? (parts[2] as ZoomLevel) : DEFAULT_ZOOM;
+ const z =
+ parts.length > 2 && Number.isInteger(parts[2]) && parts[2] >= 0 && parts[2] <= MAX_ZOOM
+ ? (parts[2] as ZoomLevel)
+ : DEFAULT_ZOOM;
return { target, zoom: z };
}
diff --git a/jarvis/ui/web/frontend/src/components/society/world/islandLayout.test.ts b/jarvis/ui/web/frontend/src/components/society/world/islandLayout.test.ts
index 805c21dff7..503e34eab5 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/islandLayout.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/islandLayout.test.ts
@@ -8,12 +8,18 @@ import {
HOUSE_RING_TILES,
ISLAND_FIELDS,
ISLAND_TILES,
+ ISLETS,
LEVEL_Y,
MARKET_FIELDS,
MARKET_HALF_TILES,
PLATEAU_LEVEL,
+ PLATEAU_RADIUS_TILES,
PLAZA_RADIUS_TILES,
+ PODIUM_LEVEL,
+ REGIONS,
RING_KIT_SLOTS,
+ SNOW_LEVEL,
+ SPOKES,
TileKind,
buildIsland,
findPath,
@@ -28,19 +34,24 @@ import {
type Island,
} from "./islandLayout";
+/** Tile under a normalised island coordinate. */
+function tileAt(nx: number, nz: number): [number, number] {
+ return [Math.floor(CENTER_TILE + nx * CENTER_TILE), Math.floor(CENTER_TILE + nz * CENTER_TILE)];
+}
+
describe("islandLayout", () => {
let island: Island;
beforeAll(() => {
island = buildIsland();
});
- it("is a 10 × 10 field grid with a centred 4 × 4 market", () => {
- expect(ISLAND_FIELDS).toBe(10);
+ it("is a 16 × 16 field grid with a centred 4 × 4 market", () => {
+ expect(ISLAND_FIELDS).toBe(16);
expect(MARKET_FIELDS).toBe(4);
expect(ISLAND_TILES).toBe(ISLAND_FIELDS * FIELD_TILES);
- // The market sits on fields 3..6 of 0..9 — symmetric around the centre.
- expect((ISLAND_FIELDS - MARKET_FIELDS) / 2).toBe(3);
- expect(CENTER_TILE - MARKET_HALF_TILES).toBe(3 * FIELD_TILES);
+ // The market sits on fields 6..9 of 0..15 — symmetric around the centre.
+ expect((ISLAND_FIELDS - MARKET_FIELDS) / 2).toBe(6);
+ expect(CENTER_TILE - MARKET_HALF_TILES).toBe(6 * FIELD_TILES);
});
it("maps tiles to world metres and back around the island centre", () => {
@@ -65,23 +76,68 @@ describe("islandLayout", () => {
expect(corner).toBe(TileKind.water);
// The bay: water south of the harbor, land north of it.
expect(map.kind[tileIndex(map, CENTER_TILE, ISLAND_TILES - 2)]).toBe(TileKind.water);
+ expect(map.kind[tileIndex(map, ...tileAt(REGIONS.bay.x, REGIONS.bay.z))]).toBe(TileKind.water);
expect(map.kind[tileIndex(map, CENTER_TILE, CENTER_TILE + 40)]).not.toBe(TileKind.water);
- // Most of the grid is land (an island, not a rock in the sea).
+ // Roughly half the grid is land (an island with sea around it, not a rock, not a continent).
let land = 0;
for (let i = 0; i < map.kind.length; i++) if (map.kind[i] !== TileKind.water) land++;
expect(land / map.kind.length).toBeGreaterThan(0.45);
- expect(land / map.kind.length).toBeLessThan(0.85);
+ expect(land / map.kind.length).toBeLessThan(0.7);
+ });
+
+ it("carries every biome, from the beach to the snow cap", () => {
+ const { map } = island;
+ const counts = new Map<number, number>();
+ let peak = 0;
+ for (let i = 0; i < map.kind.length; i++) {
+ counts.set(map.kind[i], (counts.get(map.kind[i]) ?? 0) + 1);
+ if (map.level[i] > peak) peak = map.level[i];
+ }
+ for (const kind of Object.values(TileKind)) {
+ expect(counts.get(kind) ?? 0, `kind ${kind}`).toBeGreaterThan(0);
+ }
+ expect(peak).toBe(LEVEL_Y.length - 1);
+ // Snow only on the mountain top, never below the snow line.
+ for (let i = 0; i < map.kind.length; i++) {
+ if (map.kind[i] === TileKind.snow) expect(map.level[i]).toBeGreaterThanOrEqual(SNOW_LEVEL);
+ }
+ // The mountain is the north-western backdrop.
+ const [mx, mz] = tileAt(REGIONS.mountain.x, REGIONS.mountain.z);
+ expect(map.level[tileIndex(map, mx, mz)]).toBeGreaterThanOrEqual(SNOW_LEVEL);
});
- it("keeps the whole market district flat on the plateau level", () => {
+ it("encloses a lagoon in the cove and sets rock islets off the coast", () => {
const { map } = island;
- for (let tz = CENTER_TILE - MARKET_HALF_TILES; tz < CENTER_TILE + MARKET_HALF_TILES; tz++) {
- for (let tx = CENTER_TILE - MARKET_HALF_TILES; tx < CENTER_TILE + MARKET_HALF_TILES; tx++) {
+ const [lx, lz] = tileAt(REGIONS.lagoon.x, REGIONS.lagoon.z);
+ expect(map.kind[tileIndex(map, lx, lz)]).toBe(TileKind.water);
+ // Its sandbar: beach to the west and north of the water.
+ const rim = Math.ceil(REGIONS.lagoon.r * CENTER_TILE) + 2;
+ expect(map.kind[tileIndex(map, lx - rim, lz)]).toBe(TileKind.sand);
+ expect(map.kind[tileIndex(map, lx, lz - rim)]).toBe(TileKind.sand);
+ for (const islet of ISLETS) {
+ const [ix, iz] = tileAt(islet.x, islet.z);
+ expect(map.kind[tileIndex(map, ix, iz)], `islet ${islet.x},${islet.z}`).not.toBe(TileKind.water);
+ const off = Math.ceil(islet.r * CENTER_TILE) + 3;
+ expect(map.kind[tileIndex(map, ix + off, iz)]).toBe(TileKind.water);
+ }
+ });
+
+ it("keeps the village plateau flat, with the hub one step up on its podium", () => {
+ const { map, content } = island;
+ const [hx, hz] = content.places.hub.tile;
+ const r = PLATEAU_RADIUS_TILES - 4;
+ for (let tz = CENTER_TILE - r; tz < CENTER_TILE + r; tz++) {
+ for (let tx = CENTER_TILE - r; tx < CENTER_TILE + r; tx++) {
+ if (Math.hypot(tx + 0.5 - CENTER_TILE, tz + 0.5 - CENTER_TILE) >= r) continue;
const i = tileIndex(map, tx, tz);
expect(map.kind[i], `tile ${tx},${tz}`).not.toBe(TileKind.water);
- expect(map.level[i], `tile ${tx},${tz}`).toBe(PLATEAU_LEVEL);
+ // The podium rect; its front row is overpainted by the square's rim beds.
+ const onPodium = Math.abs(tx - hx) <= 9 && Math.abs(tz - hz) <= 5;
+ if (onPodium) expect([PLATEAU_LEVEL, PODIUM_LEVEL], `tile ${tx},${tz}`).toContain(map.level[i]);
+ else expect(map.level[i], `tile ${tx},${tz}`).toBe(PLATEAU_LEVEL);
}
}
+ expect(groundY(map, ...tileToWorld(hx, hz))).toBe(LEVEL_Y[PODIUM_LEVEL]);
});
it("opens a paved square in the middle with a ring of houses around it", () => {
@@ -98,6 +154,9 @@ describe("islandLayout", () => {
const toCentre = [-h.x, -h.z];
const dot = fx * toCentre[0] + fz * toCentre[1];
expect(dot).toBeGreaterThan(0);
+ // No house stands on the hub's podium.
+ const [tx, tz] = worldToTile(h.x, h.z);
+ expect(map.level[tileIndex(map, tx, tz)]).toBe(PLATEAU_LEVEL);
}
});
@@ -116,11 +175,20 @@ describe("islandLayout", () => {
// No two hubs share a slot.
const slots = Object.values(RING_KIT_SLOTS).flat();
expect(new Set(slots).size).toBe(slots.length);
+ // No ring hub stands on the hub's podium.
+ for (const pose of Object.values(content.kitPoses)) {
+ const [tx, tz] = worldToTile(pose.x, pose.z);
+ expect(map.level[tileIndex(map, tx, tz)]).toBe(PLATEAU_LEVEL);
+ }
});
- it("leaves the four gates open in the hedge ring", () => {
+ it("leaves the four gates open in the hedge ring, the north one as wide as the hub", () => {
const { content } = island;
const r = HEDGE_RING_TILES * 2;
+ // The podium (±18 m) sits astride the ring at the north: no hedge post on it.
+ for (const h of content.hedges) {
+ if (h.z < -r + 12 && Math.abs(h.x) < 18) throw new Error(`hedge on the podium at ${h.x},${h.z}`);
+ }
for (const [gx, gz] of [
[0, -r],
[0, r],
@@ -143,6 +211,21 @@ describe("islandLayout", () => {
expect(groundY(map, 10_000, 10_000)).toBe(LEVEL_Y[0]);
});
+ it("grades every spoke so it never climbs more than one step per tile", () => {
+ const { map } = island;
+ for (const spoke of SPOKES) {
+ let prev = PLATEAU_LEVEL;
+ for (let s = PLAZA_RADIUS_TILES - 1; s <= spoke.toTiles; s++) {
+ const tx = CENTER_TILE + spoke.dir[0] * s;
+ const tz = CENTER_TILE + spoke.dir[1] * s;
+ const i = tileIndex(map, tx, tz);
+ if (map.kind[i] === TileKind.water) continue;
+ expect(Math.abs(map.level[i] - prev), `spoke ${spoke.dir} at ${s}`).toBeLessThanOrEqual(1);
+ prev = map.level[i];
+ }
+ }
+ });
+
it("makes every place reachable on foot from the square", () => {
const { map, content } = island;
const start = randomPlazaTile(map, () => 0.5);
@@ -169,16 +252,33 @@ describe("islandLayout", () => {
expect(isWalkable(map, hx, hz)).toBe(false);
});
- it("plants trees on grass only, never on roads or the square", () => {
+ it("plants each biome's trees on its own ground, never on roads or the square", () => {
const { map, content } = island;
- expect(content.trees.length).toBeGreaterThan(150);
+ expect(content.trees.length).toBeGreaterThan(800);
+ const kinds = { round: 0, pine: 0, palm: 0 };
for (const t of content.trees) {
+ kinds[t.kind]++;
const [tx, tz] = worldToTile(t.x, t.z);
const k = map.kind[tileIndex(map, tx, tz)];
- expect([TileKind.grass, TileKind.meadow]).toContain(k);
+ expect([TileKind.grass, TileKind.meadow, TileKind.forest, TileKind.alpine, TileKind.sand]).toContain(k);
+ if (k === TileKind.sand) expect(t.kind).toBe("palm");
+ if (t.kind === "palm") expect(k).toBe(TileKind.sand);
expect(Math.hypot(tx + 0.5 - CENTER_TILE, tz + 0.5 - CENTER_TILE)).toBeGreaterThan(
PLAZA_RADIUS_TILES,
);
}
+ expect(kinds.round).toBeGreaterThan(200);
+ expect(kinds.pine).toBeGreaterThan(100);
+ expect(kinds.palm).toBeGreaterThan(20);
+ });
+
+ it("scatters boulders over the high ground, never on pavement", () => {
+ const { map, content } = island;
+ expect(content.boulders.length).toBeGreaterThan(100);
+ for (const b of content.boulders) {
+ const [tx, tz] = worldToTile(b.x, b.z);
+ const k = map.kind[tileIndex(map, tx, tz)];
+ expect([TileKind.path, TileKind.plaza, TileKind.dock, TileKind.water]).not.toContain(k);
+ }
});
});
diff --git a/jarvis/ui/web/frontend/src/components/society/world/islandLayout.ts b/jarvis/ui/web/frontend/src/components/society/world/islandLayout.ts
index 6902e27540..ef5cb8b394 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/islandLayout.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/islandLayout.ts
@@ -6,24 +6,35 @@
* Nothing in this file touches three.js or React; `islandLayout.test.ts` pins
* the geometry the way `deckRoom.test.ts` pins the mission deck.
*
- * Layout decisions (maintainer, 2026-09-01 — recorded in
+ * Layout decisions (maintainer, 2026-09-01/02 — recorded in
* docs/agent-society/world-art-direction.md):
*
- * - The island is a 10 × 10 grid of "fields". One field is what the viewer
+ * - The island is a 16 × 16 grid of "fields". One field is what the viewer
* sees at the closest zoom without scrolling. Fields are the navigation
* unit, not a visible grid.
- * - The central 4 × 4 fields are the MARKET DISTRICT: a village laid out like
- * a ring — houses around one open square, the way a classic comic village
- * stands around its meeting place — but built in a bright solarpunk
- * language. The lead agent's hub stands at the head of the square.
- * - Four quarters around the market carry the places the master plan names
- * (§4.1): the workshop (west), the archive (north), the harbor gate on the
- * southern bay, the lighthouse on the eastern cape; gardens and a solar
- * field fill the corners.
+ * - The central 4 × 4 fields are the MARKET DISTRICT: a round plateau with a
+ * village laid out like a ring — houses around one open square, the way a
+ * classic comic village stands around its meeting place — but built in a
+ * bright solarpunk language. The lead agent's hub stands on its own podium
+ * at the head of the village, behind the ring road, astride the hedge ring —
+ * the palace at the north gate — with the ring hubs (docks, forge, relay,
+ * cantina) in the house ring below it.
+ * - Around the plateau the island is a composed landscape of BIOMES at
+ * different heights, arranged for the camera (which looks toward the
+ * north-west): the mountain with its snow cap is the backdrop in the
+ * north-west, the archive tower crowns a terraced hill in the north, the
+ * alpine meadows roll over the north-east, the lighthouse stands on a
+ * rocky cape in the east, the tropical cove with its lagoon and palms fills
+ * the low south-east foreground, the harbor bay bites into the south, the
+ * orchard meadows cover the south-west and the dark forest the west.
+ * - The terrain is a continuous height field quantised into steps: every
+ * slope becomes a terrace, every steep place a cliff. Roads are GRADED —
+ * never more than one step per tile — so every place stays reachable on
+ * foot; cliffs of two or more steps are real barriers.
*
* Units: 1 world unit = 1 m (matches `lib/deckRoom.ts`). One tile is 2 m.
* World origin is the island's centre; +x is east, +z is south, so the tile
- * with index (tx, tz) has its centre at ((tx + 0.5 − 80) · 2, (tz + 0.5 − 80) · 2).
+ * with index (tx, tz) has its centre at ((tx + 0.5 − 128) · 2, (tz + 0.5 − 128) · 2).
*/
// ---------------------------------------------------------------------------
@@ -35,8 +46,8 @@ export const TILE_M = 2;
/** Tiles along one edge of a "field" — the closest zoom shows about one field. */
export const FIELD_TILES = 16;
/** Fields along one island edge. */
-export const ISLAND_FIELDS = 10;
-/** Tiles along one island edge (160). */
+export const ISLAND_FIELDS = 16;
+/** Tiles along one island edge (256). */
export const ISLAND_TILES = FIELD_TILES * ISLAND_FIELDS;
/** Half the island edge in metres — the pan clamp. */
export const ISLAND_HALF_M = (ISLAND_TILES * TILE_M) / 2;
@@ -46,6 +57,8 @@ export const MARKET_FIELDS = 4;
export const MARKET_TILES = MARKET_FIELDS * FIELD_TILES;
/** Half the market edge in tiles, from the centre. */
export const MARKET_HALF_TILES = MARKET_TILES / 2;
+/** Radius (tiles) of the round plateau the market district stands on. */
+export const PLATEAU_RADIUS_TILES = MARKET_HALF_TILES + 7;
/** The island centre in tile units — also the market's centre. */
export const CENTER_TILE = ISLAND_TILES / 2;
@@ -66,19 +79,32 @@ export const TileKind = {
path: 6,
garden: 7,
dock: 8,
+ /** Dark forest floor under the dense western woods. */
+ forest: 9,
+ /** High, sun-bleached alpine meadow. */
+ alpine: 10,
+ /** The mountain's snow cap. */
+ snow: 11,
} as const;
export type TileKind = (typeof TileKind)[keyof typeof TileKind];
/**
* Ground height per terrain level, in metres. Level 0 is the water surface;
- * the steps are small enough that a walker crossing one reads as a step, not
- * a jump, and large enough that the cliff faces show under the pixel pass.
+ * the low steps are small enough that a walker crossing one reads as a step,
+ * not a jump; the high steps belong to the mountain and the cliffs, where
+ * nobody walks and the faces should tower.
*/
-export const LEVEL_Y: readonly number[] = [0, 0.35, 1.0, 1.7, 2.6];
-/** The level every road and plot sits on — the walkable plateau. */
-export const PLATEAU_LEVEL = 2;
+export const LEVEL_Y: readonly number[] = [0, 0.35, 1.0, 1.8, 2.8, 4.0, 5.5, 7.4, 9.8, 12.6];
+/** The highest level index. */
+export const MAX_LEVEL = LEVEL_Y.length - 1;
+/** The level every road and plot of the village sits on — the walkable plateau. */
+export const PLATEAU_LEVEL = 3;
+/** The hub stands one step above the village. */
+export const PODIUM_LEVEL = PLATEAU_LEVEL + 1;
/** Height of the wooden dock above the water. */
export const DOCK_Y = 0.55;
+/** Level from which a rock tile becomes snow. */
+export const SNOW_LEVEL = 8;
export interface IslandMap {
/** Tiles along one edge. */
@@ -135,6 +161,9 @@ export interface HousePlot {
seed: number;
}
+/** What grows on a spot: the biome decides. */
+export type TreeKind = "round" | "pine" | "palm";
+
export interface TreeSpot {
x: number;
z: number;
@@ -144,6 +173,17 @@ export interface TreeSpot {
size: number;
/** 0..1 — picks between the two canopy greens. */
shade: number;
+ kind: TreeKind;
+}
+
+export interface Boulder {
+ x: number;
+ z: number;
+ y: number;
+ /** 0..1 — radius scales with it. */
+ size: number;
+ /** 0..1 — a stable per-boulder rotation and shade pick. */
+ seed: number;
}
export interface Post {
@@ -158,11 +198,13 @@ export interface IslandContent {
places: Record<PlaceId, Place>;
houses: HousePlot[];
trees: TreeSpot[];
+ /** Rocks scattered over the highland, the cliffs and the beaches. */
+ boulders: Boulder[];
/** Hedge segments forming the village ring, with gaps at the four gates. */
hedges: Post[];
/** Light posts along the ring and the spokes. */
lamps: Post[];
- /** Solar panel rows in the north-west field (centre + rotation). */
+ /** Solar panel rows on the mountain's foot terrace (centre + rotation). */
panels: Post[];
/** Greenhouses in the gardens quarter. */
greenhouses: Post[];
@@ -179,45 +221,6 @@ export interface KitPose {
rotation: number;
}
-/**
- * Ring slots (of 16) a kit building takes over instead of houses. The Plugin
- * Docks are 16 m wide, a house slot is ~15 m of arc, so the docks take two
- * neighbouring north-west slots and stand centred between them.
- */
-export const RING_KIT_SLOTS: Record<KitPlace, readonly number[]> = {
- // Hubs sit on the north and west of the ring so their fronts face the camera
- // (it looks from the south-east); houses take the slots whose backs it sees.
- plugins: [13, 14], // north-west, two slots (16 m wide)
- skills: [15], // north, beside the docks: the Skill Forge
- mcp: [1], // north-east: the Relay Tower
- cli: [11], // west: the Terminal Cantina
-};
-
-/** Footprints (tiles) of the kit buildings, for blocking the walk grid. */
-export const KIT_FOOTPRINTS: Record<KitPlace, [number, number]> = {
- plugins: [8, 5],
- skills: [7, 5],
- mcp: [5, 5],
- cli: [7, 5],
-};
-
-const KIT_PLACES = Object.keys(RING_KIT_SLOTS) as KitPlace[];
-
-function kitTile(place: KitPlace): [number, number] {
- const p = ringPose(RING_KIT_SLOTS[place]);
- return [Math.floor(p.x / TILE_M + CENTER_TILE), Math.floor(p.z / TILE_M + CENTER_TILE)];
-}
-
-/** Pose of a building centred on the given ring slots, front toward the square. */
-export function ringPose(slots: readonly number[], radiusTiles = HOUSE_RING_TILES): KitPose {
- const mean = slots.reduce((a, b) => a + b, 0) / slots.length;
- const angle = (mean / 16) * Math.PI * 2; // clockwise from north
- const r = radiusTiles * TILE_M;
- const x = Math.sin(angle) * r;
- const z = -Math.cos(angle) * r;
- return { x, z, rotation: Math.atan2(-x, -z) };
-}
-
// ---------------------------------------------------------------------------
// Deterministic noise
// ---------------------------------------------------------------------------
@@ -234,6 +237,15 @@ function lerp(a: number, b: number, t: number): number {
return a + (b - a) * t;
}
+function clamp(v: number, lo: number, hi: number): number {
+ return v < lo ? lo : v > hi ? hi : v;
+}
+
+function smoothstep(e0: number, e1: number, x: number): number {
+ const t = clamp((x - e0) / (e1 - e0), 0, 1);
+ return t * t * (3 - 2 * t);
+}
+
/** Smooth value noise, 0..1. */
export function valueNoise(x: number, z: number, seed: number): number {
const x0 = Math.floor(x);
@@ -315,24 +327,69 @@ export const HEDGE_RING_TILES = 29;
/** Half-width of a gate gap in the hedge ring, in tiles. */
export const GATE_GAP_TILES = 3;
+/**
+ * Ring slots (of 16) a kit building takes over instead of houses. The Plugin
+ * Docks are 16 m wide, a house slot is ~15 m of arc, so the docks take two
+ * neighbouring north-west slots and stand centred between them.
+ */
+export const RING_KIT_SLOTS: Record<KitPlace, readonly number[]> = {
+ // Hubs sit on the north and west of the ring so their fronts face the camera
+ // (it looks from the south-east); houses take the slots whose backs it sees.
+ plugins: [13, 14], // north-west, two slots (16 m wide)
+ skills: [15], // north, beside the docks: the Skill Forge
+ mcp: [1], // north-east: the Relay Tower
+ cli: [11], // west: the Terminal Cantina
+};
+
+/** Footprints (tiles) of the kit buildings, for blocking the walk grid. */
+export const KIT_FOOTPRINTS: Record<KitPlace, [number, number]> = {
+ plugins: [8, 5],
+ skills: [7, 5],
+ mcp: [5, 5],
+ cli: [7, 5],
+};
+
+const KIT_PLACES = Object.keys(RING_KIT_SLOTS) as KitPlace[];
+
+function kitTile(place: KitPlace): [number, number] {
+ const p = ringPose(RING_KIT_SLOTS[place]);
+ return [Math.floor(p.x / TILE_M + CENTER_TILE), Math.floor(p.z / TILE_M + CENTER_TILE)];
+}
+
+/**
+ * The hub's gate: the podium sits astride the hedge ring at the north, so the
+ * gap there is as wide as the podium (the other three gates keep `GATE_GAP_TILES`).
+ */
+export const HUB_GATE_GAP_TILES = 10;
+
+/** Pose of a building centred on the given ring slots, front toward the square. */
+export function ringPose(slots: readonly number[], radiusTiles = HOUSE_RING_TILES): KitPose {
+ const mean = slots.reduce((a, b) => a + b, 0) / slots.length;
+ const angle = (mean / 16) * Math.PI * 2; // clockwise from north
+ const r = radiusTiles * TILE_M;
+ const x = Math.sin(angle) * r;
+ const z = -Math.cos(angle) * r;
+ return { x, z, rotation: Math.atan2(-x, -z) };
+}
+
/** The four spokes leave the square toward the quarters. `dir` is (dx, dz). */
-const SPOKES: ReadonlyArray<{ dir: [number, number]; toTiles: number }> = [
- { dir: [0, -1], toTiles: 52 }, // north → archive
- { dir: [0, 1], toTiles: 52 }, // south → harbor
- { dir: [-1, 0], toTiles: 52 }, // west → workshop
- { dir: [1, 0], toTiles: 58 }, // east → lighthouse cape
+export const SPOKES: ReadonlyArray<{ dir: [number, number]; toTiles: number }> = [
+ { dir: [0, -1], toTiles: 61 }, // north → archive hill
+ { dir: [0, 1], toTiles: 62 }, // south → harbor
+ { dir: [-1, 0], toTiles: 60 }, // west → workshop clearing
+ { dir: [1, 0], toTiles: 80 }, // east → lighthouse cape
];
/** Anchor tiles of the places (tile units, absolute). */
const PLACE_TILES: Record<PlaceId, [number, number]> = {
market: [CENTER_TILE, CENTER_TILE],
- hub: [CENTER_TILE, CENTER_TILE - 20],
- archive: [CENTER_TILE, CENTER_TILE - 54],
- harbor: [CENTER_TILE, CENTER_TILE + 54],
- workshop: [CENTER_TILE - 54, CENTER_TILE],
- lighthouse: [CENTER_TILE + 62, CENTER_TILE],
- gardens: [CENTER_TILE + 30, CENTER_TILE + 34],
- solar: [CENTER_TILE - 32, CENTER_TILE - 32],
+ hub: [CENTER_TILE, CENTER_TILE - 30],
+ archive: [CENTER_TILE, CENTER_TILE - 66],
+ harbor: [CENTER_TILE, CENTER_TILE + 64],
+ workshop: [CENTER_TILE - 68, CENTER_TILE],
+ lighthouse: [CENTER_TILE + 84, CENTER_TILE],
+ gardens: [CENTER_TILE + 44, CENTER_TILE + 48],
+ solar: [CENTER_TILE - 40, CENTER_TILE - 40],
// Kit hubs stand in the house ring (RING_KIT_SLOTS); these are their ring poses' tiles.
plugins: kitTile("plugins"),
skills: kitTile("skills"),
@@ -343,13 +400,13 @@ const PLACE_TILES: Record<PlaceId, [number, number]> = {
/** Half extents (tiles) of the flat plots each place is built on. */
const PLOT_HALF: Record<PlaceId, [number, number]> = {
market: [0, 0],
- hub: [5, 4],
- archive: [6, 6],
- harbor: [7, 4],
- workshop: [8, 6],
- lighthouse: [3, 3],
+ hub: [9, 5],
+ archive: [7, 7],
+ harbor: [8, 4],
+ workshop: [9, 6],
+ lighthouse: [4, 4],
gardens: [9, 7],
- solar: [8, 6],
+ solar: [8, 7],
// Ring hubs have no flat plot of their own: they sit on the village plateau.
plugins: [0, 0],
skills: [0, 0],
@@ -357,16 +414,66 @@ const PLOT_HALF: Record<PlaceId, [number, number]> = {
cli: [0, 0],
};
+/** The terrain level each plot is flattened to — its terrace in the landscape. */
+const PLOT_LEVEL: Record<PlaceId, number> = {
+ market: PLATEAU_LEVEL,
+ hub: PODIUM_LEVEL,
+ archive: 5,
+ harbor: 2,
+ workshop: 3,
+ lighthouse: 6,
+ gardens: 2,
+ solar: 4,
+ plugins: PLATEAU_LEVEL,
+ skills: PLATEAU_LEVEL,
+ mcp: PLATEAU_LEVEL,
+ cli: PLATEAU_LEVEL,
+};
+
/** Building footprints (half extents, tiles) that block walking. */
const BUILDING_HALF: Partial<Record<PlaceId, [number, number]>> = {
- hub: [4, 3],
+ hub: [6, 3],
archive: [3, 3],
workshop: [6, 3],
lighthouse: [1, 1],
};
/** Where the dock reaches into the bay: from the harbor plot southward. */
-export const DOCK_TILES = { from: CENTER_TILE + 58, to: CENTER_TILE + 70, halfWidth: 1 } as const;
+export const DOCK_TILES = { from: CENTER_TILE + 66, to: CENTER_TILE + 80, halfWidth: 1 } as const;
+
+/**
+ * The biome regions, in normalised island coordinates (−1..1 from the centre,
+ * +x east, +z south). Each is a soft disc: `r` is where its influence ends.
+ */
+export const REGIONS = {
+ /** The backdrop: the mountain with the snow cap, north-west. */
+ mountain: { x: -0.5, z: -0.5, r: 0.42 },
+ /** The terraced hill the archive tower crowns, north. */
+ archiveHill: { x: 0, z: -0.52, r: 0.2 },
+ /** Alpine meadows, north-east. */
+ highland: { x: 0.45, z: -0.45, r: 0.38 },
+ /** The lighthouse cape, east. */
+ cape: { x: 0.72, z: 0, r: 0.25 },
+ /** The tropical cove with the lagoon, south-east. */
+ cove: { x: 0.5, z: 0.5, r: 0.34 },
+ /** The lagoon inside the cove — sea water enclosed by a sandbar. */
+ lagoon: { x: 0.5, z: 0.54, r: 0.075 },
+ /** The harbor bay, south. */
+ bay: { x: 0.05, z: 0.72, r: 0.2 },
+ /** Orchard meadows, south-west. */
+ orchard: { x: -0.45, z: 0.5, r: 0.3 },
+ /** The dark forest, west. */
+ forest: { x: -0.6, z: 0.02, r: 0.34 },
+} as const;
+export type RegionId = keyof typeof REGIONS;
+
+/** Small rock islets offshore: sea stacks with foam around them. */
+export const ISLETS: ReadonlyArray<{ x: number; z: number; r: number; level: number }> = [
+ { x: 0.93, z: -0.22, r: 0.032, level: 4 },
+ { x: 0.9, z: 0.24, r: 0.026, level: 3 },
+ { x: -0.58, z: 0.8, r: 0.04, level: 5 },
+ { x: -0.86, z: -0.6, r: 0.03, level: 6 },
+];
// ---------------------------------------------------------------------------
// Building the map
@@ -378,24 +485,130 @@ function fillRect(
cz: number,
hw: number,
hd: number,
- fn: (i: number) => void,
+ fn: (i: number, tx: number, tz: number) => void,
): void {
for (let tz = cz - hd; tz <= cz + hd; tz++) {
for (let tx = cx - hw; tx <= cx + hw; tx++) {
- if (inBounds(map, tx, tz)) fn(tileIndex(map, tx, tz));
+ if (inBounds(map, tx, tz)) fn(tileIndex(map, tx, tz), tx, tz);
+ }
+ }
+}
+
+/** Rasterise a filled disc (or ring) of tiles around (cx, cz). */
+function paintDisc(
+ map: IslandMap,
+ cx: number,
+ cz: number,
+ rMin: number,
+ rMax: number,
+ fn: (i: number, tx: number, tz: number) => void,
+): void {
+ const r = Math.ceil(rMax);
+ for (let tz = Math.floor(cz - r); tz <= Math.ceil(cz + r); tz++) {
+ for (let tx = Math.floor(cx - r); tx <= Math.ceil(cx + r); tx++) {
+ if (!inBounds(map, tx, tz)) continue;
+ const dist = Math.hypot(tx + 0.5 - cx, tz + 0.5 - cz);
+ if (dist >= rMin && dist < rMax) fn(tileIndex(map, tx, tz), tx, tz);
}
}
}
-function paintPlateau(map: IslandMap, i: number, kind: TileKind): void {
- map.level[i] = PLATEAU_LEVEL;
+function paintLand(map: IslandMap, i: number, kind: TileKind, level: number): void {
+ map.level[i] = level;
map.kind[i] = kind;
- map.blocked[i] = 0;
+ map.blocked[i] = kind === TileKind.rock || kind === TileKind.snow ? 1 : 0;
+}
+
+function paintWater(map: IslandMap, i: number): void {
+ map.kind[i] = TileKind.water;
+ map.level[i] = 0;
+ map.blocked[i] = 1;
+}
+
+/** Normalised distance (0 at the centre, 1 at the edge) to a region. */
+function regionT(nx: number, nz: number, region: { x: number; z: number; r: number }): number {
+ return Math.hypot(nx - region.x, nz - region.z) / region.r;
+}
+
+/** A soft bump: 1 at the centre, 0 at the region's edge, rounded shoulders. */
+function bump(nx: number, nz: number, region: { x: number; z: number; r: number }, power = 1.3): number {
+ const t = regionT(nx, nz, region);
+ return t >= 1 ? 0 : Math.pow(1 - t, power);
}
/**
- * The terrain pass: island silhouette, bay, beaches, highland, rock, and the
- * flat market plateau in the middle.
+ * The continuous height field, in levels (float). Composed, not rolled: a
+ * radial fall-off toward the sea, the designed features of every biome on top,
+ * then a little noise so the terraces meander instead of running in circles.
+ */
+export function heightAt(nx: number, nz: number): number {
+ const d = Math.hypot(nx, nz * 1.04);
+ // Level ~2 at the coast (a narrow beach where the noise dips), ~3.6 inland.
+ let h = 1.2 + 2.4 * (1 - Math.pow(d, 1.8));
+ h += 7.2 * bump(nx, nz, REGIONS.mountain, 1.4);
+ h += 2.7 * bump(nx, nz, REGIONS.archiveHill, 1.1);
+ h += 2.0 * bump(nx, nz, REGIONS.highland, 1.0);
+ h += 4.4 * bump(nx, nz, REGIONS.cape, 1.2);
+ h -= 1.7 * bump(nx, nz, REGIONS.cove, 1.0);
+ h -= 1.3 * bump(nx, nz, REGIONS.bay, 0.8);
+ h -= 0.7 * bump(nx, nz, REGIONS.orchard, 1.0);
+ h += 1.0 * bump(nx, nz, REGIONS.forest, 1.0);
+ h += (fbm(nx * 3.3 + 11, nz * 3.3 + 5, ISLAND_SEED + 7) - 0.5) * 1.5;
+ // The market plateau: dead flat, blended in over a wide skirt of terraces.
+ const plateauT = (Math.hypot(nx, nz) * CENTER_TILE) / PLATEAU_RADIUS_TILES;
+ const w = 1 - smoothstep(1.0, 1.55, plateauT);
+ return lerp(h, PLATEAU_LEVEL, w);
+}
+
+/** Whether normalised (nx, nz) is island (true) or sea (false). */
+export function isLandAt(nx: number, nz: number): boolean {
+ const d = Math.hypot(nx, nz * 1.04);
+ const shapeNoise = fbm(nx * 1.8 + 3.1, nz * 1.8 + 7.7, ISLAND_SEED);
+ let shape = d + (shapeNoise - 0.5) * 0.34;
+ // The cape reaches out into the sea; the mountain's coast bulges.
+ shape -= 0.14 * bump(nx, nz, { x: 0.9, z: 0, r: 0.3 }, 1.0);
+ shape -= 0.06 * bump(nx, nz, REGIONS.mountain, 1.0);
+ if (shape >= 0.86) return false;
+ if (regionT(nx, nz, REGIONS.bay) < 1) return false;
+ if (regionT(nx, nz, REGIONS.lagoon) < 1) return false;
+ // The lagoon's channel to the sea, south-east of it.
+ const cx = nx - REGIONS.lagoon.x;
+ const cz = nz - REGIONS.lagoon.z;
+ const along = (cx + cz) * Math.SQRT1_2;
+ const across = Math.abs(cx - cz) * Math.SQRT1_2;
+ if (along > 0 && along < 0.4 && across < 0.022) return false;
+ return true;
+}
+
+/** The kind a land tile gets from its level and the biome it lies in. */
+function biomeKind(nx: number, nz: number, level: number): TileKind {
+ if (level >= SNOW_LEVEL) return TileKind.snow;
+ if (level >= 7) return TileKind.rock;
+ const inMountain = regionT(nx, nz, REGIONS.mountain) < 1;
+ const inCape = regionT(nx, nz, REGIONS.cape) < 1;
+ const inHighland = regionT(nx, nz, REGIONS.highland) < 1;
+ const inCove = regionT(nx, nz, REGIONS.cove) < 0.8;
+ const inForest = regionT(nx, nz, REGIONS.forest) < 0.92;
+ const grain = fbm(nx * 6 + 31, nz * 6 + 17, ISLAND_SEED + 3);
+ if (level === 6) return inMountain || inCape ? TileKind.rock : TileKind.alpine;
+ if (level === 5) {
+ if ((inMountain || inCape) && grain > 0.55) return TileKind.rock;
+ return inMountain || inHighland || inCape ? TileKind.alpine : TileKind.meadow;
+ }
+ if (level === 1) return TileKind.sand;
+ if (level === 2) {
+ if (inCove) return TileKind.sand;
+ return grain > 0.6 ? TileKind.meadow : TileKind.grass;
+ }
+ // Levels 3 and 4: the rolling middle ground.
+ if (inForest && grain > 0.3) return TileKind.forest;
+ if (level === 4) return inHighland && grain > 0.5 ? TileKind.alpine : TileKind.meadow;
+ return grain > 0.66 ? TileKind.meadow : TileKind.grass;
+}
+
+/**
+ * The terrain pass: island silhouette, bay, lagoon, the height field
+ * quantised into levels, biome kinds, flower fields, islets.
*/
function buildTerrain(map: IslandMap): void {
const C = CENTER_TILE;
@@ -404,132 +617,171 @@ function buildTerrain(map: IslandMap): void {
const i = tileIndex(map, tx, tz);
const nx = (tx + 0.5 - C) / C;
const nz = (tz + 0.5 - C) / C;
- const d = Math.hypot(nx, nz);
- const shapeNoise = fbm(nx * 1.8 + 3.1, nz * 1.8 + 7.7, ISLAND_SEED);
- const shape = d + (shapeNoise - 0.5) * 0.36;
- // The harbor bay bites into the south coast.
- const bayDist = Math.hypot(nx - 0.06, nz - 1.0);
- const inBay = bayDist < 0.27;
- const isLand = shape < 0.92 && !inBay;
-
- if (!isLand) {
- map.kind[i] = TileKind.water;
- map.level[i] = 0;
- map.blocked[i] = 1;
+ if (!isLandAt(nx, nz)) {
+ paintWater(map, i);
continue;
}
-
- const elev = 1 - d * d + (fbm(nx * 3.3 + 11, nz * 3.3 + 5, ISLAND_SEED + 7) - 0.5) * 0.5;
- const onEdge = shape > 0.8 || bayDist < 0.34;
- let level = onEdge ? 1 : elev > 0.72 ? 3 : 2;
- let kind: TileKind = level === 1 ? TileKind.sand : level === 3 ? TileKind.meadow : TileKind.grass;
-
- // The north-eastern highland turns to rock where it climbs highest.
- if (nx > 0.18 && nz < -0.18 && !onEdge) {
- const ridge = fbm(nx * 5 + 21, nz * 5 + 9, ISLAND_SEED + 3);
- if (elev + 0.35 * ridge > 1.02) {
- level = 4;
- kind = TileKind.rock;
- }
+ const level = clamp(Math.round(heightAt(nx, nz)), 1, MAX_LEVEL);
+ let kind = biomeKind(nx, nz, level);
+ // Flower fields: drifts of blossom over the meadows, clustered by noise.
+ if (
+ (kind === TileKind.meadow || kind === TileKind.alpine) &&
+ fbm(nx * 9 + 3, nz * 9 + 41, ISLAND_SEED + 13) > 0.64 &&
+ hash2(tx, tz, 77) < 0.55
+ ) {
+ kind = TileKind.garden;
}
-
- map.level[i] = level;
- map.kind[i] = kind;
- map.blocked[i] = level === 4 ? 1 : 0;
+ paintLand(map, i, kind, level);
}
}
- // The market district is one flat plateau — the village needs level ground,
- // and a plateau with a low rim reads as "the town" from any distance.
- fillRect(map, C, C, MARKET_HALF_TILES + 4, MARKET_HALF_TILES + 4, (i) => {
- if (map.kind[i] === TileKind.water) return; // the sea stays the sea
- paintPlateau(map, i, TileKind.grass);
+ // Sandbar around the lagoon: a bright rim of beach, one step above the water.
+ const lag = REGIONS.lagoon;
+ paintDisc(map, C + lag.x * C, C + lag.z * C, 0, lag.r * C + 4.5, (i) => {
+ if (map.kind[i] !== TileKind.water) paintLand(map, i, TileKind.sand, 1);
+ });
+
+ // Beach around the bay.
+ const bay = REGIONS.bay;
+ paintDisc(map, C + bay.x * C, C + bay.z * C, 0, bay.r * C + 3.5, (i) => {
+ if (map.kind[i] !== TileKind.water && map.level[i] > 1) paintLand(map, i, TileKind.sand, 1);
});
+
+ // Islets: rock stacks with a green crown, so the sea is not empty.
+ for (const islet of ISLETS) {
+ const cx = C + islet.x * C;
+ const cz = C + islet.z * C;
+ const r = islet.r * C;
+ paintDisc(map, cx, cz, 0, r, (i, tx, tz) => {
+ const wobble = (hash2(tx, tz, 21) - 0.5) * 0.8;
+ const dist = Math.hypot(tx + 0.5 - cx, tz + 0.5 - cz) + wobble;
+ if (dist > r) return;
+ if (dist < r * 0.45) paintLand(map, i, TileKind.grass, islet.level);
+ else paintLand(map, i, TileKind.rock, Math.max(1, islet.level - (dist > r * 0.75 ? 2 : 1)));
+ });
+ }
+
+ // The breakwater sheltering the harbor: a line of rock in the bay's mouth.
+ for (let t = 0; t < 14; t++) {
+ const tx = C + 18 + t;
+ const tz = C + 96 - Math.round(t * 0.55);
+ fillRect(map, tx, tz, 0, 1, (i) => {
+ if (map.kind[i] === TileKind.water) paintLand(map, i, TileKind.rock, 2);
+ });
+ }
}
-/** Rasterise a filled disc of tiles around (cx, cz). */
-function paintDisc(
- map: IslandMap,
- cx: number,
- cz: number,
- rMin: number,
- rMax: number,
- fn: (i: number, tx: number, tz: number) => void,
-): void {
- const r = Math.ceil(rMax);
- for (let tz = cz - r; tz <= cz + r; tz++) {
- for (let tx = cx - r; tx <= cx + r; tx++) {
+/** Flatten every place's plot to its terrace level. */
+function buildPlots(map: IslandMap): void {
+ for (const id of Object.keys(PLACE_TILES) as PlaceId[]) {
+ const [px, pz] = PLACE_TILES[id];
+ const [hw, hd] = PLOT_HALF[id];
+ if (hw === 0 && hd === 0) continue;
+ const kind =
+ id === "gardens"
+ ? TileKind.garden
+ : id === "solar"
+ ? TileKind.meadow
+ : id === "lighthouse"
+ ? TileKind.rock
+ : TileKind.plaza;
+ fillRect(map, px, pz, hw, hd, (i) => {
+ if (map.kind[i] === TileKind.water) return;
+ paintLand(map, i, kind, PLOT_LEVEL[id]);
+ if (id === "lighthouse") map.blocked[i] = 0; // the keeper walks the knob
+ });
+ }
+}
+
+/**
+ * A road that climbs at most one level per tile: walked outward from the
+ * square, each tile clamps to its predecessor ±1, and the shoulders beside it
+ * come along, so the road never runs in a trench. This is what keeps every
+ * place reachable on foot whatever the terrain does.
+ */
+function gradeSpoke(map: IslandMap, dir: [number, number], fromTiles: number, toTiles: number): void {
+ const C = CENTER_TILE;
+ let prev = PLATEAU_LEVEL;
+ for (let s = fromTiles; s <= toTiles; s++) {
+ const cx = C + dir[0] * s;
+ const cz = C + dir[1] * s;
+ if (!inBounds(map, cx, cz)) break;
+ const ci = tileIndex(map, cx, cz);
+ const desired = map.kind[ci] === TileKind.water ? prev : map.level[ci];
+ const lvl = clamp(desired, prev - 1, prev + 1);
+ for (let w = -2; w <= 2; w++) {
+ const tx = cx + dir[1] * w;
+ const tz = cz + dir[0] * w;
if (!inBounds(map, tx, tz)) continue;
- const dist = Math.hypot(tx + 0.5 - cx, tz + 0.5 - cz);
- if (dist >= rMin && dist < rMax) fn(tileIndex(map, tx, tz), tx, tz);
+ const i = tileIndex(map, tx, tz);
+ if (map.kind[i] === TileKind.water) continue;
+ if (Math.abs(w) <= 1) {
+ paintLand(map, i, TileKind.path, lvl);
+ } else if (Math.abs(map.level[i] - lvl) > 1) {
+ map.level[i] = lvl + Math.sign(map.level[i] - lvl);
+ }
}
+ prev = lvl;
}
}
-/** The village: square, ring road, spokes, garden beds, plots and the dock. */
+/** The village: square, ring road, spokes, garden beds and the dock. */
function buildVillage(map: IslandMap): void {
const C = CENTER_TILE;
// Open square with a ring of garden beds around it.
- paintDisc(map, C, C, 0, PLAZA_RADIUS_TILES, (i) => paintPlateau(map, i, TileKind.plaza));
+ paintDisc(map, C, C, 0, PLAZA_RADIUS_TILES, (i) => paintLand(map, i, TileKind.plaza, PLATEAU_LEVEL));
paintDisc(map, C, C, PLAZA_RADIUS_TILES, PLAZA_RADIUS_TILES + 1.5, (i, tx, tz) => {
// Beds alternate with plaza so the square stays open toward every house.
const a = Math.atan2(tz + 0.5 - C, tx + 0.5 - C);
const bed = Math.floor(((a + Math.PI) / (2 * Math.PI)) * 16) % 2 === 0;
- paintPlateau(map, i, bed ? TileKind.garden : TileKind.plaza);
+ paintLand(map, i, bed ? TileKind.garden : TileKind.plaza, PLATEAU_LEVEL);
});
- // Ring road around the houses.
- paintDisc(map, C, C, RING_ROAD_TILES - 1, RING_ROAD_TILES + 1, (i) =>
- paintPlateau(map, i, TileKind.path),
- );
+ // Ring road around the houses — it climbs the hub's podium rather than
+ // vanishing under it: the kind changes, the level stays.
+ paintDisc(map, C, C, RING_ROAD_TILES - 1, RING_ROAD_TILES + 1, (i) => {
+ const lvl = map.level[i] === PODIUM_LEVEL ? PODIUM_LEVEL : PLATEAU_LEVEL;
+ paintLand(map, i, TileKind.path, lvl);
+ });
- // Spokes from the square out to the quarters (width 3).
- for (const spoke of SPOKES) {
- for (let s = PLAZA_RADIUS_TILES - 1; s <= spoke.toTiles; s++) {
- for (let w = -1; w <= 1; w++) {
- const tx = C + spoke.dir[0] * s + spoke.dir[1] * w;
- const tz = C + spoke.dir[1] * s + spoke.dir[0] * w;
- if (!inBounds(map, tx, tz)) continue;
- const i = tileIndex(map, tx, tz);
- if (map.kind[i] === TileKind.water) continue;
- paintPlateau(map, i, TileKind.path);
- }
- }
- }
+ // Spokes from the square out to the quarters (width 3), graded.
+ for (const spoke of SPOKES) gradeSpoke(map, spoke.dir, PLAZA_RADIUS_TILES - 1, spoke.toTiles);
- // Flat plots for every place; the buildings on them block walking.
- for (const id of Object.keys(PLACE_TILES) as PlaceId[]) {
+ // Buildings block walking; their tiles keep the plot level.
+ for (const id of Object.keys(BUILDING_HALF) as PlaceId[]) {
+ const bh = BUILDING_HALF[id];
+ if (!bh) continue;
const [px, pz] = PLACE_TILES[id];
- const [hw, hd] = PLOT_HALF[id];
- if (hw === 0 && hd === 0) continue;
- const kind =
- id === "gardens" ? TileKind.garden : id === "solar" ? TileKind.meadow : TileKind.plaza;
- fillRect(map, px, pz, hw, hd, (i) => {
- if (map.kind[i] === TileKind.water) return;
- paintPlateau(map, i, kind);
+ fillRect(map, px, pz, bh[0], bh[1], (i) => {
+ map.blocked[i] = 1;
+ map.level[i] = PLOT_LEVEL[id];
});
- if (id === "lighthouse") {
- // The lighthouse stands on a rocky knob.
- fillRect(map, px, pz, hw, hd, (i) => {
- map.level[i] = 3;
- map.kind[i] = TileKind.rock;
- map.blocked[i] = 0;
- });
- }
- const bh = BUILDING_HALF[id];
- if (bh) fillRect(map, px, pz, bh[0], bh[1], (i) => (map.blocked[i] = 1));
}
- // The dock runs from the harbor plot into the bay.
+ // The dock runs from the harbor plot into the bay, one step above the water
+ // so a walker can step onto the planks from the beach.
for (let tz = DOCK_TILES.from; tz <= DOCK_TILES.to; tz++) {
for (let tx = C - DOCK_TILES.halfWidth; tx <= C + DOCK_TILES.halfWidth; tx++) {
if (!inBounds(map, tx, tz)) continue;
const i = tileIndex(map, tx, tz);
map.kind[i] = TileKind.dock;
+ map.level[i] = 1;
map.blocked[i] = 0;
}
}
+ // A small jetty into the lagoon, from its northern sandbar.
+ const lag = REGIONS.lagoon;
+ const jx = Math.round(C + lag.x * C);
+ const jz0 = Math.round(C + lag.z * C - lag.r * C) - 2;
+ for (let tz = jz0; tz <= jz0 + 6; tz++) {
+ if (!inBounds(map, jx, tz)) continue;
+ const i = tileIndex(map, jx, tz);
+ if (map.kind[i] !== TileKind.water && map.kind[i] !== TileKind.sand) continue;
+ map.kind[i] = TileKind.dock;
+ map.level[i] = 1;
+ map.blocked[i] = 0;
+ }
}
/** The house ring: 16 slots, the four gate directions left open, the hub north. */
@@ -588,8 +840,11 @@ function placeRingFurniture(map: IslandMap): { hedges: Post[]; lamps: Post[] } {
const segments = Math.round(circumference / 2.2);
for (let s = 0; s < segments; s++) {
const angle = (s / segments) * Math.PI * 2;
- // A gate is a gap centred on each cardinal direction.
- const gapHalf = (GATE_GAP_TILES * TILE_M) / r;
+ // A gate is a gap centred on each cardinal direction; the north gate is
+ // the hub's podium, so its gap is as wide as the podium.
+ const toNorth = Math.min(angle, Math.PI * 2 - angle);
+ const gapTiles = toNorth < Math.PI / 4 ? HUB_GATE_GAP_TILES : GATE_GAP_TILES;
+ const gapHalf = (gapTiles * TILE_M) / r;
const toCardinal = Math.abs(((angle + Math.PI / 4) % (Math.PI / 2)) - Math.PI / 4);
if (toCardinal < gapHalf) continue;
const x = Math.sin(angle) * r;
@@ -598,7 +853,7 @@ function placeRingFurniture(map: IslandMap): { hedges: Post[]; lamps: Post[] } {
const [tx, tz] = worldToTile(x, z);
if (inBounds(map, tx, tz)) map.blocked[tileIndex(map, tx, tz)] = 1;
}
- // Lamps: one at every gate post pair, and along the spokes every 8 tiles.
+ // Lamps: along the spokes every 8 tiles, on the road's shoulders.
for (const spoke of SPOKES) {
for (let s = PLAZA_RADIUS_TILES + 3; s <= spoke.toTiles - 2; s += 8) {
for (const side of [-2.5, 2.5]) {
@@ -640,21 +895,47 @@ function placeQuarterFurniture(map: IslandMap): { panels: Post[]; greenhouses: P
return { panels, greenhouses };
}
-/** Trees wherever grass or meadow is free, away from roads and plots. */
+/** Which tree grows on a tile, and how densely, per biome. `null` = none. */
+function treeChoice(map: IslandMap, tx: number, tz: number): { kind: TreeKind; density: number } | null {
+ const i = tileIndex(map, tx, tz);
+ const k = map.kind[i];
+ const level = map.level[i];
+ const nx = (tx + 0.5 - CENTER_TILE) / CENTER_TILE;
+ const nz = (tz + 0.5 - CENTER_TILE) / CENTER_TILE;
+ const grain = hash2(tx, tz, 8);
+ if (k === TileKind.forest) return { kind: grain < 0.72 ? "round" : "pine", density: 0.34 };
+ if (k === TileKind.alpine) return { kind: "pine", density: 0.08 };
+ if (k === TileKind.sand) {
+ // Palms only in the tropical cove, thickest around the lagoon.
+ const cove = regionT(nx, nz, REGIONS.cove);
+ if (cove >= 1) return null;
+ const lagoon = regionT(nx, nz, REGIONS.lagoon);
+ return { kind: "palm", density: lagoon < 1.9 ? 0.11 : 0.045 };
+ }
+ if (k === TileKind.meadow) return { kind: level >= 5 ? "pine" : "round", density: 0.09 };
+ if (k === TileKind.grass) {
+ // Islets carry a tree or two; the mainland's grass stays open.
+ const offshore = Math.hypot(nx, nz) > 0.8;
+ return { kind: "round", density: offshore ? 0.5 : 0.05 };
+ }
+ return null;
+}
+
+/** Trees wherever their biome allows, away from roads and plots. */
function placeTrees(map: IslandMap): TreeSpot[] {
const trees: TreeSpot[] = [];
const C = CENTER_TILE;
for (let tz = 1; tz < map.size - 1; tz++) {
for (let tx = 1; tx < map.size - 1; tx++) {
const i = tileIndex(map, tx, tz);
- const k = map.kind[i];
- if (k !== TileKind.grass && k !== TileKind.meadow) continue;
if (map.blocked[i]) continue;
+ const choice = treeChoice(map, tx, tz);
+ if (!choice) continue;
const rTiles = Math.hypot(tx + 0.5 - C, tz + 0.5 - C);
// Inside the village only a few trees, between the houses and the hedge.
const inVillage = rTiles < HEDGE_RING_TILES + 1;
if (inVillage && (rTiles < HOUSE_RING_TILES + 2 || rTiles > RING_ROAD_TILES + 1.5)) continue;
- const density = inVillage ? 0.05 : k === TileKind.meadow ? 0.13 : 0.07;
+ const density = inVillage ? 0.05 : choice.density;
if (hash2(tx, tz, ISLAND_SEED + 55) > density) continue;
// Keep a clear margin to anything built or paved.
let clear = true;
@@ -662,7 +943,12 @@ function placeTrees(map: IslandMap): TreeSpot[] {
for (let dx = -1; dx <= 1; dx++) {
const j = tileIndex(map, tx + dx, tz + dz);
const kk = map.kind[j];
- if (kk === TileKind.path || kk === TileKind.plaza || kk === TileKind.dock || kk === TileKind.garden || (map.blocked[j] && kk !== TileKind.water && kk !== TileKind.rock)) {
+ if (
+ kk === TileKind.path ||
+ kk === TileKind.plaza ||
+ kk === TileKind.dock ||
+ (map.blocked[j] && kk !== TileKind.water && kk !== TileKind.rock && kk !== TileKind.snow)
+ ) {
clear = false;
break;
}
@@ -676,6 +962,7 @@ function placeTrees(map: IslandMap): TreeSpot[] {
y: LEVEL_Y[map.level[i]],
size: hash2(tx, tz, 5),
shade: hash2(tx, tz, 6),
+ kind: choice.kind,
});
map.blocked[i] = 1;
}
@@ -683,9 +970,51 @@ function placeTrees(map: IslandMap): TreeSpot[] {
return trees;
}
+/** Boulders on the high ground, along the cliffs and on the beaches. */
+function placeBoulders(map: IslandMap): Boulder[] {
+ const boulders: Boulder[] = [];
+ const C = CENTER_TILE;
+ for (let tz = 1; tz < map.size - 1; tz++) {
+ for (let tx = 1; tx < map.size - 1; tx++) {
+ const i = tileIndex(map, tx, tz);
+ const k = map.kind[i];
+ if (k === TileKind.water || k === TileKind.path || k === TileKind.plaza || k === TileKind.dock) continue;
+ if (Math.hypot(tx + 0.5 - C, tz + 0.5 - C) < HEDGE_RING_TILES + 4) continue;
+ let density: number;
+ if (k === TileKind.rock || k === TileKind.snow) density = 0.05;
+ else if (k === TileKind.alpine) density = 0.035;
+ else if (k === TileKind.sand) density = 0.012;
+ else density = 0.008;
+ // Rocks gather at the foot of cliffs: a higher neighbour raises the odds.
+ let cliff = false;
+ for (const [dx, dz] of [
+ [1, 0],
+ [-1, 0],
+ [0, 1],
+ [0, -1],
+ ] as const) {
+ const j = tileIndex(map, tx + dx, tz + dz);
+ if (map.kind[j] !== TileKind.water && map.level[j] >= map.level[i] + 2) cliff = true;
+ }
+ if (cliff) density *= 3;
+ if (hash2(tx, tz, ISLAND_SEED + 91) > density) continue;
+ if (map.blocked[i] && k !== TileKind.rock && k !== TileKind.snow) continue; // a tree or a building
+ const [x, z] = tileToWorld(tx, tz);
+ boulders.push({
+ x: x + (hash2(tx, tz, 31) - 0.5) * 1.2,
+ z: z + (hash2(tx, tz, 32) - 0.5) * 1.2,
+ y: LEVEL_Y[map.level[i]],
+ size: hash2(tx, tz, 33),
+ seed: hash2(tx, tz, 34),
+ });
+ map.blocked[i] = 1;
+ }
+ }
+ return boulders;
+}
+
function buildPlaces(map: IslandMap): Record<PlaceId, Place> {
const C = CENTER_TILE;
- const facingCentre = (tx: number, tz: number) => Math.atan2(C - tx, C - tz);
const place = (id: PlaceId, standTile: [number, number], facing: number): Place => ({
id,
tile: PLACE_TILES[id],
@@ -695,14 +1024,14 @@ function buildPlaces(map: IslandMap): Record<PlaceId, Place> {
const places: Record<PlaceId, Place> = {
// The meeting spot: at the table under the tree, facing it.
market: place("market", [C - 4, C + 3], Math.atan2(4, -3)),
- // In front of the hub's door, facing the door (north).
- hub: place("hub", [C, PLACE_TILES.hub[1] + 5], Math.PI),
+ // On the square at the foot of the hub's grand stair, facing the door (north).
+ hub: place("hub", [C, PLACE_TILES.hub[1] + 8], Math.PI),
archive: place("archive", [C, PLACE_TILES.archive[1] + 5], Math.PI),
- harbor: place("harbor", [C, PLACE_TILES.harbor[1] + 2], 0),
+ harbor: place("harbor", [C, PLACE_TILES.harbor[1] - 2], 0),
workshop: place("workshop", [PLACE_TILES.workshop[0] + 8, C], -Math.PI / 2),
- lighthouse: place("lighthouse", [PLACE_TILES.lighthouse[0] - 3, C], Math.PI / 2),
+ lighthouse: place("lighthouse", [PLACE_TILES.lighthouse[0] - 4, C], Math.PI / 2),
gardens: place("gardens", [PLACE_TILES.gardens[0], PLACE_TILES.gardens[1]], 0),
- solar: place("solar", [PLACE_TILES.solar[0] + 1, PLACE_TILES.solar[1] + 8], Math.PI),
+ solar: place("solar", [PLACE_TILES.solar[0] + 1, PLACE_TILES.solar[1] + 9], Math.PI),
// Ring hubs: 7.5 m in front of the doors, toward the square, facing the building.
...(Object.fromEntries(
KIT_PLACES.map((id) => {
@@ -714,14 +1043,13 @@ function buildPlaces(map: IslandMap): Record<PlaceId, Place> {
}),
) as Record<KitPlace, Place>),
};
- void facingCentre;
// Make sure every stand tile is walkable — a place nobody can reach is a bug.
for (const p of Object.values(places)) {
const [tx, tz] = p.standTile;
if (inBounds(map, tx, tz)) {
const i = tileIndex(map, tx, tz);
map.blocked[i] = 0;
- if (map.kind[i] === TileKind.water) paintPlateau(map, i, TileKind.path);
+ if (map.kind[i] === TileKind.water) paintLand(map, i, TileKind.path, 1);
}
}
return places;
@@ -751,6 +1079,7 @@ export function buildIsland(): Island {
blocked: new Uint8Array(size * size),
};
buildTerrain(map);
+ buildPlots(map);
buildVillage(map);
const houses = placeHouses();
blockHouses(map, houses);
@@ -772,10 +1101,11 @@ export function buildIsland(): Island {
const { hedges, lamps } = placeRingFurniture(map);
const { panels, greenhouses } = placeQuarterFurniture(map);
const trees = placeTrees(map);
+ const boulders = placeBoulders(map);
const places = buildPlaces(map);
cached = {
map,
- content: { places, houses, trees, hedges, lamps, panels, greenhouses, kitPoses },
+ content: { places, houses, trees, boulders, hedges, lamps, panels, greenhouses, kitPoses },
};
return cached;
}
@@ -850,13 +1180,14 @@ function canStep(map: IslandMap, from: number, tx: number, tz: number): boolean
* Shortest path from tile `from` to tile `to`, as a list of tiles INCLUDING the
* start; `null` when no path exists (or the search budget runs out). Costs are
* 1 / √2 per step, octile heuristic, corner cutting between two blocked tiles
- * forbidden so figures never clip a house corner.
+ * forbidden so figures never clip a house corner. The budget covers a walk
+ * from one coast to the other on the 256-tile island.
*/
export function findPath(
map: IslandMap,
from: [number, number],
to: [number, number],
- maxExpansions = 40_000,
+ maxExpansions = 160_000,
): Array<[number, number]> | null {
if (!isWalkable(map, to[0], to[1]) || !isWalkable(map, from[0], from[1])) return null;
const n = map.size * map.size;
diff --git a/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.test.ts b/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.test.ts
index 1ad1151bec..1ca1038ac4 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
-import { buildIsland, tileIndex, TileKind } from "./islandLayout";
+import { CENTER_TILE, LEVEL_Y, buildIsland, tileIndex, TileKind } from "./islandLayout";
import { buildTerrainGeometry, triangleCount } from "./terrainGeometry";
describe("terrainGeometry", () => {
@@ -11,7 +11,7 @@ describe("terrainGeometry", () => {
for (let i = 0; i < map.kind.length; i++) if (map.kind[i] !== TileKind.water) land++;
const tris = triangleCount(geo);
expect(tris).toBeGreaterThanOrEqual(land * 2);
- // Sides exist (coast + plateau rim) but stay a fraction of the tops.
+ // Sides exist (coast, terraces, cliffs) but stay a fraction of the tops.
expect(tris).toBeLessThan(land * 2 * 2.5);
expect(geo.getAttribute("color").itemSize).toBe(3);
expect(geo.getAttribute("normal").count).toBe(geo.getAttribute("position").count);
@@ -27,9 +27,9 @@ describe("terrainGeometry", () => {
for (let v = 0; v < pos.count; v++) {
if (nor.getY(v) === 1) heights.add(Math.round(pos.getY(v) * 100) / 100);
}
- // Levels 1..4 plus the dock: never a stray height.
- expect(heights.size).toBeLessThanOrEqual(5);
- const i = tileIndex(map, 80, 80);
+ // Levels 1..9 plus the dock: never a stray height.
+ expect(heights.size).toBeLessThanOrEqual(LEVEL_Y.length);
+ const i = tileIndex(map, CENTER_TILE, CENTER_TILE);
expect(map.kind[i]).toBe(TileKind.plaza);
});
});
diff --git a/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.ts b/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.ts
index 8455e9790c..10d0030ad7 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/terrainGeometry.ts
@@ -3,18 +3,22 @@
*
* Every land tile contributes a flat top quad at its level's height and, where
* a neighbour sits lower (or is sea), a vertical side quad down to that
- * neighbour: cliffs, beach steps and the plateau rim come out of the level
- * map for free. Colours are per tile (two alternating shades per kind, so the
- * ground has the tile-art flicker under the pixel pass) and per side.
+ * neighbour: cliffs, terraces, beach steps and the plateau rim come out of the
+ * level map for free. Colours are per tile (two alternating shades per kind,
+ * so the ground has the tile-art flicker under the pixel pass) and per side;
+ * on top of that the high ground is tinted a touch lighter and the sand next
+ * to the water a touch darker (wet), the way a painted map reads height and
+ * shoreline.
*
* Pure three.js, no React: a test can build it under vitest, and the renderer
- * mounts the result once. ~13 k land tiles → roughly 40 k triangles.
+ * mounts the result once. ~36 k land tiles → roughly 110 k triangles.
*/
import { BufferAttribute, BufferGeometry, Color } from "three";
import {
DOCK_Y,
LEVEL_Y,
+ PLATEAU_LEVEL,
TILE_M,
TileKind,
hash2,
@@ -25,7 +29,11 @@ import {
import { TILE_COLORS } from "./worldPalette";
/** How far below the water surface the coast walls reach (never a visible gap). */
-const SEA_FLOOR_Y = -0.6;
+const SEA_FLOOR_Y = -1.5;
+/** Lightening per level above the plateau (and darkening below): aerial tint. */
+const LEVEL_TINT = 0.022;
+/** Sand with the sea beside it darkens by this factor: the wet line. */
+const WET_SAND = 0.9;
type Vec3 = [number, number, number];
@@ -72,6 +80,13 @@ function color(hex: string): Color {
return c;
}
+const NEIGHBOURS = [
+ [1, 0],
+ [-1, 0],
+ [0, 1],
+ [0, -1],
+] as const;
+
/** Height of a tile's top surface; the sea floor for water and out-of-map. */
function topY(map: IslandMap, tx: number, tz: number): number {
if (!inBounds(map, tx, tz)) return SEA_FLOOR_Y;
@@ -85,19 +100,26 @@ function topY(map: IslandMap, tx: number, tz: number): number {
/** 1 = fully lit; each higher neighbour and each built-on neighbour darkens the tile a step. */
function tileAo(map: IslandMap, tx: number, tz: number, y: number): number {
let ao = 1;
- for (const [dx, dz] of [
- [1, 0],
- [-1, 0],
- [0, 1],
- [0, -1],
- ] as const) {
+ for (const [dx, dz] of NEIGHBOURS) {
const nx = tx + dx;
const nz = tz + dz;
if (!inBounds(map, nx, nz)) continue;
- if (topY(map, nx, nz) > y + 0.01) ao -= 0.09;
+ const ny = topY(map, nx, nz);
+ // A higher neighbour shades; a cliff (two steps or more) shades harder.
+ if (ny > y + 0.01) ao -= ny > y + 1.2 ? 0.12 : 0.09;
else if (map.blocked[tileIndex(map, nx, nz)] && map.kind[tileIndex(map, nx, nz)] !== TileKind.water) ao -= 0.05;
}
- return Math.max(0.68, ao);
+ return Math.max(0.64, ao);
+}
+
+function touchesWater(map: IslandMap, tx: number, tz: number): boolean {
+ for (const [dx, dz] of NEIGHBOURS) {
+ const nx = tx + dx;
+ const nz = tz + dz;
+ if (!inBounds(map, nx, nz)) return true;
+ if (map.kind[tileIndex(map, nx, nz)] === TileKind.water) return true;
+ }
+ return false;
}
/** Build the terrain mesh for the whole map. */
@@ -110,6 +132,7 @@ export function buildTerrainGeometry(map: IslandMap): BufferGeometry {
const kind = map.kind[i] as TileKind;
if (kind === TileKind.water) continue;
const y = topY(map, tx, tz);
+ const level = map.level[i];
const x0 = tx * TILE_M - half;
const x1 = x0 + TILE_M;
const z0 = tz * TILE_M - half;
@@ -121,14 +144,19 @@ export function buildTerrainGeometry(map: IslandMap): BufferGeometry {
// Analytic ambient occlusion (world-masterplan-v2.md §3.3): ground next
// to a higher step or a building darkens a little, the way every corner
// of a stylised village is shaded.
- const ao = tileAo(map, tx, tz, y);
- const top = ao < 1 ? color(shades.top[topIdx]).clone().multiplyScalar(ao) : color(shades.top[topIdx]);
+ let factor = tileAo(map, tx, tz, y);
+ // Aerial tint: the high ground is a touch lighter, the low ground a touch deeper.
+ if (kind !== TileKind.dock) factor *= 1 + (level - PLATEAU_LEVEL) * LEVEL_TINT;
+ // The wet line: sand with the sea beside it.
+ if (kind === TileKind.sand && touchesWater(map, tx, tz)) factor *= WET_SAND;
+ const base = color(shades.top[topIdx]);
+ const top = Math.abs(factor - 1) > 0.001 ? base.clone().multiplyScalar(factor) : base;
b.quad([x0, y, z0], [x0, y, z1], [x1, y, z1], [x1, y, z0], UP, top);
- const side = color(shades.side);
// Dock planks stand on posts, not on a wall: no side faces, they float.
if (kind === TileKind.dock) continue;
+ const side = color(shades.side);
const south = topY(map, tx, tz + 1);
if (south < y) b.quad([x0, south, z1], [x1, south, z1], [x1, y, z1], [x0, y, z1], SOUTH, side);
const north = topY(map, tx, tz - 1);
diff --git a/jarvis/ui/web/frontend/src/components/society/world/worldCamera.test.ts b/jarvis/ui/web/frontend/src/components/society/world/worldCamera.test.ts
index 0c058cae30..5e0d53e52b 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/worldCamera.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/worldCamera.test.ts
@@ -6,6 +6,7 @@ import {
CAMERA_PITCH_DEG,
CAMERA_YAW_DEG,
DEFAULT_ZOOM,
+ MAX_ZOOM,
ZOOM_WIDTHS_M,
cameraOffset,
clampTarget,
@@ -28,10 +29,11 @@ describe("worldCamera", () => {
expect(y).toBeGreaterThan(Math.hypot(x, z));
});
- it("zooms in three fixed steps and clamps at both ends", () => {
- expect(ZOOM_WIDTHS_M).toEqual([32, 64, 128]);
+ it("zooms in five fixed steps, up to the whole island, and clamps at both ends", () => {
+ expect(ZOOM_WIDTHS_M).toEqual([32, 64, 128, 256, 512]);
+ expect(ZOOM_WIDTHS_M[MAX_ZOOM]).toBe(ISLAND_HALF_M * 2);
expect(stepZoom(DEFAULT_ZOOM, 1)).toBe(2);
- expect(stepZoom(2, 1)).toBe(2);
+ expect(stepZoom(MAX_ZOOM, 1)).toBe(MAX_ZOOM);
expect(stepZoom(0, -1)).toBe(0);
expect(stepZoom(1, -1)).toBe(0);
});
@@ -89,7 +91,8 @@ describe("worldCamera", () => {
it("reads a ?world=x,z,zoom deep link and ignores garbage", () => {
expect(focusFromSearch("?view=agents&world=12,-30,0")).toEqual({ target: [12, -30], zoom: 0 });
expect(focusFromSearch("?world=5,5")).toEqual({ target: [5, 5], zoom: 1 });
- expect(focusFromSearch("?world=9999,0,7")?.target[0]).toBe(ISLAND_HALF_M);
+ expect(focusFromSearch("?world=9999,0,7")).toEqual({ target: [ISLAND_HALF_M, 0], zoom: 1 });
+ expect(focusFromSearch("?world=0,0,4")?.zoom).toBe(4);
expect(focusFromSearch("?world=abc")).toBeNull();
expect(focusFromSearch("?view=agents")).toBeNull();
});
diff --git a/jarvis/ui/web/frontend/src/components/society/world/worldCamera.ts b/jarvis/ui/web/frontend/src/components/society/world/worldCamera.ts
index 85e778f0ea..c57f372352 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/worldCamera.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/worldCamera.ts
@@ -6,8 +6,9 @@
* Decisions (maintainer, 2026-09-01): a STEEP bird's-eye view — 50° below
* the horizon at the classic 45° dimetric yaw — so the island reads as "seen
* from above" while house fronts and figure silhouettes stay visible. Zoom
- * is three fixed steps (one field, four fields, the whole market district),
- * never continuous: with an integer pixel size every step stays crisp.
+ * is five fixed steps (one field, four fields, the market district, a quarter
+ * of the island, the whole island), never continuous: with an integer pixel
+ * size every step stays crisp, and the widest step is the postcard view.
*/
import { ISLAND_HALF_M } from "./islandLayout";
@@ -17,8 +18,10 @@ export const CAMERA_YAW_DEG = 45;
export const CAMERA_DISTANCE_M = 420;
/** Ground width the orthographic frustum shows per zoom step, in metres. */
-export const ZOOM_WIDTHS_M = [32, 64, 128] as const;
-export type ZoomLevel = 0 | 1 | 2;
+export const ZOOM_WIDTHS_M = [32, 64, 128, 256, 512] as const;
+export type ZoomLevel = 0 | 1 | 2 | 3 | 4;
+/** The widest step: the whole island in one frame. */
+export const MAX_ZOOM: ZoomLevel = 4;
/** Start on the middle step: the whole village square fits, figures stay readable. */
export const DEFAULT_ZOOM: ZoomLevel = 1;
diff --git a/jarvis/ui/web/frontend/src/components/society/world/worldMaterials.ts b/jarvis/ui/web/frontend/src/components/society/world/worldMaterials.ts
index d1f8bf9fa5..9d4ba91918 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/worldMaterials.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/worldMaterials.ts
@@ -17,8 +17,10 @@ import {
RGBAFormat,
SphereGeometry,
TorusGeometry,
+ type BufferGeometry,
} from "three";
import { RoundedBoxGeometry } from "three/examples/jsm/geometries/RoundedBoxGeometry.js";
+import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
import { BUILDING, NATURE } from "./worldPalette";
@@ -100,9 +102,36 @@ export interface WorldGeometries {
sphere: SphereGeometry;
dome: SphereGeometry;
ring: TorusGeometry;
+ /** A conifer crown: two stacked cones, unit height, for the forest and the alpine slopes. */
+ pine: BufferGeometry;
+ /** A palm crown: six drooping fronds around the trunk top, unit radius. */
+ palmCrown: BufferGeometry;
dispose: () => void;
}
+function makePine(): BufferGeometry {
+ const lower = new CylinderGeometry(0, 0.5, 0.62, 7).translate(0, 0.31, 0);
+ const upper = new CylinderGeometry(0, 0.36, 0.55, 7).translate(0, 0.72, 0);
+ const merged = mergeGeometries([lower, upper], false);
+ lower.dispose();
+ upper.dispose();
+ return merged ?? lower;
+}
+
+function makePalmCrown(): BufferGeometry {
+ const fronds: BufferGeometry[] = [];
+ for (let k = 0; k < 6; k++) {
+ const frond = new BoxGeometry(0.28, 0.06, 1.0)
+ .translate(0, 0, 0.5)
+ .rotateX(0.42)
+ .rotateY((k / 6) * Math.PI * 2 + 0.3);
+ fronds.push(frond);
+ }
+ const merged = mergeGeometries(fronds, false);
+ fronds.forEach((f) => f.dispose());
+ return merged ?? fronds[0];
+}
+
export function createWorldGeometries(): WorldGeometries {
const box = new RoundedBoxGeometry(1, 1, 1, 2, 0.05);
const slab = new BoxGeometry(1, 1, 1);
@@ -113,7 +142,9 @@ export function createWorldGeometries(): WorldGeometries {
const sphere = new SphereGeometry(0.5, 10, 8);
const dome = new SphereGeometry(0.5, 12, 6, 0, Math.PI * 2, 0, Math.PI / 2);
const ring = new TorusGeometry(0.5, 0.06, 6, 24);
- const all = [box, slab, cylinder, halfCylinder, cone, blob, sphere, dome, ring];
+ const pine = makePine();
+ const palmCrown = makePalmCrown();
+ const all = [box, slab, cylinder, halfCylinder, cone, blob, sphere, dome, ring, pine, palmCrown];
return {
box,
slab,
@@ -124,6 +155,8 @@ export function createWorldGeometries(): WorldGeometries {
sphere,
dome,
ring,
+ pine,
+ palmCrown,
dispose: () => all.forEach((g) => g.dispose()),
};
}
diff --git a/jarvis/ui/web/frontend/src/components/society/world/worldPalette.ts b/jarvis/ui/web/frontend/src/components/society/world/worldPalette.ts
index a11000f4fe..62ca63aa14 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/worldPalette.ts
+++ b/jarvis/ui/web/frontend/src/components/society/world/worldPalette.ts
@@ -3,11 +3,14 @@
* app and never wears Ink & Paper. Every colour rendered inside the viewport
* comes from here; the surrounding chrome keeps the app's theme tokens.
*
- * Direction (maintainer, 2026-09-01, docs/agent-society/world-art-direction.md):
- * a bright pixel island in the warm light of a late afternoon — saturated,
- * friendly greens and blues, warm sand and stone — with a SOLARPUNK village on
- * it: white walls, glass, solar barrels, garden roofs, wood accents. Two
- * shades per terrain kind give the tile-art flicker under the pixel pass.
+ * Direction (maintainer, 2026-09-01/02, docs/agent-society/world-art-direction.md):
+ * a bright island in the warm light of a late afternoon — saturated, friendly
+ * greens and blues, warm sand and stone — composed of biomes at different
+ * heights (beach, meadows, forest, alpine, rock, snow) with a SOLARPUNK
+ * village on its central plateau: white walls, glass, solar barrels, garden
+ * roofs, wood accents. Two shades per terrain kind give the tile-art flicker
+ * under the pixel pass; the level tint in `terrainGeometry.ts` lightens the
+ * high ground a little, the way distance haze does.
*/
import { TileKind } from "./islandLayout";
@@ -28,14 +31,19 @@ export const TILE_COLORS: Record<TileKind, TileShades> = {
[TileKind.path]: { top: ["#dcc9a5", "#d0bd97"], side: "#a48c66" },
[TileKind.garden]: { top: ["#b7dc6a", "#e18db1"], side: "#8e6a44" },
[TileKind.dock]: { top: ["#b6853f", "#a87634"], side: "#7d5623" },
+ [TileKind.forest]: { top: ["#4f9e47", "#47923f"], side: "#6d5236" },
+ [TileKind.alpine]: { top: ["#bcd97c", "#aecf6f"], side: "#7c6a4c" },
+ [TileKind.snow]: { top: ["#f6f9fc", "#e9eff6"], side: "#8f92a3" },
};
-/** Water: the animated surface and its pixel highlights. */
+/** Water: the animated surface, from the turquoise shallows to the open sea. */
export const WATER = {
+ abyss: "#1e5c9a",
deep: "#2f7fc4",
surface: "#44a0dd",
- ripple: "#8fd0f4",
- foam: "#d9f2ff",
+ shallow: "#72d3e2",
+ ripple: "#9fdcf6",
+ foam: "#e4f6ff",
};
/** Sky and light. NoToneMapping keeps these exact. */
@@ -72,12 +80,15 @@ export const BUILDING = {
door: "#e0893b",
hubAccent: "#2f6f8f",
hubGlass: "#bfe7ff",
+ /** The hub's forecourt pool: still water, lit from within. */
+ pool: "#86d9ea",
beacon: "#ffe08a",
beaconCore: "#fff6d5",
workshopRoof: "#d86a4a",
archiveDome: "#5aa7c8",
lighthouseStripe: "#e05a5a",
metal: "#8b8f9c",
+ buoy: "#e8563f",
};
export const NATURE = {
@@ -87,6 +98,17 @@ export const NATURE = {
canopyLight: "#93da7c",
bigCanopy: "#57b84f",
bigCanopyLight: "#8fdc7a",
+ /** Conifers of the forest and the alpine slopes. */
+ pineA: "#2f7f45",
+ pineB: "#3b9452",
+ pineLight: "#5aae64",
+ /** Palms of the cove. */
+ palmTrunk: "#a8794a",
+ palmLeaf: "#4fb254",
+ palmLeafLight: "#7ccf6c",
+ /** Boulders: two greys, warm and cool. */
+ boulderA: "#a19fab",
+ boulderB: "#7e7c8a",
hedge: "#3f8f3f",
hedgeLight: "#57a94f",
flower: "#ef8fb6",
@@ -109,3 +131,10 @@ export const LABEL = {
export function minimapColor(kind: TileKind): string {
return TILE_COLORS[kind].top[0];
}
+
+/** A hex colour scaled by `factor` (clamped), for the minimap's height shading. */
+export function shadeHex(hex: string, factor: number): string {
+ const n = parseInt(hex.slice(1), 16);
+ const ch = (shift: number) => Math.max(0, Math.min(255, Math.round(((n >> shift) & 255) * factor)));
+ return `rgb(${ch(16)},${ch(8)},${ch(0)})`;
+}