@threenative/terrain 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/editor/index.d.ts +63 -5
  2. package/dist/editor/index.js +323 -6
  3. package/dist/editor/server.d.ts +2 -2
  4. package/dist/editor/server.js +198 -4
  5. package/dist/editor/worker.d.ts +1 -1
  6. package/dist/editor/worker.js +199 -5
  7. package/dist/export.d.ts +1 -1
  8. package/dist/index.d.ts +146 -7
  9. package/dist/index.js +638 -39
  10. package/dist/kit.d.ts +3 -2
  11. package/dist/kit.js +198 -4
  12. package/dist/mcp/cook-child.js +1766 -125
  13. package/dist/mcp/server.js +728 -37
  14. package/dist/{server-C8Ydr_IM.d.ts → server-B5RdvEAC.d.ts} +1 -1
  15. package/dist/starter.d.ts +1 -1
  16. package/dist/starter.js +2 -1
  17. package/dist/{terrain-B3DkduPw.d.ts → terrain-CAEaW0mQ.d.ts} +1 -1
  18. package/dist/three.d.ts +1 -1
  19. package/dist/{types-CPYAc9vo.d.ts → types-BpH00qsx.d.ts} +10 -3
  20. package/dist/{world-package-B7KGYIou.d.ts → world-package-B8QgHjAQ.d.ts} +9 -50
  21. package/package.json +5 -5
  22. package/starter/alpine/biome.data.json +22 -2
  23. package/starter/alpine/world.ts +1 -1
  24. package/starter/coastal/README.md +5 -2
  25. package/starter/coastal/assets.json +2 -1
  26. package/starter/coastal/biome.data.json +23 -2
  27. package/starter/coastal/sea.ts +2 -50
  28. package/starter/desert/biome.data.json +12 -2
  29. package/starter/desert/world.ts +1 -1
  30. package/starter/forest/README.md +1 -1
  31. package/starter/forest/assets.json +2 -1
  32. package/starter/forest/biome.data.json +37 -14
  33. package/starter/forest/water.ts +9 -28
  34. package/starter/forest/world.ts +6 -1
  35. package/starter/tundra/biome.data.json +12 -2
  36. package/starter/tundra/water.ts +9 -28
  37. package/starter/tundra/world.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import { I as ITerrainState, b as ITerrainDocument, i as IPlacementOverride } from './types-CPYAc9vo.js';
2
+ import { I as ITerrainState, b as ITerrainDocument, i as IPlacementOverride } from './types-BpH00qsx.js';
3
3
 
4
4
  type IAssetKind = "model" | "image" | "environment";
5
5
  interface IAssetBounds {
package/dist/starter.d.ts CHANGED
@@ -2,7 +2,7 @@ import { IComputeDriven, ICtx } from '@threenative/core';
2
2
  import { IWorldPackage, WorldCells, Heightfield, IWorldCellsLoadOptions } from '@threenative/core/world';
3
3
  import { RigidBody3D, IPhysicsContext } from '@threenative/physics';
4
4
  import { Object3D, Material, Mesh, Texture, MeshStandardMaterial, Color } from 'three';
5
- import { i as IPlacementOverride } from './types-CPYAc9vo.js';
5
+ import { i as IPlacementOverride } from './types-BpH00qsx.js';
6
6
 
7
7
  type PlacementEdit = Omit<IPlacementOverride, "position" | "quaternion" | "scale" | "grounding"> & {
8
8
  readonly position: readonly [number, number, number];
package/dist/starter.js CHANGED
@@ -91,7 +91,8 @@ Object.freeze({
91
91
  "capacity",
92
92
  "erosion",
93
93
  "deposition",
94
- "evaporation"
94
+ "evaporation",
95
+ "rain"
95
96
  ],
96
97
  terrace: ["step", "softness", "strength", "offset"],
97
98
  materials: ["base", "rules", "reset"],
@@ -1,4 +1,4 @@
1
- import { L as Layer, O as OperationType, c as IMask, d as LayerParams, e as ITerrainConfig, b as ITerrainDocument, f as IEvaluateOptions, I as ITerrainState, g as ICopyRegionOptions } from './types-CPYAc9vo.js';
1
+ import { L as Layer, O as OperationType, c as IMask, d as LayerParams, e as ITerrainConfig, b as ITerrainDocument, f as IEvaluateOptions, I as ITerrainState, g as ICopyRegionOptions } from './types-BpH00qsx.js';
2
2
 
3
3
  type OperationOptions<T extends OperationType> = LayerParams[T] & {
4
4
  id?: string;
package/dist/three.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BufferGeometry } from 'three';
2
- import { h as IBakedMesh } from './types-CPYAc9vo.js';
2
+ import { h as IBakedMesh } from './types-BpH00qsx.js';
3
3
 
4
4
  /**
5
5
  * Converts baked arrays to ordinary geometry using the consumer's installed Three.js.
@@ -129,10 +129,13 @@ interface IStampParams extends IOperationBase {
129
129
  interface IPasteParams extends Omit<IStampParams, "shape" | "roughness" | "amplitude"> {
130
130
  }
131
131
  interface IErodeParams extends IBrushParams {
132
- readonly method?: "thermal" | "hydraulic" | "fluvial";
133
- /** Thermal passes, or fluvial time steps (default 40). */
132
+ readonly method?: "thermal" | "hydraulic" | "fluvial" | "gully" | "scree";
133
+ /** Erosion passes: thermal, scree, hydraulic, gully (default 200), or fluvial time steps (default 40). */
134
134
  readonly iterations?: number;
135
- /** Maximum stable slope in degrees; `fluvial` also enforces it as its landslide threshold. */
135
+ /**
136
+ * Maximum stable slope in degrees. `fluvial` enforces it as its landslide threshold, `scree`
137
+ * slides anything steeper (default 35; upstream's scree angle defaults to 90, which is "off").
138
+ */
136
139
  readonly talus?: number;
137
140
  /** `fluvial`: rock uplift at the highest input point, m/yr (default 1e-3). Relief scales with uplift / erodibility. */
138
141
  readonly uplift?: number;
@@ -142,14 +145,18 @@ interface IErodeParams extends IBrushParams {
142
145
  readonly timeStep?: number;
143
146
  /** `fluvial`: metres; rescales the eroded surface to this highest-minus-lowest. Omit to keep the natural relief. */
144
147
  readonly relief?: number;
148
+ /** `thermal`: share of the excess a pass moves (default 0.22). `scree`: the same, default 0.05. */
145
149
  readonly rate?: number;
146
150
  readonly droplets?: number;
147
151
  readonly maxSteps?: number;
148
152
  readonly inertia?: number;
153
+ /** `hydraulic`: sediment capacity (default 4). `gully`: transport capacity Kc (default 0.05). */
149
154
  readonly capacity?: number;
150
155
  readonly erosion?: number;
151
156
  readonly deposition?: number;
152
157
  readonly evaporation?: number;
158
+ /** `gully`: metres of rain per step (default 0.0005, upstream `rain`). */
159
+ readonly rain?: number;
153
160
  }
154
161
  interface ITerraceParams extends IOperationBase {
155
162
  readonly step?: number;
@@ -1,56 +1,15 @@
1
- import { I as ITerrainState } from './types-CPYAc9vo.js';
1
+ import * as _threenative_core_world from '@threenative/core/world';
2
+ import { I as ITerrainState } from './types-BpH00qsx.js';
2
3
 
3
4
  /** One streamed asset: its LOD0 model, its authored bounds and the levels it swaps to. */
4
- interface IWorldPackageAsset {
5
- readonly glb: string;
6
- readonly bounds: {
7
- readonly min: readonly [number, number, number];
8
- readonly max: readonly [number, number, number];
9
- };
10
- readonly lods?: readonly {
11
- readonly glb: string;
12
- readonly distance: number;
13
- /** Scene inside `glb`; a cooked species keeps every level in one file and selects by scene. */
14
- readonly scene?: string;
15
- }[];
16
- readonly maxDistance?: number;
17
- }
5
+ type IWorldPackageAsset = _threenative_core_world.IWorldAsset;
18
6
  /** One cell's contiguous run of placement records, eight float32 values each. */
19
- interface IWorldPackageRun {
20
- readonly asset: string;
21
- /** Record offset into the placement buffer, not a byte offset. */
22
- readonly offset: number;
23
- readonly count: number;
24
- }
25
- /** The `world.json` contract, declared here so this addon needs no `@threenative/core` import. */
26
- interface IWorldPackageManifest {
27
- readonly version: 1;
28
- readonly extent: {
29
- readonly minX: number;
30
- readonly minZ: number;
31
- readonly sizeX: number;
32
- readonly sizeZ: number;
33
- };
34
- readonly cellSize: number;
35
- readonly terrain: {
36
- readonly heightmap: string;
37
- readonly columns: number;
38
- readonly rows: number;
39
- readonly spacing: number;
40
- readonly heightMin: number;
41
- readonly heightMax: number;
42
- readonly layers?: Readonly<Record<string, string>>;
43
- };
44
- readonly assets: Readonly<Record<string, IWorldPackageAsset>>;
45
- readonly placements: string;
46
- /** Optional package-relative JSON array of placement IDs in binary record order. */
47
- readonly placementIds?: string;
48
- readonly cells: readonly {
49
- readonly x: number;
50
- readonly z: number;
51
- readonly runs: readonly IWorldPackageRun[];
52
- }[];
53
- }
7
+ type IWorldPackageRun = _threenative_core_world.IWorldRun;
8
+ /**
9
+ * The `world.json` contract. Its one declaration is core's (`IWorldPackage`), imported as a type so
10
+ * this addon still pulls nothing from core at runtime — a type import is erased before the bundle.
11
+ */
12
+ type IWorldPackageManifest = _threenative_core_world.IWorldPackage;
54
13
  /** The splat layout to copy into a terrain table: eight material masks in two RGBA8 planes. */
55
14
  interface IWorldPackageSplat {
56
15
  readonly size: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/terrain",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "license": "MIT",
5
5
  "description": "Headless terrain authoring — noise, erosion, sculpting, roads, rivers, material splats and scatter — evaluated into ordinary typed arrays and indexed Three.js geometry.",
6
6
  "keywords": [
@@ -83,12 +83,12 @@
83
83
  "typescript": "npm:@typescript/typescript6@6.0.2",
84
84
  "@typescript/native": "npm:typescript@7.0.2",
85
85
  "vite": "8.2.0",
86
- "@threenative/core": "0.3.12",
87
- "@threenative/physics": "0.3.12"
86
+ "@threenative/core": "0.3.13",
87
+ "@threenative/physics": "0.3.13"
88
88
  },
89
89
  "peerDependencies": {
90
- "@threenative/core": ">=0.3.12 <0.4.0",
91
- "@threenative/physics": ">=0.3.12 <0.4.0",
90
+ "@threenative/core": ">=0.3.13 <0.4.0",
91
+ "@threenative/physics": ">=0.3.13 <0.4.0",
92
92
  "three": ">=0.187.0 <0.188.0",
93
93
  "vite": ">=7.0.0 <9.0.0"
94
94
  },
@@ -13,7 +13,17 @@
13
13
  "seed": 466468,
14
14
  "attempts": 80000,
15
15
  "stoneRadius": 1.9,
16
- "clearings": [[850, -1000, 10]]
16
+ "clearings": [[850, -1000, 10]],
17
+ "understorey": {
18
+ "attempts": 14000,
19
+ "litter": 1,
20
+ "fern": 1,
21
+ "bush": 1,
22
+ "flower": 1,
23
+ "deadfall": 0,
24
+ "shade": 0,
25
+ "shadeRadius": 3
26
+ }
17
27
  },
18
28
  "foliage": [
19
29
  {
@@ -110,5 +120,15 @@
110
120
  "focus": [180, -190]
111
121
  },
112
122
  "species": ["boulder", "grass", "mountain", "riverrock", "sapling", "scree", "scrub", "spruce"],
113
- "aliases": ["alpine", "mountain", "mountains", "snowy", "peaks"]
123
+ "aliases": [
124
+ "alpine",
125
+ "mountain",
126
+ "mountains",
127
+ "snowy",
128
+ "peaks",
129
+ "alps",
130
+ "glacier",
131
+ "glaciers",
132
+ "snow"
133
+ ]
114
134
  }
@@ -48,7 +48,7 @@ const spec: IStarterWorldSpec<{ dispose(): void }> = {
48
48
  url,
49
49
  table: surface as unknown as ILoadTerrainSplatOptions["table"],
50
50
  }),
51
- lighting: { sky: "sky.hdr", lods: false, dress: dressProp },
51
+ lighting: { sky: "sky.hdr", lods: true, dress: dressProp },
52
52
  streaming: {
53
53
  ring: 5,
54
54
  impostors: false,
@@ -7,7 +7,7 @@ water. It is game source: once copied, every file is yours to edit.
7
7
  | File | What it decides |
8
8
  | --- | --- |
9
9
  | `recipe.json` | The terrain: the survey heightmap, erosion, the rock and sand surfaces, the ocean and the stands. |
10
- | `assets.json` | The fir model, its LOD distance and draw distance, and its bounds. |
10
+ | `assets.json` | The fir model, its LOD distance and draw distance, its bounds, and `"tree": true`: the art a landform cook plants the biome's own tree with. |
11
11
  | `surface.json` | The ground: the sand base, the rock layer, tiles, tints and blend thresholds. |
12
12
  | `bake.mjs` | Writes the world package and `world/water.json` from the three files above. |
13
13
  | `world.ts` | The runtime: streams the baked world, one heightfield for the ground, sphere colliders for the firs near the player, and the sky as the props' light. |
@@ -20,7 +20,10 @@ Art is CC0 (Poly Haven); provenance is in `@threenative/terrain/starter-credits.
20
20
 
21
21
  The preview's coastal stands use its licensed spruce models, which cannot ship in a kit. This kit
22
22
  plants the CC0 fir from the forest kit in their place, with the same count and spacing. The
23
- ocean is written to `water.json` as the one entry in `lakes`, with no `at`: the game draws it.
23
+ `"tree": true` mark on that row is what a `terrain_generate` landform cook reads, so the biome
24
+ file's own tree row grows the pack's fir instead of a treeless world; a kit with no such mark draws
25
+ its preset's ground alone. The ocean is written to `water.json` as the one entry in `lakes`, with no
26
+ `at`: the game draws it.
24
27
 
25
28
  ## Status
26
29
 
@@ -5,6 +5,7 @@
5
5
  "bounds": {
6
6
  "min": [-2.869, 0, -3.619],
7
7
  "max": [2.763, 14.078, 2.465]
8
- }
8
+ },
9
+ "tree": true
9
10
  }
10
11
  }
@@ -13,7 +13,17 @@
13
13
  "seed": 466468,
14
14
  "attempts": 80000,
15
15
  "stoneRadius": 1.9,
16
- "clearings": [[110, -35, 10], [185, 145, 10]]
16
+ "clearings": [[110, -35, 10], [185, 145, 10]],
17
+ "understorey": {
18
+ "attempts": 14000,
19
+ "litter": 1,
20
+ "fern": 1,
21
+ "bush": 1,
22
+ "flower": 1,
23
+ "deadfall": 0,
24
+ "shade": 0,
25
+ "shadeRadius": 3
26
+ }
17
27
  },
18
28
  "foliage": [
19
29
  {
@@ -131,5 +141,16 @@
131
141
  "scrub",
132
142
  "spruce"
133
143
  ],
134
- "aliases": ["coastal", "beach", "coast", "sea", "ocean"]
144
+ "aliases": [
145
+ "coastal",
146
+ "beach",
147
+ "coast",
148
+ "sea",
149
+ "ocean",
150
+ "tropical",
151
+ "shore",
152
+ "lagoon",
153
+ "fjord",
154
+ "fjords"
155
+ ]
135
156
  }
@@ -5,6 +5,7 @@
5
5
  // the depth tint. Change `SEA`, `SURFACE` or `OCEAN_LOOK` to change the sea; nothing in a package decides it.
6
6
  import type { ICtx, ISpectralOceanOptions } from "@threenative/core";
7
7
  import { SpectralOcean } from "@threenative/core";
8
+ import { shoreField } from "@threenative/core/world";
8
9
  import type { IPhysicsContext } from "@threenative/physics";
9
10
  import {
10
11
  Color,
@@ -130,56 +131,7 @@ function createSeaMesh(ocean: SpectralOcean, data: ICoastalSeaData): Mesh {
130
131
  (deepest, height) => Math.max(deepest, level - height),
131
132
  cell,
132
133
  );
133
- const distance = Float32Array.from(data.heights, (height) => (height >= level ? 0 : 1e4));
134
- const exposed = new Uint8Array(n * n);
135
- const queue: number[] = [];
136
- for (let i = 0; i < n * n; i++) {
137
- const row = Math.floor(i / n);
138
- const col = i % n;
139
- if (
140
- (row === 0 || col === 0 || row === n - 1 || col === n - 1) &&
141
- (data.heights[i] as number) < level - 2
142
- ) {
143
- exposed[i] = 1;
144
- queue.push(i);
145
- }
146
- if (col > 0) distance[i] = Math.min(distance[i] as number, (distance[i - 1] as number) + cell);
147
- if (row > 0) distance[i] = Math.min(distance[i] as number, (distance[i - n] as number) + cell);
148
- }
149
- for (let i = n * n - 1; i >= 0; i--) {
150
- if (i % n < n - 1)
151
- distance[i] = Math.min(distance[i] as number, (distance[i + 1] as number) + cell);
152
- if (i < n * (n - 1))
153
- distance[i] = Math.min(distance[i] as number, (distance[i + n] as number) + cell);
154
- }
155
- for (let head = 0; head < queue.length; head++) {
156
- const i = queue[head] as number;
157
- for (const next of [i % n > 0 ? i - 1 : -1, i % n < n - 1 ? i + 1 : -1, i - n, i + n]) {
158
- if (
159
- next < 0 ||
160
- next >= exposed.length ||
161
- exposed[next] ||
162
- (data.heights[next] as number) >= level - 2
163
- )
164
- continue;
165
- exposed[next] = 1;
166
- queue.push(next);
167
- }
168
- }
169
- // Carry exposure through the last eighteen metres of shallow water, never across a dry sand bar.
170
- for (let pass = 0; pass < Math.ceil(18 / cell); pass++) {
171
- const previous = exposed.slice();
172
- for (let i = 0; i < exposed.length; i++) {
173
- if ((data.heights[i] as number) >= level) continue;
174
- if (
175
- (i % n > 0 && previous[i - 1]) ||
176
- (i % n < n - 1 && previous[i + 1]) ||
177
- previous[i - n] ||
178
- previous[i + n]
179
- )
180
- exposed[i] = 1;
181
- }
182
- }
134
+ const { distance, exposed } = shoreField(data.heights, n, data.size, level);
183
135
  const pixels = new Uint16Array(n * n * 4);
184
136
  for (let i = 0; i < n * n; i++) {
185
137
  pixels[i * 4] = DataUtils.toHalfFloat(data.heights[i] as number);
@@ -13,7 +13,17 @@
13
13
  "seed": 466468,
14
14
  "attempts": 80000,
15
15
  "stoneRadius": 1.9,
16
- "clearings": [[195, 190, 10]]
16
+ "clearings": [[195, 190, 10]],
17
+ "understorey": {
18
+ "attempts": 14000,
19
+ "litter": 1,
20
+ "fern": 1,
21
+ "bush": 1,
22
+ "flower": 1,
23
+ "deadfall": 0,
24
+ "shade": 0,
25
+ "shadeRadius": 3
26
+ }
17
27
  },
18
28
  "foliage": [
19
29
  {
@@ -110,5 +120,5 @@
110
120
  "focus": [170, 180]
111
121
  },
112
122
  "species": ["boulder", "grass", "reveal", "riverrock", "scree", "scrub", "volcanic"],
113
- "aliases": ["desert", "dune", "dunes", "sand"]
123
+ "aliases": ["desert", "dune", "dunes", "sand", "canyon", "canyons", "arid", "badlands", "mesa"]
114
124
  }
@@ -48,7 +48,7 @@ const spec: IStarterWorldSpec<{ dispose(): void }> = {
48
48
  url,
49
49
  table: surface as unknown as ILoadTerrainSplatOptions["table"],
50
50
  }),
51
- lighting: { sky: "sky.hdr", lods: false, dress: dressProp },
51
+ lighting: { sky: "sky.hdr", lods: true, dress: dressProp },
52
52
  streaming: {
53
53
  ring: 5,
54
54
  impostors: false,
@@ -6,7 +6,7 @@ stands, young firs and boulder fields. It is game source: once copied, every fil
6
6
  | File | What it decides |
7
7
  | --- | --- |
8
8
  | `recipe.json` | The terrain and the scatter: seed, size, erosion, `count`, `minDistance`, slope limits, `scale`, masks. |
9
- | `assets.json` | Each prop's models, LOD distance, draw distance and bounds. |
9
+ | `assets.json` | Each prop's models, LOD distance, draw distance and bounds; `"tree": true` marks the art a landform cook plants the biome's own tree with. |
10
10
  | `surface.json` | The ground: texture layers, tiles, tints, far tiles and blend thresholds. |
11
11
  | `bake.mjs` | Writes the world package and `world/water.json` (the lake and river) from the three files above. |
12
12
  | `world.ts` | `addForest(ctx, follow)`: terrain, props, shadows, collision; `COLLIDERS` per prop. |
@@ -7,7 +7,8 @@
7
7
  "max": [2.763, 14.078, 2.465]
8
8
  },
9
9
  "mid": "fir_tree_01/fir-b-lod2.glb",
10
- "midDistance": 45
10
+ "midDistance": 45,
11
+ "tree": true
11
12
  },
12
13
  "boulder": {
13
14
  "near": "boulder_01/boulder-near.glb",
@@ -11,21 +11,31 @@
11
11
  "cover": {
12
12
  "ground": "wood",
13
13
  "seed": 466468,
14
- "attempts": 80000,
14
+ "attempts": 240000,
15
15
  "stoneRadius": 1.9,
16
- "clearings": [[165, -95, 10], [-145, -120, 10], [360, 200, 10]]
16
+ "clearings": [[165, -95, 10], [-145, -120, 10], [360, 200, 10]],
17
+ "understorey": {
18
+ "attempts": 120000,
19
+ "litter": 1.6,
20
+ "fern": 2.2,
21
+ "bush": 0.35,
22
+ "flower": 0.5,
23
+ "deadfall": 1.5,
24
+ "shade": 0.8,
25
+ "shadeRadius": 1.2
26
+ }
17
27
  },
18
28
  "foliage": [
19
29
  {
20
30
  "species": "spruce",
21
- "density": 3200,
31
+ "density": 7000,
22
32
  "slope": [0, 32],
23
33
  "height": null,
24
34
  "spacing": [3.2, 6.4],
25
35
  "collision": "trunk",
26
36
  "stands": true,
27
37
  "grassThreshold": 0.3,
28
- "standThreshold": 0.3,
38
+ "standThreshold": 0.16,
29
39
  "far": {
30
40
  "cell": 6,
31
41
  "spacing": [6.5, 13],
@@ -45,8 +55,8 @@
45
55
  "species": "grass",
46
56
  "density": 1,
47
57
  "slope": [0, 42],
48
- "height": [0, 66],
49
- "spacing": 1.2,
58
+ "height": null,
59
+ "spacing": 0.8,
50
60
  "slopeFalloff": 20,
51
61
  "heightFalloff": 28,
52
62
  "mats": null,
@@ -56,11 +66,11 @@
56
66
  "drift": {
57
67
  "field": "stand",
58
68
  "frequency": [3.1, 2.7],
59
- "offset": 0.65,
60
- "amplitude": 0.35,
69
+ "offset": 0.8,
70
+ "amplitude": 0.2,
61
71
  "band": [0, 1]
62
72
  },
63
- "bladeScale": 0.8,
73
+ "bladeScale": 1,
64
74
  "bladeJitter": 0.65,
65
75
  "scrubChance": 0.3,
66
76
  "scrubScale": 0.9,
@@ -83,13 +93,13 @@
83
93
  },
84
94
  {
85
95
  "layer": "treeline",
86
- "from": 6.5,
87
- "to": 10
96
+ "from": 11,
97
+ "to": 14
88
98
  },
89
99
  {
90
100
  "layer": "cap",
91
- "from": 14,
92
- "to": 17
101
+ "from": 17,
102
+ "to": 21
93
103
  },
94
104
  {
95
105
  "layer": "desertRock",
@@ -134,6 +144,7 @@
134
144
  "boulder",
135
145
  "bush",
136
146
  "cliff",
147
+ "deadfall",
137
148
  "fern",
138
149
  "grass",
139
150
  "litter",
@@ -146,5 +157,17 @@
146
157
  "scrub",
147
158
  "spruce"
148
159
  ],
149
- "aliases": ["forest", "pine", "pines", "woods", "woodland"]
160
+ "aliases": [
161
+ "forest",
162
+ "pine",
163
+ "pines",
164
+ "woods",
165
+ "woodland",
166
+ "spruce",
167
+ "fir",
168
+ "trees",
169
+ "jungle",
170
+ "rainforest",
171
+ "grove"
172
+ ]
150
173
  }
@@ -6,7 +6,7 @@
6
6
  // the shore are this file's to change: the kit owns its look.
7
7
  import type { ICtx } from "@threenative/core";
8
8
  import { WaterSurface3D } from "@threenative/core";
9
- import type { Heightfield } from "@threenative/core/world";
9
+ import { type Heightfield, riverRibbonGeometry } from "@threenative/core/world";
10
10
  import type { IPhysicsContext } from "@threenative/physics";
11
11
  import {
12
12
  BufferAttribute,
@@ -199,32 +199,6 @@ function lakeMaterial(surface: WaterSurface3D): MeshBasicNodeMaterial {
199
199
  return material;
200
200
  }
201
201
 
202
- /** A ribbon along the river's profile: each point's left and right edge across the course. */
203
- function riverGeometry(river: IRiver): BufferGeometry {
204
- const half = river.width / 2;
205
- const positions: number[] = [];
206
- const indices: number[] = [];
207
- river.points.forEach(([x, y, z], i) => {
208
- const before = river.points[Math.max(0, i - 1)] ?? [x, y, z];
209
- const after = river.points[Math.min(river.points.length - 1, i + 1)] ?? [x, y, z];
210
- const tx = after[0] - before[0];
211
- const tz = after[2] - before[2];
212
- const length = Math.hypot(tx, tz) || 1;
213
- const sx = (-tz / length) * half;
214
- const sz = (tx / length) * half;
215
- positions.push(x + sx, y + RIVER_LIFT, z + sz, x - sx, y + RIVER_LIFT, z - sz);
216
- if (i > 0) {
217
- const a = 2 * (i - 1);
218
- const b = 2 * i;
219
- indices.push(a, b, a + 1, b, b + 1, a + 1);
220
- }
221
- });
222
- const geometry = new BufferGeometry();
223
- geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
224
- geometry.setIndex(indices);
225
- return geometry;
226
- }
227
-
228
202
  /**
229
203
  * Adds the lake and river the bake wrote. `field` is the ground the props and the colliders stand on.
230
204
  * The caller owns the returned handle: its `dispose` removes both meshes and releases each surface.
@@ -258,7 +232,14 @@ export function addForestWater(
258
232
  opacity: 0.9,
259
233
  side: DoubleSide,
260
234
  });
261
- meshes.push(new Mesh(riverGeometry(river), material));
235
+ // One channel width across, out a half width past each end where the bed is carved; dry
236
+ // quads drop, so the water ends at the bank (core `riverRibbonGeometry`).
237
+ const mesh = new Mesh(
238
+ riverRibbonGeometry([river], field, { reach: 0.5, columns: 3 }),
239
+ material,
240
+ );
241
+ mesh.position.y = RIVER_LIFT;
242
+ meshes.push(mesh);
262
243
  }
263
244
  for (const mesh of meshes) ctx.add(mesh);
264
245
  return {
@@ -159,10 +159,15 @@ export const FOLIAGE_SKY_LIGHT = 1;
159
159
  /** 0 keeps each card's own normal, 1 points every normal straight out from the crown's axis. */
160
160
  export const CROWN_NORMAL_BEND = 0.7;
161
161
 
162
- function bendCrownNormals(geometry: BufferGeometry, bend: number): void {
162
+ export function bendCrownNormals(geometry: BufferGeometry, bend: number): void {
163
163
  const position = geometry.getAttribute("position");
164
164
  const normal = geometry.getAttribute("normal");
165
165
  if (position === undefined || normal === undefined) return;
166
+ // One cached model hands the same geometry to every visit; a second bend would lerp the bent
167
+ // normals again and the shading would drift. The original normals are gone after the first pass,
168
+ // so the geometry records the bend it already took.
169
+ if (geometry.userData.crownBend !== undefined) return;
170
+ geometry.userData.crownBend = bend;
166
171
  geometry.computeBoundingBox();
167
172
  const box = geometry.boundingBox as Box3;
168
173
  const midY = (box.min.y + box.max.y) / 2;
@@ -13,7 +13,17 @@
13
13
  "seed": 466468,
14
14
  "attempts": 80000,
15
15
  "stoneRadius": 1.9,
16
- "clearings": [[166, 180, 10]]
16
+ "clearings": [[166, 180, 10]],
17
+ "understorey": {
18
+ "attempts": 14000,
19
+ "litter": 1,
20
+ "fern": 1,
21
+ "bush": 1,
22
+ "flower": 1,
23
+ "deadfall": 0,
24
+ "shade": 0,
25
+ "shadeRadius": 3
26
+ }
17
27
  },
18
28
  "foliage": [
19
29
  {
@@ -127,5 +137,5 @@
127
137
  "focus": [150, 160]
128
138
  },
129
139
  "species": ["boulder", "bush", "riverrock", "sapling", "scree", "scrub"],
130
- "aliases": ["tundra", "arctic", "ice"]
140
+ "aliases": ["tundra", "arctic", "ice", "frozen", "permafrost", "glacial"]
131
141
  }