@threenative/terrain 0.1.11 → 0.1.13

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
package/README.md CHANGED
@@ -48,5 +48,6 @@ Five starter worlds ship as copy-out game source in `starter/<world>/` (`forest`
48
48
  | --- | --- |
49
49
  | [Authoring a recipe](docs/authoring/recipes.md) | You write or patch a recipe: operations, masks, materials, water, export formats, limits |
50
50
  | [The live editor](docs/authoring/editor.md) | You run the editor, change its environment or assets, or save placement overrides |
51
+ | [A new environment](docs/authoring/new-environment.md) | You make a new biome or place on the forest kit's stack: ground, plants, look, bake |
51
52
  | [Exporting a static world](docs/authoring/world-export.md) | You export terrain, models and water as one GLB for another project |
52
53
  | [Source provenance](THIRD_PARTY_NOTICES.md) | You need the origin and license of the recovered Strata code |
@@ -0,0 +1,82 @@
1
+ import { T as Terrain } from './terrain-DYCyAOCJ.js';
2
+ import { e as ITerrainConfig, I as ITerrainState, j as IBakeMeshOptions, i as IBakedMesh, k as IBakeTerrainOptions, l as IBakedTerrain } from './types-kpI0C4hW.js';
3
+
4
+ type LandformKind = "alpine" | "temperateMountains" | "rollingHills" | "desertMesa" | "coastalCliffs" | "tundra" | "volcanic";
5
+ interface ILandformOptions extends Partial<ITerrainConfig> {
6
+ /** Highest minus lowest height in metres. Defaults to the kind's real ratio times `size`. */
7
+ relief?: number;
8
+ }
9
+ interface ILandformInfo {
10
+ readonly summary: string;
11
+ /** Default relief as a fraction of the world size. */
12
+ readonly reliefRatio: number;
13
+ /** Where the shape comes from: a public-domain DEM the repo carries, or a cited landscape. */
14
+ readonly reference: string;
15
+ /** Measured DEM statistics (5 km, 513 samples), when the repo carries that DEM; `terrainStats` fields. */
16
+ readonly target?: {
17
+ readonly slopeP50: number;
18
+ readonly slopeP90: number;
19
+ readonly hypsometricIntegral: number;
20
+ readonly curvatureKurtosis: number;
21
+ };
22
+ }
23
+ /**
24
+ * Shape-only presets. Each names its reference landscape so a calibration can be repeated; no
25
+ * material, colour or texture is chosen here. Targets were measured with `terrainStats` on the
26
+ * 1/3 arc-second USGS 3DEP crops in `examples/strata-terrain-preview/scripts/dem` (public domain).
27
+ */
28
+ declare const LANDFORMS: Readonly<Record<LandformKind, ILandformInfo>>;
29
+ /**
30
+ * One call, one landscape: a calibrated layer recipe for a kind of environment.
31
+ * @requires npm i @threenative/terrain
32
+ * @situation start an open world, a distant backdrop or a mountain level from a kind of place
33
+ * @constraint returns an ordinary `Terrain`: add roads, rivers, scatter or more layers, then `evaluate()` in a build script
34
+ * @constraint shape only; materials, colours and textures belong to the game
35
+ * @constraint calibrated at size 5000, resolution 513; other sizes keep the same slopes and scale the relief with `size`
36
+ * @example const terrain = landform("alpine", { size: 5000, resolution: 513, seed: 4 }); const state = terrain.evaluate();
37
+ * @override `relief` is the highest-minus-lowest height in metres before the finishing passes shave a few percent; `size`, `resolution` and `seed` as in `Terrain`
38
+ */
39
+ declare function landform(kind: LandformKind, options?: ILandformOptions): Terrain;
40
+ interface ILandformBackdrop {
41
+ readonly size: number;
42
+ readonly resolution: number;
43
+ /** Row-major metres, centre sample at `centerHeight`. */
44
+ readonly heights: Float32Array;
45
+ }
46
+ interface IBackdropOptions extends Partial<ITerrainConfig> {
47
+ /** Highest minus lowest height of the returned window, metres. Defaults to the kind's ratio times `size`. */
48
+ relief?: number;
49
+ /** Elevation of the centre sample, metres: the game's own ground height where the backdrop meets it. */
50
+ centerHeight?: number;
51
+ }
52
+ /**
53
+ * Distant mountains around a playable area: a landform window with a valley floor at its centre.
54
+ * @requires npm i @threenative/terrain
55
+ * @situation add a mountain backdrop around a playable area that the game's detail terrain covers
56
+ * @constraint resolution up to 513: the window is cut from a world twice as wide at the same spacing; build script only
57
+ * @constraint shape only; the game places, colours and fades it
58
+ * @example const { size, resolution, heights } = landformBackdrop("temperateMountains", { seed: 7, centerHeight: 13 });
59
+ * @override `relief` and `centerHeight` in metres; `size`, `resolution` and `seed` as in `landform`
60
+ */
61
+ declare function landformBackdrop(kind: LandformKind, options?: IBackdropOptions): ILandformBackdrop;
62
+
63
+ /**
64
+ * Bakes the recovered indexed top surface and optional vertical skirts into caller-owned arrays.
65
+ * @requires npm i @threenative/terrain
66
+ * @situation bake an authored terrain into portable indexed mesh arrays
67
+ * @constraint no material is chosen; vertex colours exist only with a caller-supplied palette
68
+ * @example const mesh = bakeMesh(new Terrain({ resolution: 17 }).evaluate());
69
+ * @override step, chunk bounds, skirtDepth and palette belong to the caller
70
+ */
71
+ declare function bakeMesh(state: ITerrainState, { step, x, z, cells, skirtDepth, palette, }?: IBakeMeshOptions): IBakedMesh;
72
+ /**
73
+ * Bakes finite LOD chunks, the same collision samples and resolved placements.
74
+ * @requires npm i @threenative/terrain
75
+ * @situation prepare terrain arrays and collision before a game starts
76
+ * @constraint collision origin is the southwest corner; engine Heightfield origin is its centre
77
+ * @example const baked = bakeTerrain(new Terrain({ resolution: 129 }).evaluate(), { chunkCells: 64 });
78
+ * @override chunkCells, lodSteps, skirtDepth and palette are explicit authoring choices
79
+ */
80
+ declare function bakeTerrain(state: ITerrainState, { chunkCells, lodSteps, skirtDepth, palette, }?: IBakeTerrainOptions): IBakedTerrain;
81
+
82
+ export { type IBackdropOptions as I, type LandformKind as L, type ILandformBackdrop as a, bakeMesh as b, type ILandformInfo as c, type ILandformOptions as d, LANDFORMS as e, bakeTerrain as f, landformBackdrop as g, landform as l };
@@ -1,7 +1,7 @@
1
- import { P as PatchCommand } from '../terrain-CAEaW0mQ.js';
2
- import { L as Layer, i as IPlacementOverride, I as ITerrainState } from '../types-BpH00qsx.js';
3
- import { I as IEditorSnapshot, a as IAuthoringDocument, b as ISavedCamera, c as IFocusRequest, d as IFocusOutcome, e as IFocusBounds, f as IEnvironment, g as IEditorActivation, h as ISpatialQuery, i as ISpatialObservation, j as ICameraOperation, k as ICameraResult, l as IEnvironmentOperation, m as IEnvironmentResult, n as IAssetOperation, o as IAssetResult } from '../server-B5RdvEAC.js';
4
- export { p as IAssetAdjust, q as IAssetBounds, r as IAssetKind, s as IAssetLimits, t as ICameraPose, u as ICameraSet, v as IFocusFraming, w as IFocusResolver, x as IFocusTarget, y as IHexColour, z as IPointObservation, A as IProfileObservation, B as IProfileSample, C as IProjectAsset, D as IReferenceObservation, E as ISavedSpatialReference, F as ISpatialControlPoint, G as ISpatialReference, H as ISurfaceMapping, J as ISurfaceMappings, K as ISurfaceReading, L as checkEnvironmentAssets, M as focusCamera, N as inspectSpatial, O as probeTerrain, P as runCameraOperation, Q as runEnvironmentOperation, R as sniff, S as surfaceSpace, T as validateAsset, U as validateAssets, V as validateCamera, W as validateCameras, X as validateEnvironment, Y as validateSpatialReference, Z as validateSurfaces } from '../server-B5RdvEAC.js';
1
+ import { P as PatchCommand } from '../terrain-DYCyAOCJ.js';
2
+ import { L as Layer, m as IPlacementOverride, I as ITerrainState } from '../types-kpI0C4hW.js';
3
+ import { I as IEditorSnapshot, a as IAuthoringDocument, b as ISavedCamera, c as IFocusRequest, d as IFocusOutcome, e as IFocusBounds, f as IEnvironment, g as IEditorActivation, h as ISpatialQuery, i as ISpatialObservation, j as ICameraOperation, k as ICameraResult, l as IEnvironmentOperation, m as IEnvironmentResult, n as IAssetOperation, o as IAssetResult } from '../server-LnFwY8sr.js';
4
+ export { p as IAssetAdjust, q as IAssetBounds, r as IAssetKind, s as IAssetLimits, t as ICameraPose, u as ICameraSet, v as IFocusFraming, w as IFocusResolver, x as IFocusTarget, y as IHexColour, z as IPointObservation, A as IProfileObservation, B as IProfileSample, C as IProjectAsset, D as IReferenceObservation, E as ISavedSpatialReference, F as ISpatialControlPoint, G as ISpatialReference, H as ISurfaceMapping, J as ISurfaceMappings, K as ISurfaceReading, L as checkEnvironmentAssets, M as focusCamera, N as inspectSpatial, O as probeTerrain, P as runCameraOperation, Q as runEnvironmentOperation, R as sniff, S as surfaceSpace, T as validateAsset, U as validateAssets, V as validateCamera, W as validateCameras, X as validateEnvironment, Y as validateSpatialReference, Z as validateSurfaces } from '../server-LnFwY8sr.js';
5
5
  import * as three from 'three';
6
6
  import { Quaternion, Vector3, Camera, Vector2, Object3D, Intersection, Mesh, Matrix4 } from 'three';
7
7
  import { TransformControls } from 'three/addons/controls/TransformControls.js';
@@ -3021,7 +3021,7 @@ function encodeGLB(input) {
3021
3021
  }
3022
3022
  const binary = join(chunks);
3023
3023
  const doc = {
3024
- asset: { version: "2.0", generator: "@threenative/terrain 0.1.11" },
3024
+ asset: { version: "2.0", generator: "@threenative/terrain 0.1.13" },
3025
3025
  scene: 0,
3026
3026
  scenes: [{ nodes: meshes.map((_, i) => i) }],
3027
3027
  nodes: meshes.map((m, i) => ({ mesh: i, name: m.name ?? `Terrain ${i}` })),
@@ -1,3 +1,3 @@
1
1
  import 'vite';
2
- import '../types-BpH00qsx.js';
3
- export { a as IAuthoringDocument, g as IEditorActivation, I as IEditorSnapshot, _ as TerrainEditorDocument, $ as terrainEditor } from '../server-B5RdvEAC.js';
2
+ import '../types-kpI0C4hW.js';
3
+ export { a as IAuthoringDocument, g as IEditorActivation, I as IEditorSnapshot, _ as TerrainEditorDocument, $ as terrainEditor } from '../server-LnFwY8sr.js';
@@ -1,4 +1,4 @@
1
- import { I as ITerrainState, a as IExportArchive, b as ITerrainDocument, E as ExportKind } from '../types-BpH00qsx.js';
1
+ import { I as ITerrainState, a as IExportArchive, b as ITerrainDocument, E as ExportKind } from '../types-kpI0C4hW.js';
2
2
 
3
3
  interface IWorkerRequest {
4
4
  id: number;
@@ -2491,7 +2491,7 @@ function encodeGLB(input) {
2491
2491
  }
2492
2492
  const binary = join(chunks);
2493
2493
  const doc = {
2494
- asset: { version: "2.0", generator: "@threenative/terrain 0.1.11" },
2494
+ asset: { version: "2.0", generator: "@threenative/terrain 0.1.13" },
2495
2495
  scene: 0,
2496
2496
  scenes: [{ nodes: meshes.map((_, i) => i) }],
2497
2497
  nodes: meshes.map((m, i) => ({ mesh: i, name: m.name ?? `Terrain ${i}` })),
package/dist/export.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Mesh, Object3D, Matrix4 } from 'three';
2
- import { I as ITerrainState } from './types-BpH00qsx.js';
2
+ import { I as ITerrainState } from './types-kpI0C4hW.js';
3
3
 
4
4
  interface IWorldGLBInput {
5
5
  readonly revision: string;
package/dist/index.d.ts CHANGED
@@ -1,70 +1,14 @@
1
- import { e as ITerrainConfig, c as IMask, j as IPlacement, k as IErosionMaps, I as ITerrainState, M as MaterialId, l as ISampledGrid, O as OperationType, b as ITerrainDocument, m as IBakeMeshOptions, h as IBakedMesh, n as IBakeTerrainOptions, o as IBakedTerrain, i as IPlacementOverride, p as IDecodeHeightPngOptions, q as IDecodeRaw16Options, r as IHeightRange, s as IRaw16Options, t as IExportFile, a as IExportArchive, E as ExportKind } from './types-BpH00qsx.js';
2
- export { u as IBiomeParams, v as IBrushParams, w as IClearParams, g as ICopyRegionOptions, x as IDecodedHeightPng, y as IErodeParams, f as IEvaluateOptions, z as IFlattenParams, A as IGradeParams, B as IGrid, C as IHeightData, D as IHeightPngMetadata, F as IHeightmapParams, G as ILayer, H as IMaterialRule, J as IMaterialsParams, K as INoiseParams, N as IPaintParams, P as IPasteParams, Q as IRampParams, R as IRiver, S as IRiverParams, T as IRoadParams, U as IScatterClear, V as IScatterParams, W as IScatterRule, X as ISculptParams, Y as ISmoothParams, Z as ISplatPng, _ as IStampParams, $ as ITerraceParams, a0 as ITerrainInspection, a1 as IWaterBody, a2 as IWaterParams, a3 as IWaterRule, L as Layer, d as LayerParams, a4 as MaskSampler, a5 as MaskType, a6 as SplinePoint } from './types-BpH00qsx.js';
3
- import { T as Terrain } from './terrain-CAEaW0mQ.js';
4
- export { L as LayerPatch, O as OperationOptions, P as PatchCommand, a as TerrainEvaluator } from './terrain-CAEaW0mQ.js';
5
- import { c as IBakeWorldPackageOptions, I as IWorldPackageAsset, d as IBakedWorldPackage, a as IWorldPackageManifest, e as IWorldPackageRun } from './world-package-B8QgHjAQ.js';
6
- export { b as bakeWorldPackage } from './world-package-B8QgHjAQ.js';
1
+ import { c as IMask, h as IPlacement, n as IErosionMaps, I as ITerrainState, M as MaterialId, o as ISampledGrid, O as OperationType, b as ITerrainDocument, m as IPlacementOverride, p as IDecodeHeightPngOptions, q as IDecodeRaw16Options, i as IBakedMesh, r as IHeightRange, s as IRaw16Options, t as IExportFile, a as IExportArchive, E as ExportKind } from './types-kpI0C4hW.js';
2
+ export { j as IBakeMeshOptions, k as IBakeTerrainOptions, l as IBakedTerrain, u as IBiomeParams, v as IBrushParams, w as IClearParams, g as ICopyRegionOptions, x as IDecodedHeightPng, y as IErodeParams, f as IEvaluateOptions, z as IFlattenParams, A as IGradeParams, B as IGrid, C as IHeightData, D as IHeightPngMetadata, F as IHeightmapParams, G as ILayer, H as IMaterialRule, J as IMaterialsParams, K as INoiseParams, N as IPaintParams, P as IPasteParams, Q as IRampParams, R as IRiver, S as IRiverParams, T as IRoadParams, U as IScatterClear, V as IScatterParams, W as IScatterRule, X as ISculptParams, Y as ISmoothParams, Z as ISplatPng, _ as IStampParams, $ as ITerraceParams, e as ITerrainConfig, a0 as ITerrainInspection, a1 as IWaterBody, a2 as IWaterParams, a3 as IWaterRule, L as Layer, d as LayerParams, a4 as MaskSampler, a5 as MaskType, a6 as SplinePoint } from './types-kpI0C4hW.js';
3
+ import { L as LandformKind } from './bake-DJ5cxg0C.js';
4
+ export { I as IBackdropOptions, a as ILandformBackdrop, c as ILandformInfo, d as ILandformOptions, e as LANDFORMS, b as bakeMesh, f as bakeTerrain, l as landform, g as landformBackdrop } from './bake-DJ5cxg0C.js';
5
+ import { d as IBakeWorldPackageOptions, b as IWorldPackageAsset, e as IBakedWorldPackage } from './world-package-DqJC3-Nn.js';
6
+ export { c as bakeWorldPackage } from './world-package-DqJC3-Nn.js';
7
7
  import { Heightfield, HeightfieldCollar } from '@threenative/core/world';
8
8
  import { BufferAttribute } from 'three';
9
-
10
- type LandformKind = "alpine" | "temperateMountains" | "rollingHills" | "desertMesa" | "coastalCliffs" | "tundra" | "volcanic";
11
- interface ILandformOptions extends Partial<ITerrainConfig> {
12
- /** Highest minus lowest height in metres. Defaults to the kind's real ratio times `size`. */
13
- relief?: number;
14
- }
15
- interface ILandformInfo {
16
- readonly summary: string;
17
- /** Default relief as a fraction of the world size. */
18
- readonly reliefRatio: number;
19
- /** Where the shape comes from: a public-domain DEM the repo carries, or a cited landscape. */
20
- readonly reference: string;
21
- /** Measured DEM statistics (5 km, 513 samples), when the repo carries that DEM; `terrainStats` fields. */
22
- readonly target?: {
23
- readonly slopeP50: number;
24
- readonly slopeP90: number;
25
- readonly hypsometricIntegral: number;
26
- readonly curvatureKurtosis: number;
27
- };
28
- }
29
- /**
30
- * Shape-only presets. Each names its reference landscape so a calibration can be repeated; no
31
- * material, colour or texture is chosen here. Targets were measured with `terrainStats` on the
32
- * 1/3 arc-second USGS 3DEP crops in `examples/strata-terrain-preview/scripts/dem` (public domain).
33
- */
34
- declare const LANDFORMS: Readonly<Record<LandformKind, ILandformInfo>>;
35
- /**
36
- * One call, one landscape: a calibrated layer recipe for a kind of environment.
37
- * @requires npm i @threenative/terrain
38
- * @situation start an open world, a distant backdrop or a mountain level from a kind of place
39
- * @constraint returns an ordinary `Terrain`: add roads, rivers, scatter or more layers, then `evaluate()` in a build script
40
- * @constraint shape only; materials, colours and textures belong to the game
41
- * @constraint calibrated at size 5000, resolution 513; other sizes keep the same slopes and scale the relief with `size`
42
- * @example const terrain = landform("alpine", { size: 5000, resolution: 513, seed: 4 }); const state = terrain.evaluate();
43
- * @override `relief` is the highest-minus-lowest height in metres before the finishing passes shave a few percent; `size`, `resolution` and `seed` as in `Terrain`
44
- */
45
- declare function landform(kind: LandformKind, options?: ILandformOptions): Terrain;
46
- interface ILandformBackdrop {
47
- readonly size: number;
48
- readonly resolution: number;
49
- /** Row-major metres, centre sample at `centerHeight`. */
50
- readonly heights: Float32Array;
51
- }
52
- interface IBackdropOptions extends Partial<ITerrainConfig> {
53
- /** Highest minus lowest height of the returned window, metres. Defaults to the kind's ratio times `size`. */
54
- relief?: number;
55
- /** Elevation of the centre sample, metres: the game's own ground height where the backdrop meets it. */
56
- centerHeight?: number;
57
- }
58
- /**
59
- * Distant mountains around a playable area: a landform window with a valley floor at its centre.
60
- * @requires npm i @threenative/terrain
61
- * @situation add a mountain backdrop around a playable area that the game's detail terrain covers
62
- * @constraint resolution up to 513: the window is cut from a world twice as wide at the same spacing; build script only
63
- * @constraint shape only; the game places, colours and fades it
64
- * @example const { size, resolution, heights } = landformBackdrop("temperateMountains", { seed: 7, centerHeight: 13 });
65
- * @override `relief` and `centerHeight` in metres; `size`, `resolution` and `seed` as in `landform`
66
- */
67
- declare function landformBackdrop(kind: LandformKind, options?: IBackdropOptions): ILandformBackdrop;
9
+ import { T as Terrain } from './terrain-DYCyAOCJ.js';
10
+ export { L as LayerPatch, O as OperationOptions, P as PatchCommand, a as TerrainEvaluator } from './terrain-DYCyAOCJ.js';
11
+ export { c as ICompilePropBucketsOptions, d as IPropBucketEntry, I as IPropBucketKind, b as IPropBucketPackage, e as IPropBucketRecord, a as IPropPackage, f as IPropPackageFiles, P as PROP_CELL_SIZE, g as compilePropBuckets, h as decodePropBucket, p as propAssetOf, i as propPackageFile, j as propPackageFiles } from './prop-package-Dwz0EWoB.js';
68
12
 
69
13
  /**
70
14
  * A biome as a data file: the rules one world grows by, and no appearance at all.
@@ -757,6 +701,47 @@ declare function placeMassif(terrain: Terrain, options: IPlaceMassifOptions): {
757
701
  placement: IMassifPlacement;
758
702
  };
759
703
 
704
+ /**
705
+ * Paint each placed tree's crown into a per-vertex canopy grid, so the ground under a stand reads as
706
+ * forest floor rather than open turf. `values` is row-major Z then X, centred on the origin, at the
707
+ * heightfield's own spacing; each vertex keeps the strongest crown that reaches it (0 to 1).
708
+ * @situation shade the ground under a baked stand, at bake time or after a placement edit
709
+ * @constraint `crowns` is metres of crown radius per unit of placement scale, keyed by asset; other assets paint nothing
710
+ * @requires npm i -D @threenative/terrain
711
+ * @example paintCanopyCover(values, { size: 512, resolution: 257 }, placements, { spruce: 7 });
712
+ */
713
+ declare function paintCanopyCover(values: Float32Array, world: {
714
+ readonly size: number;
715
+ readonly resolution: number;
716
+ }, placements: readonly {
717
+ readonly asset: string;
718
+ readonly position: readonly number[];
719
+ readonly scale: number;
720
+ }[], crowns: Readonly<Record<string, number>>): void;
721
+
722
+ /**
723
+ * The share of the sky each heightfield vertex sees past the terrain around it: 1 on open ground,
724
+ * lower on a valley floor, at a cliff foot or in a crater.
725
+ *
726
+ * The logic follows TerraForge3D's horizon ambient pass (MIT, `heightfield/ambient/compute.glsl`):
727
+ * march outward along evenly spaced azimuths, keep the highest horizon each one meets, and integrate
728
+ * the cosine-weighted sky above it, which is `cos²` of the horizon angle per azimuth. Only ground
729
+ * that rises over both the vertex's tangent plane and the horizontal occludes, so a straight slope
730
+ * and a steep face over a flat floor stay open: the lighting already counts the slope's own tilt.
731
+ *
732
+ * Heights are row-major Z then X, centred on the origin, as the baked world stores them. Every node
733
+ * marches: a strided march filled bilinearly erred by 0.13 at p99 on the alpine survey's creases.
734
+ * About 0.4 s of CPU a world, so `bakeKit` runs it and the game loads `<world>.sky.bin`.
735
+ * @situation bake a heightfield's sky occlusion for the ground's ambient light
736
+ * @constraint offline: about 0.4 s of CPU for a 257² field; bake it, do not run it per frame
737
+ * @requires npm i -D @threenative/terrain
738
+ * @example const sky = skyVisibility(heights, 257, 512);
739
+ */
740
+ declare function skyVisibility(heights: ArrayLike<number>, resolution: number, size: number, { azimuths, reach }?: {
741
+ azimuths?: number;
742
+ reach?: number;
743
+ }): Float32Array;
744
+
760
745
  interface ITerrainStats {
761
746
  /** Highest minus lowest height, metres. */
762
747
  readonly relief: number;
@@ -885,25 +870,6 @@ declare const PARAMS: Readonly<Record<OperationType, readonly string[]>>;
885
870
  */
886
871
  declare function validateDocument(doc: ITerrainDocument): void;
887
872
 
888
- /**
889
- * Bakes the recovered indexed top surface and optional vertical skirts into caller-owned arrays.
890
- * @requires npm i @threenative/terrain
891
- * @situation bake an authored terrain into portable indexed mesh arrays
892
- * @constraint no material is chosen; vertex colours exist only with a caller-supplied palette
893
- * @example const mesh = bakeMesh(new Terrain({ resolution: 17 }).evaluate());
894
- * @override step, chunk bounds, skirtDepth and palette belong to the caller
895
- */
896
- declare function bakeMesh(state: ITerrainState, { step, x, z, cells, skirtDepth, palette, }?: IBakeMeshOptions): IBakedMesh;
897
- /**
898
- * Bakes finite LOD chunks, the same collision samples and resolved placements.
899
- * @requires npm i @threenative/terrain
900
- * @situation prepare terrain arrays and collision before a game starts
901
- * @constraint collision origin is the southwest corner; engine Heightfield origin is its centre
902
- * @example const baked = bakeTerrain(new Terrain({ resolution: 129 }).evaluate(), { chunkCells: 64 });
903
- * @override chunkCells, lodSteps, skirtDepth and palette are explicit authoring choices
904
- */
905
- declare function bakeTerrain(state: ITerrainState, { chunkCells, lodSteps, skirtDepth, palette, }?: IBakeTerrainOptions): IBakedTerrain;
906
-
907
873
  /**
908
874
  * Validate and clone stable-key placement transforms before saving or previewing them.
909
875
  * @requires npm i -D @threenative/terrain
@@ -1009,143 +975,6 @@ declare function encodeZIP(files: readonly IExportFile[]): Uint8Array<ArrayBuffe
1009
975
  declare function makeExport(state: ITerrainState | null, recipe: ITerrainDocument, kind: "project"): Promise<IExportArchive>;
1010
976
  declare function makeExport(state: ITerrainState, recipe: ITerrainDocument, kind: ExportKind): Promise<IExportArchive>;
1011
977
 
1012
- /**
1013
- * The streamed prop worlds one bake writes, and what each one holds.
1014
- *
1015
- * A prop package is the same container as a world package (`world-package.ts`): eight float32 per
1016
- * placement, cells of a fixed size, and one run per asset inside a cell. What it adds is the split
1017
- * into streamed worlds. The game draws its placements in more than one `WorldCells` because reach
1018
- * and shadow policy differ between a horizon-canopy tree and a shadowless blade of grass, and the
1019
- * far field and the vista meadow answer a query flag. This module turns labelled placements into
1020
- * those worlds, so the bake writes them and the game loads them, and neither side owns the grouping.
1021
- */
1022
- /** Which streamed world a record draws in, for a loader that answers a query flag before it loads. */
1023
- type IPropBucketKind = "local" | "far" | "meadow";
1024
- /** One placement, the streamed world it belongs to, and how far it may draw. */
1025
- interface IPropBucketEntry {
1026
- readonly placement: IPlacement;
1027
- /** The streamed world's name, e.g. `local:true`. Two entries of one name share every container field. */
1028
- readonly bucket: string;
1029
- /** Metres at which the record may be culled; `Number.POSITIVE_INFINITY` keeps every cell resident. */
1030
- readonly reach: number;
1031
- /**
1032
- * The model the record draws, when it is not the placement's asset alone: the game's
1033
- * `asset:variant` key, with a shape suffix when one scale cannot carry the placement. The run a
1034
- * record sits in names it, and the loader's asset table is keyed by it.
1035
- */
1036
- readonly key?: string;
1037
- /** Defaults to `local`. A bucket that names two kinds fails the compile. */
1038
- readonly kind?: IPropBucketKind;
1039
- }
1040
- /** One streamed prop world: its container, its per-record reach, and its per-record placement ID. */
1041
- interface IPropBucketPackage {
1042
- readonly bucket: string;
1043
- readonly kind: IPropBucketKind;
1044
- readonly extent: IWorldPackageManifest["extent"];
1045
- readonly cells: readonly {
1046
- readonly x: number;
1047
- readonly z: number;
1048
- readonly runs: readonly IWorldPackageRun[];
1049
- }[];
1050
- /** Eight float32 per record: position, quaternion, uniform scale. */
1051
- readonly placements: Uint8Array;
1052
- /** One float32 per record, in record order. */
1053
- readonly reach: Float32Array;
1054
- /** One placement ID per record, in record order. The game's `variantFor` hashes it. */
1055
- readonly ids: readonly string[];
1056
- }
1057
- interface IPropPackage {
1058
- readonly cellSize: number;
1059
- readonly buckets: readonly IPropBucketPackage[];
1060
- }
1061
- interface ICompilePropBucketsOptions {
1062
- /** Metres per streamed cell. Defaults to 128. */
1063
- readonly cellSize?: number;
1064
- /**
1065
- * The extent every bucket includes before its own placements widen it, e.g. the world square.
1066
- * Without it a bucket spans exactly its own placements.
1067
- */
1068
- readonly bounds?: IWorldPackageManifest["extent"];
1069
- }
1070
- /** The cell size the game streams props in: 128 m, coarse enough that admission jobs stay bounded. */
1071
- declare const PROP_CELL_SIZE = 128;
1072
- /**
1073
- * Group placements into their streamed worlds and write each world's cells and records.
1074
- *
1075
- * The order is the streamed one: cells sorted by `x` then `z`, assets sorted by name inside a cell,
1076
- * and records in the order the entries arrived inside a run. Same-cell, same-asset placements keep
1077
- * their input order, so a re-run of a seeded bake reproduces the buffer byte for byte.
1078
- *
1079
- * @requires npm i -D @threenative/terrain
1080
- * @situation bake the prop worlds a game streams, once, instead of compiling them at load
1081
- * @constraint headless; the caller decides every placement, its streamed world, its reach and its pose
1082
- * @example const pkg = compilePropBuckets(entries, { bounds });
1083
- * @override cellSize and the base extent; the bucket, reach and kind of every entry
1084
- */
1085
- declare function compilePropBuckets(entries: readonly IPropBucketEntry[], options?: ICompilePropBucketsOptions): IPropPackage;
1086
- /**
1087
- * The asset a package run names.
1088
- *
1089
- * A prop run names the model it draws, `asset:variant[@shape]`; a container written by
1090
- * `bakeWorldPackage` names the asset alone. Both reduce to the asset here, which is what a count, a
1091
- * material or a placement's own `asset` field holds.
1092
- *
1093
- * @requires npm i -D @threenative/terrain
1094
- * @situation count one species across a world's prop buckets, or name the asset a run draws
1095
- * @example const asset = propAssetOf("spruce:2"); // "spruce"
1096
- */
1097
- declare function propAssetOf(modelKey: string): string;
1098
- /** One record of a compiled prop bucket, in record order. */
1099
- interface IPropBucketRecord {
1100
- readonly id: string;
1101
- /** The model the record draws, as its run names it (`spruce:2`, or with a shape suffix). */
1102
- readonly key: string;
1103
- /** The asset alone, `propAssetOf(key)`. */
1104
- readonly asset: string;
1105
- readonly position: readonly [number, number, number];
1106
- readonly quaternion: readonly [number, number, number, number];
1107
- readonly scale: number;
1108
- readonly reach: number;
1109
- }
1110
- /**
1111
- * The records of one compiled prop bucket, read back in record order: the inverse of
1112
- * `compilePropBuckets`, so a loader that fetched a bake's files gets each record's ID, model,
1113
- * pose and reach without re-deriving the container layout.
1114
- *
1115
- * @requires npm i -D @threenative/terrain
1116
- * @situation read a baked prop bucket back into placements to ground them on this machine's terrain
1117
- * @constraint throws `TN_PROP_BUCKET_INVALID` when the record buffer, the IDs and the runs disagree
1118
- * @example for (const record of decodePropBucket(bucket)) pose(record.key, record.position, record.quaternion);
1119
- */
1120
- declare function decodePropBucket(bucket: IPropBucketPackage): IPropBucketRecord[];
1121
- /** The files one bake writes for a world's prop package: its bucket list and each bucket's three files. */
1122
- interface IPropPackageFiles {
1123
- readonly manifest: Uint8Array;
1124
- readonly files: Readonly<Record<string, Uint8Array>>;
1125
- }
1126
- /**
1127
- * A path under `world/` that no bucket name can break: `local:true` becomes `local-true`.
1128
- *
1129
- * The bucket's own name is kept in the manifest, so this rename is only a file-system concern.
1130
- *
1131
- * @requires npm i -D @threenative/terrain
1132
- * @situation name one of a bucket's three files without a bucket key that breaks a path
1133
- * @example const file = propPackageFile("forest", "local:true", "props.bin"); // "forest.local-true.props.bin"
1134
- */
1135
- declare function propPackageFile(world: string, bucket: string, suffix: string): string;
1136
- /**
1137
- * Write a compiled package as the manifest the game fetches and one set of files per bucket.
1138
- *
1139
- * The manifest names the files rather than embedding them, so a loader fetches only the buckets its
1140
- * query flags keep (`?farForest=on` keeps the far field, `?meadow=off` drops the vista cover).
1141
- *
1142
- * @requires npm i -D @threenative/terrain
1143
- * @situation write a compiled package to disk: one manifest and three files per streamed world
1144
- * @constraint the manifest names the files; nothing here touches a file system
1145
- * @example const { manifest, files } = propPackageFiles(pkg, "forest");
1146
- */
1147
- declare function propPackageFiles(pkg: IPropPackage, world: string): IPropPackageFiles;
1148
-
1149
978
  /**
1150
979
  * A spatial index for water proximity: river segments, river stations and lake shores.
1151
980
  *
@@ -1179,4 +1008,4 @@ interface ISegmentIndex<T> {
1179
1008
  */
1180
1009
  declare function createSegmentIndex<T>(segments: readonly IWaterSegment<T>[], cellSize: number): ISegmentIndex<T>;
1181
1010
 
1182
- export { BAKE_BIOME_STAGES, type CoverFieldName, type CoverGround, ExportKind, type IBackdropOptions, type IBakeBiomeOptions, type IBakeBiomeStage, IBakeMeshOptions, IBakeTerrainOptions, type IBakedBiome, IBakedMesh, IBakedTerrain, type IBiomeSpec, type IBiomeWaterBody, type ICompilePropBucketsOptions, type ICoverDriftRow, type ICoverField, type ICoverFieldDrift, type ICoverSpec, IDecodeHeightPngOptions, IDecodeRaw16Options, IErosionMaps, IExportArchive, IExportFile, type IFarFieldOptions, type IFarFieldRule, type IFoliageType, type IGrassFieldPlacement, type IGrassGround, type IGrassType, IHeightRange, type ILandformBackdrop, type ILandformInfo, type ILandformOptions, type ILayerInfo, IMask, type IMassifPlacement, type IMassifTile, type IMeasuredBands, type IOrderedScatter, type IOrderedScatterField, type IOrderedScatterRules, type IPlaceMassifOptions, IPlacement, IPlacementOverride, type IPropBucketEntry, type IPropBucketKind, type IPropBucketPackage, type IPropBucketRecord, type IPropPackage, type IPropPackageFiles, IRaw16Options, ISampledGrid, type ISegmentIndex, type ISpawnSpec, ITerrainConfig, ITerrainDocument, ITerrainState, type ITerrainStats, type IUnderstoreySpec, type IWaterSegment, LANDFORMS, type LandformKind, MATERIAL_IDS, MATS_FIELD, Mask, MaterialId, OperationType, PARAMS, PROP_CELL_SIZE, RESOLUTIONS, STAND_FIELD, Terrain, applyPlacementOverrides, bakeBiome, bakeMesh, bakeTerrain, collarSampler, compilePropBuckets, createSegmentIndex, decodeHeightPNG, decodePropBucket, decodeRAW16, encodeGLB, encodeHeightPNG, encodeRAW16, encodeSplatPNGs, encodeZIP, farForestPlacements, fieldWeight, gradientAt, grassFieldFromBiome, landform, landformBackdrop, liftMassif, makeExport, measureBands, orderedScatterRules, placeMassif, propAssetOf, propPackageFile, propPackageFiles, sampleHeight, scatterProps, slopeAtIndex, slopeQuantile, splinePoints, terrainStats, validateBiome, validateDocument, validatePlacementOverrides };
1011
+ export { BAKE_BIOME_STAGES, type CoverFieldName, type CoverGround, ExportKind, type IBakeBiomeOptions, type IBakeBiomeStage, type IBakedBiome, IBakedMesh, type IBiomeSpec, type IBiomeWaterBody, type ICoverDriftRow, type ICoverField, type ICoverFieldDrift, type ICoverSpec, IDecodeHeightPngOptions, IDecodeRaw16Options, IErosionMaps, IExportArchive, IExportFile, type IFarFieldOptions, type IFarFieldRule, type IFoliageType, type IGrassFieldPlacement, type IGrassGround, type IGrassType, IHeightRange, type ILayerInfo, IMask, type IMassifPlacement, type IMassifTile, type IMeasuredBands, type IOrderedScatter, type IOrderedScatterField, type IOrderedScatterRules, type IPlaceMassifOptions, IPlacement, IPlacementOverride, IRaw16Options, ISampledGrid, type ISegmentIndex, type ISpawnSpec, ITerrainDocument, ITerrainState, type ITerrainStats, type IUnderstoreySpec, type IWaterSegment, LandformKind, MATERIAL_IDS, MATS_FIELD, Mask, MaterialId, OperationType, PARAMS, RESOLUTIONS, STAND_FIELD, Terrain, applyPlacementOverrides, bakeBiome, collarSampler, createSegmentIndex, decodeHeightPNG, decodeRAW16, encodeGLB, encodeHeightPNG, encodeRAW16, encodeSplatPNGs, encodeZIP, farForestPlacements, fieldWeight, gradientAt, grassFieldFromBiome, liftMassif, makeExport, measureBands, orderedScatterRules, paintCanopyCover, placeMassif, sampleHeight, scatterProps, skyVisibility, slopeAtIndex, slopeQuantile, splinePoints, terrainStats, validateBiome, validateDocument, validatePlacementOverrides };
package/dist/index.js CHANGED
@@ -4514,6 +4514,115 @@ function placeMassif(terrain, options) {
4514
4514
  };
4515
4515
  }
4516
4516
 
4517
+ // src/ground/canopy.ts
4518
+ function paintCanopyCover(values, world2, placements, crowns) {
4519
+ if (world2.resolution < 2) return;
4520
+ if (values.length !== world2.resolution ** 2)
4521
+ throw new RangeError(
4522
+ `paintCanopyCover: ${values.length} values do not fill a ${world2.resolution}\xB2 grid`
4523
+ );
4524
+ const spacing = world2.size / (world2.resolution - 1);
4525
+ for (const placement of placements) {
4526
+ const crown = crowns[placement.asset];
4527
+ if (crown === void 0) continue;
4528
+ const radius = Math.max(spacing, crown * placement.scale);
4529
+ paintCrown(values, world2, placement.position[0] ?? 0, placement.position[2] ?? 0, radius);
4530
+ }
4531
+ }
4532
+ function paintCrown(values, world2, x, z, radius) {
4533
+ const spacing = world2.size / (world2.resolution - 1);
4534
+ const half = world2.size / 2;
4535
+ const last = world2.resolution - 1;
4536
+ const fromColumn = Math.max(0, Math.ceil((x - radius + half) / spacing));
4537
+ const toColumn = Math.min(last, Math.floor((x + radius + half) / spacing));
4538
+ const fromRow = Math.max(0, Math.ceil((z - radius + half) / spacing));
4539
+ const toRow = Math.min(last, Math.floor((z + radius + half) / spacing));
4540
+ for (let row = fromRow; row <= toRow; row++)
4541
+ for (let column = fromColumn; column <= toColumn; column++) {
4542
+ const dx = column * spacing - half - x;
4543
+ const dz = row * spacing - half - z;
4544
+ const reach = 1 - (dx * dx + dz * dz) / (radius * radius);
4545
+ if (reach <= 0) continue;
4546
+ const index = row * world2.resolution + column;
4547
+ values[index] = Math.max(values[index], reach);
4548
+ }
4549
+ }
4550
+
4551
+ // src/ground/sky-visibility.ts
4552
+ function skyVisibility(heights, resolution, size, { azimuths = 16, reach = 160 } = {}) {
4553
+ if (resolution < 2 || heights.length !== resolution * resolution)
4554
+ throw new RangeError(
4555
+ `skyVisibility: ${heights.length} heights do not fill a ${resolution}\xB2 grid`
4556
+ );
4557
+ const spacing = size / (resolution - 1);
4558
+ const last = resolution - 1;
4559
+ const grid = Float32Array.from(heights);
4560
+ const radii = [];
4561
+ for (let r = spacing; r <= reach; r += Math.max(spacing, r * 0.1)) radii.push(r);
4562
+ const steps = radii.length;
4563
+ const offsetColumn = new Float32Array(azimuths * steps);
4564
+ const offsetRow = new Float32Array(azimuths * steps);
4565
+ const directionX = new Float32Array(azimuths);
4566
+ const directionZ = new Float32Array(azimuths);
4567
+ for (let a = 0; a < azimuths; a++) {
4568
+ const angle = a / azimuths * Math.PI * 2;
4569
+ directionX[a] = Math.cos(angle);
4570
+ directionZ[a] = Math.sin(angle);
4571
+ for (let k = 0; k < steps; k++) {
4572
+ offsetColumn[a * steps + k] = Math.cos(angle) * radii[k] / spacing;
4573
+ offsetRow[a * steps + k] = Math.sin(angle) * radii[k] / spacing;
4574
+ }
4575
+ }
4576
+ const march = {
4577
+ grid,
4578
+ resolution,
4579
+ steps,
4580
+ offsetColumn,
4581
+ offsetRow,
4582
+ inverseRadius: Float32Array.from(radii, (r) => 1 / r)
4583
+ };
4584
+ const visibility = new Float32Array(resolution * resolution);
4585
+ for (let row = 0; row < resolution; row++) {
4586
+ const up = Math.min(row + 1, last);
4587
+ const down = Math.max(row - 1, 0);
4588
+ for (let column = 0; column < resolution; column++) {
4589
+ const right = Math.min(column + 1, last);
4590
+ const left = Math.max(column - 1, 0);
4591
+ const gradientX = (grid[row * resolution + right] - grid[row * resolution + left]) / ((right - left) * spacing);
4592
+ const gradientZ = (grid[up * resolution + column] - grid[down * resolution + column]) / ((up - down) * spacing);
4593
+ let sky = 0;
4594
+ for (let a = 0; a < azimuths; a++) {
4595
+ const plane = Math.max(
4596
+ 0,
4597
+ gradientX * directionX[a] + gradientZ * directionZ[a]
4598
+ );
4599
+ const horizon = horizonTangent(march, row, column, a, plane);
4600
+ sky += 1 / (1 + horizon * horizon);
4601
+ }
4602
+ visibility[row * resolution + column] = sky / azimuths;
4603
+ }
4604
+ }
4605
+ return visibility;
4606
+ }
4607
+ function horizonTangent({ grid, resolution, steps, offsetColumn, offsetRow, inverseRadius }, row, column, azimuth, plane) {
4608
+ const last = resolution - 1;
4609
+ const h0 = grid[row * resolution + column];
4610
+ let horizon = 0;
4611
+ for (let k = 0; k < steps; k++) {
4612
+ const c = column + offsetColumn[azimuth * steps + k];
4613
+ const w = row + offsetRow[azimuth * steps + k];
4614
+ if (c < 0 || c > last || w < 0 || w > last) break;
4615
+ const c0 = c < last ? c | 0 : last - 1;
4616
+ const w0 = w < last ? w | 0 : last - 1;
4617
+ const i = w0 * resolution + c0;
4618
+ const top = grid[i] + (grid[i + 1] - grid[i]) * (c - c0);
4619
+ const bottom = grid[i + resolution] + (grid[i + resolution + 1] - grid[i + resolution]) * (c - c0);
4620
+ const tangent = (top + (bottom - top) * (w - w0) - h0) * inverseRadius[k] - plane;
4621
+ if (tangent > horizon) horizon = tangent;
4622
+ }
4623
+ return horizon;
4624
+ }
4625
+
4517
4626
  // src/core/stats.ts
4518
4627
  var CHANNEL_AREA_M2 = 1e5;
4519
4628
  var quantile = (sorted, q) => sorted[Math.min(sorted.length - 1, Math.floor(q * sorted.length))];
@@ -5124,7 +5233,7 @@ function encodeGLB(input) {
5124
5233
  }
5125
5234
  const binary = join(chunks);
5126
5235
  const doc = {
5127
- asset: { version: "2.0", generator: "@threenative/terrain 0.1.11" },
5236
+ asset: { version: "2.0", generator: "@threenative/terrain 0.1.13" },
5128
5237
  scene: 0,
5129
5238
  scenes: [{ nodes: meshes.map((_, i) => i) }],
5130
5239
  nodes: meshes.map((m, i) => ({ mesh: i, name: m.name ?? `Terrain ${i}` })),
@@ -5479,4 +5588,4 @@ function propPackageFiles(pkg, world2) {
5479
5588
  return { files, manifest: new TextEncoder().encode(JSON.stringify(manifest)) };
5480
5589
  }
5481
5590
 
5482
- export { BAKE_BIOME_STAGES, LANDFORMS, MATERIAL_IDS, MATS_FIELD, Mask, PARAMS, PROP_CELL_SIZE, RESOLUTIONS, STAND_FIELD, Terrain, TerrainEvaluator, applyPlacementOverrides, bakeBiome, bakeMesh, bakeTerrain, bakeWorldPackage, collarSampler, compilePropBuckets, createSegmentIndex, decodeHeightPNG, decodePropBucket, decodeRAW16, encodeGLB, encodeHeightPNG, encodeRAW16, encodeSplatPNGs, encodeZIP, farForestPlacements, fieldWeight, gradientAt, grassFieldFromBiome, landform, landformBackdrop, liftMassif, makeExport, measureBands, orderedScatterRules, placeMassif, propAssetOf, propPackageFile, propPackageFiles, sampleHeight, scatterProps, slopeAtIndex, slopeQuantile, splinePoints, terrainStats, validateBiome, validateDocument, validatePlacementOverrides };
5591
+ export { BAKE_BIOME_STAGES, LANDFORMS, MATERIAL_IDS, MATS_FIELD, Mask, PARAMS, PROP_CELL_SIZE, RESOLUTIONS, STAND_FIELD, Terrain, TerrainEvaluator, applyPlacementOverrides, bakeBiome, bakeMesh, bakeTerrain, bakeWorldPackage, collarSampler, compilePropBuckets, createSegmentIndex, decodeHeightPNG, decodePropBucket, decodeRAW16, encodeGLB, encodeHeightPNG, encodeRAW16, encodeSplatPNGs, encodeZIP, farForestPlacements, fieldWeight, gradientAt, grassFieldFromBiome, landform, landformBackdrop, liftMassif, makeExport, measureBands, orderedScatterRules, paintCanopyCover, placeMassif, propAssetOf, propPackageFile, propPackageFiles, sampleHeight, scatterProps, skyVisibility, slopeAtIndex, slopeQuantile, splinePoints, terrainStats, validateBiome, validateDocument, validatePlacementOverrides };