@threenative/core 0.3.11 → 0.3.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 (236) hide show
  1. package/README.md +1 -1
  2. package/capabilities.json +1988 -204
  3. package/dist/{assets-YUbXa3-Y.d.ts → assets-CfMKnOsK.d.ts} +78 -1
  4. package/dist/camera-shake-CZKOfGn4.d.ts +46 -0
  5. package/dist/{canvas-layer-vCtanIeB.d.ts → canvas-layer-G7ttVy7y.d.ts} +1 -1
  6. package/dist/chunk-4SRAQFTU.js +133 -0
  7. package/dist/chunk-CFGTPFUH.js +231 -0
  8. package/dist/chunk-DIPIJICH.js +8916 -0
  9. package/dist/chunk-EEABDLUC.js +2237 -0
  10. package/dist/chunk-EFWZWLPY.js +1895 -0
  11. package/dist/chunk-GXY7B3JG.js +46 -0
  12. package/dist/chunk-GYUZJQ7U.js +280 -0
  13. package/dist/chunk-H4J6IAJE.js +504 -0
  14. package/dist/chunk-KIRUKTBQ.js +187 -0
  15. package/dist/chunk-QWJEMUUT.js +94 -0
  16. package/dist/chunk-SV4QVUTQ.js +31 -0
  17. package/dist/chunk-U4YHUKKL.js +615 -0
  18. package/dist/chunk-VP43GIWW.js +18 -0
  19. package/dist/chunk-XDTZ4QMO.js +160 -0
  20. package/dist/default-tone-mapping-GgKPTiBP.d.ts +4 -0
  21. package/dist/{game-DzMcitDO.d.ts → game-k8K3hZai.d.ts} +85 -9
  22. package/dist/hot.d.ts +5 -4
  23. package/dist/hot.js +5 -52
  24. package/dist/index.d.ts +633 -1351
  25. package/dist/index.js +12873 -23068
  26. package/dist/{model-lod-CTpZ6imz.d.ts → model-lod-DPTzeCcD.d.ts} +35 -3
  27. package/dist/playtest.d.ts +5 -4
  28. package/dist/playtest.js +25 -75
  29. package/dist/quality-BYqKGAwo.d.ts +868 -0
  30. package/dist/react-css.js +1 -215
  31. package/dist/react.d.ts +3 -2
  32. package/dist/render-environment.d.ts +170 -0
  33. package/dist/render-environment.js +352 -0
  34. package/dist/{renderer-rZm0hVqq.d.ts → renderer-BtOSseYf.d.ts} +42 -35
  35. package/dist/spells/index.d.ts +643 -0
  36. package/dist/spells/index.js +1558 -0
  37. package/dist/spells/ultra/index.d.ts +1600 -0
  38. package/dist/spells/ultra/index.js +6804 -0
  39. package/dist/terrain-jobs-worker.js +1 -123
  40. package/dist/two-sided-foliage-W523J3UM.js +1 -0
  41. package/dist/ui-layer.js +6 -384
  42. package/dist/worker.js +13 -43
  43. package/dist/world.d.ts +988 -268
  44. package/dist/world.js +17464 -18290
  45. package/mcp/animation-server.mjs +1 -1
  46. package/mcp/animation.mjs +2 -3
  47. package/mcp/engine-server.mjs +245 -52
  48. package/mcp/servers.mjs +10 -3
  49. package/mcp/terrain.mjs +8 -0
  50. package/package.json +19 -7
  51. package/patches/three@0.187.0-prd269-upgrade.patch +2102 -0
  52. package/patches/three@0.187.0.patch +2004 -407
  53. package/src/animation-batch.ts +193 -0
  54. package/src/animation-layers.ts +7 -3
  55. package/src/animation.ts +209 -29
  56. package/src/asset-cache.ts +3 -3
  57. package/src/asset-memo.ts +202 -0
  58. package/src/assets.ts +437 -125
  59. package/src/auto-batch.ts +190 -44
  60. package/src/card-lod.ts +152 -0
  61. package/src/compressed-texture-preparation.ts +1008 -0
  62. package/src/compute-driven.ts +1 -1
  63. package/src/config.ts +8 -0
  64. package/src/debug.ts +103 -22
  65. package/src/dev-global.ts +54 -0
  66. package/src/engine-hooks.ts +37 -0
  67. package/src/frame-budget.ts +50 -23
  68. package/src/game-boot-phase.ts +269 -0
  69. package/src/game-dev-tools.ts +86 -0
  70. package/src/game-frame-loop.ts +958 -0
  71. package/src/game-renderer-metrics.ts +77 -0
  72. package/src/game-startup.ts +1076 -0
  73. package/src/game-ui.ts +84 -0
  74. package/src/game-validate.ts +70 -0
  75. package/src/game.ts +198 -2264
  76. package/src/gamepad-mappings.ts +269 -0
  77. package/src/generated/console-markers.ts +13 -0
  78. package/src/geometry-capture.ts +28 -4
  79. package/src/gpu-readings.ts +98 -0
  80. package/src/gpu-scene-bvh.ts +149 -36
  81. package/src/hot.ts +4 -7
  82. package/src/index.ts +141 -9
  83. package/src/input.ts +237 -25
  84. package/src/instanced-batch-lod.ts +3 -8
  85. package/src/interpolation.ts +171 -40
  86. package/src/launch-diagnostics.ts +22 -12
  87. package/src/look/ao-admission.ts +25 -0
  88. package/src/look/auto-exposure.ts +5 -16
  89. package/src/look/default-tone-mapping.ts +41 -5
  90. package/src/look/filmic-tone-mapping.ts +15 -13
  91. package/src/look/local-exposure.ts +2 -7
  92. package/src/look/look-diagnostics.ts +3 -3
  93. package/src/look/quad-pass.ts +21 -0
  94. package/src/look/quality.ts +14 -5
  95. package/src/look/unreal-bloom.ts +4 -13
  96. package/src/look/world-environment.ts +113 -103
  97. package/src/loop.ts +29 -0
  98. package/src/merge-parts.ts +20 -24
  99. package/src/model-lod.ts +139 -17
  100. package/src/particle-kinds.ts +515 -0
  101. package/src/particle-significance.ts +12 -0
  102. package/src/particles.ts +19 -10
  103. package/src/picking.ts +17 -3
  104. package/src/platform.ts +23 -4
  105. package/src/playtest.ts +27 -1
  106. package/src/profiling/FrameStages.ts +5 -6
  107. package/src/profiling/Spans.ts +3 -17
  108. package/src/profiling/debug-telemetry.ts +2 -6
  109. package/src/profiling/render-list-validate.ts +6 -15
  110. package/src/projection-apply.ts +4 -1
  111. package/src/projection-marker.ts +2 -1
  112. package/src/projection-plan.ts +9 -6
  113. package/src/quiet-markers.ts +3 -10
  114. package/src/render/cpu-bvh.ts +100 -0
  115. package/src/render/depth-pyramid.ts +6 -14
  116. package/src/render/environment/environmentContribution.ts +202 -0
  117. package/src/render/environment/environmentRadiance.ts +44 -0
  118. package/src/render/environment/environmentSampleCache.ts +56 -0
  119. package/src/render/environment/environmentSampling.ts +201 -0
  120. package/src/render/environment/environmentSnapshot.ts +71 -0
  121. package/src/render/environment/gate.ts +57 -0
  122. package/src/render/mesh-pool.ts +4 -20
  123. package/src/render/probe-trace.ts +872 -0
  124. package/src/render/probe-volume.ts +780 -34
  125. package/src/render/radiance-cache.ts +17 -0
  126. package/src/render/resolution-subrect.ts +2 -0
  127. package/src/render/rough-diffuse.ts +46 -12
  128. package/src/render/soft-shadow.ts +27 -12
  129. package/src/render/virtual-shadow-adaptive.ts +55 -0
  130. package/src/render/virtual-shadow-casters.ts +175 -0
  131. package/src/render/virtual-shadow-layers.ts +76 -0
  132. package/src/render/virtual-shadow-level.ts +224 -0
  133. package/src/render/virtual-shadow-markers.ts +193 -0
  134. package/src/render/virtual-shadow-options.ts +370 -0
  135. package/src/render/virtual-shadow-pages.ts +5 -0
  136. package/src/render/virtual-shadow-partial.ts +13 -0
  137. package/src/render/virtual-shadow.ts +231 -1008
  138. package/src/render/world-impostor-surface.ts +402 -40
  139. package/src/render/world-impostor.ts +5 -2
  140. package/src/render-camera-cull.ts +98 -3
  141. package/src/render-environment.ts +41 -0
  142. package/src/render-pass-budget.ts +34 -7
  143. package/src/renderProjection.ts +22 -0
  144. package/src/renderer-config.ts +36 -0
  145. package/src/renderer-facts.ts +37 -0
  146. package/src/renderer.ts +144 -65
  147. package/src/resolution-scaler.ts +3 -2
  148. package/src/scene-entry-inspectors.ts +61 -0
  149. package/src/snow-field.ts +2 -1
  150. package/src/spells/cast-pool.ts +361 -0
  151. package/src/spells/index.ts +177 -0
  152. package/src/spells/mechanisms.ts +295 -0
  153. package/src/spells/reaction-field.ts +415 -0
  154. package/src/spells/spell-lights.ts +139 -0
  155. package/src/spells/spell-world.ts +187 -0
  156. package/src/spells/spell.ts +397 -0
  157. package/src/spells/spells.ts +283 -0
  158. package/src/spells/ultra/engine/camera.ts +184 -0
  159. package/src/spells/ultra/engine/quality.ts +96 -0
  160. package/src/spells/ultra/index.ts +52 -0
  161. package/src/spells/ultra/main.ts +305 -0
  162. package/src/spells/ultra/scene/arenaMaterial.ts +325 -0
  163. package/src/spells/ultra/spells/cast.ts +233 -0
  164. package/src/spells/ultra/spells/fire.ts +1267 -0
  165. package/src/spells/ultra/vfx/FluidVolume.ts +816 -0
  166. package/src/spells/ultra/vfx/FluidVolume.tsl.ts +855 -0
  167. package/src/spells/ultra/vfx/FxTarget.ts +61 -0
  168. package/src/spells/ultra/vfx/GroundField.ts +1399 -0
  169. package/src/spells/ultra/vfx/Particles.ts +1475 -0
  170. package/src/spells/ultra/vfx/Ribbons.ts +645 -0
  171. package/src/spells/ultra/vfx/Shockwaves.ts +286 -0
  172. package/src/spells/ultra/vfx/Volumes.ts +489 -0
  173. package/src/spells/ultra/vfx/common.ts +1195 -0
  174. package/src/spells/ultra/vfx/noise.ts +441 -0
  175. package/src/startup-offscreen-bytes.ts +78 -0
  176. package/src/startup-readiness.ts +128 -34
  177. package/src/static-transform.ts +25 -19
  178. package/src/streamed-textures.ts +112 -0
  179. package/src/streaming.ts +68 -4
  180. package/src/texture-streaming.ts +331 -0
  181. package/src/version.ts +1 -1
  182. package/src/warmup.ts +56 -8
  183. package/src/water-surface.ts +9 -3
  184. package/src/worker.ts +12 -2
  185. package/src/world-bundle-safety.ts +446 -0
  186. package/src/world-cell-batches.ts +1178 -0
  187. package/src/world-cell-chunks.ts +1128 -0
  188. package/src/world-cell-data.ts +995 -0
  189. package/src/world-cell-impostors.ts +1461 -0
  190. package/src/world-cell-lod-bias.ts +151 -0
  191. package/src/world-cell-models.ts +1074 -0
  192. package/src/world-cell-options.ts +177 -0
  193. package/src/world-cell-placements.ts +798 -0
  194. package/src/world-cell-prewarm.ts +592 -0
  195. package/src/world-cell-readiness.ts +357 -0
  196. package/src/world-cell-records.ts +401 -0
  197. package/src/world-cell-render-bundles.ts +459 -0
  198. package/src/world-cell-render-gpu-dress.ts +710 -0
  199. package/src/world-cell-render-main-cull.ts +540 -0
  200. package/src/world-cell-render-shadow-claims.ts +198 -0
  201. package/src/world-cell-render-util.ts +259 -0
  202. package/src/world-cell-render.ts +1501 -0
  203. package/src/world-cell-residency.ts +754 -0
  204. package/src/world-cell-stale.ts +238 -0
  205. package/src/world-cells.ts +1335 -10418
  206. package/src/world-chunk-shadow.ts +308 -0
  207. package/src/world-collar.ts +315 -0
  208. package/src/world-gpu-flags.ts +131 -0
  209. package/src/world-gpu-readback.ts +881 -0
  210. package/src/world-gpu-reference.ts +524 -0
  211. package/src/world-gpu-scene.ts +256 -2286
  212. package/src/world-gpu-shadow.ts +203 -0
  213. package/src/world-gpu-types.ts +409 -0
  214. package/src/world-gpu-validation.ts +518 -0
  215. package/src/world-heightfield.ts +802 -0
  216. package/src/world-load-limiter.ts +111 -0
  217. package/src/world-model-sections.ts +80 -0
  218. package/src/world-noise.ts +241 -0
  219. package/src/world-package.ts +42 -0
  220. package/src/world-region.ts +1 -1
  221. package/src/world-river-ribbon.ts +282 -0
  222. package/src/world-root-frame.ts +39 -0
  223. package/src/world-shore-field.ts +91 -0
  224. package/src/world-static-pose.ts +163 -0
  225. package/src/world-surface-sampler.ts +48 -0
  226. package/src/world-terrain-splat.ts +361 -153
  227. package/src/world-tile-budget.ts +249 -0
  228. package/src/world-tile-geometry.ts +469 -0
  229. package/src/world-tile-lod.ts +408 -0
  230. package/src/world-tile-observation.ts +566 -0
  231. package/src/world-tile-stitch.ts +166 -0
  232. package/src/world-tiles.ts +247 -1755
  233. package/src/world-validate.ts +6 -14
  234. package/src/world-warm.ts +51 -0
  235. package/src/world-water-bodies.ts +359 -0
  236. package/src/world.ts +48 -741
package/src/world.ts CHANGED
@@ -1,745 +1,41 @@
1
- import { BufferAttribute, BufferGeometry, Group, Sphere, Vector3 } from "three";
2
- import type { IComputeDriven } from "./compute-driven.js";
3
- import { GPUReadback, type IGPUReadbackSample } from "./gpu-readback.js";
4
- import type { IRendererLike } from "./renderer.js";
5
- import {
6
- type IWorldErosionOptions,
7
- type IWorldGpuPasses,
8
- createWorldGpuPasses,
9
- simulateWorldPassesCpu,
10
- } from "./world-passes.js";
11
- import { unionBounds } from "./world-region.js";
1
+ export * from "./world-heightfield.js";
12
2
 
13
- export interface IHeightfieldOrigin {
14
- readonly x: number;
15
- readonly z: number;
16
- }
17
-
18
- export interface IHeightfieldOptions {
19
- readonly columns: number;
20
- readonly depth: number;
21
- readonly heights: Float32Array;
22
- readonly origin: IHeightfieldOrigin;
23
- readonly rows: number;
24
- readonly width: number;
25
- readonly worldPasses?: IHeightfieldWorldPassOptions;
26
- }
27
-
28
- /** A rectangular window of a heightfield's canonical samples, in grid indices. */
29
- /** Hands out the union of every window `updateHeights` wrote since the last `take`. */
30
- export interface IHeightfieldChangeTracker {
31
- /** The changed window since the previous take, or undefined when nothing changed. */
32
- take(): IHeightfieldRegionBounds | undefined;
33
- /** Stop tracking. Idempotent. */
34
- dispose(): void;
35
- }
36
-
37
- export interface IHeightfieldRegionBounds {
38
- /** First column (x index), inclusive. */
39
- readonly column: number;
40
- /** Number of columns covered. */
41
- readonly columns: number;
42
- /** First row (z index), inclusive. */
43
- readonly row: number;
44
- /** Number of rows covered. */
45
- readonly rows: number;
46
- }
47
-
48
- /** A rectangular window plus the replacement samples written over it. */
49
- export interface IHeightfieldRegion extends IHeightfieldRegionBounds {
50
- /** Row-major samples, `columns * rows` long and read with the region's own stride. */
51
- readonly heights: Float32Array;
52
- }
53
-
54
- export interface IHeightfieldWorldPassOptions {
55
- /** Maximum TSL compute dispatches submitted by one rendered frame. */
56
- readonly dispatchBudget: number;
57
- /** Reserved GPU path; true is rejected until GPU readback owns the canonical field. */
58
- readonly gpu?: boolean;
59
- /** Every physical coefficient is game supplied; core owns no terrain preset. */
60
- readonly erosion: IWorldErosionOptions;
61
- }
62
-
63
- export interface IHeightfieldSamplerOptions extends Omit<IHeightfieldOptions, "heights"> {
64
- /** Game-owned terrain function. It is evaluated once and never retained. */
65
- readonly sampleHeight: (x: number, z: number) => number;
66
- }
67
-
68
- interface IStoredHeightfieldChannels {
69
- readonly flow?: Float32Array;
70
- readonly moisture?: Float32Array;
71
- }
72
-
73
- function finite(value: number, name: string): number {
74
- if (!Number.isFinite(value)) throw new Error(`Heightfield ${name} must be finite.`);
75
- return value;
76
- }
77
-
78
- function positive(value: number, name: string): number {
79
- finite(value, name);
80
- if (value <= 0) throw new Error(`Heightfield ${name} must be greater than zero.`);
81
- return value;
82
- }
83
-
84
- function count(value: number, name: string): number {
85
- if (!Number.isInteger(value) || value < 2)
86
- throw new Error(`Heightfield ${name} must be an integer of at least 2.`);
87
- return value;
88
- }
89
-
90
- /** Validates one axis of an update window against the field's own sample count. */
91
- function regionAxis(
92
- start: number,
93
- size: number,
94
- total: number,
95
- names: readonly [string, string],
96
- ): { readonly count: number; readonly start: number } {
97
- if (!Number.isInteger(start) || start < 0)
98
- throw new Error(`Heightfield region ${names[0]} must be an integer of at least 0.`);
99
- if (!Number.isInteger(size) || size < 1)
100
- throw new Error(`Heightfield region ${names[1]} must be an integer of at least 1.`);
101
- if (start + size > total)
102
- throw new Error(
103
- `Heightfield region ${names[0]} ${String(start)} + ${names[1]} ${String(size)} exceeds the field's ${String(total)} samples.`,
104
- );
105
- return { count: size, start };
106
- }
107
-
108
- function regionColumns(
109
- region: IHeightfieldRegionBounds,
110
- total: number,
111
- ): { readonly count: number; readonly start: number } {
112
- return regionAxis(region.column, region.columns, total, ["column", "columns"]);
113
- }
114
-
115
- function regionRows(
116
- region: IHeightfieldRegionBounds,
117
- total: number,
118
- ): { readonly count: number; readonly start: number } {
119
- return regionAxis(region.row, region.rows, total, ["row", "rows"]);
120
- }
121
-
122
- function shouldBuildGpuPasses(options: IHeightfieldWorldPassOptions | undefined): boolean {
123
- return options?.gpu === true;
124
- }
125
-
126
- function validateWorldPassBudget(options: IHeightfieldWorldPassOptions): void {
127
- if (!Number.isInteger(options.dispatchBudget) || options.dispatchBudget <= 0)
128
- throw new Error("Heightfield world passes dispatchBudget must be a positive integer.");
129
- if (options.gpu === true) return;
130
- if (!Number.isInteger(options.erosion.iterations) || options.erosion.iterations < 0) return;
131
- if (options.erosion.iterations > options.dispatchBudget)
132
- throw new Error("Heightfield dispatchBudget cannot cover synchronous CPU erosion iterations.");
133
- }
134
-
135
- /**
136
- * One height buffer shared by world queries, rendered geometry, and a physics heightfield.
137
- *
138
- * The game supplies every value, so changing the terrain's shape never requires a package edit.
139
- * `fromSampler` evaluates that game function exactly once at each vertex and retains only the
140
- * resulting numbers. Queries interpolate those same numbers instead of evaluating the function
141
- * again.
142
- *
143
- * @situation build terrain geometry and collision from one game-authored height function
144
- * @situation generate a terrain a player can walk across
145
- * @situation query the same ground height or normal that a player sees and collides with
146
- * @situation ask how high the ground is here
147
- * @situation build islands and coastlines from terrain
148
- * @situation keep a collider or other copy of a deforming terrain in step without rescanning the whole field (`trackChanges`)
149
- * @constraint sampleHeight owns the terrain shape and stays in game source; the framework stores and interpolates its output
150
- * @constraint rows and columns are vertex counts; geometry is row-major z-then-x and collider export transposes once into Rapier's column-major matrix order
151
- * @override rows, columns, width, depth, origin, and sampleHeight are explicit on every field
152
- * @example const field = Heightfield.fromSampler({ rows: 65, columns: 65, width: 64, depth: 64, origin: { x: 0, z: 0 }, sampleHeight: terrainHeight });
153
- */
154
- export class Heightfield extends Group implements IComputeDriven {
155
- readonly columns: number;
156
- readonly depth: number;
157
- readonly origin: IHeightfieldOrigin;
158
- readonly rows: number;
159
- readonly width: number;
160
- readonly processCadence = "render" as const;
161
- readonly warmupNodes: readonly unknown[];
162
- readonly #cellDepth: number;
163
- readonly #cellWidth: number;
164
- readonly #colliderHeights: Float32Array;
165
- readonly #trackers = new Set<{ region: IHeightfieldRegionBounds | undefined }>();
166
- readonly #heights: Float32Array;
167
- readonly #minimumX: number;
168
- readonly #minimumZ: number;
169
- readonly #flow: Float32Array | undefined;
170
- readonly #moisture: Float32Array | undefined;
171
- readonly #gpu: IWorldGpuPasses | undefined;
172
- readonly #heightReadback: GPUReadback | undefined;
173
- readonly #flowReadback: GPUReadback | undefined;
174
- readonly #moistureReadback: GPUReadback | undefined;
175
- #renderer: IRendererLike | undefined;
176
- #gpuCompletionObserved = false;
177
- #released = false;
178
- #version = 0;
179
-
180
- constructor(options: IHeightfieldOptions & IStoredHeightfieldChannels) {
181
- super();
182
- this.columns = count(options.columns, "columns");
183
- this.rows = count(options.rows, "rows");
184
- this.width = positive(options.width, "width");
185
- this.depth = positive(options.depth, "depth");
186
- this.origin = {
187
- x: finite(options.origin.x, "origin.x"),
188
- z: finite(options.origin.z, "origin.z"),
189
- };
190
- const expected = this.rows * this.columns;
191
- if (options.heights.length !== expected)
192
- throw new Error(
193
- `Heightfield expected ${expected} heights, received ${options.heights.length}.`,
194
- );
195
- if (options.flow !== undefined && options.flow.length !== expected)
196
- throw new Error(
197
- `Heightfield expected ${expected} flow samples, received ${options.flow.length}.`,
198
- );
199
- if (options.moisture !== undefined && options.moisture.length !== expected)
200
- throw new Error(
201
- `Heightfield expected ${expected} moisture samples, received ${options.moisture.length}.`,
202
- );
203
- for (const height of options.heights) finite(height, "height sample");
204
- for (const value of options.flow ?? []) finite(value, "flow sample");
205
- for (const value of options.moisture ?? []) finite(value, "moisture sample");
206
- const baseHeights = options.heights.slice();
207
- const storedFlow = options.flow?.slice();
208
- const storedMoisture = options.moisture?.slice();
209
- const passOptions = options.worldPasses;
210
- if (passOptions !== undefined) validateWorldPassBudget(passOptions);
211
- if (passOptions?.gpu === true)
212
- throw new Error(
213
- "Heightfield GPU generation cannot be canonical; use gpu: false until GPU readback owns the field.",
214
- );
215
- const cpu =
216
- passOptions === undefined
217
- ? undefined
218
- : simulateWorldPassesCpu({
219
- cellDepth: this.depth / (this.rows - 1),
220
- cellWidth: this.width / (this.columns - 1),
221
- columns: this.columns,
222
- erosion: passOptions.erosion,
223
- heights: baseHeights,
224
- rows: this.rows,
225
- });
226
- this.#heights = cpu?.heights ?? baseHeights;
227
- this.#flow = cpu?.flow ?? storedFlow;
228
- this.#moisture = cpu?.moisture ?? storedMoisture;
229
- // The explicit GPU request is rejected above; omitted and CPU-fallback paths never create GPU
230
- // state and cannot accidentally expose a CPU-canonical field as GPU-generated.
231
- this.#gpu =
232
- passOptions === undefined || !shouldBuildGpuPasses(passOptions)
233
- ? undefined
234
- : createWorldGpuPasses({
235
- cellDepth: this.depth / (this.rows - 1),
236
- cellWidth: this.width / (this.columns - 1),
237
- columns: this.columns,
238
- dispatchBudget: passOptions.dispatchBudget,
239
- erosion: passOptions.erosion,
240
- heights: baseHeights,
241
- rows: this.rows,
242
- });
243
- this.warmupNodes = this.#gpu?.stages.flatMap((stage) => stage.nodes) ?? [];
244
- this.#heightReadback =
245
- this.#gpu === undefined
246
- ? undefined
247
- : new GPUReadback({ attribute: this.#gpu.height.value, everyFrames: 1 });
248
- this.#flowReadback =
249
- this.#gpu === undefined
250
- ? undefined
251
- : new GPUReadback({ attribute: this.#gpu.flow.value, everyFrames: 1 });
252
- this.#moistureReadback =
253
- this.#gpu === undefined
254
- ? undefined
255
- : new GPUReadback({ attribute: this.#gpu.moisture.value, everyFrames: 1 });
256
- this.#colliderHeights = new Float32Array(expected);
257
- for (let column = 0; column < this.columns; column += 1) {
258
- for (let row = 0; row < this.rows; row += 1) {
259
- this.#colliderHeights[column * this.rows + row] = this.#height(row * this.columns + column);
260
- }
261
- }
262
- this.#cellWidth = this.width / (this.columns - 1);
263
- this.#cellDepth = this.depth / (this.rows - 1);
264
- this.#minimumX = this.origin.x - this.width / 2;
265
- this.#minimumZ = this.origin.z - this.depth / 2;
266
- }
267
-
268
- static fromSampler(options: IHeightfieldSamplerOptions): Heightfield {
269
- const columns = count(options.columns, "columns");
270
- const rows = count(options.rows, "rows");
271
- const width = positive(options.width, "width");
272
- const depth = positive(options.depth, "depth");
273
- const originX = finite(options.origin.x, "origin.x");
274
- const originZ = finite(options.origin.z, "origin.z");
275
- const minimumX = originX - width / 2;
276
- const minimumZ = originZ - depth / 2;
277
- const cellWidth = width / (columns - 1);
278
- const cellDepth = depth / (rows - 1);
279
- const heights = new Float32Array(rows * columns);
280
-
281
- for (let row = 0; row < rows; row += 1) {
282
- const z = minimumZ + row * cellDepth;
283
- for (let column = 0; column < columns; column += 1) {
284
- const x = minimumX + column * cellWidth;
285
- heights[row * columns + column] = finite(options.sampleHeight(x, z), "sampleHeight result");
286
- }
287
- }
288
-
289
- return new Heightfield({
290
- columns,
291
- depth,
292
- heights,
293
- origin: options.origin,
294
- rows,
295
- width,
296
- ...(options.worldPasses === undefined ? {} : { worldPasses: options.worldPasses }),
297
- });
298
- }
299
-
300
- sample(channel: string, x: number, z: number): number {
301
- if (channel === "height") return this.heightAt(x, z);
302
- if (channel === "slope") return 1 - this.normalAt(x, z).y;
303
- const values =
304
- channel === "flow" ? this.#flow : channel === "moisture" ? this.#moisture : undefined;
305
- if (values === undefined) throw new Error(`Heightfield unknown channel '${channel}'.`);
306
- return this.#interpolateValues(values, x, z);
307
- }
308
-
309
- get released(): boolean {
310
- return this.#released;
311
- }
312
-
313
- get generationComplete(): boolean {
314
- return this.#gpu?.queue.complete ?? true;
315
- }
316
-
317
- get gpuHeightSample(): IGPUReadbackSample | undefined {
318
- return this.#heightReadback?.sample;
319
- }
320
-
321
- attachRenderer(renderer: IRendererLike): void {
322
- if (this.#released) throw new Error("Heightfield cannot be attached after release.");
323
- if (this.#gpu === undefined) return;
324
- if (renderer.kind !== "webgpu") throw new Error("Heightfield world passes require WebGPU.");
325
- if (this.#renderer !== undefined && this.#renderer !== renderer)
326
- throw new Error("Heightfield is already attached to a renderer.");
327
- this.#renderer = renderer;
328
- }
329
-
330
- process(renderer = this.#renderer): void {
331
- if (this.#released || this.#gpu === undefined) return;
332
- if (renderer === undefined) throw new Error("Heightfield is not attached to a renderer.");
333
- const submitted = this.#gpu.queue.process(renderer);
334
- if (submitted > 0 || !this.#gpu.queue.complete) {
335
- this.#gpuCompletionObserved = false;
336
- return;
337
- }
338
- // Compute is scheduled before the renderer's draw. Delay the first copy until the next loop
339
- // turn so the submitted passes have actually run; an immediate getArrayBufferAsync observes
340
- // the previous storage contents on WebGPU and turns parity into a false no-data report.
341
- if (!this.#gpuCompletionObserved) {
342
- this.#gpuCompletionObserved = true;
343
- return;
344
- }
345
- if (this.#heightReadback?.sample === undefined) {
346
- this.#heightReadback?.request(renderer);
347
- return;
348
- }
349
- if (this.#flowReadback?.sample === undefined) {
350
- this.#flowReadback?.request(renderer);
351
- return;
352
- }
353
- if (this.#moistureReadback?.sample === undefined) this.#moistureReadback?.request(renderer);
354
- }
355
-
356
- debug(): Record<string, unknown> {
357
- return {
358
- complete: this.generationComplete,
359
- dispatched: this.#gpu?.queue.dispatched ?? 0,
360
- gpuHeightMaxError: this.#sampleError(this.#heightReadback?.sample, this.#heights),
361
- gpuFlowMaxError: this.#sampleError(this.#flowReadback?.sample, this.#flow),
362
- gpuMoistureMaxError: this.#sampleError(this.#moistureReadback?.sample, this.#moisture),
363
- released: this.#released,
364
- };
365
- }
366
-
367
- detach(): void {
368
- if (this.#released) return;
369
- this.#renderer = undefined;
370
- this.#heightReadback?.dispose();
371
- this.#flowReadback?.dispose();
372
- this.#moistureReadback?.dispose();
373
- this.#gpu?.dispose();
374
- this.#released = true;
375
- }
376
-
377
- /** A copy of the canonical row-major samples, safe for game-side analysis. */
378
- get heights(): Float32Array {
379
- return this.#heights.slice();
380
- }
381
-
382
- /** A copy of the normalized routed-flow channel, when world passes were requested. */
383
- get flow(): Float32Array | undefined {
384
- return this.#flow?.slice();
385
- }
386
-
387
- /** Bytes retained by this field's CPU channels and its conservative GPU allowance. */
388
- get memoryBytes(): number {
389
- const sampleBytes = this.rows * this.columns * Float32Array.BYTES_PER_ELEMENT;
390
- const cpuBytes =
391
- sampleBytes * 2 +
392
- (this.#flow === undefined ? 0 : sampleBytes) +
393
- (this.#moisture === undefined ? 0 : sampleBytes);
394
- return this.#gpu === undefined ? cpuBytes : Math.max(cpuBytes, sampleBytes * 24);
395
- }
396
-
397
- heightAt(x: number, z: number): number {
398
- finite(x, "query x");
399
- finite(z, "query z");
400
- const column = (x - this.#minimumX) / this.#cellWidth;
401
- const row = (z - this.#minimumZ) / this.#cellDepth;
402
- const epsilon = 1e-9;
403
- if (
404
- column < -epsilon ||
405
- row < -epsilon ||
406
- column > this.columns - 1 + epsilon ||
407
- row > this.rows - 1 + epsilon
408
- )
409
- throw new Error(`Heightfield query (${x}, ${z}) is outside its resident region.`);
410
- return this.#interpolate(
411
- Math.min(this.columns - 1, Math.max(0, column)),
412
- Math.min(this.rows - 1, Math.max(0, row)),
413
- );
414
- }
415
-
416
- normalAt(x: number, z: number, target = new Vector3()): Vector3 {
417
- this.heightAt(x, z);
418
- const leftX = Math.max(this.#minimumX, x - this.#cellWidth);
419
- const rightX = Math.min(this.#minimumX + this.width, x + this.#cellWidth);
420
- const nearZ = Math.max(this.#minimumZ, z - this.#cellDepth);
421
- const farZ = Math.min(this.#minimumZ + this.depth, z + this.#cellDepth);
422
- const slopeX = (this.heightAt(rightX, z) - this.heightAt(leftX, z)) / (rightX - leftX);
423
- const slopeZ = (this.heightAt(x, farZ) - this.heightAt(x, nearZ)) / (farZ - nearZ);
424
- return target.set(-slopeX, 1, -slopeZ).normalize();
425
- }
426
-
427
- /**
428
- * Monotonic sample version, incremented by every `updateHeights` call.
429
- *
430
- * A renderer or collider that caches derived data compares this against its own last-seen value
431
- * instead of diffing the whole grid each frame.
432
- */
433
- get version(): number {
434
- return this.#version;
435
- }
436
-
437
- /**
438
- * Overwrite one rectangular window of the canonical samples.
439
- *
440
- * Height is the one buffer queries, rendered geometry and collider export share, so a second
441
- * terrain representation is never needed: a simulation writes its surface here and every
442
- * consumer already reads it. The whole window is validated before any sample changes, so a
443
- * malformed call leaves the field untouched rather than half-written.
444
- * @situation deform terrain, snow or water in place and have queries and collision follow
445
- * @constraint the region must lie inside the field; an out-of-bounds window throws and writes nothing
446
- * @constraint heights is `columns * rows` long, row-major, and every sample must be finite
447
- */
448
- updateHeights(region: IHeightfieldRegion): void {
449
- if (this.#released) throw new Error("Heightfield cannot be updated after release.");
450
- const column = regionColumns(region, this.columns);
451
- const row = regionRows(region, this.rows);
452
- const expected = column.count * row.count;
453
- if (region.heights.length !== expected)
454
- throw new Error(
455
- `Heightfield region expected ${expected} heights, received ${region.heights.length}.`,
456
- );
457
- for (const height of region.heights) finite(height, "region sample");
458
- for (let index = 0; index < row.count; index += 1) {
459
- for (let offset = 0; offset < column.count; offset += 1) {
460
- const target = row.start + index;
461
- const source = column.start + offset;
462
- this.#heights[target * this.columns + source] = region.heights[
463
- index * column.count + offset
464
- ] as number;
465
- this.#colliderHeights[source * this.rows + target] = this.#height(
466
- target * this.columns + source,
467
- );
468
- }
469
- }
470
- const written = {
471
- column: column.start,
472
- columns: column.count,
473
- row: row.start,
474
- rows: row.count,
475
- };
476
- for (const tracker of this.#trackers) tracker.region = unionBounds(tracker.region, written);
477
- this.#version += 1;
478
- }
479
-
480
- /**
481
- * Follow which samples change, independently of every other follower.
482
- *
483
- * A consumer that mirrors the surface — a collider, a GPU copy, a cache — needs the window that
484
- * changed since *it* last looked; comparing the whole field instead costs every sample on every
485
- * change. Each tracker keeps its own union of the windows `updateHeights` wrote, so two
486
- * consumers never take each other's changes.
487
- *
488
- * ```ts
489
- * const changes = field.trackChanges();
490
- * const changed = changes.take(); // undefined when nothing was written
491
- * ```
492
- */
493
- trackChanges(): IHeightfieldChangeTracker {
494
- const state: { region: IHeightfieldRegionBounds | undefined } = { region: undefined };
495
- this.#trackers.add(state);
496
- return {
497
- take: () => {
498
- const region = state.region;
499
- state.region = undefined;
500
- return region;
501
- },
502
- dispose: () => {
503
- this.#trackers.delete(state);
504
- },
505
- };
506
- }
507
-
508
- /** The collider sample at `row`, `column`: what `toColliderHeights()` holds there, without a copy. */
509
- colliderHeight(row: number, column: number): number {
510
- if (
511
- !Number.isInteger(row) ||
512
- !Number.isInteger(column) ||
513
- row < 0 ||
514
- column < 0 ||
515
- row >= this.rows ||
516
- column >= this.columns
517
- )
518
- throw new Error(`Heightfield sample ${row},${column} is outside the field.`);
519
- return this.#colliderHeights[column * this.rows + row] as number;
520
- }
521
-
522
- /**
523
- * Rewrite an existing `toGeometry()` result from the current canonical samples.
524
- *
525
- * Positions carry over unchanged because only the surface moves; y and normals are refreshed
526
- * from the same sampler queries use, which is what keeps a rendered vertex and a height query
527
- * from disagreeing. Pass a region to touch only the window a simulation just changed.
528
- * @situation redraw a terrain, snow or water mesh after its samples changed
529
- * @constraint geometry must come from `toGeometry()` with the same rows and columns
530
- */
531
- refreshGeometry(geometry: BufferGeometry, bounds?: IHeightfieldRegionBounds): void {
532
- const position = geometry.getAttribute("position");
533
- const normalAttribute = geometry.getAttribute("normal");
534
- if (position.count !== this.rows * this.columns)
535
- throw new Error(
536
- `Heightfield geometry has ${position.count} vertices, expected ${this.rows * this.columns}.`,
537
- );
538
- // Only a plain BufferAttribute exposes its lanes raw; a custom subclass or an own setter would be bypassed.
539
- const floatLanes = (attribute: typeof position): Float32Array | undefined => {
540
- if (Object.getPrototypeOf(attribute) !== BufferAttribute.prototype) return undefined;
541
- if (Object.hasOwn(attribute, "setY") || Object.hasOwn(attribute, "setXYZ")) return undefined;
542
- if (attribute.itemSize !== 3 || attribute.normalized === true) return undefined;
543
- if (
544
- (attribute as { isInterleavedBufferAttribute?: boolean }).isInterleavedBufferAttribute ===
545
- true
546
- )
547
- return undefined;
548
- const array: unknown = attribute.array;
549
- return array instanceof Float32Array && array.length === position.count * 3
550
- ? array
551
- : undefined;
552
- };
553
- const positionArray = floatLanes(position);
554
- const normalArray = normalAttribute === undefined ? undefined : floatLanes(normalAttribute);
555
- const column =
556
- bounds === undefined
557
- ? { count: this.columns, start: 0 }
558
- : regionColumns(bounds, this.columns);
559
- const row =
560
- bounds === undefined ? { count: this.rows, start: 0 } : regionRows(bounds, this.rows);
561
- let lowest = Number.POSITIVE_INFINITY;
562
- let highest = Number.NEGATIVE_INFINITY;
563
- for (let index = 0; index < row.count; index += 1) {
564
- const target = row.start + index;
565
- for (let offset = 0; offset < column.count; offset += 1) {
566
- const source = column.start + offset;
567
- const vertex = target * this.columns + source;
568
- const height = this.#height(vertex);
569
- if (positionArray === undefined) position.setY(vertex, height);
570
- else positionArray[vertex * 3 + 1] = height;
571
- lowest = Math.min(lowest, height);
572
- highest = Math.max(highest, height);
573
- if (normalAttribute === undefined) continue;
574
- this.#gridNormal(source, target, normalArray ?? normalAttribute, vertex);
575
- }
576
- }
577
- // Upload only the rows this refresh touched. Ranges accumulate until the renderer uploads, and
578
- // an unbounded refresh records the full range so a later window cannot shrink a pending one.
579
- const first = row.start * this.columns + column.start;
580
- const last = (row.start + row.count - 1) * this.columns + column.start + column.count;
581
- for (const attribute of normalAttribute === undefined
582
- ? [position]
583
- : [position, normalAttribute]) {
584
- if (attribute instanceof BufferAttribute && row.count > 0 && column.count > 0)
585
- attribute.addUpdateRange(first * 3, (last - first) * 3);
586
- attribute.needsUpdate = true;
587
- }
588
- // Only heights move, so a windowed refresh grows the existing bounds by the window's own
589
- // range instead of walking every vertex again: on a 321-sample field the full recompute cost
590
- // two milliseconds for a footprint-sized window. Bounds may stay conservative after a refill.
591
- const box = geometry.boundingBox;
592
- if (bounds === undefined || box === null) {
593
- geometry.computeBoundingBox();
594
- geometry.computeBoundingSphere();
595
- return;
596
- }
597
- box.min.y = Math.min(box.min.y, lowest);
598
- box.max.y = Math.max(box.max.y, highest);
599
- geometry.boundingSphere = box.getBoundingSphere(geometry.boundingSphere ?? new Sphere());
600
- }
601
-
602
- /** The same values transposed once into Rapier's column-major height-matrix order. */
603
- toColliderHeights(): Float32Array {
604
- return this.#colliderHeights.slice();
605
- }
606
-
607
- /** Builds an ordinary Three.js geometry without choosing its surface. */
608
- toGeometry(): BufferGeometry {
609
- const count = this.rows * this.columns;
610
- const positions = new Float32Array(count * 3);
611
- const normals = new Float32Array(count * 3);
612
- const normal = new Vector3();
613
- for (let row = 0; row < this.rows; row += 1) {
614
- const localZ = -this.depth / 2 + row * this.#cellDepth;
615
- const worldZ = this.origin.z + localZ;
616
- for (let column = 0; column < this.columns; column += 1) {
617
- const index = row * this.columns + column;
618
- const localX = -this.width / 2 + column * this.#cellWidth;
619
- const worldX = this.origin.x + localX;
620
- positions[index * 3] = localX;
621
- positions[index * 3 + 1] = this.#height(index);
622
- positions[index * 3 + 2] = localZ;
623
- this.normalAt(worldX, worldZ, normal);
624
- normals[index * 3] = normal.x;
625
- normals[index * 3 + 1] = normal.y;
626
- normals[index * 3 + 2] = normal.z;
627
- }
628
- }
629
-
630
- const indices = new Uint32Array((this.rows - 1) * (this.columns - 1) * 6);
631
- let offset = 0;
632
- for (let row = 0; row < this.rows - 1; row += 1) {
633
- for (let column = 0; column < this.columns - 1; column += 1) {
634
- const upperLeft = row * this.columns + column;
635
- const upperRight = upperLeft + 1;
636
- const lowerLeft = upperLeft + this.columns;
637
- const lowerRight = lowerLeft + 1;
638
- indices.set([upperLeft, lowerLeft, upperRight, upperRight, lowerLeft, lowerRight], offset);
639
- offset += 6;
640
- }
641
- }
642
-
643
- const geometry = new BufferGeometry();
644
- geometry.setAttribute("position", new BufferAttribute(positions, 3));
645
- geometry.setAttribute("normal", new BufferAttribute(normals, 3));
646
- geometry.setIndex(new BufferAttribute(indices, 1));
647
- return geometry;
648
- }
649
-
650
- #interpolate(column: number, row: number): number {
651
- const column0 = Math.floor(column);
652
- const row0 = Math.floor(row);
653
- const column1 = Math.min(this.columns - 1, column0 + 1);
654
- const row1 = Math.min(this.rows - 1, row0 + 1);
655
- const columnMix = column - column0;
656
- const rowMix = row - row0;
657
- const upperLeft = this.#height(row0 * this.columns + column0);
658
- const upperRight = this.#height(row0 * this.columns + column1);
659
- const lowerLeft = this.#height(row1 * this.columns + column0);
660
- const lowerRight = this.#height(row1 * this.columns + column1);
661
- const upper = upperLeft + (upperRight - upperLeft) * columnMix;
662
- const lower = lowerLeft + (lowerRight - lowerLeft) * columnMix;
663
- return upper + (lower - upper) * rowMix;
664
- }
665
-
666
- #interpolateValues(values: Float32Array, x: number, z: number): number {
667
- finite(x, "query x");
668
- finite(z, "query z");
669
- const column = (x - this.#minimumX) / this.#cellWidth;
670
- const row = (z - this.#minimumZ) / this.#cellDepth;
671
- if (column < 0 || row < 0 || column > this.columns - 1 || row > this.rows - 1)
672
- throw new Error(`Heightfield query (${x}, ${z}) is outside its resident region.`);
673
- const column0 = Math.floor(column);
674
- const row0 = Math.floor(row);
675
- const column1 = Math.min(this.columns - 1, column0 + 1);
676
- const row1 = Math.min(this.rows - 1, row0 + 1);
677
- const columnMix = column - column0;
678
- const rowMix = row - row0;
679
- const upper =
680
- (values[row0 * this.columns + column0] as number) * (1 - columnMix) +
681
- (values[row0 * this.columns + column1] as number) * columnMix;
682
- const lower =
683
- (values[row1 * this.columns + column0] as number) * (1 - columnMix) +
684
- (values[row1 * this.columns + column1] as number) * columnMix;
685
- return upper * (1 - rowMix) + lower * rowMix;
686
- }
687
-
688
- #sampleError(
689
- sample: IGPUReadbackSample | undefined,
690
- expected: Float32Array | undefined,
691
- ): number | undefined {
692
- if (sample === undefined || expected === undefined) return undefined;
693
- if (sample.data.length !== expected.length) return Number.POSITIVE_INFINITY;
694
- let maximum = 0;
695
- for (let index = 0; index < expected.length; index += 1)
696
- maximum = Math.max(
697
- maximum,
698
- Math.abs((sample.data[index] as number) - (expected[index] as number)),
699
- );
700
- return maximum;
701
- }
702
-
703
- /**
704
- * `normalAt` at a sample, read straight from the grid: the same central differences, one-sided
705
- * at the border, without five validated bilinear queries per vertex. On a 401-sample field a
706
- * windowed refresh spent most of its time in those queries.
707
- */
708
- #gridNormal(
709
- column: number,
710
- row: number,
711
- target: { setXYZ(index: number, x: number, y: number, z: number): unknown } | Float32Array,
712
- vertex: number,
713
- ): void {
714
- const left = Math.max(0, column - 1);
715
- const right = Math.min(this.columns - 1, column + 1);
716
- const near = Math.max(0, row - 1);
717
- const far = Math.min(this.rows - 1, row + 1);
718
- const slopeX =
719
- (this.#height(row * this.columns + right) - this.#height(row * this.columns + left)) /
720
- ((right - left) * this.#cellWidth);
721
- const slopeZ =
722
- (this.#height(far * this.columns + column) - this.#height(near * this.columns + column)) /
723
- ((far - near) * this.#cellDepth);
724
- const length = Math.hypot(slopeX, 1, slopeZ);
725
- const x = -slopeX / length;
726
- const y = 1 / length;
727
- const z = -slopeZ / length;
728
- if (target instanceof Float32Array) {
729
- target[vertex * 3] = x;
730
- target[vertex * 3 + 1] = y;
731
- target[vertex * 3 + 2] = z;
732
- } else {
733
- target.setXYZ(vertex, x, y, z);
734
- }
735
- }
3
+ export { HeightfieldCollar } from "./world-collar.js";
4
+ export type {
5
+ IHeightfieldCollarOptions,
6
+ IHeightfieldCollarQuad,
7
+ IHeightfieldCollarSite,
8
+ IHeightfieldCollarWalk,
9
+ } from "./world-collar.js";
736
10
 
737
- #height(index: number): number {
738
- const height = this.#heights[index];
739
- if (height === undefined) throw new Error(`Heightfield internal sample ${index} is missing.`);
740
- return height;
741
- }
742
- }
11
+ export {
12
+ WATER_RIBBON_REACH,
13
+ WaterBodies,
14
+ lakeReach,
15
+ waterlineRadius,
16
+ } from "./world-water-bodies.js";
17
+ export type {
18
+ IWaterBodiesOptions,
19
+ IWaterCurrent,
20
+ IWaterFootprint,
21
+ IWaterLake,
22
+ IWaterOcean,
23
+ IWaterRibbon,
24
+ WaterBodyKind,
25
+ } from "./world-water-bodies.js";
26
+ export { lakeSurfaceGeometry, riverRibbonGeometry } from "./world-river-ribbon.js";
27
+ export type { ILakeSurfaceOptions, IRiverRibbonOptions } from "./world-river-ribbon.js";
28
+ export { AdmissionBudget } from "./world-load-limiter.js";
29
+ export { shoreField } from "./world-shore-field.js";
30
+ export { surfaceSampler } from "./world-surface-sampler.js";
31
+ export { baseRingGap, footprintGap, staticLowestY } from "./world-static-pose.js";
32
+ export { meshSections, repairZeroNormals, sectionGeometry } from "./world-model-sections.js";
33
+ export type { IMeshSection } from "./world-model-sections.js";
34
+ export type { IBaseRing, StaticGroundQuery } from "./world-static-pose.js";
35
+ export type { SurfaceSampler } from "./world-surface-sampler.js";
36
+ export { warmUnculled } from "./world-warm.js";
37
+ export type { IWarmUnculledOptions } from "./world-warm.js";
38
+ export type { IShoreField, IShoreFieldOptions } from "./world-shore-field.js";
743
39
 
744
40
  export { TerrainTiles } from "./world-tiles.js";
745
41
  export type {
@@ -783,16 +79,27 @@ export type {
783
79
  } from "./snow-field.js";
784
80
 
785
81
  export { heightSamplerFromHeightmap, loadWorldHeightmap } from "./world-heightmap.js";
786
- export { loadTerrainSplat } from "./world-terrain-splat.js";
82
+ export { applyTerrainSurface, loadTerrainSplat } from "./world-terrain-splat.js";
83
+ export {
84
+ bakedFractalNoise,
85
+ bakedNoise,
86
+ NOISE_PERIOD,
87
+ NOISE_TEXELS,
88
+ noiseVolume,
89
+ } from "./world-noise.js";
787
90
  export type {
788
91
  ILoadTerrainSplatOptions,
789
92
  ITerrainSplatLayer,
790
93
  ITerrainSplatMaskedLayer,
791
94
  ITerrainSplatTable,
792
95
  ITerrainSplatWeightContext,
96
+ ITerrainSplatSampleContext,
97
+ ITerrainSplatSample,
98
+ ITerrainSplatMaterialContext,
793
99
  } from "./world-terrain-splat.js";
794
100
 
795
101
  export { WorldCells } from "./world-cells.js";
102
+ export { instanceRandom } from "./render/world-impostor-surface.js";
796
103
  export type {
797
104
  IShadowRegion,
798
105
  IWorldCellsBudget,