@threenative/terrain 0.1.11 → 0.1.12

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 (218) hide show
  1. package/README.md +1 -0
  2. package/dist/bake-DJ5cxg0C.d.ts +82 -0
  3. package/dist/editor/index.d.ts +4 -4
  4. package/dist/editor/index.js +1 -1
  5. package/dist/editor/server.d.ts +2 -2
  6. package/dist/editor/worker.d.ts +1 -1
  7. package/dist/editor/worker.js +1 -1
  8. package/dist/export.d.ts +1 -1
  9. package/dist/index.d.ts +51 -222
  10. package/dist/index.js +111 -2
  11. package/dist/kit-world.d.ts +107 -0
  12. package/dist/kit-world.js +5134 -0
  13. package/dist/kit.d.ts +21 -4
  14. package/dist/kit.js +19 -4
  15. package/dist/mcp/cook-child.js +9 -6
  16. package/dist/mcp/server.js +14 -4
  17. package/dist/prop-package-Dwz0EWoB.d.ts +141 -0
  18. package/dist/{server-B5RdvEAC.d.ts → server-LnFwY8sr.d.ts} +1 -1
  19. package/dist/starter.d.ts +1141 -6
  20. package/dist/starter.js +1999 -17
  21. package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
  22. package/dist/three.d.ts +1 -1
  23. package/dist/{types-BpH00qsx.d.ts → types-kpI0C4hW.d.ts} +1 -1
  24. package/dist/{world-package-B8QgHjAQ.d.ts → world-package-DqJC3-Nn.d.ts} +2 -2
  25. package/docs/authoring/new-environment.md +97 -0
  26. package/package.json +8 -8
  27. package/starter/alpine/README.md +22 -14
  28. package/starter/alpine/bake.mjs +14 -1
  29. package/starter/alpine/biome.data.json +187 -25
  30. package/starter/alpine/heightmap.r16 +0 -0
  31. package/starter/alpine/playerRig.ts +89 -0
  32. package/starter/alpine/recipe.json +169 -15
  33. package/starter/alpine/render/bakedFile.ts +17 -0
  34. package/starter/alpine/render/benchmark.ts +77 -0
  35. package/starter/alpine/render/biomeData.ts +14 -0
  36. package/starter/alpine/render/biomes.ts +687 -0
  37. package/starter/alpine/render/ground/cover.ts +565 -0
  38. package/starter/alpine/render/ground/horizon.ts +219 -0
  39. package/starter/alpine/render/ground/palette.d.ts +1 -0
  40. package/starter/alpine/render/ground/palette.js +11 -0
  41. package/starter/alpine/render/ground/scatter.ts +104 -0
  42. package/starter/alpine/render/ground/terrain.ts +1860 -0
  43. package/starter/alpine/render/kitAssets.ts +28 -0
  44. package/starter/alpine/render/loading.ts +354 -0
  45. package/starter/alpine/render/lookKnobs.ts +37 -0
  46. package/starter/alpine/render/orbitCamera.ts +155 -0
  47. package/starter/alpine/render/props/farForest.ts +94 -0
  48. package/starter/alpine/render/props/pack.ts +1114 -0
  49. package/starter/alpine/render/props/prepared.ts +225 -0
  50. package/starter/alpine/render/props/propMaterials.ts +1239 -0
  51. package/starter/alpine/render/props/propProgress.ts +2 -0
  52. package/starter/alpine/render/props/propWorld.ts +105 -0
  53. package/starter/alpine/render/props/props.ts +633 -0
  54. package/starter/alpine/render/props/spruce.ts +440 -0
  55. package/starter/alpine/render/sky/atmosphere.ts +329 -0
  56. package/starter/alpine/render/sky/sky.ts +382 -0
  57. package/starter/alpine/render/texturePreparation.ts +135 -0
  58. package/starter/alpine/render/water/river.ts +1132 -0
  59. package/starter/alpine/render/worldNames.ts +6 -0
  60. package/starter/alpine/scene.ts +715 -0
  61. package/starter/alpine/sceneProps.ts +561 -0
  62. package/starter/alpine/sceneState.ts +33 -0
  63. package/starter/alpine/world/terrainAssets.ts +145 -0
  64. package/starter/alpine/world/walkBand.ts +47 -0
  65. package/starter/alpine/world/water.ts +74 -0
  66. package/starter/alpine/worlds.ts +13 -0
  67. package/starter/coastal/README.md +26 -27
  68. package/starter/coastal/assets.json +10 -0
  69. package/starter/coastal/bake.mjs +14 -1
  70. package/starter/coastal/biome.data.json +18 -3
  71. package/starter/coastal/playerRig.ts +89 -0
  72. package/starter/coastal/recipe.json +220 -18
  73. package/starter/coastal/render/bakedFile.ts +17 -0
  74. package/starter/coastal/render/benchmark.ts +81 -0
  75. package/starter/coastal/render/biomeData.ts +14 -0
  76. package/starter/coastal/render/biomes.ts +678 -0
  77. package/starter/coastal/render/ground/cover.ts +565 -0
  78. package/starter/coastal/render/ground/horizon.ts +219 -0
  79. package/starter/coastal/render/ground/palette.d.ts +1 -0
  80. package/starter/coastal/render/ground/palette.js +11 -0
  81. package/starter/coastal/render/ground/scatter.ts +104 -0
  82. package/starter/coastal/render/ground/terrain.ts +1829 -0
  83. package/starter/coastal/render/kitAssets.ts +28 -0
  84. package/starter/coastal/render/loading.ts +354 -0
  85. package/starter/coastal/render/lookKnobs.ts +37 -0
  86. package/starter/coastal/render/orbitCamera.ts +155 -0
  87. package/starter/coastal/render/props/farForest.ts +94 -0
  88. package/starter/coastal/render/props/pack.ts +1109 -0
  89. package/starter/coastal/render/props/prepared.ts +225 -0
  90. package/starter/coastal/render/props/propMaterials.ts +1239 -0
  91. package/starter/coastal/render/props/propProgress.ts +2 -0
  92. package/starter/coastal/render/props/propWorld.ts +105 -0
  93. package/starter/coastal/render/props/props.ts +633 -0
  94. package/starter/coastal/render/props/spruce.ts +440 -0
  95. package/starter/coastal/render/sky/atmosphere.ts +329 -0
  96. package/starter/coastal/render/sky/sky.ts +382 -0
  97. package/starter/coastal/render/texturePreparation.ts +135 -0
  98. package/starter/coastal/render/water/ocean.ts +284 -0
  99. package/starter/coastal/render/water/river.ts +1132 -0
  100. package/starter/coastal/render/worldNames.ts +6 -0
  101. package/starter/coastal/scene.ts +740 -0
  102. package/starter/coastal/sceneProps.ts +559 -0
  103. package/starter/coastal/sceneState.ts +33 -0
  104. package/starter/coastal/world/terrainAssets.ts +151 -0
  105. package/starter/coastal/world/walkBand.ts +47 -0
  106. package/starter/coastal/world/water.ts +74 -0
  107. package/starter/coastal/worlds.ts +13 -0
  108. package/starter/desert/README.md +51 -25
  109. package/starter/desert/bake-flora.mjs +142 -0
  110. package/starter/desert/bake-rocks.mjs +291 -0
  111. package/starter/desert/bake.mjs +14 -1
  112. package/starter/desert/biome.data.json +24 -12
  113. package/starter/desert/playerRig.ts +89 -0
  114. package/starter/desert/recipe.json +63 -16
  115. package/starter/desert/render/bakedFile.ts +17 -0
  116. package/starter/desert/render/benchmark.ts +79 -0
  117. package/starter/desert/render/biomeData.ts +14 -0
  118. package/starter/desert/render/biomes.ts +660 -0
  119. package/starter/desert/render/ground/cover.ts +565 -0
  120. package/starter/desert/render/ground/debris.ts +136 -0
  121. package/starter/desert/render/ground/horizon.ts +219 -0
  122. package/starter/desert/render/ground/palette.d.ts +1 -0
  123. package/starter/desert/render/ground/palette.js +11 -0
  124. package/starter/desert/render/ground/scatter.ts +104 -0
  125. package/starter/desert/render/ground/terrain.ts +1854 -0
  126. package/starter/desert/render/kitAssets.ts +28 -0
  127. package/starter/desert/render/loading.ts +354 -0
  128. package/starter/desert/render/lookKnobs.ts +37 -0
  129. package/starter/desert/render/orbitCamera.ts +155 -0
  130. package/starter/desert/render/props/farForest.ts +96 -0
  131. package/starter/desert/render/props/formations.ts +630 -0
  132. package/starter/desert/render/props/pack.ts +1195 -0
  133. package/starter/desert/render/props/prepared.ts +225 -0
  134. package/starter/desert/render/props/propMaterials.ts +1255 -0
  135. package/starter/desert/render/props/propProgress.ts +2 -0
  136. package/starter/desert/render/props/propWorld.ts +105 -0
  137. package/starter/desert/render/props/props.ts +624 -0
  138. package/starter/desert/render/props/spruce.ts +440 -0
  139. package/starter/desert/render/sand.ts +581 -0
  140. package/starter/desert/render/sky/atmosphere.ts +329 -0
  141. package/starter/desert/render/sky/sky.ts +382 -0
  142. package/starter/desert/render/texturePreparation.ts +135 -0
  143. package/starter/desert/render/water/river.ts +1132 -0
  144. package/starter/desert/render/worldNames.ts +6 -0
  145. package/starter/desert/scene.ts +748 -0
  146. package/starter/desert/sceneProps.ts +562 -0
  147. package/starter/desert/sceneState.ts +33 -0
  148. package/starter/desert/world/terrainAssets.ts +162 -0
  149. package/starter/desert/world/walkBand.ts +47 -0
  150. package/starter/desert/world/water.ts +74 -0
  151. package/starter/desert/worlds.ts +13 -0
  152. package/starter/forest/README.md +8 -5
  153. package/starter/forest/bake.mjs +21 -413
  154. package/starter/forest/playerRig.ts +37 -171
  155. package/starter/forest/recipe.json +237 -47
  156. package/starter/forest/render/biomes.ts +2 -1
  157. package/starter/forest/render/ground/horizon.ts +4 -302
  158. package/starter/forest/render/ground/terrain.ts +14 -32
  159. package/starter/forest/render/kitAssets.ts +3 -2
  160. package/starter/forest/render/props/farForest.ts +2 -1
  161. package/starter/forest/render/props/pack.ts +4 -2
  162. package/starter/forest/render/props/prepared.ts +2 -1
  163. package/starter/forest/render/props/propProgress.ts +1 -11
  164. package/starter/forest/render/props/propWorld.ts +48 -662
  165. package/starter/forest/render/props/props.ts +64 -248
  166. package/starter/forest/render/sky/sky.ts +2 -1
  167. package/starter/forest/render/worldNames.ts +6 -2
  168. package/starter/forest/scene.ts +34 -25
  169. package/starter/forest/sceneProps.ts +2 -2
  170. package/starter/forest/sceneState.ts +5 -4
  171. package/starter/forest/surface.json +2 -2
  172. package/starter/forest/worlds.ts +3 -2
  173. package/starter/tundra/README.md +35 -16
  174. package/starter/tundra/bake.mjs +14 -1
  175. package/starter/tundra/biome.data.json +6 -6
  176. package/starter/tundra/playerRig.ts +89 -0
  177. package/starter/tundra/recipe.json +111 -110
  178. package/starter/tundra/render/bakedFile.ts +17 -0
  179. package/starter/tundra/render/benchmark.ts +79 -0
  180. package/starter/tundra/render/biomeData.ts +14 -0
  181. package/starter/tundra/render/biomes.ts +714 -0
  182. package/starter/tundra/render/ground/cover.ts +565 -0
  183. package/starter/tundra/render/ground/horizon.ts +219 -0
  184. package/starter/tundra/render/ground/palette.d.ts +1 -0
  185. package/starter/tundra/render/ground/palette.js +11 -0
  186. package/starter/tundra/render/ground/scatter.ts +104 -0
  187. package/starter/tundra/render/ground/terrain.ts +1874 -0
  188. package/starter/tundra/render/kitAssets.ts +28 -0
  189. package/starter/tundra/render/loading.ts +354 -0
  190. package/starter/tundra/render/lookKnobs.ts +37 -0
  191. package/starter/tundra/render/orbitCamera.ts +155 -0
  192. package/starter/tundra/render/props/farForest.ts +96 -0
  193. package/starter/tundra/render/props/pack.ts +1088 -0
  194. package/starter/tundra/render/props/prepared.ts +225 -0
  195. package/starter/tundra/render/props/propMaterials.ts +1247 -0
  196. package/starter/tundra/render/props/propProgress.ts +2 -0
  197. package/starter/tundra/render/props/propWorld.ts +105 -0
  198. package/starter/tundra/render/props/props.ts +624 -0
  199. package/starter/tundra/render/props/spruce.ts +440 -0
  200. package/starter/tundra/render/sky/atmosphere.ts +329 -0
  201. package/starter/tundra/render/sky/sky.ts +382 -0
  202. package/starter/tundra/render/texturePreparation.ts +135 -0
  203. package/starter/tundra/render/water/river.ts +1132 -0
  204. package/starter/tundra/render/worldNames.ts +6 -0
  205. package/starter/tundra/scene.ts +715 -0
  206. package/starter/tundra/sceneProps.ts +559 -0
  207. package/starter/tundra/sceneState.ts +33 -0
  208. package/starter/tundra/world/terrainAssets.ts +159 -0
  209. package/starter/tundra/world/walkBand.ts +47 -0
  210. package/starter/tundra/world/water.ts +74 -0
  211. package/starter/tundra/worlds.ts +13 -0
  212. package/starter-assets.json +4 -4
  213. package/starter-credits.json +613 -10
  214. package/starter/forest/diagnostics.ts +0 -1020
  215. package/starter/forest/render/sky/skyVisibility.ts +0 -121
  216. package/starter/forest/spawnGate.ts +0 -183
  217. package/starter/forest/viewStatistics.ts +0 -47
  218. package/starter/forest/world/streamedGround.ts +0 -139
@@ -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-BpH00qsx.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-kpI0C4hW.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-BpH00qsx.js';
2
+ import { i as IBakedMesh } from './types-kpI0C4hW.js';
3
3
 
4
4
  /**
5
5
  * Converts baked arrays to ordinary geometry using the consumer's installed Three.js.
@@ -499,4 +499,4 @@ interface ISplatPng {
499
499
  interface IHeightPngMetadata extends IHeightRange {
500
500
  }
501
501
 
502
- export type { ITerraceParams as $, IGradeParams as A, IGrid as B, IHeightData as C, IHeightPngMetadata as D, ExportKind as E, IHeightmapParams as F, ILayer as G, IMaterialRule as H, ITerrainState as I, IMaterialsParams as J, INoiseParams as K, Layer as L, MaterialId as M, IPaintParams as N, OperationType as O, IPasteParams as P, IRampParams as Q, IRiver as R, IRiverParams as S, IRoadParams as T, IScatterClear as U, IScatterParams as V, IScatterRule as W, ISculptParams as X, ISmoothParams as Y, ISplatPng as Z, IStampParams as _, IExportArchive as a, ITerrainInspection as a0, IWaterBody as a1, IWaterParams as a2, IWaterRule as a3, MaskSampler as a4, MaskType as a5, SplinePoint as a6, ITerrainDocument as b, IMask as c, LayerParams as d, ITerrainConfig as e, IEvaluateOptions as f, ICopyRegionOptions as g, IBakedMesh as h, IPlacementOverride as i, IPlacement as j, IErosionMaps as k, ISampledGrid as l, IBakeMeshOptions as m, IBakeTerrainOptions as n, IBakedTerrain as o, IDecodeHeightPngOptions as p, IDecodeRaw16Options as q, IHeightRange as r, IRaw16Options as s, IExportFile as t, IBiomeParams as u, IBrushParams as v, IClearParams as w, IDecodedHeightPng as x, IErodeParams as y, IFlattenParams as z };
502
+ export type { ITerraceParams as $, IGradeParams as A, IGrid as B, IHeightData as C, IHeightPngMetadata as D, ExportKind as E, IHeightmapParams as F, ILayer as G, IMaterialRule as H, ITerrainState as I, IMaterialsParams as J, INoiseParams as K, Layer as L, MaterialId as M, IPaintParams as N, OperationType as O, IPasteParams as P, IRampParams as Q, IRiver as R, IRiverParams as S, IRoadParams as T, IScatterClear as U, IScatterParams as V, IScatterRule as W, ISculptParams as X, ISmoothParams as Y, ISplatPng as Z, IStampParams as _, IExportArchive as a, ITerrainInspection as a0, IWaterBody as a1, IWaterParams as a2, IWaterRule as a3, MaskSampler as a4, MaskType as a5, SplinePoint as a6, ITerrainDocument as b, IMask as c, LayerParams as d, ITerrainConfig as e, IEvaluateOptions as f, ICopyRegionOptions as g, IPlacement as h, IBakedMesh as i, IBakeMeshOptions as j, IBakeTerrainOptions as k, IBakedTerrain as l, IPlacementOverride as m, IErosionMaps as n, ISampledGrid as o, IDecodeHeightPngOptions as p, IDecodeRaw16Options as q, IHeightRange as r, IRaw16Options as s, IExportFile as t, IBiomeParams as u, IBrushParams as v, IClearParams as w, IDecodedHeightPng as x, IErodeParams as y, IFlattenParams as z };
@@ -1,5 +1,5 @@
1
1
  import * as _threenative_core_world from '@threenative/core/world';
2
- import { I as ITerrainState } from './types-BpH00qsx.js';
2
+ import { I as ITerrainState } from './types-kpI0C4hW.js';
3
3
 
4
4
  /** One streamed asset: its LOD0 model, its authored bounds and the levels it swaps to. */
5
5
  type IWorldPackageAsset = _threenative_core_world.IWorldAsset;
@@ -50,4 +50,4 @@ interface IBakedWorldPackage {
50
50
  */
51
51
  declare function bakeWorldPackage(state: ITerrainState, options: IBakeWorldPackageOptions): IBakedWorldPackage;
52
52
 
53
- export { type IWorldPackageAsset as I, type IWorldPackageManifest as a, bakeWorldPackage as b, type IBakeWorldPackageOptions as c, type IBakedWorldPackage as d, type IWorldPackageRun as e };
53
+ export { type IWorldPackageManifest as I, type IWorldPackageRun as a, type IWorldPackageAsset as b, bakeWorldPackage as c, type IBakeWorldPackageOptions as d, type IBakedWorldPackage as e };
@@ -0,0 +1,97 @@
1
+ # Terrain: making a new environment from the forest kit
2
+
3
+ How to make a new playable environment (a desert, a taiga, a coast, a place on a map) on the
4
+ forest kit's stack: real ground, streamed props, far forest, a sky and a walking player. Read
5
+ [`../../README.md`](../../README.md) first. This file ships in the npm package.
6
+
7
+ The forest kit is one stack, and an environment is the data it reads. Do not write a new bake, a
8
+ new streaming loop or a new scene. Copy the kit, then change its data and its look.
9
+
10
+ ```mermaid
11
+ flowchart LR
12
+ recipe["recipe.json<br/>ground, water, far ring, art"] --> bake["bake.mjs<br/>one bakeKit call"]
13
+ biome["biome.data.json<br/>stands, understorey, cover"] --> bake
14
+ look["render/<br/>look row, palette, species pack"] --> bake
15
+ bake --> world["assets/terrain/&lt;name&gt;/world/"]
16
+ world --> scene["scene.ts<br/>ForestScene"]
17
+ look --> scene
18
+ ```
19
+
20
+ ## 1. Copy the kit and name the environment
21
+
22
+ ```sh
23
+ cp -r node_modules/@threenative/terrain/starter/forest src/terrain/taiga
24
+ npm install --save-dev @threenative/terrain tsx
25
+ ```
26
+
27
+ The name is in two places, and they must be equal:
28
+
29
+ - `recipe.json`: `world.name`. Every baked file is `world/<name>.*`.
30
+ - `render/worldNames.ts`: `WORLD`. The scene, the asset root (`terrain/<name>/`) and the look rows read it.
31
+
32
+ After you rename `WORLD`, the type checker names each look row that still has the old key.
33
+
34
+ ## 2. The ground: `recipe.json`
35
+
36
+ `recipe.recipe` is an ordinary terrain recipe ([Authoring a recipe](recipes.md)): the heightmap,
37
+ erosion, surfaces, roads, pads, rivers and lakes, in order.
38
+
39
+ - **A real place.** Call the MCP tool `terrain_generate` with `ground: { location: [lat, lon] }`, or
40
+ with a region word. Copy the heightmap layer of the `recipe.json` it returns into your recipe. A
41
+ heightmap layer takes inline `values` or a `raw16` file of 0.1 m steps.
42
+ - **A generated shape.** Use a `landform(kind, …)` heightmap ([Authoring a recipe](recipes.md)).
43
+ - **Surfaces.** The `materials` rules paint the splat channels. The ground shader draws what a
44
+ channel means (moss, litter, sand), so a look with no rule for a channel draws none of it.
45
+
46
+ The `world` row holds what the bake makes beyond the terrain:
47
+
48
+ | Field | What it decides |
49
+ | --- | --- |
50
+ | `name` | The baked file names. |
51
+ | `ground` | The base layer, the blended layers and their roughness, by material id. The maps come from the kit's `world/terrainAssets.ts`. |
52
+ | `farRing` | The ring past the playable square: a surveyed grid from the starter assets (`survey`), a generated `backdrop` on its relief, extra recipe `layers`, and an optional surveyed `massif`. Omit it for no ring. |
53
+ | `art` | The starter-asset paths copied into the output as named. |
54
+
55
+ ## 3. What grows: `biome.data.json`
56
+
57
+ The biome file lists the tree stands, understorey, rocks, deadfall and ground cover, with density,
58
+ slope, height and spacing for each. The forest's own file is the worked example; `validateBiome`
59
+ names every field (`engine_capability_detail validateBiome`). The bake validates the file before it
60
+ places anything, and an unknown field fails by name.
61
+
62
+ Every plant comes from one of two sources, in this order:
63
+
64
+ 1. A CC0 Poly Haven scan. Search with the asset MCP tool `polyhaven_search_assets`.
65
+ 2. A `bakeVegetation` preset from `@threenative/procedural-environment`. A dwarf or krummholz tree is a
66
+ `form` change on an existing preset, not a new species.
67
+
68
+ Name each species and its scan or preset in `render/props/pack.ts`. A species with neither source
69
+ becomes a new `@threenative/procedural-environment` preset. Do not model it by hand.
70
+
71
+ ## 4. The look: `render/`
72
+
73
+ The look is your source. Change it freely.
74
+
75
+ | File | What it decides |
76
+ | --- | --- |
77
+ | `render/biomes.ts` | The look row: sun, sky, haze, exposure, tints, snow and tree-line bands. |
78
+ | `render/ground/palette.js` | The baked ground's vertex colours. |
79
+ | `render/ground/terrain.ts` | The ground material, and `CANOPY_CROWN`: the crown radius that shades the ground under each tree. |
80
+ | `world/terrainAssets.ts` | Every ground map and its tile size. |
81
+ | `render/props/pack.ts`, `render/props/props.ts` | The species pack, its variants, draw reach and shadows. |
82
+ | `render/sky/`, `render/water/` | The sky, the atmosphere, the lake and the river surfaces. |
83
+
84
+ `bake.mjs` passes the palette, ground maps, canopy crowns and prop policy to `bakeKit` as `look`.
85
+ Edit those files, not the bake.
86
+
87
+ ## 5. Bake and play
88
+
89
+ ```sh
90
+ node src/terrain/taiga/bake.mjs
91
+ ```
92
+
93
+ The bake writes `assets/terrain/<name>/` (`--out <dir>` moves it). The same kit always bakes the
94
+ same bytes. Start the game on `ForestScene` from the kit's `scene.ts`, as the kit's `README.md` shows.
95
+
96
+ Before you call the environment done, play it from the spawn and read `TN_FRAME_BUDGET`,
97
+ `TN_SCENE_WARNING` and `TN_RENDER_PROJECTION`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/terrain",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
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": [
@@ -87,14 +87,14 @@
87
87
  "typescript": "npm:@typescript/typescript6@6.0.2",
88
88
  "@typescript/native": "npm:typescript@7.0.2",
89
89
  "vite": "8.2.0",
90
- "@threenative/core": "0.3.15",
91
- "@threenative/physics": "0.3.15",
92
- "@threenative/procedural-vegetation": "0.1.1"
90
+ "@threenative/core": "0.3.16",
91
+ "@threenative/procedural-environment": "0.1.2",
92
+ "@threenative/physics": "0.3.16"
93
93
  },
94
94
  "peerDependencies": {
95
- "@threenative/core": ">=0.3.15 <0.4.0",
96
- "@threenative/physics": ">=0.3.15 <0.4.0",
97
- "@threenative/procedural-vegetation": ">=0.1.1 <0.2.0",
95
+ "@threenative/core": ">=0.3.16 <0.4.0",
96
+ "@threenative/physics": ">=0.3.16 <0.4.0",
97
+ "@threenative/procedural-environment": ">=0.1.2 <0.2.0",
98
98
  "three": ">=0.187.0 <0.188.0",
99
99
  "vite": ">=7.0.0 <9.0.0"
100
100
  },
@@ -105,7 +105,7 @@
105
105
  "@threenative/physics": {
106
106
  "optional": true
107
107
  },
108
- "@threenative/procedural-vegetation": {
108
+ "@threenative/procedural-environment": {
109
109
  "optional": true
110
110
  },
111
111
  "vite": {
@@ -1,37 +1,45 @@
1
1
  # Alpine starter kit
2
2
 
3
- A 512 m alpine headwall on a real survey (USGS 1 m DEM, Longs Peak, Colorado), with hydraulic and
4
- thermal erosion, rock base, dirt on slopes, snow on the high steep ground and boulder scree. It is
3
+ A 512 m alpine pasture at Kleine Scheidegg, under the Eiger north face (swissALTI3D through
4
+ Mapterhorn), with hydraulic and thermal erosion, rock base, dirt on slopes, snow on the high ground
5
+ and boulder scree. The far ring is the same survey out to 5 km: the Eiger and the Mönch, real
6
+ heights on the square's own datum. It is
5
7
  game source: once copied, every file is yours to edit.
6
8
 
7
9
  | File | What it decides |
8
10
  | --- | --- |
9
11
  | `recipe.json` | The terrain: the survey heightmap, erosion, the rock, dirt and snow surfaces, and the scree. |
10
- | `heightmap.r16` | The real elevations the recipe's heightmap layer reads: 16-bit samples, decoded at the bake to 0.1 m steps. |
11
- | `biome.data.json` | The biome record the `terrain_generate` MCP tool cooks from. The bake does not read it. |
12
- | `assets.json` | The boulder model, its LOD distance and draw distance, and its bounds. |
13
- | `surface.json` | The ground: the rock base, the dirt and snow layers, tiles, tints and blend thresholds. |
14
- | `bake.mjs` | Writes the world package from `recipe.json`, `heightmap.r16`, `assets.json` and `surface.json`. |
15
- | `world.ts` | The runtime: streams the baked world, one heightfield for the ground, sphere colliders for the boulders near the player, and the sky as the props' light. |
16
- | `sky.ts` | The daylight: the sun, sky, fill, haze, exposure and tone curve. |
12
+ | `heightmap.r16` | The real elevations the recipe's heightmap layer reads: 16-bit samples, decoded at the bake to 0.1 m steps. `scripts/cook-kit-survey.ts` in `@threenative/terrain` cuts it and the far ring from any lat/lon. |
13
+ | `biome.data.json` | The biome record: tree stands, understorey, ground cover and their bands. The streamed bake places from it. |
14
+ | `assets.json` | The legacy cell package's boulder model, LOD distance, draw distance and bounds. |
15
+ | `surface.json` | The legacy cell package's ground table: rock base, dirt and snow layers, tiles, tints and thresholds. |
16
+ | `bake.mjs` | Runs `bakeKit` with this kit's look and writes the streamed world: the baked grid, its splat, the canopy and sky bytes, `horizon.json`, the prop package and the art. |
17
+ | `scene.ts` | The scene, `AlpineScene`, and `ALPINE_GAME`: the streamed ground, the far ring, the props, the sky, the water and the player rig. |
18
+ | `render/` | The look: the biome row, the ground material, the palette, the species pack, the sky and the water. |
19
+ | `world.ts`, `sky.ts` | The legacy cell-package loader and its daylight, kept until the streamed bake retires them here. |
17
20
 
18
21
  Art is CC0 (Poly Haven); provenance is in `@threenative/terrain/starter-credits.json`.
19
22
 
20
23
  ## Status
21
24
 
22
- The kit bakes and streams. The kit ships no scene: the game writes one. The terrain is too steep to
23
- stand on near its centre, so a scene picks its spawn from the loaded heightfield. The proof's scene
24
- rings the nearest boulder with gentle ground and a clear walk.
25
+ The kit is a source kit on the forest's stack: `scene.ts` streams the baked world, its far ring and
26
+ its props, and composes the player rig and diagnostics from `@threenative/terrain/starter`. The
27
+ terrain is too steep to stand on near its centre, so the scene picks its spawn from the loaded
28
+ heightfield.
25
29
 
26
30
  ## Steps
27
31
 
28
32
  1. Copy `node_modules/@threenative/terrain/starter/alpine` to `src/terrain/alpine`.
29
33
  2. Run `node src/terrain/alpine/bake.mjs --out assets/terrain/alpine` (needs `@threenative/terrain`
30
- as a devDependency). The same recipe always writes the same bytes.
31
- 3. In the scene, call `addAlpine(ctx, follow)` for the world and `alpineDaylight(follow)` for the light.
34
+ and `tsx` as devDependencies, because the bake reads this kit's TypeScript look). The same recipe
35
+ always writes the same bytes.
36
+ 3. Spread `ALPINE_GAME` into `defineGame` and register `AlpineScene`, as the forest kit's README shows.
32
37
 
33
38
  ## Edit at startup, without rebaking
34
39
 
40
+ > The streamed bake retires this path for the alpine kit: the ground table and the props now come
41
+ > from `render/`, and the section below still describes the legacy cell package.
42
+
35
43
  The copied `world.ts` loads its own `surface.json` as the ground table on every startup.
36
44
  Edit tints, tiling and blend thresholds there, or the material graph and prop dressing in
37
45
  `world.ts`, then reload. The package's `terrain-table.json` remains the baked default for
@@ -1,6 +1,19 @@
1
1
  // Run with [--assets <dir>] [--out <dir>]; defaults to installed assets and ./world.
2
+ // The alpine kit's look: its palette, its ground maps, its canopy rows and its prop policy.
2
3
  import { bakeKit } from "@threenative/terrain/kit";
4
+ import { register } from "tsx/esm/api";
5
+
6
+ register();
7
+ const { terrainPalette } = await import("./render/ground/palette.js");
8
+ const { GROUND_MAPS, GROUND_TILE } = await import("./world/terrainAssets.ts");
9
+ const { CANOPY_CROWN } = await import("./render/ground/terrain.ts");
10
+ const props = await import("./render/props/props.ts");
3
11
 
4
12
  await bakeKit(import.meta.url, {
5
- sky: "hdri/kloofendal_48d_partly_cloudy_1k.hdr",
13
+ look: {
14
+ palette: terrainPalette,
15
+ ground: { maps: GROUND_MAPS, tile: GROUND_TILE },
16
+ canopy: CANOPY_CROWN,
17
+ props,
18
+ },
6
19
  });
@@ -9,57 +9,198 @@
9
9
  "seed": 41,
10
10
  "stream": "ordered",
11
11
  "cover": {
12
- "ground": "crag",
12
+ "ground": "wood",
13
13
  "seed": 466468,
14
14
  "attempts": 80000,
15
15
  "stoneRadius": 1.9,
16
16
  "clearings": [[850, -1000, 10]],
17
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
18
+ "attempts": 120000,
19
+ "litter": 1.6,
20
+ "fern": 0.6,
21
+ "bush": 0.6,
22
+ "flower": 1.4,
23
+ "deadfall": 1.5,
24
+ "shade": 0.8,
25
+ "shadeRadius": 1.2
26
26
  }
27
27
  },
28
28
  "foliage": [
29
29
  {
30
30
  "species": "spruce",
31
- "density": 0,
32
- "slope": [0, 32],
33
- "height": [0, 52],
34
- "spacing": [3.4, 3.4],
31
+ "density": 600,
32
+ "slope": [0, 34],
33
+ "height": [0, 40],
34
+ "spacing": [3.6, 7],
35
35
  "collision": "trunk",
36
- "stands": false,
37
- "grassThreshold": 0.18,
38
- "standThreshold": 0.42,
39
- "far": null
36
+ "stands": true,
37
+ "grassThreshold": 0.3,
38
+ "standThreshold": 0.18,
39
+ "far": {
40
+ "cell": 6,
41
+ "spacing": [7, 14],
42
+ "spacingAt": [150, 1200],
43
+ "slope": [30, 44],
44
+ "meadowSlope": [10, 22],
45
+ "reach": 1800,
46
+ "treelineJitter": 25,
47
+ "stand": [0.18, 0.32],
48
+ "seed": 466561,
49
+ "impostor": 95
50
+ }
51
+ },
52
+ {
53
+ "species": "scotspine",
54
+ "density": 1400,
55
+ "slope": [0, 40],
56
+ "height": [0, 30],
57
+ "spacing": [3.4, 6.4],
58
+ "collision": "trunk",
59
+ "stands": true,
60
+ "grassThreshold": 0.26,
61
+ "standThreshold": 0.2,
62
+ "far": {
63
+ "cell": 6,
64
+ "spacing": [7, 14],
65
+ "spacingAt": [150, 1200],
66
+ "slope": [30, 44],
67
+ "meadowSlope": [10, 22],
68
+ "reach": 1900,
69
+ "treelineJitter": 25,
70
+ "stand": [0.18, 0.32],
71
+ "seed": 466563,
72
+ "impostor": 105
73
+ }
74
+ },
75
+ {
76
+ "species": "blackspruce",
77
+ "density": 900,
78
+ "slope": [0, 30],
79
+ "height": [0, 26],
80
+ "spacing": [4.2, 8.2],
81
+ "collision": "trunk",
82
+ "stands": true,
83
+ "grassThreshold": 0.24,
84
+ "standThreshold": 0.22,
85
+ "far": {
86
+ "cell": 6,
87
+ "spacing": [7, 14],
88
+ "spacingAt": [150, 1200],
89
+ "slope": [30, 44],
90
+ "meadowSlope": [10, 22],
91
+ "reach": 1500,
92
+ "treelineJitter": 25,
93
+ "stand": [0.18, 0.32],
94
+ "seed": 466567,
95
+ "impostor": 85
96
+ }
40
97
  }
41
98
  ],
42
99
  "grass": [
43
100
  {
44
- "species": "grass",
45
- "density": 0,
46
- "slope": [0, 0],
101
+ "species": "tundragrass",
102
+ "density": 0.95,
103
+ "slope": [0, 42],
104
+ "height": null,
105
+ "spacing": 0.9,
106
+ "slopeFalloff": 0,
107
+ "heightFalloff": 28,
108
+ "mats": null,
109
+ "waterMargin": 7.5,
110
+ "beach": null,
111
+ "detailSpacing": 0.5,
112
+ "drift": {
113
+ "field": "stand",
114
+ "frequency": [2.1, 2.4],
115
+ "offset": 0,
116
+ "amplitude": 1,
117
+ "band": [0.25, 0.55]
118
+ },
119
+ "bladeScale": 0.5,
120
+ "bladeJitter": 0.5,
121
+ "scrubChance": 0.3,
122
+ "scrubScale": 0.9,
123
+ "scrubJitter": 0.6,
124
+ "scrubBush": false,
125
+ "shoreGround": false,
126
+ "cobbledBed": false
127
+ },
128
+ {
129
+ "species": "tussock",
130
+ "density": 0.6,
131
+ "slope": [0, 42],
47
132
  "height": null,
48
- "spacing": 3.5,
133
+ "spacing": 1.3,
49
134
  "slopeFalloff": 0,
50
135
  "heightFalloff": 28,
51
136
  "mats": null,
52
137
  "waterMargin": 7.5,
53
138
  "beach": null,
54
- "detailSpacing": 0.6,
139
+ "detailSpacing": 0.5,
55
140
  "drift": {
56
141
  "field": "stand",
57
142
  "frequency": [2.1, 2.4],
58
143
  "offset": 0,
59
144
  "amplitude": 1,
60
- "band": [0.3, 0.45]
145
+ "band": [0.2, 0.5]
61
146
  },
62
- "bladeScale": 0.55,
147
+ "bladeScale": 0.7,
148
+ "bladeJitter": 0.5,
149
+ "scrubChance": 0.3,
150
+ "scrubScale": 0.9,
151
+ "scrubJitter": 0.6,
152
+ "scrubBush": false,
153
+ "shoreGround": false,
154
+ "cobbledBed": false
155
+ },
156
+ {
157
+ "species": "fireweed",
158
+ "density": 0.22,
159
+ "slope": [0, 42],
160
+ "height": null,
161
+ "spacing": 1.6,
162
+ "slopeFalloff": 0,
163
+ "heightFalloff": 28,
164
+ "mats": null,
165
+ "waterMargin": 7.5,
166
+ "beach": null,
167
+ "detailSpacing": 0.5,
168
+ "drift": {
169
+ "field": "stand",
170
+ "frequency": [2.1, 2.4],
171
+ "offset": 0,
172
+ "amplitude": 1,
173
+ "band": [0.3, 0.6]
174
+ },
175
+ "bladeScale": 0.8,
176
+ "bladeJitter": 0.5,
177
+ "scrubChance": 0.3,
178
+ "scrubScale": 0.9,
179
+ "scrubJitter": 0.6,
180
+ "scrubBush": false,
181
+ "shoreGround": false,
182
+ "cobbledBed": false
183
+ },
184
+ {
185
+ "species": "blueberry",
186
+ "density": 0.3,
187
+ "slope": [0, 42],
188
+ "height": null,
189
+ "spacing": 1.2,
190
+ "slopeFalloff": 0,
191
+ "heightFalloff": 28,
192
+ "mats": null,
193
+ "waterMargin": 7.5,
194
+ "beach": null,
195
+ "detailSpacing": 0.5,
196
+ "drift": {
197
+ "field": "stand",
198
+ "frequency": [2.1, 2.4],
199
+ "offset": 0,
200
+ "amplitude": 1,
201
+ "band": [0.35, 0.65]
202
+ },
203
+ "bladeScale": 0.6,
63
204
  "bladeJitter": 0.5,
64
205
  "scrubChance": 0.3,
65
206
  "scrubScale": 0.9,
@@ -119,7 +260,28 @@
119
260
  "cameraOffset": [28, 24, 42],
120
261
  "focus": [180, -190]
121
262
  },
122
- "species": ["boulder", "grass", "mountain", "riverrock", "sapling", "scree", "scrub", "spruce"],
263
+ "species": [
264
+ "blackspruce",
265
+ "blueberry",
266
+ "boulder",
267
+ "bush",
268
+ "deadfall",
269
+ "fern",
270
+ "fireweed",
271
+ "grass",
272
+ "litter",
273
+ "mountain",
274
+ "poppy",
275
+ "riverrock",
276
+ "rock",
277
+ "sapling",
278
+ "scotspine",
279
+ "scree",
280
+ "scrub",
281
+ "spruce",
282
+ "tundragrass",
283
+ "tussock"
284
+ ],
123
285
  "aliases": [
124
286
  "alpine",
125
287
  "mountain",
Binary file
@@ -0,0 +1,89 @@
1
+ import type { Heightfield } from "@threenative/core/world";
2
+ import {
3
+ type IMannequin,
4
+ type IPlayerRig,
5
+ type PlayerWallProbe,
6
+ createPlayerRig as createRig,
7
+ } from "@threenative/terrain/starter";
8
+ import { type AnimationClip, Vector3 } from "three";
9
+ import { CAMERA_RIG, type WallProbe, createOrbitCamera } from "./render/orbitCamera.js";
10
+ import { SIGHT_RADIUS, sightLine } from "./render/props/pack.js";
11
+ import type { TerrainCtx } from "./sceneState.js";
12
+
13
+ export type { IMannequin, IPlayerRig };
14
+ export type { WallProbe };
15
+
16
+ /** The starter kit's mannequin (Quaternius Universal Animation Library, CC0) and its clips. */
17
+ const CLIPS = {
18
+ idle: "Idle_Loop",
19
+ walk: "Walk_Loop",
20
+ run: "Jog_Fwd_Loop",
21
+ fall: "Jump_Loop",
22
+ swim: "Swim_Fwd_Loop",
23
+ tread: "Swim_Idle_Loop",
24
+ } as const;
25
+ /** Ground speeds in m/s: the walk clip's pace, the jog, and the Shift sprint. */
26
+ const STRIDE = 1.8;
27
+ const JOG = 6;
28
+ const SPRINT = 9;
29
+
30
+ export interface IPlayerRigOptions {
31
+ readonly world: string;
32
+ /** The player's launch point, in world metres. */
33
+ readonly at: readonly [number, number];
34
+ /** Where the launch camera stands relative to the player: above the ground under the spawn. */
35
+ readonly cameraOffset: readonly [number, number, number];
36
+ /** The ground the spawn stands on: the launch pose is measured from it, not guessed. */
37
+ readonly field: Heightfield;
38
+ readonly mannequin: IMannequin;
39
+ /** The rig's two swim clips, which the mannequin's own clips do not carry. */
40
+ readonly swimClips: readonly AnimationClip[];
41
+ /** A staged world streams its own ground, so the player walks only while the player view draws. */
42
+ readonly staged: boolean;
43
+ /** A vista look frames the player from a fixed aim instead of the orbit camera. */
44
+ readonly vista: boolean;
45
+ /** Centres the sun's shadow pages, or clears them when no player framing draws. */
46
+ readonly focusShadows: (at: Vector3 | undefined) => void;
47
+ /** The horizon seam the scene draws under the player, for the scene picker's report. */
48
+ readonly horizon: () => unknown;
49
+ }
50
+
51
+ /**
52
+ * The player: the package's capsule and clip state machine, this kit's mannequin, gait data and
53
+ * orbit camera. The follow camera and the wall probe stay here because the arm's framing and the
54
+ * sight line are look decisions of this game.
55
+ */
56
+ export function createPlayerRig(ctx: TerrainCtx, options: IPlayerRigOptions): IPlayerRig {
57
+ const { at, cameraOffset, field, focusShadows, horizon, mannequin, staged, swimClips, vista } =
58
+ options;
59
+ // The terrain and the prop colliders are the camera's walls; both answer on the kit's ground lens.
60
+ const along = new Vector3();
61
+ const probe: WallProbe = (from, to) =>
62
+ along.subVectors(to, from).lengthSq() < 1e-8
63
+ ? undefined
64
+ : ctx.physics.directSpaceState.intersectRay({
65
+ ...(staged ? {} : { collisionMask: 4 }),
66
+ from,
67
+ to,
68
+ })?.distance;
69
+ const camera = createOrbitCamera(ctx.camera);
70
+ return createRig({
71
+ ctx,
72
+ at,
73
+ field,
74
+ mannequin,
75
+ clips: CLIPS,
76
+ swimClips,
77
+ cameraOffset,
78
+ collisionMask: staged ? undefined : 4,
79
+ gait: { stride: STRIDE, run: JOG, sprint: SPRINT },
80
+ camera,
81
+ probe: probe as PlayerWallProbe,
82
+ following: () => !vista && ctx.state.getState().view === "player",
83
+ aimHeight: CAMERA_RIG.aimHeight,
84
+ // The vision line the camera aims: the player's own eye line at the prop pack's sight radius.
85
+ sight: { aim: sightLine.aim, radius: sightLine.radius, radiusValue: SIGHT_RADIUS },
86
+ focusShadows,
87
+ horizon,
88
+ });
89
+ }