@threenative/terrain 0.1.9 → 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 (243) hide show
  1. package/README.md +40 -59
  2. package/THIRD_PARTY_NOTICES.md +2 -1
  3. package/dist/bake-DJ5cxg0C.d.ts +82 -0
  4. package/dist/editor/index.d.ts +4 -4
  5. package/dist/editor/index.js +130 -128
  6. package/dist/editor/server.d.ts +2 -2
  7. package/dist/editor/server.js +38 -35
  8. package/dist/editor/worker.d.ts +1 -1
  9. package/dist/editor/worker.js +101 -101
  10. package/dist/export.d.ts +1 -1
  11. package/dist/index.d.ts +156 -273
  12. package/dist/index.js +562 -378
  13. package/dist/kit-world.d.ts +107 -0
  14. package/dist/kit-world.js +5134 -0
  15. package/dist/kit.d.ts +21 -4
  16. package/dist/kit.js +337 -223
  17. package/dist/mcp/cook-child.js +1963 -1543
  18. package/dist/mcp/server.js +716 -429
  19. package/dist/prop-package-Dwz0EWoB.d.ts +141 -0
  20. package/dist/{server-B5RdvEAC.d.ts → server-LnFwY8sr.d.ts} +1 -1
  21. package/dist/starter.d.ts +1142 -7
  22. package/dist/starter.js +2102 -120
  23. package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
  24. package/dist/three.d.ts +1 -1
  25. package/dist/three.js +1 -1
  26. package/dist/{types-BpH00qsx.d.ts → types-kpI0C4hW.d.ts} +1 -1
  27. package/dist/{world-package-B8QgHjAQ.d.ts → world-package-DqJC3-Nn.d.ts} +2 -2
  28. package/docs/authoring/editor.md +73 -0
  29. package/docs/authoring/new-environment.md +97 -0
  30. package/docs/authoring/recipes.md +97 -0
  31. package/docs/authoring/world-export.md +66 -0
  32. package/package.json +24 -8
  33. package/starter/alpine/README.md +22 -12
  34. package/starter/alpine/bake.mjs +14 -1
  35. package/starter/alpine/biome.data.json +187 -25
  36. package/starter/alpine/heightmap.r16 +0 -0
  37. package/starter/alpine/playerRig.ts +89 -0
  38. package/starter/alpine/recipe.json +169 -15
  39. package/starter/alpine/render/bakedFile.ts +17 -0
  40. package/starter/alpine/render/benchmark.ts +77 -0
  41. package/starter/alpine/render/biomeData.ts +14 -0
  42. package/starter/alpine/render/biomes.ts +687 -0
  43. package/starter/alpine/render/ground/cover.ts +565 -0
  44. package/starter/alpine/render/ground/horizon.ts +219 -0
  45. package/starter/alpine/render/ground/palette.d.ts +1 -0
  46. package/starter/alpine/render/ground/palette.js +11 -0
  47. package/starter/alpine/render/ground/scatter.ts +104 -0
  48. package/starter/alpine/render/ground/terrain.ts +1860 -0
  49. package/starter/alpine/render/kitAssets.ts +28 -0
  50. package/starter/alpine/render/loading.ts +354 -0
  51. package/starter/alpine/render/lookKnobs.ts +37 -0
  52. package/starter/alpine/render/orbitCamera.ts +155 -0
  53. package/starter/alpine/render/props/farForest.ts +94 -0
  54. package/starter/alpine/render/props/pack.ts +1114 -0
  55. package/starter/alpine/render/props/prepared.ts +225 -0
  56. package/starter/alpine/render/props/propMaterials.ts +1239 -0
  57. package/starter/alpine/render/props/propProgress.ts +2 -0
  58. package/starter/alpine/render/props/propWorld.ts +105 -0
  59. package/starter/alpine/render/props/props.ts +633 -0
  60. package/starter/alpine/render/props/spruce.ts +440 -0
  61. package/starter/alpine/render/sky/atmosphere.ts +329 -0
  62. package/starter/alpine/render/sky/sky.ts +382 -0
  63. package/starter/alpine/render/texturePreparation.ts +135 -0
  64. package/starter/alpine/render/water/river.ts +1132 -0
  65. package/starter/alpine/render/worldNames.ts +6 -0
  66. package/starter/alpine/scene.ts +715 -0
  67. package/starter/alpine/sceneProps.ts +561 -0
  68. package/starter/alpine/sceneState.ts +33 -0
  69. package/starter/alpine/world/terrainAssets.ts +145 -0
  70. package/starter/alpine/world/walkBand.ts +47 -0
  71. package/starter/alpine/world/water.ts +74 -0
  72. package/starter/alpine/worlds.ts +13 -0
  73. package/starter/arbor/wind.ts +84 -0
  74. package/starter/coastal/README.md +26 -25
  75. package/starter/coastal/assets.json +10 -0
  76. package/starter/coastal/bake.mjs +14 -1
  77. package/starter/coastal/biome.data.json +18 -3
  78. package/starter/coastal/playerRig.ts +89 -0
  79. package/starter/coastal/recipe.json +220 -18
  80. package/starter/coastal/render/bakedFile.ts +17 -0
  81. package/starter/coastal/render/benchmark.ts +81 -0
  82. package/starter/coastal/render/biomeData.ts +14 -0
  83. package/starter/coastal/render/biomes.ts +678 -0
  84. package/starter/coastal/render/ground/cover.ts +565 -0
  85. package/starter/coastal/render/ground/horizon.ts +219 -0
  86. package/starter/coastal/render/ground/palette.d.ts +1 -0
  87. package/starter/coastal/render/ground/palette.js +11 -0
  88. package/starter/coastal/render/ground/scatter.ts +104 -0
  89. package/starter/coastal/render/ground/terrain.ts +1829 -0
  90. package/starter/coastal/render/kitAssets.ts +28 -0
  91. package/starter/coastal/render/loading.ts +354 -0
  92. package/starter/coastal/render/lookKnobs.ts +37 -0
  93. package/starter/coastal/render/orbitCamera.ts +155 -0
  94. package/starter/coastal/render/props/farForest.ts +94 -0
  95. package/starter/coastal/render/props/pack.ts +1109 -0
  96. package/starter/coastal/render/props/prepared.ts +225 -0
  97. package/starter/coastal/render/props/propMaterials.ts +1239 -0
  98. package/starter/coastal/render/props/propProgress.ts +2 -0
  99. package/starter/coastal/render/props/propWorld.ts +105 -0
  100. package/starter/coastal/render/props/props.ts +633 -0
  101. package/starter/coastal/render/props/spruce.ts +440 -0
  102. package/starter/coastal/render/sky/atmosphere.ts +329 -0
  103. package/starter/coastal/render/sky/sky.ts +382 -0
  104. package/starter/coastal/render/texturePreparation.ts +135 -0
  105. package/starter/coastal/render/water/ocean.ts +284 -0
  106. package/starter/coastal/render/water/river.ts +1132 -0
  107. package/starter/coastal/render/worldNames.ts +6 -0
  108. package/starter/coastal/scene.ts +740 -0
  109. package/starter/coastal/sceneProps.ts +559 -0
  110. package/starter/coastal/sceneState.ts +33 -0
  111. package/starter/coastal/world/terrainAssets.ts +151 -0
  112. package/starter/coastal/world/walkBand.ts +47 -0
  113. package/starter/coastal/world/water.ts +74 -0
  114. package/starter/coastal/worlds.ts +13 -0
  115. package/starter/desert/README.md +51 -23
  116. package/starter/desert/bake-flora.mjs +142 -0
  117. package/starter/desert/bake-rocks.mjs +291 -0
  118. package/starter/desert/bake.mjs +14 -1
  119. package/starter/desert/biome.data.json +24 -12
  120. package/starter/desert/playerRig.ts +89 -0
  121. package/starter/desert/recipe.json +63 -16
  122. package/starter/desert/render/bakedFile.ts +17 -0
  123. package/starter/desert/render/benchmark.ts +79 -0
  124. package/starter/desert/render/biomeData.ts +14 -0
  125. package/starter/desert/render/biomes.ts +660 -0
  126. package/starter/desert/render/ground/cover.ts +565 -0
  127. package/starter/desert/render/ground/debris.ts +136 -0
  128. package/starter/desert/render/ground/horizon.ts +219 -0
  129. package/starter/desert/render/ground/palette.d.ts +1 -0
  130. package/starter/desert/render/ground/palette.js +11 -0
  131. package/starter/desert/render/ground/scatter.ts +104 -0
  132. package/starter/desert/render/ground/terrain.ts +1854 -0
  133. package/starter/desert/render/kitAssets.ts +28 -0
  134. package/starter/desert/render/loading.ts +354 -0
  135. package/starter/desert/render/lookKnobs.ts +37 -0
  136. package/starter/desert/render/orbitCamera.ts +155 -0
  137. package/starter/desert/render/props/farForest.ts +96 -0
  138. package/starter/desert/render/props/formations.ts +630 -0
  139. package/starter/desert/render/props/pack.ts +1195 -0
  140. package/starter/desert/render/props/prepared.ts +225 -0
  141. package/starter/desert/render/props/propMaterials.ts +1255 -0
  142. package/starter/desert/render/props/propProgress.ts +2 -0
  143. package/starter/desert/render/props/propWorld.ts +105 -0
  144. package/starter/desert/render/props/props.ts +624 -0
  145. package/starter/desert/render/props/spruce.ts +440 -0
  146. package/starter/desert/render/sand.ts +581 -0
  147. package/starter/desert/render/sky/atmosphere.ts +329 -0
  148. package/starter/desert/render/sky/sky.ts +382 -0
  149. package/starter/desert/render/texturePreparation.ts +135 -0
  150. package/starter/desert/render/water/river.ts +1132 -0
  151. package/starter/desert/render/worldNames.ts +6 -0
  152. package/starter/desert/scene.ts +748 -0
  153. package/starter/desert/sceneProps.ts +562 -0
  154. package/starter/desert/sceneState.ts +33 -0
  155. package/starter/desert/world/terrainAssets.ts +162 -0
  156. package/starter/desert/world/walkBand.ts +47 -0
  157. package/starter/desert/world/water.ts +74 -0
  158. package/starter/desert/worlds.ts +13 -0
  159. package/starter/forest/README.md +59 -116
  160. package/starter/forest/assets.json +14 -14
  161. package/starter/forest/bake.mjs +26 -4
  162. package/starter/forest/playerRig.ts +89 -0
  163. package/starter/forest/recipe.json +233 -43
  164. package/starter/forest/render/bakedFile.ts +17 -0
  165. package/starter/forest/render/benchmark.ts +77 -0
  166. package/starter/forest/render/biomeData.ts +14 -0
  167. package/starter/forest/render/biomes.ts +637 -0
  168. package/starter/forest/render/ground/cover.ts +565 -0
  169. package/starter/forest/render/ground/horizon.ts +219 -0
  170. package/starter/forest/render/ground/palette.d.ts +1 -0
  171. package/starter/forest/render/ground/palette.js +11 -0
  172. package/starter/forest/render/ground/scatter.ts +104 -0
  173. package/starter/forest/render/ground/terrain.ts +1796 -0
  174. package/starter/forest/render/kitAssets.ts +28 -0
  175. package/starter/forest/render/loading.ts +354 -0
  176. package/starter/forest/render/lookKnobs.ts +37 -0
  177. package/starter/forest/render/orbitCamera.ts +155 -0
  178. package/starter/forest/render/props/farForest.ts +94 -0
  179. package/starter/forest/render/props/pack.ts +1078 -0
  180. package/starter/forest/render/props/prepared.ts +226 -0
  181. package/starter/forest/render/props/propMaterials.ts +1247 -0
  182. package/starter/forest/render/props/propProgress.ts +2 -0
  183. package/starter/forest/render/props/propWorld.ts +105 -0
  184. package/starter/forest/render/props/props.ts +624 -0
  185. package/starter/forest/render/props/spruce.ts +440 -0
  186. package/starter/forest/render/sky/atmosphere.ts +329 -0
  187. package/starter/forest/render/sky/sky.ts +382 -0
  188. package/starter/forest/render/texturePreparation.ts +135 -0
  189. package/starter/forest/render/water/river.ts +1132 -0
  190. package/starter/forest/render/worldNames.ts +6 -0
  191. package/starter/forest/scene.ts +715 -0
  192. package/starter/forest/sceneProps.ts +559 -0
  193. package/starter/forest/sceneState.ts +33 -0
  194. package/starter/forest/surface.json +2 -2
  195. package/starter/forest/world/terrainAssets.ts +158 -0
  196. package/starter/forest/world/walkBand.ts +47 -0
  197. package/starter/forest/world/water.ts +74 -0
  198. package/starter/forest/worlds.ts +13 -0
  199. package/starter/tundra/README.md +35 -14
  200. package/starter/tundra/bake.mjs +14 -1
  201. package/starter/tundra/biome.data.json +6 -6
  202. package/starter/tundra/playerRig.ts +89 -0
  203. package/starter/tundra/recipe.json +111 -110
  204. package/starter/tundra/render/bakedFile.ts +17 -0
  205. package/starter/tundra/render/benchmark.ts +79 -0
  206. package/starter/tundra/render/biomeData.ts +14 -0
  207. package/starter/tundra/render/biomes.ts +714 -0
  208. package/starter/tundra/render/ground/cover.ts +565 -0
  209. package/starter/tundra/render/ground/horizon.ts +219 -0
  210. package/starter/tundra/render/ground/palette.d.ts +1 -0
  211. package/starter/tundra/render/ground/palette.js +11 -0
  212. package/starter/tundra/render/ground/scatter.ts +104 -0
  213. package/starter/tundra/render/ground/terrain.ts +1874 -0
  214. package/starter/tundra/render/kitAssets.ts +28 -0
  215. package/starter/tundra/render/loading.ts +354 -0
  216. package/starter/tundra/render/lookKnobs.ts +37 -0
  217. package/starter/tundra/render/orbitCamera.ts +155 -0
  218. package/starter/tundra/render/props/farForest.ts +96 -0
  219. package/starter/tundra/render/props/pack.ts +1088 -0
  220. package/starter/tundra/render/props/prepared.ts +225 -0
  221. package/starter/tundra/render/props/propMaterials.ts +1247 -0
  222. package/starter/tundra/render/props/propProgress.ts +2 -0
  223. package/starter/tundra/render/props/propWorld.ts +105 -0
  224. package/starter/tundra/render/props/props.ts +624 -0
  225. package/starter/tundra/render/props/spruce.ts +440 -0
  226. package/starter/tundra/render/sky/atmosphere.ts +329 -0
  227. package/starter/tundra/render/sky/sky.ts +382 -0
  228. package/starter/tundra/render/texturePreparation.ts +135 -0
  229. package/starter/tundra/render/water/river.ts +1132 -0
  230. package/starter/tundra/render/worldNames.ts +6 -0
  231. package/starter/tundra/scene.ts +715 -0
  232. package/starter/tundra/sceneProps.ts +559 -0
  233. package/starter/tundra/sceneState.ts +33 -0
  234. package/starter/tundra/world/terrainAssets.ts +159 -0
  235. package/starter/tundra/world/walkBand.ts +47 -0
  236. package/starter/tundra/world/water.ts +74 -0
  237. package/starter/tundra/worlds.ts +13 -0
  238. package/starter-assets.json +4 -4
  239. package/starter-credits.json +901 -15
  240. package/AGENT_GUIDE.md +0 -209
  241. package/starter/forest/sky.ts +0 -38
  242. package/starter/forest/water.ts +0 -257
  243. package/starter/forest/world.ts +0 -182
@@ -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.
package/dist/three.js CHANGED
@@ -2,7 +2,7 @@ import { BufferGeometry, BufferAttribute } from 'three';
2
2
 
3
3
  // src/three.ts
4
4
 
5
- // src/core/bake.ts
5
+ // src/package/bake.ts
6
6
  function validateBakedMesh(mesh) {
7
7
  if (![mesh.positions, mesh.normals, mesh.uvs, ...mesh.colors ? [mesh.colors] : []].every(
8
8
  (array) => array instanceof Float32Array
@@ -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,73 @@
1
+ # Terrain: the live editor
2
+
3
+ The optional editor lets an agent and a person edit one terrain document at the same time. It is
4
+ authoring tooling: keep its imports, worker, watcher and document out of the game runtime. Read
5
+ [`../../README.md`](../../README.md) first. This file ships in the npm package.
6
+
7
+ ## How it connects
8
+
9
+ ```mermaid
10
+ flowchart LR
11
+ file["document file<br/>{ version: 1, recipe }"] <--> server["terrainEditor({ documentPath })<br/>/editor/server, in vite.config"]
12
+ server <-->|"JSON + SSE,<br/>revision-checked"| controller["TerrainEditorController<br/>/editor"]
13
+ controller --> view["mountTerrainEditor<br/>your IEditorView"]
14
+ agent["an agent"] -->|"commit, environment, asset"| controller
15
+ ```
16
+
17
+ - `terrainEditor({ documentPath })` from `@threenative/terrain/editor/server` mounts revisioned JSON and
18
+ SSE endpoints on the project's existing loopback Vite server. Agent patches and GUI changes share the
19
+ one document file.
20
+ - An invalid external save keeps the last valid document and shows a diagnostic. A write with a stale
21
+ `baseRevision` returns 409 and changes nothing.
22
+ - The loopback API is not a public write service. For remote access, configure a forwarded viewer URL.
23
+
24
+ ## The browser side
25
+
26
+ The project provides `/terrain-editor/index.html` and calls `mountTerrainEditor` from
27
+ `@threenative/terrain/editor` with its own `IEditorView` and material colours. The addon creates no
28
+ renderer or scene. `mountTerrainEditor` passes `(host, controller)` to `createView`. The view implements
29
+ `setDocument(document, revision)` for changes that need no evaluation, and `update(state)`, which may
30
+ return the resolved state for inspection and data bakes.
31
+
32
+ `TerrainEditorController(editorUrl)` exposes `activate`, `snapshot` and atomic `commit`. The activation
33
+ result names the bound URL, project, session and revision.
34
+
35
+ ## Environment, assets and surfaces
36
+
37
+ Each operation below is revision-checked and has a GUI panel that calls the same code.
38
+
39
+ - `controller.environment({ op: "get" | "patch" | "reset" }, revision)`: sun azimuth, elevation, intensity
40
+ and colour, sky fill, sky colour or image, `exp2` haze, exposure, sea colours, and a separate `lighting`
41
+ image. `null` returns a field to the project's own value. Another fog mode is refused by name. The
42
+ project's `src/render/` decides what each value does. Nothing here evaluates the terrain.
43
+ - `controller.asset({ op: "register" | "upload" | "adjust" | "remove" | "list" | "map" | "unmap" }, revision)`:
44
+ - `register` takes an absolute local path (for example an asset-MCP download); `upload` takes base64 bytes.
45
+ - Files are stored as `<kind>/<sha12>-<id>.<ext>`, so a replacement gets a new URL. GLB, PNG, JPEG, WebP,
46
+ HDR and EXR are recognised by their bytes. A damaged file, a file over the project's limits, or a GLB
47
+ that points outside itself is refused by name. The same ID with other bytes needs `replace: true`.
48
+ - `remove` drops the entry, not the file, and is refused while a surface or the environment uses it.
49
+ - `map` binds an image to a `<surface>.<channel>` input the project exposes (`bark.albedo`,
50
+ `stone.normal`). Albedo is read as sRGB; every other channel is linear data.
51
+ - `adjust` sets a model's unit scale and pivot without editing the file. To place a model, add a
52
+ `scatter` layer whose `asset` is its ID.
53
+
54
+ ## Placement overrides
55
+
56
+ A scatter placement `id` names the layer, the unsigned seed and the candidate attempt, not the array
57
+ index. A mask or spacing change can remove candidates, but the surviving keys keep their seeded scale and
58
+ yaw. A new seed makes new identities. Save keys, not mesh instance indices.
59
+
60
+ The document may hold `placementOverrides`, keyed by those IDs:
61
+
62
+ - `validatePlacementOverrides()` checks a finite position and quaternion and a positive scale, and sets
63
+ an omitted `grounding` to true.
64
+ - `applyPlacementOverrides(state, overrides)` attaches each transform to its placement and reports the
65
+ keys that matched nothing. `bakeTerrain()` keeps those records.
66
+ - The game grounds each override against its real mesh bounds and terrain triangles. With grounding off,
67
+ the measured clearance stays.
68
+
69
+ ## Footprint edits
70
+
71
+ Stamp, paste and heightmap layers are selected by stable ID. One proxy edits a footprint (`at`, `size`,
72
+ degree `rotation`, `falloff`) and its vertical `scale` and `offset`. X and Z rotation is off, because a
73
+ heightfield cannot overhang. A heightmap with no footprint fields samples the whole world, as before.
@@ -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`.
@@ -0,0 +1,97 @@
1
+ # Terrain: authoring a recipe
2
+
3
+ The reference for writing a terrain recipe with `@threenative/terrain`. Read
4
+ [`../../README.md`](../../README.md) first. This file ships in the npm package.
5
+
6
+ ## Units and identity
7
+
8
+ - Metres, Y up. X and Z run from `-size/2` to `+size/2`. Brushes and masks take `[x,z]`; splines take `[x,y,z]`.
9
+ - Rotations and slope thresholds are degrees. **Placement output yaw is radians.** Heights are absolute metres.
10
+ - An operation records intent; `evaluate()` returns disposable arrays. Editing them does not edit the recipe.
11
+ - Use stable semantic IDs (`base`, `north-peak`, `river-main`). Reusing an ID replaces that layer in place.
12
+ `label` is the display name in fluent calls and `name` in saved JSON; in `biome()`, `name` is the biome key.
13
+ - A scatter placement `id` encodes layer, seed and candidate, not the array index. Save IDs, not instance indices.
14
+
15
+ ## Workflow
16
+
17
+ 1. Set size, seed and a preview resolution (129 or 257). For real relief, start from `landform(kind, { size, seed,
18
+ relief })` (`alpine`, `temperateMountains`, `rollingHills`, `desertMesa`, `coastalCliffs`, `tundra`, `volcanic`).
19
+ Its heights are absolute, so read `terrainStats()` before you choose height masks or water levels.
20
+ 2. Erode before fine roads and pads. Add surface rules and population after the shape they read.
21
+ 3. Inspect with `t.inspect()`, change known IDs, then verify the final resolution: erosion and population change with it.
22
+
23
+ Layers run in the order you add them, and each one reads the ground that the layers before it left.
24
+ The diagram is the recommended order. Population is the one fixed stage: it runs last, on the final ground.
25
+
26
+ ```mermaid
27
+ flowchart LR
28
+ shape["shape<br/>landform or noise,<br/>sculpt, stamp, paste"] --> erode["erode<br/>thermal, hydraulic,<br/>fluvial, terrace"]
29
+ erode --> detail["detail<br/>flatten, ramp,<br/>road, river"]
30
+ detail --> water["water<br/>lake, ocean"]
31
+ water --> surface["surface<br/>materials, paint, biome"]
32
+ surface --> final["final heights,<br/>splat, biomes"]
33
+ final --> population["population<br/>scatter, clear<br/>(masks re-read here)"]
34
+ population --> state["ITerrainState<br/>from evaluate()"]
35
+ ```
36
+
37
+ A height or slope mask on a surface rule reads the ground at that rule's place in the order. A scatter mask is
38
+ read again on the final ground, so a later height edit does not leave a tree in the air.
39
+
40
+ ```js
41
+ import { Terrain, Mask } from '@threenative/terrain';
42
+ const t = new Terrain({ size: 512, resolution: 129, seed: 73 }).noise({ id: 'base', base: 15, amplitude: 20, scale: 140 });
43
+ t.flatten({ id: 'camp-pad', at: [-70, 50], radius: 28 }); // no height: a bench at ground level
44
+ t.road({ id: 'access-road', points: [[-220, null, 100], [-70, null, 50]], width: 12, shoulder: 8 });
45
+ t.river({ id: 'river-main', points: [[20, 14, -240], [80, 3, 240]], width: 18, depth: 4, enforceDownhill: true });
46
+ t.water({ id: 'lake', kind: 'lake', at: [80, 210], radius: 75, level: 4 });
47
+ t.materials({ id: 'surfaces', base: 'grass', rules: [{ material: 'rock', mask: Mask.slope(42, 90, 8) }] });
48
+ t.scatter({ id: 'trees', asset: 'pine', count: 900, minDistance: 5, maxSlope: 35,
49
+ mask: Mask.and(Mask.height(8, 85, 10), Mask.not(Mask.material('road'))) });
50
+ const state = t.evaluate({ resolution: 257 }); // 900 placements on 2026-11-13
51
+ ```
52
+
53
+ ## Operations
54
+
55
+ Other operations: `noise`, `sculpt`, `smooth`, `ramp`, `stamp`, `paste`, `heightmap`, `erode` (`thermal`,
56
+ `hydraulic`, `fluvial`), `terrace`, `paint`, `biome`, `clear`, `copyRegion`. Every layer takes `opacity`.
57
+ There is no `terrain.generate()`, `terrain.bake()` or `terrain.saveGLB()`.
58
+
59
+ - **Edits.** `transaction()` groups synchronous edits into one undo; a validation failure rolls back all of it.
60
+ `applyPatch([...])` takes JSON commands: `upsert` (`layer`), `update` (`id`, `patch`), `remove` (`id`),
61
+ `move` (`id`, zero-based `index`), `toggle` (`id`, optional `enabled`).
62
+ - **Brushes.** `radius` is a radius. Sculpt strength is signed metres; smooth, flatten and paint take `0..1`.
63
+ A stationary brush does not keep adding height.
64
+ - **Masks** are data, not callbacks: `height`, `slope`, `material`, `biome`, `circle`, `rectangle`, `noise`,
65
+ `and`, `or`, `not`, `all`, `none`. Height and slope masks read the terrain at their own stage.
66
+ - **Population** samples the final ground, so later height edits leave no floating trees. `minDistance`
67
+ holds within one rule only, and a rule can place fewer than `count`: read the diagnostics.
68
+ - **Materials** are `grass`, `dirt`, `rock`, `snow`, `sand`, `mud`, `road`, `moss`. Splat is sample-major
69
+ (`splat[i * 8 + channel]`) and sums to one. Read it as linear data (NoColorSpace), not as a colour image.
70
+ - **Roads, rivers, ramps** grade to the ground where a point's Y is `null` or `followTerrain: true`, within
71
+ `maxGrade` (0.12), `maxCut` (2.5 m) and `maxFill` (1.5 m). River carving only lowers. A lake floods from
72
+ `at` below `level` and digs no basin; an ocean floods from the borders. Scatter avoids water by default.
73
+ - **Heightfields.** Paste, stamp and heightmap data is `{ width, height, values }` in metres. Footprints take
74
+ `at`, `radius` or `size`, `rotation` (degrees) and `falloff`. PNG import is grayscale 8/16-bit only; RAW
75
+ carries no size or range, so keep its sidecar. Read PNG16 with the supplied decoder, not a canvas.
76
+
77
+ ## Export
78
+
79
+ - `t.toJSON()` and `Terrain.fromJSON()` round-trip the recipe. Save the recipe, not only the mesh.
80
+ - `makeExport(state, recipe, kind)` with `project`, `png`, `raw`, `splat`, `glb` or `runtime` returns
81
+ `{ name, type, bytes }`. Its `glb` is terrain only.
82
+ - `bakeTerrain(state, { chunkCells, lodSteps, skirtDepth })` makes LOD chunks. Heights are row-major,
83
+ Z then X; vertex `(x, z)` sits at `((x/(N-1) - .5) * size, height[z*N + x], (z/(N-1) - .5) * size)`.
84
+ - `toGeometry(bakeMesh(state))` from `/three` gives indexed geometry. Your `src/render/` makes the mesh
85
+ and material, and disposes the geometry.
86
+ - A full world (terrain, props, water) goes through `prepareWorldGLTF` from `/export` in the browser, then
87
+ `cookTerrainWorld` from `@threenative/assets` in Node. Its input contract is in `dist/export.d.ts`.
88
+ - Not provided: navmesh, EXR, mixed-LOD stitching, caves, water simulation, materials or colours.
89
+
90
+ ## Limits
91
+
92
+ - Resolutions: 17, 33, 65, 129, 257, 513, 1025 vertices per side. At most 512 layers, 20 000 instances per
93
+ scatter rule, 200 000 droplets, 128 steps per droplet, 200 thermal or smooth iterations, 10 octaves,
94
+ 8 192 input points and 65 536 interpolated brush centres. These are guards, not performance targets.
95
+ - `evaluate()` is synchronous and checks an `AbortSignal` only between operations. To cancel, run it in a
96
+ worker or child process and end that. The prefix cache holds 48 MiB by default (`cacheMB`).
97
+ - Recipes are data. Run no JavaScript from a recipe. A failed validation keeps the previous valid recipe.
@@ -0,0 +1,66 @@
1
+ # Terrain: exporting a resolved static world
2
+
3
+ `makeExport(state, recipe, "glb")` exports the terrain alone. To export a full world (terrain, models,
4
+ final transforms, water and embedded PBR maps) as one GLB, use `prepareWorldGLTF` from
5
+ `@threenative/terrain/export`. Read [`../../README.md`](../../README.md) first. This file ships in the
6
+ npm package.
7
+
8
+ ```mermaid
9
+ sequenceDiagram
10
+ participant page as browser authoring page
11
+ participant prep as prepareWorldGLTF (/export)
12
+ participant node as Node authoring process
13
+ participant cook as cookTerrainWorld (@threenative/assets)
14
+ page->>prep: revision, snapshotTime, state, terrain,<br/>assets, transforms, water
15
+ prep-->>page: prepared.json + report
16
+ page->>node: send prepared.json
17
+ node->>cook: cookTerrainWorld({ preparedWorld })
18
+ cook-->>node: worldGlb (self-contained world.glb)
19
+ ```
20
+
21
+ ```ts
22
+ import { prepareWorldGLTF } from '@threenative/terrain/export';
23
+ const prepared = await prepareWorldGLTF({
24
+ revision, // the accepted document's 64-character content hash
25
+ snapshotTime, // finite seconds, the same for every baked deformation
26
+ state, // the evaluated recipe with its placement overrides applied
27
+ terrain, // a metre-frame Mesh with UVs and prepared PBR maps
28
+ assets, // Map<assetId, Object3D>: the real static models
29
+ transforms, // Map<placementId, Matrix4>: the final grounded root matrices
30
+ water, // [{ id, object, time: snapshotTime, staleFrames: 0 }]
31
+ });
32
+ // In Node: const { worldGlb } = await cookTerrainWorld({ preparedWorld: prepared.json });
33
+ // Write world.glb only after the call succeeds.
34
+ ```
35
+
36
+ The import itself has no DOM. Preparing a scene needs browser `FileReader` and canvas. The root and
37
+ `/three` entries stay headless.
38
+
39
+ ## What the caller supplies
40
+
41
+ - **Materials.** `MeshStandardMaterial` metallic-roughness only. The terrain needs `map`, `normalMap`,
42
+ `roughnessMap` and `aoMap`; vertex colours alone are not enough. Colour and emissive images are sRGB;
43
+ data maps are `NoColorSpace`.
44
+ - **Images.** Decoded byte images of at most 16 megapixels. A `DataTexture` needs complete RGBA bytes.
45
+ Bake alpha into the colour image.
46
+ - **Static geometry.** Bake displacement, bump and light maps, node shaders, skinning, morphing and wind
47
+ into the geometry and material first. Normal maps are tangent-space with equal X and Y scale.
48
+ `MeshPhysicalMaterial` extensions are not supported.
49
+ - **Transforms.** Metres, Y up, positive scale, no shear. Keys are placement IDs, not instance indices.
50
+ A matrix that matches no placement fails.
51
+ - **Water.** Every evaluated water body and river needs its baked object at exactly `snapshotTime`, with
52
+ `staleFrames: 0`. A low-resolution or stale ocean height sample does not qualify.
53
+
54
+ ## What you get
55
+
56
+ - Ordinary glTF nodes that share model mesh data, with no `EXT_mesh_gpu_instancing`. A vanilla Three.js
57
+ `GLTFLoader` or a normal game model loader reads the result without this package.
58
+ - A copy of the source geometry, images and materials taken before encoding, so later edits cannot leak
59
+ into the export. The input objects stay yours.
60
+ - `report` with the revision, resolution, time, and placement and water IDs.
61
+ - No model cameras, lights or source `userData`. The game supplies its own lighting, sky, fog, exposure,
62
+ post-processing and live water or wind.
63
+
64
+ Missing or unbaked content fails before any bytes are written. Keep the previous valid export and document.
65
+ The encoder does not run the project's material bake, re-evaluate at a chosen resolution, or read the
66
+ ocean back for you.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/terrain",
3
- "version": "0.1.9",
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": [
@@ -27,12 +27,13 @@
27
27
  "starter/*/*.json",
28
28
  "starter/*/*.r16",
29
29
  "starter/*/*.mjs",
30
- "starter/*/*.ts",
30
+ "starter/**/*.ts",
31
+ "starter/**/*.js",
31
32
  "starter/*/*.md",
32
33
  "starter-assets.json",
33
34
  "starter-credits.json",
34
35
  "README.md",
35
- "AGENT_GUIDE.md",
36
+ "docs/authoring/*.md",
36
37
  "THIRD_PARTY_NOTICES.md"
37
38
  ],
38
39
  "bin": "./dist/mcp/server.js",
@@ -74,6 +75,9 @@
74
75
  "access": "public"
75
76
  },
76
77
  "sideEffects": false,
78
+ "dependencies": {
79
+ "sharp": "0.35.4"
80
+ },
77
81
  "devDependencies": {
78
82
  "@types/node": "20.19.43",
79
83
  "@types/three": "0.187.0",
@@ -83,12 +87,14 @@
83
87
  "typescript": "npm:@typescript/typescript6@6.0.2",
84
88
  "@typescript/native": "npm:typescript@7.0.2",
85
89
  "vite": "8.2.0",
86
- "@threenative/core": "0.3.13",
87
- "@threenative/physics": "0.3.13"
90
+ "@threenative/core": "0.3.16",
91
+ "@threenative/procedural-environment": "0.1.2",
92
+ "@threenative/physics": "0.3.16"
88
93
  },
89
94
  "peerDependencies": {
90
- "@threenative/core": ">=0.3.13 <0.4.0",
91
- "@threenative/physics": ">=0.3.13 <0.4.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",
92
98
  "three": ">=0.187.0 <0.188.0",
93
99
  "vite": ">=7.0.0 <9.0.0"
94
100
  },
@@ -99,6 +105,9 @@
99
105
  "@threenative/physics": {
100
106
  "optional": true
101
107
  },
108
+ "@threenative/procedural-environment": {
109
+ "optional": true
110
+ },
102
111
  "vite": {
103
112
  "optional": true
104
113
  }
@@ -106,6 +115,13 @@
106
115
  "scripts": {
107
116
  "build": "tsup --config tsup.config.ts && publint",
108
117
  "typecheck": "tsc --noEmit",
109
- "test": "pnpm run build && vitest run --root ../.. terrain/__tests__ && publint --strict"
118
+ "test": "pnpm run build && vitest run --root ../.. terrain/__tests__ && publint --strict",
119
+ "test:consumer": "pnpm run build && vitest run --root ../.. packages/terrain/__tests__/terrain-consumer.spec.ts",
120
+ "test:map": "vitest run --root ../.. scripts/__tests__/terrain-architecture-census.spec.ts",
121
+ "bake:forest": "pnpm run build && node starter/forest/bake.mjs --out ../../artifacts/terrain/forest",
122
+ "bake:coastal": "pnpm run build && node starter/coastal/bake.mjs --out ../../artifacts/terrain/coastal",
123
+ "bake:alpine": "pnpm run build && node starter/alpine/bake.mjs --out ../../artifacts/terrain/alpine",
124
+ "bake:desert": "pnpm run build && node starter/desert/bake.mjs --out ../../artifacts/terrain/desert",
125
+ "bake:tundra": "pnpm run build && node starter/tundra/bake.mjs --out ../../artifacts/terrain/tundra"
110
126
  }
111
127
  }
@@ -1,35 +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
- | `assets.json` | The boulder model, its LOD distance and draw distance, and its bounds. |
11
- | `surface.json` | The ground: the rock base, the dirt and snow layers, tiles, tints and blend thresholds. |
12
- | `bake.mjs` | Writes the world package from the three files above. |
13
- | `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. |
14
- | `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. |
15
20
 
16
21
  Art is CC0 (Poly Haven); provenance is in `@threenative/terrain/starter-credits.json`.
17
22
 
18
23
  ## Status
19
24
 
20
- The kit bakes and streams. The kit ships no scene: the game writes one. The terrain is too steep to
21
- stand on near its centre, so a scene picks its spawn from the loaded heightfield. The proof's scene
22
- 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.
23
29
 
24
30
  ## Steps
25
31
 
26
32
  1. Copy `node_modules/@threenative/terrain/starter/alpine` to `src/terrain/alpine`.
27
33
  2. Run `node src/terrain/alpine/bake.mjs --out assets/terrain/alpine` (needs `@threenative/terrain`
28
- as a devDependency). The same recipe always writes the same bytes.
29
- 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.
30
37
 
31
38
  ## Edit at startup, without rebaking
32
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
+
33
43
  The copied `world.ts` loads its own `surface.json` as the ground table on every startup.
34
44
  Edit tints, tiling and blend thresholds there, or the material graph and prop dressing in
35
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
  });